From 8660d4e2186ba1e910e10456cfc6b8b0b91ae919 Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Sun, 12 Feb 2017 22:37:11 -0500 Subject: [PATCH] Pre-populate card id in Barcode Selector If a user is attempting to update a card id of an existing card, before when the Enter Card button was selected the barcode selector view would be empty. To be more useful, the view will now be pre-populated with the existing card id. --- .../protect/card_locker/BarcodeSelectorActivity.java | 8 ++++++++ .../protect/card_locker/LoyaltyCardViewActivity.java | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java b/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java index 10dcb8e24..3688cabd7 100644 --- a/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java +++ b/app/src/main/java/protect/card_locker/BarcodeSelectorActivity.java @@ -124,6 +124,14 @@ public class BarcodeSelectorActivity extends AppCompatActivity // Noting to do } }); + + final Bundle b = getIntent().getExtras(); + final String initialCardId = b != null ? b.getString("initialCardId") : null; + + if(initialCardId != null) + { + cardId.setText(initialCardId); + } } private void createBarcodeOption(final ImageView image, final String formatType, final String cardId) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index c4b759ce2..054fd2af0 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -222,6 +222,15 @@ public class LoyaltyCardViewActivity extends AppCompatActivity public void onClick(View v) { Intent i = new Intent(getApplicationContext(), BarcodeSelectorActivity.class); + + String cardId = cardIdFieldEdit.getText().toString(); + if(cardId.length() > 0) + { + final Bundle b = new Bundle(); + b.putString("initialCardId", cardId); + i.putExtras(b); + } + startActivityForResult(i, SELECT_BARCODE_REQUEST); } });