Skip to content

Commit

Permalink
Updated sample app to test fix for issue card-io#158
Browse files Browse the repository at this point in the history
  • Loading branch information
rexmtorres committed Feb 1, 2018
1 parent 6aa3b40 commit b1e6a90
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 25 deletions.
56 changes: 33 additions & 23 deletions SampleApp/src/main/java/io/card/development/SampleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());

Expand Down Expand Up @@ -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);
Expand Down
32 changes: 32 additions & 0 deletions SampleApp/src/main/res/layout/overlay_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="32dp">

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="top|center_horizontal"
android:text="OVERLAY MESSAGE" />

<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="OVERLAY MESSAGE" />

<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom|center_horizontal"
android:text="OVERLAY MESSAGE" />

</LinearLayout>
16 changes: 14 additions & 2 deletions SampleApp/src/main/res/layout/sample_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<!--tools:context=".SampleActivity">-->

<LinearLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -110,6 +110,18 @@
android:layout_height="wrap_content"
android:text="Keep application theme"/>

<CheckBox
android:id="@+id/lock_orientation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lock orientation"/>

<CheckBox
android:id="@+id/add_overlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Show sample overlay layout"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down

0 comments on commit b1e6a90

Please sign in to comment.