package io.card.payment;
/* CardIOActivity.java
* See the file "LICENSE.md" for the full license governing this code.
*/
import android.Manifest;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.hardware.SensorManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Vibrator;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.OrientationEventListener;
import android.view.Surface;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
import java.io.ByteArrayInputStream;
import java.lang.reflect.Constructor;
import java.util.Date;
import org.my.scanExample.BuildConfig;
import io.card.payment.i18n.LocalizedStrings;
import io.card.payment.i18n.StringKey;
import io.card.payment.ui.ActivityHelper;
import io.card.payment.ui.Appearance;
import io.card.payment.ui.ViewUtil;
/**
* This is the entry point {@link android.app.Activity} for a card.io client to use <a
* href="https://card.io">card.io</a>.
*
* @version 1.0
*/
public final class CardIOActivity extends Activity {
/**
* Boolean extra. Optional. Defaults to <code>false</code>. If set, the card will not be scanned
* with the camera.
*/
public static final String EXTRA_NO_CAMERA = "io.card.payment.noCamera";
/**
* Boolean extra. Optional. Defaults to <code>false</code>. If
* set to <code>false</code>, expiry information will not be required.
*/
public static final String EXTRA_REQUIRE_EXPIRY = "io.card.payment.requireExpiry";
/**
* Boolean extra. Optional. Defaults to <code>true</code>. If
* set to <code>true</code>, and {@link #EXTRA_REQUIRE_EXPIRY} is <code>true</code>,
* an attempt to extract the expiry from the card image will be made.
*/
public static final String EXTRA_SCAN_EXPIRY = "io.card.payment.scanExpiry";
/**
* Boolean extra. Optional. Defaults to <code>false</code>. If set, the user will be prompted
* for the card CVV.
*/
public static final String EXTRA_REQUIRE_CVV = "io.card.payment.requireCVV";
/**
* Boolean extra. Optional. Defaults to <code>false</code>. If set, the user will be prompted
* for the card billing postal code.
*/
public static final String EXTRA_REQUIRE_POSTAL_CODE = "io.card.payment.requirePostalCode";
/**
* Boolean extra. Optional. Defaults to <code>false</code>. If set, the postal code will only collect numeric
* input. Set this if you know the <a href="https://en.wikipedia.org/wiki/Postal_code">expected country's
* postal code</a> has only numeric postal codes.
*/
public static final String EXTRA_RESTRICT_POSTAL_CODE_TO_NUMERIC_ONLY = "io.card.payment.restrictPostalCodeToNumericOnly";
/**
* Boolean extra. Optional. Defaults to <code>false</code>. If set, the user will be prompted
* for the cardholder name.
*/
public static final String EXTRA_REQUIRE_CARDHOLDER_NAME = "io.card.payment.requireCardholderName";
/**
* Boolean extra. Optional. Defaults to <code>false</code>. If set, the card.io logo will be
* shown instead of the PayPal logo.
*/
public static final String EXTRA_USE_CARDIO_LOGO = "io.card.payment.useCardIOLogo";
/**
* Parcelable extra containing {@link CreditCard}. The data intent returned to your {@link android.app.Activity}'s
* {@link Activity#onActivityResult(int, int, Intent)} will contain this extra if the resultCode is
* {@link #RESULT_CARD_INFO}.
*/
public static final String EXTRA_SCAN_RESULT = "io.card.payment.scanResult";
/**
* Boolean extra indicating card was not scanned.
*/
private static final String EXTRA_MANUAL_ENTRY_RESULT = "io.card.payment.manualEntryScanResult";
/**
* Boolean extra. Optional. Defaults to <code>false</code>. Removes the keyboard button from the
* scan screen.
* <br><br>
* If scanning is unavailable, the {@link android.app.Activity} result will be {@link #RESULT_SCAN_NOT_AVAILABLE}.
*/
public static final String EXTRA_SUPPRESS_MANUAL_ENTRY = "io.card.payment.suppressManual";
/**
* String extra. Optional. The preferred language for all strings appearing in the user
* interface. If not set, or if set to null, defaults to the device's current language setting.
* <br><br>
* Can be specified as a language code ("en", "fr", "zh-Hans", etc.) or as a locale ("en_AU",
* "fr_FR", "zh-Hant_TW", etc.).
* <br><br>
* If the library does not contain localized strings for a specified locale, then will fall back
* to the language. E.g., "es_CO" -> "es".
* <br><br>
* If the library does not contain localized strings for a specified language, then will fall
* back to American English.
* <br><br>
* If you specify only a language code, and that code matches the device's currently preferred
* language, then the library will attempt to use the device's current region as well. E.g.,
* specifying "en" on a device set to "English" and "United Kingdom" will result in "en_GB".
* <br><br>
* These localizations are currently included:
* <br><br>
* da, de, en, en_AU, en_GB, es, es_MX, fr, he, is, it, ja, ko, nb, nl, pl, pt, pt_BR, ru,
* sv, tr, zh-Hans, zh-Hant, zh-Hant_TW.
*/
public static final String EXTRA_LANGUAGE_OR_LOCALE = "io.card.payment.languageOrLocale";
/**
* Integer extra. Optional. Defaults to {@link Color#GREEN}. Changes the color of the guide overlay on the
* camera.
*/
public static final String EXTRA_GUIDE_COLOR = "io.card.payment.guideColor";
/**
* Boolean extra. Optional. If this value is set to <code>true</code> the user will not be prompted to
* confirm their card number after processing.
*/
public static final String EXTRA_SUPPRESS_CONFIRMATION = "io.card.payment.suppressConfirmation";
/**
* Boolean extra. Optional. Defaults to <code>false</code>. When set to <code>true</code> the card.io logo
* will not be shown overlaid on the camera.
*/
public static final String EXTRA_HIDE_CARDIO_LOGO = "io.card.payment.hideLogo";
/**
* String extra. Optional. Used to display instructions to the user while they are scanning
* their card.
*/
public static final String EXTRA_SCAN_INSTRUCTIONS = "io.card.payment.scanInstructions";
/**
* Boolean extra. Optional. Once a card image has been captured but before it has been
* processed, this value will determine whether to continue processing as usual. If the value is
* <code>true</code> the {@link CardIOActivity} will finish with a {@link #RESULT_SCAN_SUPPRESSED} result code.
*/
public static final String EXTRA_SUPPRESS_SCAN = "io.card.payment.suppressScan";
/**
* String extra. If {@link #EXTRA_RETURN_CARD_IMAGE} is set to <code>true</code>, the data intent passed to your
* {@link android.app.Activity} will have the card image stored as a JPEG formatted byte array in this extra.
*/
public static final String EXTRA_CAPTURED_CARD_IMAGE = "io.card.payment.capturedCardImage";
/**
* Boolean extra. Optional. If this