Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Add hide torch button support and update gradle & sdk version #151

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions SampleApp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:3.0.0'
}
}

repositories {
jcenter()
google()
maven {
url "https://jitpack.io"
}
Expand All @@ -17,13 +19,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'
Expand All @@ -37,10 +39,10 @@ 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")
variant.outputs.all { output ->
def outputFile = output.getOutputFile()
if (outputFile != null && outputFile.name.endsWith(".apk")) {
outputFileName = new File(outputFile.parent, "card.io-sample-app-${variant.name}.apk")
}
}
}
Expand Down
61 changes: 26 additions & 35 deletions SampleApp/src/main/java/io/card/development/SampleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

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

Expand All @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
66 changes: 36 additions & 30 deletions SampleApp/src/main/res/layout/sample_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"/>
android:paddingBottom="8dp" />

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -28,120 +28,126 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="Expiry"
android:onClick="onExpiryToggle"/>
android:onClick="onExpiryToggle"
android:text="Expiry" />

<CheckBox
android:id="@+id/gather_cvv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="CVV"/>
android:text="CVV" />

<CheckBox
android:id="@+id/gather_postal_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="Postal Code"/>
android:text="Postal Code" />

</LinearLayout>

<CheckBox
android:id="@+id/gather_cardholder_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cardholder Name"/>
android:text="Cardholder Name" />

<CheckBox
android:id="@+id/postal_code_numeric_only"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Restrict Postal Code to Numeric Only"/>
android:text="Restrict Postal Code to Numeric Only" />

<CheckBox
android:id="@+id/scan_expiry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Scan Expiry"
android:checked="true"/>
android:checked="true"
android:text="Scan Expiry" />

<CheckBox
android:id="@+id/force_manual"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Force keyboard entry (bypass scan)"/>
android:text="Force keyboard entry (bypass scan)" />

<CheckBox
android:id="@+id/suppress_manual"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suppress keyboard number entry"/>
android:text="Suppress keyboard number entry" />

<CheckBox
android:id="@+id/suppress_confirmation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Suppress confirmation"/>
android:text="Suppress confirmation" />

<CheckBox
android:id="@+id/detect_only"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Detect card-ish rectangle only"/>
android:text="Detect card-ish rectangle only" />

<CheckBox
android:id="@+id/use_card_io_logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Use card.io logo"/>
android:text="Use card.io logo" />

<CheckBox
android:id="@+id/show_paypal_action_bar_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="PayPal icon in action bar"/>
android:text="PayPal icon in action bar" />

<CheckBox
android:id="@+id/keep_application_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Keep application theme"/>
android:text="Keep application theme" />

<CheckBox
android:id="@+id/hide_torch_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hide torch button" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusableInTouchMode="true">
android:focusableInTouchMode="true"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Language:"/>
android:text="Language:" />

<Spinner
android:id="@+id/language"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
android:gravity="center" />

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:paddingLeft="50dp"
android:text="Digits not blurred:"/>
android:text="Digits not blurred:" />

<EditText
android:id="@+id/unblur"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="4"
android:gravity="center"
android:inputType="number"/>
android:inputType="number"
android:text="4" />

</LinearLayout>

Expand All @@ -155,39 +161,39 @@
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" />

<Button
android:id="@+id/auto_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:onClick="onAutotest"
android:text="Auto-test loop"/>
android:text="Auto-test loop" />

</LinearLayout>

<Spinner
android:id="@+id/recordings"
android:layout_width="match_parent"
android:layout_height="50dp"
android:visibility="gone"/>
android:visibility="gone" />

<TextView
android:id="@+id/result"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />

<ImageView
android:id="@+id/result_card_type_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />

<ImageView
android:id="@+id/result_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />

</LinearLayout>

Expand Down
Loading