From e6241b5a47a4bc3528df9e6df4a15d6dbb7151b7 Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Wed, 10 Feb 2016 21:29:15 -0500 Subject: [PATCH 1/3] Update to using latest zxing library release, 3.2.1 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 977979b86..0def8e889 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ dependencies { compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.journeyapps:zxing-android-embedded:3.0.1@aar' - compile 'com.google.zxing:core:3.2.0' + compile 'com.google.zxing:core:3.2.1' testCompile 'junit:junit:4.12' testCompile "org.robolectric:robolectric:3.0" } From 73aff4aeb83df49eedacb86b2ec36ce469f21963 Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Wed, 10 Feb 2016 21:37:32 -0500 Subject: [PATCH 2/3] Support all barcodes zxing can generate --- .../card_locker/LoyaltyCardViewActivity.java | 28 +++++++++++++++++-- app/src/main/res/values/dimens.xml | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 18c1cc55f..03fc6c548 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -23,11 +23,32 @@ import com.google.zxing.common.BitMatrix; import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentResult; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; + public class LoyaltyCardViewActivity extends AppCompatActivity { private static final String TAG = "CardLocker"; + // These are all the barcode types that the zxing library + // is able to generate a barcode for, and thus should be + // the only barcodes which we should attempt to scan. + Collection supportedBarcodeTypes = Collections.unmodifiableList(Arrays.asList( + BarcodeFormat.AZTEC.name(), + BarcodeFormat.CODE_39.name(), + BarcodeFormat.CODE_128.name(), + BarcodeFormat.CODABAR.name(), + BarcodeFormat.DATA_MATRIX.name(), + BarcodeFormat.EAN_8.name(), + BarcodeFormat.EAN_13.name(), + BarcodeFormat.ITF.name(), + BarcodeFormat.PDF_417.name(), + BarcodeFormat.QR_CODE.name(), + BarcodeFormat.UPC_A.name() + )); + @Override protected void onCreate(Bundle savedInstanceState) { @@ -126,11 +147,14 @@ public class LoyaltyCardViewActivity extends AppCompatActivity throw new IllegalArgumentException("Unrecognized barcode format: " + formatString); } + int generateWidth = 100; + int generateHeight = 100; + String cardIdString = cardIdField.getText().toString(); Log.i(TAG, "Card: " + cardIdString); - result = writer.encode(cardIdString, format, 1500, 400, null); + result = writer.encode(cardIdString, format, generateWidth, generateHeight, null); final int WHITE = 0xFFFFFFFF; final int BLACK = 0xFF000000; @@ -170,7 +194,7 @@ public class LoyaltyCardViewActivity extends AppCompatActivity public void onClick(View v) { IntentIntegrator integrator = new IntentIntegrator(LoyaltyCardViewActivity.this); - integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES); + integrator.setDesiredBarcodeFormats(supportedBarcodeTypes); String prompt = getResources().getString(R.string.scanCardBarcode); integrator.setPrompt(prompt); diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index d420afd39..fff462f02 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,5 +6,5 @@ 16sp 22dp - 50dp + 200dp From 5e57d66daa38ef197dba80030aca5586205cf155 Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Wed, 10 Feb 2016 21:40:46 -0500 Subject: [PATCH 3/3] Do not bring up keyboard in view activity Typically one will open the view activity to bring up a barcode, and the keyboard is not expected. Disable the keyboard until an editable field is selected. --- app/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f722dfbed..fdc322e6b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -35,6 +35,7 @@ android:name=".LoyaltyCardViewActivity" android:theme="@style/AppTheme.NoActionBar" android:configChanges="orientation|screenSize" + android:windowSoftInputMode="stateHidden" android:parentActivityName="protect.card_locker.MainActivity"/>