正在查看: Clash Legends v0.0.1 应用的 DataEntryActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 DataEntryActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package io.card.payment;
import android.R;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.text.method.DateKeyListener;
import android.text.method.DigitsKeyListener;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
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;
import kotlinx.coroutines.internal.LockFreeTaskQueueCore;
public final class DataEntryActivity extends Activity implements TextWatcher {
private static final String TAG = DataEntryActivity.class.getSimpleName();
private TextView activityTitleTextView;
private boolean autoAcceptDone;
private Button cancelBtn;
private CreditCard capture;
private ImageView cardView;
private EditText cardholderNameEdit;
private Validator cardholderNameValidator;
private EditText cvvEdit;
private Validator cvvValidator;
private int defaultTextColor;
private Button doneBtn;
private EditText expiryEdit;
private Validator expiryValidator;
private String labelLeftPadding;
private EditText numberEdit;
private Validator numberValidator;
private EditText postalCodeEdit;
private Validator postalCodeValidator;
private boolean useApplicationTheme;
private int viewIdCounter = 1;
private int editTextIdCounter = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
int i;
int i2;
String str;
RelativeLayout container;
String str2;
super.onCreate(savedInstanceState);
if (getIntent().getExtras() == null) {
onBackPressed();
return;
}
boolean booleanExtra = getIntent().getBooleanExtra(CardIOActivity.EXTRA_KEEP_APPLICATION_THEME, false);
this.useApplicationTheme = booleanExtra;
ActivityHelper.setActivityTheme(this, booleanExtra);
this.defaultTextColor = new TextView(this).getTextColors().getDefaultColor();
this.labelLeftPadding = ActivityHelper.holoSupported() ? "12dip" : "2dip";
LocalizedStrings.setLanguage(getIntent());
int paddingPx = ViewUtil.typedDimensionValueToPixelsInt("4dip", this);
RelativeLayout relativeLayout = new RelativeLayout(this);
if (!this.useApplicationTheme) {
relativeLayout.setBackgroundColor(Appearance.DEFAULT_BACKGROUND_COLOR);
}
ScrollView scrollView = new ScrollView(this);
int i3 = this.viewIdCounter;
this.viewIdCounter = i3 + 1;
scrollView.setId(i3);
RelativeLayout.LayoutParams scrollParams = new RelativeLayout.LayoutParams(-1, -2);
scrollParams.addRule(10);
relativeLayout.addView(scrollView, scrollParams);
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(1);
scrollView.addView(linearLayout, -1, -1);
LinearLayout linearLayout2 = new LinearLayout(this);
linearLayout2.setOrientation(1);
ViewGroup.LayoutParams mainParams = new LinearLayout.LayoutParams(-1, -1);
this.capture = (CreditCard) getIntent().getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);
this.autoAcceptDone = getIntent().getBooleanExtra("debug_autoAcceptResult", false);
if (this.capture != null) {
this.numberValidator = new CardNumberValidator(this.capture.cardNumber);
this.cardView = new ImageView(this);
LinearLayout.LayoutParams cardParams = new LinearLayout.LayoutParams(-1, -2);
this.cardView.setPadding(0, 0, 0, paddingPx);
cardParams.weight = 1.0f;
this.cardView.setImageBitmap(CardIOActivity.markedCardImage);
linearLayout2.addView(this.cardView, cardParams);
ViewUtil.setMargins(this.cardView, null, null, null, "8dip");
i2 = -2;
i = -1;
} else {
TextView textView = new TextView(this);
this.activityTitleTextView = textView;
textView.setTextSize(24.0f);
if (!this.useApplicationTheme) {
this.activityTitleTextView.setTextColor(Appearance.PAY_BLUE_COLOR);
}
linearLayout2.addView(this.activityTitleTextView);
ViewUtil.setPadding(this.activityTitleTextView, null, null, null, "8dip");
ViewUtil.setDimensions(this.activityTitleTextView, -2, -2);
LinearLayout numberLayout = new LinearLayout(this);
numberLayout.setOrientation(1);
ViewUtil.setPadding(numberLayout, null, "4dip", null, "4dip");
TextView numberLabel = new TextView(this);
ViewUtil.setPadding(numberLabel, this.labelLeftPadding, null, null, null);
numberLabel.setText(LocalizedStrings.getString(StringKey.ENTRY_CARD_NUMBER));
if (!this.useApplicationTheme) {
numberLabel.setTextColor(Appearance.TEXT_COLOR_LABEL);
}
numberLayout.addView(numberLabel, -2, -2);
EditText editText = new EditText(this);
this.numberEdit = editText;
int i4 = this.editTextIdCounter;
this.editTextIdCounter = i4 + 1;
editText.setId(i4);
this.numberEdit.setMaxLines(1);
this.numberEdit.setImeOptions(6);
this.numberEdit.setTextAppearance(getApplicationContext(), R.attr.textAppearanceLarge);
this.numberEdit.setInputType(3);
this.numberEdit.setHint("1234 5678 1234 5678");
if (!this.useApplicationTheme) {
this.numberEdit.setHintTextColor(-3355444);
}
CardNumberValidator cardNumberValidator = new CardNumberValidator();
this.numberValidator = cardNumberValidator;
this.numberEdit.addTextChangedListener(cardNumberValidator);
this.numberEdit.addTextChangedListener(this);
this.numberEdit.setFilters(new InputFilter[]{new DigitsKeyListener(), this.numberValidator});
i = -1;
i2 = -2;
numberLayout.addView(this.numberEdit, -1, -2);
linearLayout2.addView(numberLayout, -1, -1);
}
LinearLayout linearLayout3 = new LinearLayout(this);
ViewGroup.LayoutParams optionLayoutParam = new LinearLayout.LayoutParams(i, i2);
ViewUtil.setPadding(linearLayout3, null, "4dip", null, "4dip");
linearLayout3.setOrientation(0);
boolean requireExpiry = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, false);
boolean requireCVV = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false);
boolean requirePostalCode = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false);
if (requireExpiry) {
LinearLayout expiryLayout = new LinearLayout(this);
container = relativeLayout;
str = "4dip";
str2 = "8dip";
LinearLayout.LayoutParams expiryLayoutParam = new LinearLayout.LayoutParams(0, -1, 1.0f);
expiryLayout.setOrientation(1);
TextView expiryLabel = new TextView(this);
if (!this.useApplicationTheme) {
expiryLabel.setTextColor(Appearance.TEXT_COLOR_LABEL);
}
expiryLabel.setText(LocalizedStrings.getString(StringKey.ENTRY_EXPIRES));
ViewUtil.setPadding(expiryLabel, this.labelLeftPadding, null, null, null);
expiryLayout.addView(expiryLabel, -2, -2);
EditText editText2 = new EditText(this);
this.expiryEdit = editText2;
int i5 = this.editTextIdCounter;
this.editTextIdCounter = i5 + 1;
editText2.setId(i5);
this.expiryEdit.setMaxLines(1);
this.expiryEdit.setImeOptions(6);
this.expiryEdit.setTextAppearance(getApplicationContext(), R.attr.textAppearanceLarge);
this.expiryEdit.setInputType(3);
this.expiryEdit.setHint(LocalizedStrings.getString(StringKey.EXPIRES_PLACEHOLDER));
if (!this.useApplicationTheme) {
this.expiryEdit.setHintTextColor(-3355444);
}
if (this.capture != null) {
this.expiryValidator = new ExpiryValidator(this.capture.expiryMonth, this.capture.expiryYear);
} else {
this.expiryValidator = new ExpiryValidator();
}
if (this.expiryValidator.hasFullLength()) {
this.expiryEdit.setText(this.expiryValidator.getValue());
}
this.expiryEdit.addTextChangedListener(this.expiryValidator);
this.expiryEdit.addTextChangedListener(this);
this.expiryEdit.setFilters(new InputFilter[]{new DateKeyListener(), this.expiryValidator});
expiryLayout.addView(this.expiryEdit, -1, -2);
linearLayout3.addView(expiryLayout, expiryLayoutParam);
ViewUtil.setMargins(expiryLayout, null, null, (requireCVV || requirePostalCode) ? str : null, null);
} else {
str = "4dip";
container = relativeLayout;
str2 = "8dip";
this.expiryValidator = new AlwaysValid();
}
if (requireCVV) {
LinearLayout cvvLayout = new LinearLayout(this);
LinearLayout.LayoutParams cvvLayoutParam = new LinearLayout.LayoutParams(0, -1, 1.0f);
cvvLayout.setOrientation(1);
TextView cvvLabel = new TextView(this);
if (!this.useApplicationTheme) {
cvvLabel.setTextColor(Appearance.TEXT_COLOR_LABEL);
}
ViewUtil.setPadding(cvvLabel, this.labelLeftPadding, null, null, null);
cvvLabel.setText(LocalizedStrings.getString(StringKey.ENTRY_CVV));
cvvLayout.addView(cvvLabel, -2, -2);
EditText editText3 = new EditText(this);
this.cvvEdit = editText3;
int i6 = this.editTextIdCounter;
this.editTextIdCounter = i6 + 1;
editText3.setId(i6);
this.cvvEdit.setMaxLines(1);
this.cvvEdit.setImeOptions(6);
this.cvvEdit.setTextAppearance(getApplicationContext(), R.attr.textAppearanceLarge);
this.cvvEdit.setInputType(3);
this.cvvEdit.setHint("123");
if (!this.useApplicationTheme) {
this.cvvEdit.setHintTextColor(-3355444);
}
int length = 4;
if (this.capture != null) {
CardType type = CardType.fromCardNumber(this.numberValidator.getValue());
length = type.cvvLength();
}
this.cvvValidator = new FixedLengthValidator(length);
this.cvvEdit.setFilters(new InputFilter[]{new DigitsKeyListener(), this.cvvValidator});
this.cvvEdit.addTextChangedListener(this.cvvValidator);
this.cvvEdit.addTextChangedListener(this);
cvvLayout.addView(this.cvvEdit, -1, -2);
linearLayout3.addView(cvvLayout, cvvLayoutParam);
ViewUtil.setMargins(cvvLayout, requireExpiry ? str : null, null, requirePostalCode ? str : null, null);
} else {
this.cvvValidator = new AlwaysValid();
}
if (requirePostalCode) {
LinearLayout postalCodeLayout = new LinearLayout(this);
LinearLayout.LayoutParams postalCodeLayoutParam = new LinearLayout.LayoutParams(0, -1, 1.0f);
postalCodeLayout.setOrientation(1);
TextView zipLabel = new TextView(this);
if (!this.useApplicationTheme) {
zipLabel.setTextColor(Appearance.TEXT_COLOR_LABEL);
}
ViewUtil.setPadding(zipLabel, this.labelLeftPadding, null, null, null);
zipLabel.setText(LocalizedStrings.getString(StringKey.ENTRY_POSTAL_CODE));
postalCodeLayout.addView(zipLabel, -2, -2);
boolean postalCodeNumericOnly = getIntent().getBooleanExtra(CardIOActivity.EXTRA_RESTRICT_POSTAL_CODE_TO_NUMERIC_ONLY, false);
EditText editText4 = new EditText(this);
this.postalCodeEdit = editText4;
int i7 = this.editTextIdCounter;
this.editTextIdCounter = i7 + 1;
editText4.setId(i7);
this.postalCodeEdit.setMaxLines(1);
this.postalCodeEdit.setImeOptions(6);
this.postalCodeEdit.setTextAppearance(getApplicationContext(), R.attr.textAppearanceLarge);
if (postalCodeNumericOnly) {
this.postalCodeEdit.setInputType(3);
} else {
this.postalCodeEdit.setInputType(1);
}
if (!this.useApplicationTheme) {
this.postalCodeEdit.setHintTextColor(-3355444);
}
MaxLengthValidator maxLengthValidator = new MaxLengthValidator(20);
this.postalCodeValidator = maxLengthValidator;
this.postalCodeEdit.addTextChangedListener(maxLengthValidator);
this.postalCodeEdit.addTextChangedListener(this);
postalCodeLayout.addView(this.postalCodeEdit, -1, -2);
linearLayout3.addView(postalCodeLayout, postalCodeLayoutParam);
ViewUtil.setMargins(postalCodeLayout, (requireExpiry || requireCVV) ? str : null, null, null, null);
} else {
this.postalCodeValidator = new AlwaysValid();
}
linearLayout2.addView(linearLayout3, optionLayoutParam);
addCardholderNameIfNeeded(linearLayout2);
linearLayout.addView(linearLayout2, mainParams);
ViewUtil.setMargins(linearLayout2, "16dip", "20dip", "16dip", "20dip");
LinearLayout buttonLayout = new LinearLayout(this);
int i8 = this.viewIdCounter;
this.viewIdCounter = i8 + 1;
buttonLayout.setId(i8);
RelativeLayout.LayoutParams buttonLayoutParam = new RelativeLayout.LayoutParams(-1, -2);
buttonLayoutParam.addRule(12);
buttonLayout.setPadding(0, paddingPx, 0, 0);
buttonLayout.setBackgroundColor(0);
scrollParams.addRule(2, buttonLayout.getId());
this.doneBtn = new Button(this);
LinearLayout.LayoutParams doneParam = new LinearLayout.LayoutParams(-1, -2, 1.0f);
this.doneBtn.setText(LocalizedStrings.getString(StringKey.DONE));
this.doneBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DataEntryActivity.this.completed();
}
});
this.doneBtn.setEnabled(false);
buttonLayout.addView(this.doneBtn, doneParam);
ViewUtil.styleAsButton(this.doneBtn, true, this, this.useApplicationTheme);
ViewUtil.setPadding(this.doneBtn, "5dip", null, "5dip", null);
String str3 = str2;
ViewUtil.setMargins(this.doneBtn, str3, str3, str3, str3);
if (!this.useApplicationTheme) {
this.doneBtn.setTextSize(16.0f);
}
this.cancelBtn = new Button(this);
LinearLayout.LayoutParams cancelParam = new LinearLayout.LayoutParams(-1, -2, 1.0f);
this.cancelBtn.setText(LocalizedStrings.getString(StringKey.CANCEL));
this.cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DataEntryActivity.this.onBackPressed();
}
});
buttonLayout.addView(this.cancelBtn, cancelParam);
ViewUtil.styleAsButton(this.cancelBtn, false, this, this.useApplicationTheme);
ViewUtil.setPadding(this.cancelBtn, "5dip", null, "5dip", null);
ViewUtil.setMargins(this.cancelBtn, str, str3, str3, str3);
if (!this.useApplicationTheme) {
this.cancelBtn.setTextSize(16.0f);
}
RelativeLayout container2 = container;
container2.addView(buttonLayout, buttonLayoutParam);
ActivityHelper.addActionBarIfSupported(this);
setContentView(container2);
Drawable icon = null;
boolean usePayPalActionBarIcon = getIntent().getBooleanExtra(CardIOActivity.EXTRA_USE_PAYPAL_ACTIONBAR_ICON, true);
if (usePayPalActionBarIcon) {
icon = getResources().getDrawable(R.drawable.cio_ic_paypal_monogram);
}
if (requireExpiry && this.expiryValidator.isValid()) {
afterTextChanged(this.expiryEdit.getEditableText());
}
ActivityHelper.setupActionBarIfSupported(this, this.activityTitleTextView, LocalizedStrings.getString(StringKey.MANUAL_ENTRY_TITLE), "card.io - ", icon);
}
public void completed() {
if (this.capture == null) {
this.capture = new CreditCard();
}
if (this.expiryEdit != null) {
this.capture.expiryMonth = ((ExpiryValidator) this.expiryValidator).month;
this.capture.expiryYear = ((ExpiryValidator) this.expiryValidator).year;
}
CreditCard result = new CreditCard(this.numberValidator.getValue(), this.capture.expiryMonth, this.capture.expiryYear, this.cvvValidator.getValue(), this.postalCodeValidator.getValue(), this.cardholderNameValidator.getValue());
Intent dataIntent = new Intent();
dataIntent.putExtra(CardIOActivity.EXTRA_SCAN_RESULT, result);
if (getIntent().hasExtra(CardIOActivity.EXTRA_CAPTURED_CARD_IMAGE)) {
dataIntent.putExtra(CardIOActivity.EXTRA_CAPTURED_CARD_IMAGE, getIntent().getByteArrayExtra(CardIOActivity.EXTRA_CAPTURED_CARD_IMAGE));
}
setResult(CardIOActivity.RESULT_CARD_INFO, dataIntent);
finish();
}
@Override
public void onBackPressed() {
setResult(CardIOActivity.RESULT_ENTRY_CANCELED);
finish();
}
@Override
protected void onResume() {
super.onResume();
getWindow().setFlags(0, LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY);
ActivityHelper.setFlagSecure(this);
validateAndEnableDoneButtonIfValid();
if (this.numberEdit == null && this.expiryEdit != null && !this.expiryValidator.isValid()) {
this.expiryEdit.requestFocus();
} else {
advanceToNextEmptyField();
}
if (this.numberEdit != null || this.expiryEdit != null || this.cvvEdit != null || this.postalCodeEdit != null || this.cardholderNameEdit != null) {
getWindow().setSoftInputMode(5);
}
}
private EditText advanceToNextEmptyField() {
int viewId = 100;
while (true) {
int viewId2 = viewId + 1;
EditText et = (EditText) findViewById(viewId);
if (et != null) {
if (et.getText().length() == 0 && et.requestFocus()) {
return et;
}
viewId = viewId2;
} else {
return null;
}
}
}
private void validateAndEnableDoneButtonIfValid() {
this.doneBtn.setEnabled(this.numberValidator.isValid() && this.expiryValidator.isValid() && this.cvvValidator.isValid() && this.postalCodeValidator.isValid() && this.cardholderNameValidator.isValid());
if (this.autoAcceptDone && this.numberValidator.isValid() && this.expiryValidator.isValid() && this.cvvValidator.isValid() && this.postalCodeValidator.isValid() && this.cardholderNameValidator.isValid()) {
completed();
}
}
@Override
public void afterTextChanged(Editable et) {
EditText editText = this.numberEdit;
if (editText != null && et == editText.getText()) {
if (this.numberValidator.hasFullLength()) {
if (!this.numberValidator.isValid()) {
this.numberEdit.setTextColor(Appearance.TEXT_COLOR_ERROR);
} else {
setDefaultColor(this.numberEdit);
advanceToNextEmptyField();
}
} else {
setDefaultColor(this.numberEdit);
}
if (this.cvvEdit != null) {
CardType type = CardType.fromCardNumber(this.numberValidator.getValue().toString());
FixedLengthValidator v = (FixedLengthValidator) this.cvvValidator;
int length = type.cvvLength();
v.requiredLength = length;
this.cvvEdit.setHint(length == 4 ? "1234" : "123");
}
} else {
EditText editText2 = this.expiryEdit;
if (editText2 != null && et == editText2.getText()) {
if (this.expiryValidator.hasFullLength()) {
if (!this.expiryValidator.isValid()) {
this.expiryEdit.setTextColor(Appearance.TEXT_COLOR_ERROR);
} else {
setDefaultColor(this.expiryEdit);
advanceToNextEmptyField();
}
} else {
setDefaultColor(this.expiryEdit);
}
} else {
EditText editText3 = this.cvvEdit;
if (editText3 != null && et == editText3.getText()) {
if (this.cvvValidator.hasFullLength()) {
if (!this.cvvValidator.isValid()) {
this.cvvEdit.setTextColor(Appearance.TEXT_COLOR_ERROR);
} else {
setDefaultColor(this.cvvEdit);
advanceToNextEmptyField();
}
} else {
setDefaultColor(this.cvvEdit);
}
} else {
EditText editText4 = this.postalCodeEdit;
if (editText4 != null && et == editText4.getText()) {
if (this.postalCodeValidator.hasFullLength()) {
if (!this.postalCodeValidator.isValid()) {
this.postalCodeEdit.setTextColor(Appearance.TEXT_COLOR_ERROR);
} else {
setDefaultColor(this.postalCodeEdit);
}
} else {
setDefaultColor(this.postalCodeEdit);
}
} else {
EditText editText5 = this.cardholderNameEdit;
if (editText5 != null && et == editText5.getText()) {
if (this.cardholderNameValidator.hasFullLength()) {
if (!this.cardholderNameValidator.isValid()) {
this.cardholderNameEdit.setTextColor(Appearance.TEXT_COLOR_ERROR);
} else {
setDefaultColor(this.cardholderNameEdit);
}
} else {
setDefaultColor(this.cardholderNameEdit);
}
}
}
}
}
}
validateAndEnableDoneButtonIfValid();
}
private void setDefaultColor(EditText editText) {
if (this.useApplicationTheme) {
editText.setTextColor(this.defaultTextColor);
} else {
editText.setTextColor(-12303292);
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
}
private void addCardholderNameIfNeeded(ViewGroup viewGroup) {
boolean requireCardholderName = getIntent().getBooleanExtra(CardIOActivity.EXTRA_REQUIRE_CARDHOLDER_NAME, false);
if (requireCardholderName) {
LinearLayout cardholderNameLayout = new LinearLayout(this);
ViewUtil.setPadding(cardholderNameLayout, null, "4dip", null, null);
cardholderNameLayout.setOrientation(1);
TextView cardholderNameLabel = new TextView(this);
if (!this.useApplicationTheme) {
cardholderNameLabel.setTextColor(Appearance.TEXT_COLOR_LABEL);
}
ViewUtil.setPadding(cardholderNameLabel, this.labelLeftPadding, null, null, null);
cardholderNameLabel.setText(LocalizedStrings.getString(StringKey.ENTRY_CARDHOLDER_NAME));
cardholderNameLayout.addView(cardholderNameLabel, -2, -2);
EditText editText = new EditText(this);
this.cardholderNameEdit = editText;
int i = this.editTextIdCounter;
this.editTextIdCounter = i + 1;
editText.setId(i);
this.cardholderNameEdit.setMaxLines(1);
this.cardholderNameEdit.setImeOptions(6);
this.cardholderNameEdit.setTextAppearance(getApplicationContext(), R.attr.textAppearanceLarge);
this.cardholderNameEdit.setInputType(1);
if (!this.useApplicationTheme) {
this.cardholderNameEdit.setHintTextColor(-3355444);
}
MaxLengthValidator maxLengthValidator = new MaxLengthValidator(175);
this.cardholderNameValidator = maxLengthValidator;
this.cardholderNameEdit.addTextChangedListener(maxLengthValidator);
this.cardholderNameEdit.addTextChangedListener(this);
cardholderNameLayout.addView(this.cardholderNameEdit, -1, -2);
viewGroup.addView(cardholderNameLayout, -1, -2);
return;
}
this.cardholderNameValidator = new AlwaysValid();
}
}