正在查看: Clash Legends v0.0.1 应用的 CardIOActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 CardIOActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package io.card.payment;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Vibrator;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.OrientationEventListener;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
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 com.onesignal.core.internal.config.InfluenceConfigModel;
import io.card.payment.i18n.LocalizedStrings;
import io.card.payment.i18n.StringKey;
import io.card.payment.ui.ActivityHelper;
import io.card.payment.ui.ViewUtil;
import java.io.ByteArrayInputStream;
import java.lang.reflect.Constructor;
import java.util.Date;
import kotlin.io.ConstantsKt;
import kotlinx.coroutines.internal.LockFreeTaskQueueCore;
import kotlinx.coroutines.scheduling.WorkQueueKt;
public final class CardIOActivity extends Activity {
static final boolean $assertionsDisabled = false;
public static final String EXTRA_CAPTURED_CARD_IMAGE = "io.card.payment.capturedCardImage";
public static final String EXTRA_GUIDE_COLOR = "io.card.payment.guideColor";
public static final String EXTRA_HIDE_CARDIO_LOGO = "io.card.payment.hideLogo";
public static final String EXTRA_KEEP_APPLICATION_THEME = "io.card.payment.keepApplicationTheme";
public static final String EXTRA_LANGUAGE_OR_LOCALE = "io.card.payment.languageOrLocale";
public static final String EXTRA_NO_CAMERA = "io.card.payment.noCamera";
public static final String EXTRA_REQUIRE_CARDHOLDER_NAME = "io.card.payment.requireCardholderName";
public static final String EXTRA_REQUIRE_CVV = "io.card.payment.requireCVV";
public static final String EXTRA_REQUIRE_EXPIRY = "io.card.payment.requireExpiry";
public static final String EXTRA_REQUIRE_POSTAL_CODE = "io.card.payment.requirePostalCode";
public static final String EXTRA_RESTRICT_POSTAL_CODE_TO_NUMERIC_ONLY = "io.card.payment.restrictPostalCodeToNumericOnly";
public static final String EXTRA_RETURN_CARD_IMAGE = "io.card.payment.returnCardImage";
public static final String EXTRA_SCAN_EXPIRY = "io.card.payment.scanExpiry";
public static final String EXTRA_SCAN_INSTRUCTIONS = "io.card.payment.scanInstructions";
public static final String EXTRA_SCAN_OVERLAY_LAYOUT_ID = "io.card.payment.scanOverlayLayoutId";
public static final String EXTRA_SCAN_RESULT = "io.card.payment.scanResult";
public static final String EXTRA_SUPPRESS_CONFIRMATION = "io.card.payment.suppressConfirmation";
public static final String EXTRA_SUPPRESS_MANUAL_ENTRY = "io.card.payment.suppressManual";
public static final String EXTRA_SUPPRESS_SCAN = "io.card.payment.suppressScan";
public static final String EXTRA_UNBLUR_DIGITS = "io.card.payment.unblurDigits";
public static final String EXTRA_USE_CARDIO_LOGO = "io.card.payment.useCardIOLogo";
public static final String EXTRA_USE_PAYPAL_ACTIONBAR_ICON = "io.card.payment.intentSenderIsPayPal";
public static final int RESULT_CONFIRMATION_SUPPRESSED;
public static final int RESULT_ENTRY_CANCELED;
public static final int RESULT_SCAN_NOT_AVAILABLE;
public static final int RESULT_SCAN_SUPPRESSED;
private static int lastResult;
private static int numActivityAllocations;
private LinearLayout customOverlayLayout;
private CardScanner mCardScanner;
private boolean mDetectOnly;
private CreditCard mDetectedCard;
private int mFrameOrientation;
private Rect mGuideFrame;
private int mLastDegrees;
private FrameLayout mMainLayout;
private OverlayView mOverlay;
Preview mPreview;
private RelativeLayout mUIBar;
private boolean manualEntryFallbackOrForced = false;
private OrientationEventListener orientationListener;
private boolean suppressManualEntry;
private boolean useApplicationTheme;
private boolean waitingForPermission;
public static final int RESULT_CARD_INFO = 13274384;
private static final String TAG = CardIOActivity.class.getSimpleName();
private static final long[] VIBRATE_PATTERN = {0, 70, 10, 40};
static Bitmap markedCardImage = null;
static {
lastResult = 13274384;
int i = 13274384 + 1;
lastResult = i;
int i2 = i + 1;
lastResult = i2;
RESULT_ENTRY_CANCELED = i;
int i3 = i2 + 1;
lastResult = i3;
RESULT_SCAN_NOT_AVAILABLE = i2;
int i4 = i3 + 1;
lastResult = i4;
RESULT_SCAN_SUPPRESSED = i3;
lastResult = i4 + 1;
RESULT_CONFIRMATION_SUPPRESSED = i4;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int i = numActivityAllocations + 1;
numActivityAllocations = i;
if (i != 1) {
Log.i(TAG, String.format("INTERNAL WARNING: There are %d (not 1) CardIOActivity allocations!", Integer.valueOf(i)));
}
Intent clientData = getIntent();
boolean booleanExtra = getIntent().getBooleanExtra(EXTRA_KEEP_APPLICATION_THEME, false);
this.useApplicationTheme = booleanExtra;
ActivityHelper.setActivityTheme(this, booleanExtra);
LocalizedStrings.setLanguage(clientData);
this.mDetectOnly = clientData.getBooleanExtra(EXTRA_SUPPRESS_SCAN, false);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(clientData, 65536);
String errorMsg = Util.manifestHasConfigChange(resolveInfo, CardIOActivity.class);
if (errorMsg == null) {
this.suppressManualEntry = clientData.getBooleanExtra(EXTRA_SUPPRESS_MANUAL_ENTRY, false);
if (savedInstanceState != null) {
this.waitingForPermission = savedInstanceState.getBoolean("io.card.payment.waitingForPermission");
}
if (clientData.getBooleanExtra(EXTRA_NO_CAMERA, false)) {
Log.i("card.io", "EXTRA_NO_CAMERA set to true. Skipping camera.");
this.manualEntryFallbackOrForced = true;
return;
}
if (!CardScanner.processorSupported()) {
Log.i("card.io", "Processor not Supported. Skipping camera.");
this.manualEntryFallbackOrForced = true;
return;
}
try {
if (!this.waitingForPermission) {
if (checkSelfPermission("android.permission.CAMERA") == -1) {
Log.d(TAG, "permission denied to camera - requesting it");
String[] permissions = {"android.permission.CAMERA"};
this.waitingForPermission = true;
requestPermissions(permissions, 11);
} else {
checkCamera();
android23AndAboveHandleCamera();
}
}
return;
} catch (Exception e) {
handleGeneralExceptionError(e);
return;
}
}
throw new RuntimeException(errorMsg);
}
private void android23AndAboveHandleCamera() {
if (this.manualEntryFallbackOrForced) {
finishIfSuppressManualEntry();
} else {
showCameraScannerOverlay();
}
}
private void android22AndBelowHandleCamera() {
if (this.manualEntryFallbackOrForced) {
finishIfSuppressManualEntry();
} else {
requestWindowFeature(1);
showCameraScannerOverlay();
}
}
private void finishIfSuppressManualEntry() {
if (this.suppressManualEntry) {
Log.i("card.io", "Camera not available and manual entry suppressed.");
setResultAndFinish(RESULT_SCAN_NOT_AVAILABLE, null);
}
}
private void checkCamera() {
try {
if (!Util.hardwareSupported()) {
StringKey errorKey = StringKey.ERROR_NO_DEVICE_SUPPORT;
Log.w("card.io", errorKey + ": " + LocalizedStrings.getString(errorKey));
this.manualEntryFallbackOrForced = true;
}
} catch (CameraUnavailableException e) {
StringKey errorKey2 = StringKey.ERROR_CAMERA_CONNECT_FAIL;
String localizedError = LocalizedStrings.getString(errorKey2);
Log.e("card.io", errorKey2 + ": " + localizedError);
Toast toast = Toast.makeText(this, localizedError, 1);
toast.setGravity(17, 0, -75);
toast.show();
this.manualEntryFallbackOrForced = true;
}
}
private void showCameraScannerOverlay() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(4);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.hide();
}
try {
this.mGuideFrame = new Rect();
this.mFrameOrientation = 1;
int i = 2;
if (getIntent().getBooleanExtra("io.card.payment.cameraBypassTestMode", false)) {
if (!getPackageName().contentEquals("io.card.development")) {
throw new IllegalStateException("Illegal access of private extra");
}
Class<?> testScannerClass = Class.forName("io.card.payment.CardScannerTester");
Constructor<?> cons = testScannerClass.getConstructor(getClass(), Integer.TYPE);
this.mCardScanner = (CardScanner) cons.newInstance(this, Integer.valueOf(this.mFrameOrientation));
} else {
this.mCardScanner = new CardScanner(this, this.mFrameOrientation);
}
this.mCardScanner.prepareScanner();
setPreviewLayout();
this.orientationListener = new OrientationEventListener(this, i) {
@Override
public void onOrientationChanged(int orientation) {
CardIOActivity.this.doOrientationChange(orientation);
}
};
} catch (Exception e) {
handleGeneralExceptionError(e);
}
}
private void handleGeneralExceptionError(Exception e) {
StringKey errorKey = StringKey.ERROR_CAMERA_UNEXPECTED_FAIL;
String localizedError = LocalizedStrings.getString(errorKey);
Log.e("card.io", "Unknown exception, please post the stack trace as a GitHub issue", e);
Toast toast = Toast.makeText(this, localizedError, 1);
toast.setGravity(17, 0, -75);
toast.show();
this.manualEntryFallbackOrForced = true;
}
public void doOrientationChange(int orientation) {
CardScanner cardScanner;
if (orientation < 0 || (cardScanner = this.mCardScanner) == null) {
return;
}
int orientation2 = orientation + cardScanner.getRotationalOffset();
if (orientation2 > 360) {
orientation2 -= 360;
}
int degrees = -1;
if (orientation2 < 15 || orientation2 > 345) {
degrees = 0;
this.mFrameOrientation = 1;
} else if (orientation2 > 75 && orientation2 < 105) {
degrees = 90;
this.mFrameOrientation = 4;
} else if (orientation2 > 165 && orientation2 < 195) {
degrees = 180;
this.mFrameOrientation = 2;
} else if (orientation2 > 255 && orientation2 < 285) {
degrees = 270;
this.mFrameOrientation = 3;
}
if (degrees >= 0 && degrees != this.mLastDegrees) {
this.mCardScanner.setDeviceOrientation(this.mFrameOrientation);
setDeviceDegrees(degrees);
if (degrees == 90) {
rotateCustomOverlay(270.0f);
} else if (degrees == 270) {
rotateCustomOverlay(90.0f);
} else {
rotateCustomOverlay(degrees);
}
}
}
@Override
protected void onResume() {
super.onResume();
if (!this.waitingForPermission) {
if (this.manualEntryFallbackOrForced) {
nextActivity();
return;
}
Util.logNativeMemoryStats();
getWindow().addFlags(LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY);
getWindow().addFlags(WorkQueueKt.BUFFER_CAPACITY);
ActivityHelper.setFlagSecure(this);
setRequestedOrientation(1);
this.orientationListener.enable();
if (!restartPreview()) {
Log.e(TAG, "Could not connect to camera.");
StringKey error = StringKey.ERROR_CAMERA_UNEXPECTED_FAIL;
showErrorMessage(LocalizedStrings.getString(error));
nextActivity();
} else {
setFlashOn(false);
}
doOrientationChange(this.mLastDegrees);
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("io.card.payment.waitingForPermission", this.waitingForPermission);
}
@Override
protected void onPause() {
super.onPause();
OrientationEventListener orientationEventListener = this.orientationListener;
if (orientationEventListener != null) {
orientationEventListener.disable();
}
setFlashOn(false);
CardScanner cardScanner = this.mCardScanner;
if (cardScanner != null) {
cardScanner.pauseScanning();
}
}
@Override
protected void onDestroy() {
this.mOverlay = null;
numActivityAllocations--;
OrientationEventListener orientationEventListener = this.orientationListener;
if (orientationEventListener != null) {
orientationEventListener.disable();
}
setFlashOn(false);
CardScanner cardScanner = this.mCardScanner;
if (cardScanner != null) {
cardScanner.endScanning();
this.mCardScanner = null;
}
super.onDestroy();
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == 11) {
this.waitingForPermission = false;
if (grantResults.length > 0 && grantResults[0] == 0) {
showCameraScannerOverlay();
} else {
this.manualEntryFallbackOrForced = true;
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case InfluenceConfigModel.DEFAULT_NOTIFICATION_LIMIT:
if (resultCode == 0) {
Log.d(TAG, "ignoring onActivityResult(RESULT_CANCELED) caused only when Camera Permissions are Denied in Android 23");
break;
} else if (resultCode == RESULT_CARD_INFO || resultCode == RESULT_ENTRY_CANCELED || this.manualEntryFallbackOrForced) {
if (data != null && data.hasExtra(EXTRA_SCAN_RESULT)) {
Log.v(TAG, "EXTRA_SCAN_RESULT: " + data.getParcelableExtra(EXTRA_SCAN_RESULT));
} else {
Log.d(TAG, "no data in EXTRA_SCAN_RESULT");
}
setResultAndFinish(resultCode, data);
break;
} else {
RelativeLayout relativeLayout = this.mUIBar;
if (relativeLayout != null) {
relativeLayout.setVisibility(0);
break;
}
}
break;
}
}
@Override
public void onBackPressed() {
if (!this.manualEntryFallbackOrForced && this.mOverlay.isAnimating()) {
try {
restartPreview();
return;
} catch (RuntimeException re) {
Log.w(TAG, "*** could not return to preview: " + re);
return;
}
}
if (this.mCardScanner != null) {
super.onBackPressed();
}
}
public static boolean canReadCardWithCamera() {
try {
return Util.hardwareSupported();
} catch (CameraUnavailableException e) {
return false;
} catch (RuntimeException e2) {
Log.w(TAG, "RuntimeException accessing Util.hardwareSupported()");
return false;
}
}
public static String sdkVersion() {
return BuildConfig.PRODUCT_VERSION;
}
public static Date sdkBuildDate() {
return new Date(BuildConfig.BUILD_TIME);
}
public static Bitmap getCapturedCardImage(Intent intent) {
if (intent == null || !intent.hasExtra(EXTRA_CAPTURED_CARD_IMAGE)) {
return null;
}
byte[] imageData = intent.getByteArrayExtra(EXTRA_CAPTURED_CARD_IMAGE);
ByteArrayInputStream inStream = new ByteArrayInputStream(imageData);
Bitmap result = BitmapFactory.decodeStream(inStream, null, new BitmapFactory.Options());
return result;
}
void onFirstFrame(int orientation) {
SurfaceView sv = this.mPreview.getSurfaceView();
OverlayView overlayView = this.mOverlay;
if (overlayView != null) {
overlayView.setCameraPreviewRect(new Rect(sv.getLeft(), sv.getTop(), sv.getRight(), sv.getBottom()));
}
this.mFrameOrientation = 1;
setDeviceDegrees(0);
if (orientation != this.mFrameOrientation) {
Log.wtf("card.io", "the orientation of the scanner doesn't match the orientation of the activity");
}
onEdgeUpdate(new DetectionInfo());
}
void onEdgeUpdate(DetectionInfo dInfo) {
this.mOverlay.setDetectionInfo(dInfo);
}
void onCardDetected(Bitmap detectedBitmap, DetectionInfo dInfo) {
float sf;
try {
Vibrator vibrator = (Vibrator) getSystemService("vibrator");
vibrator.vibrate(VIBRATE_PATTERN, -1);
} catch (SecurityException e) {
Log.e("card.io", "Could not activate vibration feedback. Please add <uses-permission android:name=\"android.permission.VIBRATE\" /> to your application's manifest.");
} catch (Exception e2) {
Log.w("card.io", "Exception while attempting to vibrate: ", e2);
}
this.mCardScanner.pauseScanning();
this.mUIBar.setVisibility(4);
if (dInfo.predicted()) {
CreditCard creditCard = dInfo.creditCard();
this.mDetectedCard = creditCard;
this.mOverlay.setDetectedCard(creditCard);
}
int i = this.mFrameOrientation;
if (i == 1 || i == 2) {
sf = (this.mGuideFrame.right / 428.0f) * 0.95f;
} else {
sf = (this.mGuideFrame.right / 428.0f) * 1.15f;
}
Matrix m = new Matrix();
m.postScale(sf, sf);
Bitmap scaledCard = Bitmap.createBitmap(detectedBitmap, 0, 0, detectedBitmap.getWidth(), detectedBitmap.getHeight(), m, false);
this.mOverlay.setBitmap(scaledCard);
if (this.mDetectOnly) {
Intent dataIntent = new Intent();
Util.writeCapturedCardImageIfNecessary(getIntent(), dataIntent, this.mOverlay);
setResultAndFinish(RESULT_SCAN_SUPPRESSED, dataIntent);
return;
}
nextActivity();
}
public void nextActivity() {
final Intent origIntent = getIntent();
if (origIntent != null && origIntent.getBooleanExtra(EXTRA_SUPPRESS_CONFIRMATION, false)) {
Intent dataIntent = new Intent(this, (Class<?>) DataEntryActivity.class);
CreditCard creditCard = this.mDetectedCard;
if (creditCard != null) {
dataIntent.putExtra(EXTRA_SCAN_RESULT, creditCard);
this.mDetectedCard = null;
}
Util.writeCapturedCardImageIfNecessary(origIntent, dataIntent, this.mOverlay);
setResultAndFinish(RESULT_CONFIRMATION_SUPPRESSED, dataIntent);
return;
}
new Handler().post(new Runnable() {
@Override
public void run() {
CardIOActivity.this.getWindow().clearFlags(LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY);
CardIOActivity.this.getWindow().addFlags(ConstantsKt.MINIMUM_BLOCK_SIZE);
Intent dataIntent2 = new Intent(CardIOActivity.this, (Class<?>) DataEntryActivity.class);
Util.writeCapturedCardImageIfNecessary(origIntent, dataIntent2, CardIOActivity.this.mOverlay);
if (CardIOActivity.this.mOverlay != null) {
CardIOActivity.this.mOverlay.markupCard();
if (CardIOActivity.markedCardImage != null && !CardIOActivity.markedCardImage.isRecycled()) {
CardIOActivity.markedCardImage.recycle();
}
CardIOActivity.markedCardImage = CardIOActivity.this.mOverlay.getCardImage();
}
if (CardIOActivity.this.mDetectedCard != null) {
dataIntent2.putExtra(CardIOActivity.EXTRA_SCAN_RESULT, CardIOActivity.this.mDetectedCard);
CardIOActivity.this.mDetectedCard = null;
} else {
dataIntent2.putExtra("io.card.payment.manualEntryScanResult", true);
}
dataIntent2.putExtras(CardIOActivity.this.getIntent());
dataIntent2.addFlags(1082195968);
CardIOActivity.this.startActivityForResult(dataIntent2, 10);
}
});
}
private void showErrorMessage(String msgStr) {
Log.e("card.io", "error display: " + msgStr);
Toast toast = Toast.makeText(this, msgStr, 1);
toast.show();
}
private boolean restartPreview() {
this.mDetectedCard = null;
Preview preview = this.mPreview;
if (preview == null) {
throw new AssertionError();
}
boolean success = this.mCardScanner.resumeScanning(preview.getSurfaceHolder());
if (success) {
this.mUIBar.setVisibility(0);
}
return success;
}
private void setDeviceDegrees(int degrees) {
View sv = this.mPreview.getSurfaceView();
if (sv == null) {
Log.wtf("card.io", "surface view is null.. recovering... rotation might be weird.");
return;
}
Rect guideFrame = this.mCardScanner.getGuideFrame(sv.getWidth(), sv.getHeight());
this.mGuideFrame = guideFrame;
guideFrame.top += sv.getTop();
this.mGuideFrame.bottom += sv.getTop();
this.mOverlay.setGuideAndRotation(this.mGuideFrame, degrees);
this.mLastDegrees = degrees;
}
void toggleFlash() {
setFlashOn(!this.mCardScanner.isFlashOn());
}
void setFlashOn(boolean b) {
boolean success = (this.mPreview == null || this.mOverlay == null || !this.mCardScanner.setFlashOn(b)) ? false : true;
if (success) {
this.mOverlay.setTorchOn(b);
}
}
void triggerAutoFocus() {
this.mCardScanner.triggerAutoFocus(true);
}
private void setPreviewLayout() {
FrameLayout frameLayout = new FrameLayout(this);
this.mMainLayout = frameLayout;
frameLayout.setBackgroundColor(-16777216);
this.mMainLayout.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
FrameLayout previewFrame = new FrameLayout(this);
previewFrame.setId(1);
this.mCardScanner.getClass();
this.mCardScanner.getClass();
Preview preview = new Preview(this, null, 640, 480);
this.mPreview = preview;
preview.setLayoutParams(new FrameLayout.LayoutParams(-1, -1, 48));
previewFrame.addView(this.mPreview);
OverlayView overlayView = new OverlayView(this, null, Util.deviceSupportsTorch(this));
this.mOverlay = overlayView;
overlayView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
if (getIntent() != null) {
boolean useCardIOLogo = getIntent().getBooleanExtra(EXTRA_USE_CARDIO_LOGO, false);
this.mOverlay.setUseCardIOLogo(useCardIOLogo);
int color = getIntent().getIntExtra(EXTRA_GUIDE_COLOR, 0);
if (color != 0) {
int alphaRemovedColor = (-16777216) | color;
if (color != alphaRemovedColor) {
Log.w("card.io", "Removing transparency from provided guide color.");
}
this.mOverlay.setGuideColor(alphaRemovedColor);
} else {
this.mOverlay.setGuideColor(-16711936);
}
boolean hideCardIOLogo = getIntent().getBooleanExtra(EXTRA_HIDE_CARDIO_LOGO, false);
this.mOverlay.setHideCardIOLogo(hideCardIOLogo);
String scanInstructions = getIntent().getStringExtra(EXTRA_SCAN_INSTRUCTIONS);
if (scanInstructions != null) {
this.mOverlay.setScanInstructions(scanInstructions);
}
}
previewFrame.addView(this.mOverlay);
RelativeLayout.LayoutParams previewParams = new RelativeLayout.LayoutParams(-1, -1);
previewParams.addRule(10);
previewParams.addRule(2, 2);
this.mMainLayout.addView(previewFrame, previewParams);
RelativeLayout relativeLayout = new RelativeLayout(this);
this.mUIBar = relativeLayout;
relativeLayout.setGravity(80);
RelativeLayout.LayoutParams mUIBarParams = new RelativeLayout.LayoutParams(-1, -2);
previewParams.addRule(12);
this.mUIBar.setLayoutParams(mUIBarParams);
this.mUIBar.setId(2);
this.mUIBar.setGravity(85);
if (!this.suppressManualEntry) {
Button keyboardBtn = new Button(this);
keyboardBtn.setId(3);
keyboardBtn.setText(LocalizedStrings.getString(StringKey.KEYBOARD));
keyboardBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CardIOActivity.this.nextActivity();
}
});
this.mUIBar.addView(keyboardBtn);
ViewUtil.styleAsButton(keyboardBtn, false, this, this.useApplicationTheme);
if (!this.useApplicationTheme) {
keyboardBtn.setTextSize(14.0f);
}
keyboardBtn.setMinimumHeight(ViewUtil.typedDimensionValueToPixelsInt("42dip", this));
RelativeLayout.LayoutParams keyboardParams = (RelativeLayout.LayoutParams) keyboardBtn.getLayoutParams();
keyboardParams.width = -2;
keyboardParams.height = -2;
keyboardParams.addRule(12);
ViewUtil.setPadding(keyboardBtn, "16dip", null, "16dip", null);
ViewUtil.setMargins(keyboardBtn, "4dip", "4dip", "4dip", "4dip");
}
RelativeLayout.LayoutParams uiParams = new RelativeLayout.LayoutParams(-1, -2);
uiParams.addRule(12);
float scale = getResources().getDisplayMetrics().density;
int uiBarMarginPx = (int) ((15.0f * scale) + 0.5f);
uiParams.setMargins(0, uiBarMarginPx, 0, uiBarMarginPx);
this.mMainLayout.addView(this.mUIBar, uiParams);
if (getIntent() != null) {
LinearLayout linearLayout = this.customOverlayLayout;
if (linearLayout != null) {
this.mMainLayout.removeView(linearLayout);
this.customOverlayLayout = null;
}
int resourceId = getIntent().getIntExtra(EXTRA_SCAN_OVERLAY_LAYOUT_ID, -1);
if (resourceId != -1) {
LinearLayout linearLayout2 = new LinearLayout(this);
this.customOverlayLayout = linearLayout2;
linearLayout2.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
LayoutInflater inflater = getLayoutInflater();
inflater.inflate(resourceId, this.customOverlayLayout);
this.mMainLayout.addView(this.customOverlayLayout);
}
}
setContentView(this.mMainLayout);
}
private void rotateCustomOverlay(float degrees) {
LinearLayout linearLayout = this.customOverlayLayout;
if (linearLayout != null) {
float pivotX = linearLayout.getWidth() / 2;
float pivotY = this.customOverlayLayout.getHeight() / 2;
Animation an = new RotateAnimation(0.0f, degrees, pivotX, pivotY);
an.setDuration(0L);
an.setRepeatCount(0);
an.setFillAfter(true);
this.customOverlayLayout.setAnimation(an);
}
}
private void setResultAndFinish(int resultCode, Intent data) {
setResult(resultCode, data);
markedCardImage = null;
finish();
}
public Rect getTorchRect() {
OverlayView overlayView = this.mOverlay;
if (overlayView == null) {
return null;
}
return overlayView.getTorchRect();
}
}