From b1e6a90c61f0f65d180008e3ae98a08e6844b666 Mon Sep 17 00:00:00 2001 From: rexmtorres Date: Fri, 2 Feb 2018 02:02:56 +0800 Subject: [PATCH] Updated sample app to test fix for issue #158 --- .../io/card/development/SampleActivity.java | 56 +++++++++++-------- .../src/main/res/layout/overlay_layout.xml | 32 +++++++++++ .../src/main/res/layout/sample_activity.xml | 16 +++++- 3 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 SampleApp/src/main/res/layout/overlay_layout.xml diff --git a/SampleApp/src/main/java/io/card/development/SampleActivity.java b/SampleApp/src/main/java/io/card/development/SampleActivity.java index ac3a5120..8c8aa7b0 100644 --- a/SampleApp/src/main/java/io/card/development/SampleActivity.java +++ b/SampleApp/src/main/java/io/card/development/SampleActivity.java @@ -56,6 +56,8 @@ public class SampleActivity extends Activity { private CheckBox mUseCardIOLogoToggle; private CheckBox mShowPayPalActionBarIconToggle; private CheckBox mKeepApplicationThemeToggle; + private CheckBox mLockOrientationToggle; + private CheckBox mAddOverlayToggle; private Spinner mLanguageSpinner; private EditText mUnblurEdit; @@ -64,29 +66,32 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sample_activity); - mManualToggle = (CheckBox) findViewById(R.id.force_manual); - mEnableExpiryToggle = (CheckBox) findViewById(R.id.gather_expiry); - mScanExpiryToggle = (CheckBox) findViewById(R.id.scan_expiry); - mCvvToggle = (CheckBox) findViewById(R.id.gather_cvv); - mPostalCodeToggle = (CheckBox) findViewById(R.id.gather_postal_code); - mPostalCodeNumericOnlyToggle = (CheckBox) findViewById(R.id.postal_code_numeric_only); - mCardholderNameToggle = (CheckBox) findViewById(R.id.gather_cardholder_name); - mSuppressManualToggle = (CheckBox) findViewById(R.id.suppress_manual); - mSuppressConfirmationToggle = (CheckBox) findViewById(R.id.suppress_confirmation); - mSuppressScanToggle = (CheckBox) findViewById(R.id.detect_only); - - mUseCardIOLogoToggle = (CheckBox) findViewById(R.id.use_card_io_logo); - mShowPayPalActionBarIconToggle = (CheckBox) findViewById(R.id.show_paypal_action_bar_icon); - mKeepApplicationThemeToggle = (CheckBox) findViewById(R.id.keep_application_theme); - - mLanguageSpinner = (Spinner) findViewById(R.id.language); - mUnblurEdit = (EditText) findViewById(R.id.unblur); - - mResultLabel = (TextView) findViewById(R.id.result); - mResultImage = (ImageView) findViewById(R.id.result_image); - mResultCardTypeImage = (ImageView) findViewById(R.id.result_card_type_image); - - TextView version = (TextView) findViewById(R.id.version); + mManualToggle = findViewById(R.id.force_manual); + mEnableExpiryToggle = findViewById(R.id.gather_expiry); + mScanExpiryToggle = findViewById(R.id.scan_expiry); + mCvvToggle = findViewById(R.id.gather_cvv); + mPostalCodeToggle = findViewById(R.id.gather_postal_code); + mPostalCodeNumericOnlyToggle = findViewById(R.id.postal_code_numeric_only); + mCardholderNameToggle = findViewById(R.id.gather_cardholder_name); + mSuppressManualToggle = findViewById(R.id.suppress_manual); + mSuppressConfirmationToggle = findViewById(R.id.suppress_confirmation); + mSuppressScanToggle = findViewById(R.id.detect_only); + + mUseCardIOLogoToggle = findViewById(R.id.use_card_io_logo); + mShowPayPalActionBarIconToggle = findViewById(R.id.show_paypal_action_bar_icon); + mKeepApplicationThemeToggle = findViewById(R.id.keep_application_theme); + + mLockOrientationToggle = findViewById(R.id.lock_orientation); + mAddOverlayToggle = findViewById(R.id.add_overlay); + + mLanguageSpinner = findViewById(R.id.language); + mUnblurEdit = findViewById(R.id.unblur); + + mResultLabel = findViewById(R.id.result); + mResultImage = findViewById(R.id.result_image); + mResultCardTypeImage = findViewById(R.id.result_card_type_image); + + TextView version = findViewById(R.id.version); version.setText("card.io library: " + CardIOActivity.sdkVersion() + "\n" + "Build date: " + CardIOActivity.sdkBuildDate()); @@ -116,11 +121,16 @@ public void onScan(View pressed) { .putExtra(CardIOActivity.EXTRA_LANGUAGE_OR_LOCALE, (String) mLanguageSpinner.getSelectedItem()) .putExtra(CardIOActivity.EXTRA_USE_PAYPAL_ACTIONBAR_ICON, mShowPayPalActionBarIconToggle.isChecked()) .putExtra(CardIOActivity.EXTRA_KEEP_APPLICATION_THEME, mKeepApplicationThemeToggle.isChecked()) + .putExtra(CardIOActivity.EXTRA_LOCK_ORIENTATION, mLockOrientationToggle.isChecked()) .putExtra(CardIOActivity.EXTRA_GUIDE_COLOR, Color.GREEN) .putExtra(CardIOActivity.EXTRA_SUPPRESS_CONFIRMATION, mSuppressConfirmationToggle.isChecked()) .putExtra(CardIOActivity.EXTRA_SUPPRESS_SCAN, mSuppressScanToggle.isChecked()) .putExtra(CardIOActivity.EXTRA_RETURN_CARD_IMAGE, true); + if (mAddOverlayToggle.isChecked()) { + intent.putExtra(CardIOActivity.EXTRA_SCAN_OVERLAY_LAYOUT_ID, R.layout.overlay_layout); + } + try { int unblurDigits = Integer.parseInt(mUnblurEdit.getText().toString()); intent.putExtra(CardIOActivity.EXTRA_UNBLUR_DIGITS, unblurDigits); diff --git a/SampleApp/src/main/res/layout/overlay_layout.xml b/SampleApp/src/main/res/layout/overlay_layout.xml new file mode 100644 index 00000000..1906e5e9 --- /dev/null +++ b/SampleApp/src/main/res/layout/overlay_layout.xml @@ -0,0 +1,32 @@ + + + + + + + + + + diff --git a/SampleApp/src/main/res/layout/sample_activity.xml b/SampleApp/src/main/res/layout/sample_activity.xml index 5444e783..11a27aea 100644 --- a/SampleApp/src/main/res/layout/sample_activity.xml +++ b/SampleApp/src/main/res/layout/sample_activity.xml @@ -3,8 +3,8 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:padding="16dp" - tools:context=".SampleActivity"> + android:padding="16dp"> + + + + +