mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-01-25 23:38:00 -05:00
Refactor to allow updating a loyalty card from a bundle (#2051)
This allows us to send any (partial) loyalty card into the edit activity, granting us greater flexibility in what kind of scan result we can parse
This commit is contained in:
@@ -82,7 +82,7 @@ public class ScanActivity extends CatimaAppCompatActivity {
|
||||
|
||||
private void extractIntentFields(Intent intent) {
|
||||
final Bundle b = intent.getExtras();
|
||||
cardId = b != null ? b.getString(LoyaltyCardEditActivity.BUNDLE_CARDID) : null;
|
||||
cardId = b != null ? b.getString(LoyaltyCard.BUNDLE_LOYALTY_CARD_CARD_ID) : null;
|
||||
addGroup = b != null ? b.getString(LoyaltyCardEditActivity.BUNDLE_ADDGROUP) : null;
|
||||
Log.d(TAG, "Scan activity: id=" + cardId);
|
||||
}
|
||||
@@ -291,7 +291,9 @@ public class ScanActivity extends CatimaAppCompatActivity {
|
||||
Utils.makeUserChooseBarcodeFromList(this, barcodeValuesList, new BarcodeValuesListDisambiguatorCallback() {
|
||||
@Override
|
||||
public void onUserChoseBarcode(BarcodeValues barcodeValues) {
|
||||
returnResult(barcodeValues.content(), barcodeValues.format());
|
||||
CatimaBarcode barcodeType = barcodeValues.format();
|
||||
|
||||
returnResult(barcodeValues.content(), barcodeType != null ? barcodeType.name() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -338,7 +340,7 @@ public class ScanActivity extends CatimaAppCompatActivity {
|
||||
|
||||
// Buttons
|
||||
builder.setPositiveButton(getString(R.string.ok), (dialog, which) -> {
|
||||
returnResult(input.getText().toString(), "");
|
||||
returnResult(input.getText().toString(), null);
|
||||
});
|
||||
builder.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.cancel());
|
||||
AlertDialog dialog = builder.create();
|
||||
@@ -373,7 +375,7 @@ public class ScanActivity extends CatimaAppCompatActivity {
|
||||
Intent i = new Intent(getApplicationContext(), BarcodeSelectorActivity.class);
|
||||
if (cardId != null) {
|
||||
final Bundle b = new Bundle();
|
||||
b.putString("initialCardId", cardId);
|
||||
b.putString(LoyaltyCard.BUNDLE_LOYALTY_CARD_CARD_ID, cardId);
|
||||
i.putExtras(b);
|
||||
}
|
||||
manualAddLauncher.launch(i);
|
||||
|
||||
Reference in New Issue
Block a user