From f683233a02fb8618528e3cdcf00010518edec43d Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Thu, 9 Nov 2017 18:13:57 +0700 Subject: [PATCH 1/7] Update latest gradle and sdk version --- .travis.yml | 4 ++-- SampleApp/build.gradle | 24 ++++++++++++------------ build.gradle | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 544e9295..fda62a81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ android: components: - tools - tools - - android-25 + - android-26 - android-22 - sys-img-armeabi-v7a-android-22 - - build-tools-25.0.2 + - build-tools-26.0.2 - platform-tools - extra-android-support - extra-android-m2repository diff --git a/SampleApp/build.gradle b/SampleApp/build.gradle index 01d4c570..24389465 100644 --- a/SampleApp/build.gradle +++ b/SampleApp/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:3.0.0' } } @@ -17,13 +17,13 @@ repositories { apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 26 + buildToolsVersion "26.0.2" defaultConfig { applicationId "io.card.development" minSdkVersion 18 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 1 versionName "1.0.0" testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' @@ -36,14 +36,14 @@ android { } } - android.applicationVariants.all { variant -> - variant.outputs.each { output -> - def outputFile = output.outputFile - if (outputFile != null && outputFile.name.endsWith('.apk')) { - output.outputFile = new File(outputFile.parent, "card.io-sample-app-${variant.name}.apk") - } - } - } +// android.applicationVariants.all { variant -> +// variant.outputs.each { output -> +// def outputFile = output.outputFile +// if (outputFile != null && outputFile.name.endsWith('.apk')) { +// output.outputFile = new File(outputFile.parent, "card.io-sample-app-${variant.name}.apk") +// } +// } +// } } dependencies { diff --git a/build.gradle b/build.gradle index 415f8368..490a8edd 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:3.0.0' classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3" } } @@ -11,6 +11,6 @@ buildscript { task assemble {} ext { - sdkVersion = 25 - buildToolsVersion = '25.0.2' + sdkVersion = 26 + buildToolsVersion = '26.0.2' } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0a48d7d6..d09d2ec7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip From 8c628f6e44ace76f22cbcb82dee62ef885f44875 Mon Sep 17 00:00:00 2001 From: Akexorcist Date: Thu, 9 Nov 2017 18:16:16 +0700 Subject: [PATCH 2/7] Add hide torch toggle button support --- .../io/card/development/SampleActivity.java | 61 ++++++++--------- .../src/main/res/layout/sample_activity.xml | 66 ++++++++++--------- .../java/io/card/payment/CardIOActivity.java | 66 ++++++++++++------- 3 files changed, 105 insertions(+), 88 deletions(-) diff --git a/SampleApp/src/main/java/io/card/development/SampleActivity.java b/SampleApp/src/main/java/io/card/development/SampleActivity.java index ac3a5120..0e457985 100644 --- a/SampleApp/src/main/java/io/card/development/SampleActivity.java +++ b/SampleApp/src/main/java/io/card/development/SampleActivity.java @@ -30,7 +30,6 @@ import io.card.payment.i18n.locales.LocalizedStringsList; public class SampleActivity extends Activity { - protected static final String TAG = SampleActivity.class.getSimpleName(); private static final int REQUEST_SCAN = 100; @@ -56,6 +55,7 @@ public class SampleActivity extends Activity { private CheckBox mUseCardIOLogoToggle; private CheckBox mShowPayPalActionBarIconToggle; private CheckBox mKeepApplicationThemeToggle; + private CheckBox mHideTorchButtonToggle; private Spinner mLanguageSpinner; private EditText mUnblurEdit; @@ -64,32 +64,29 @@ 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); + mHideTorchButtonToggle = findViewById(R.id.hide_torch_button); + 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()); - setScanExpiryEnabled(); setupLanguageList(); } @@ -116,39 +113,35 @@ 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_HIDE_TORCH_BUTTON, mHideTorchButtonToggle.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); - try { int unblurDigits = Integer.parseInt(mUnblurEdit.getText().toString()); intent.putExtra(CardIOActivity.EXTRA_UNBLUR_DIGITS, unblurDigits); - } catch(NumberFormatException ignored) {} - + } catch (NumberFormatException ignored) { + } startActivityForResult(intent, REQUEST_SCAN); } public void onAutotest(View v) { Log.i(TAG, "\n\n\n ============================== \n" + "successfully completed " + numAutotestsPassed + " tests\n" + "beginning new test run\n"); - Intent intent = new Intent(this, CardIOActivity.class) .putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, false) .putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false) .putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false) .putExtra(CardIOActivity.EXTRA_REQUIRE_CARDHOLDER_NAME, false) .putExtra("debug_autoAcceptResult", true); - startActivityForResult(intent, REQUEST_AUTOTEST); - autotestMode = true; } @Override public void onStop() { super.onStop(); - mResultLabel.setText(""); } @@ -157,7 +150,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.v(TAG, "onActivityResult(" + requestCode + ", " + resultCode + ", " + data + ")"); - String outStr = new String(); + String outStr = ""; Bitmap cardTypeImage = null; if ((requestCode == REQUEST_SCAN || requestCode == REQUEST_AUTOTEST) && data != null @@ -204,9 +197,7 @@ public void run() { Bitmap card = CardIOActivity.getCapturedCardImage(data); mResultImage.setImageBitmap(card); mResultCardTypeImage.setImageBitmap(cardTypeImage); - Log.i(TAG, "Set result: " + outStr); - mResultLabel.setText(outStr); } diff --git a/SampleApp/src/main/res/layout/sample_activity.xml b/SampleApp/src/main/res/layout/sample_activity.xml index 5444e783..7d93713b 100644 --- a/SampleApp/src/main/res/layout/sample_activity.xml +++ b/SampleApp/src/main/res/layout/sample_activity.xml @@ -15,7 +15,7 @@ android:id="@+id/version" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingBottom="8dp"/> + android:paddingBottom="8dp" /> + android:onClick="onExpiryToggle" + android:text="Expiry" /> + android:text="CVV" /> + android:text="Postal Code" /> @@ -53,95 +53,101 @@ android:id="@+id/gather_cardholder_name" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="Cardholder Name"/> + android:text="Cardholder Name" /> + android:text="Restrict Postal Code to Numeric Only" /> + android:checked="true" + android:text="Scan Expiry" /> + android:text="Force keyboard entry (bypass scan)" /> + android:text="Suppress keyboard number entry" /> + android:text="Suppress confirmation" /> + android:text="Detect card-ish rectangle only" /> + android:text="Use card.io logo" /> + android:text="PayPal icon in action bar" /> + android:text="Keep application theme" /> + + + android:focusableInTouchMode="true" + android:orientation="horizontal"> + android:text="Language:" /> + android:gravity="center" /> + android:text="Digits not blurred:" /> + android:inputType="number" + android:text="4" /> @@ -155,8 +161,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0.4" - android:text="Scan Credit Card using Card.io" - android:onClick="onScan"/> + android:onClick="onScan" + android:text="Scan Credit Card using Card.io" />