TRsnnPP♥️️ v2.7.0版本的 MD5 值为:b2c0ede0dab6219a3c74c99b83ed6b25
以下内容为反编译后的 TwoStepVerificationActivity.java 源代码,内容仅作参考
package im.uslhaplvsp.ui;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Vibrator;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.extractor.ts.TsExtractor;
import im.uslhaplvsp.messenger.AndroidUtilities;
import im.uslhaplvsp.messenger.FileLog;
import im.uslhaplvsp.messenger.LocaleController;
import im.uslhaplvsp.messenger.NotificationCenter;
import im.uslhaplvsp.messenger.R;
import im.uslhaplvsp.messenger.SRPHelper;
import im.uslhaplvsp.messenger.UserConfig;
import im.uslhaplvsp.messenger.Utilities;
import im.uslhaplvsp.messenger.browser.Browser;
import im.uslhaplvsp.tgnet.ConnectionsManager;
import im.uslhaplvsp.tgnet.RequestDelegate;
import im.uslhaplvsp.tgnet.TLObject;
import im.uslhaplvsp.tgnet.TLRPC;
import im.uslhaplvsp.ui.actionbar.ActionBar;
import im.uslhaplvsp.ui.actionbar.ActionBarMenuItem;
import im.uslhaplvsp.ui.actionbar.AlertDialog;
import im.uslhaplvsp.ui.actionbar.BaseFragment;
import im.uslhaplvsp.ui.actionbar.Theme;
import im.uslhaplvsp.ui.actionbar.ThemeDescription;
import im.uslhaplvsp.ui.cells.EditTextSettingsCell;
import im.uslhaplvsp.ui.cells.TextInfoPrivacyCell;
import im.uslhaplvsp.ui.cells.TextSettingsCell;
import im.uslhaplvsp.ui.components.AlertsCreator;
import im.uslhaplvsp.ui.components.ContextProgressView;
import im.uslhaplvsp.ui.components.EditTextBoldCursor;
import im.uslhaplvsp.ui.components.EmptyTextProgressView;
import im.uslhaplvsp.ui.components.LayoutHelper;
import im.uslhaplvsp.ui.components.RecyclerListView;
import im.uslhaplvsp.ui.components.toast.ToastUtils;
import java.math.BigInteger;
public class TwoStepVerificationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private static final int done_button = 1;
private int abortPasswordRow;
private TextView bottomButton;
private TextView bottomTextView;
private int changePasswordRow;
private int changeRecoveryEmailRow;
private boolean closeAfterSet;
private EditTextSettingsCell codeFieldCell;
private TLRPC.TL_account_password currentPassword;
private byte[] currentPasswordHash;
private byte[] currentSecret;
private long currentSecretId;
private TwoStepVerificationActivityDelegate delegate;
private boolean destroyed;
private ActionBarMenuItem doneItem;
private AnimatorSet doneItemAnimation;
private String email;
private int emailCodeLength;
private boolean emailOnly;
private EmptyTextProgressView emptyView;
private String firstPassword;
private String hint;
private ListAdapter listAdapter;
private RecyclerListView listView;
private boolean loading;
private int passwordCodeFieldRow;
private EditTextBoldCursor passwordEditText;
private int passwordEnabledDetailRow;
private boolean passwordEntered;
private int passwordSetState;
private int passwordSetupDetailRow;
private boolean paused;
private AlertDialog progressDialog;
private ContextProgressView progressView;
private int resendCodeRow;
private int rowCount;
private ScrollView scrollView;
private int setPasswordDetailRow;
private int setPasswordRow;
private int setRecoveryEmailRow;
private int shadowRow;
private Runnable shortPollRunnable;
private TextView titleTextView;
private int turnPasswordOffRow;
private int type;
private boolean waitingForEmail;
public interface TwoStepVerificationActivityDelegate {
void didEnterPassword(TLRPC.InputCheckPasswordSRP inputCheckPasswordSRP);
}
public static void lambda$checkSecretValues$26(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$null$8(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public TwoStepVerificationActivity(int i) {
this.emailCodeLength = 6;
this.passwordEntered = true;
this.currentPasswordHash = new byte[0];
this.type = i;
if (i == 0) {
loadPasswordInfo(false);
}
}
public TwoStepVerificationActivity(int i, int i2) {
this.emailCodeLength = 6;
this.passwordEntered = true;
this.currentPasswordHash = new byte[0];
this.currentAccount = i;
this.type = i2;
if (i2 == 0) {
loadPasswordInfo(false);
}
}
public void setRecoveryParams(TLRPC.TL_account_password tL_account_password) {
this.currentPassword = tL_account_password;
this.passwordSetState = 4;
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
updateRows();
if (this.type != 0) {
return true;
}
NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.didSetTwoStepPassword);
return true;
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
if (this.type == 0) {
NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.didSetTwoStepPassword);
Runnable runnable = this.shortPollRunnable;
if (runnable != null) {
AndroidUtilities.cancelRunOnUIThread(runnable);
this.shortPollRunnable = null;
}
this.destroyed = true;
}
AlertDialog alertDialog = this.progressDialog;
if (alertDialog != null) {
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
this.progressDialog = null;
}
AndroidUtilities.removeAdjustResize(getParentActivity(), this.classGuid);
}
@Override
public View createView(Context context) {
this.actionBar.setBackButtonImage(R.mipmap.ic_back);
this.actionBar.setAllowOverlayTitle(false);
this.actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int i) {
if (i == -1) {
TwoStepVerificationActivity.this.finishFragment();
} else if (i == 1) {
TwoStepVerificationActivity.this.processDone();
}
}
});
this.fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) this.fragmentView;
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
this.doneItem = this.actionBar.createMenu().addItemWithWidth(1, R.drawable.ic_done, AndroidUtilities.dp(56.0f));
ContextProgressView contextProgressView = new ContextProgressView(context, 1);
this.progressView = contextProgressView;
contextProgressView.setAlpha(0.0f);
this.progressView.setScaleX(0.1f);
this.progressView.setScaleY(0.1f);
this.progressView.setVisibility(4);
this.doneItem.addView(this.progressView, LayoutHelper.createFrame(-1, -1.0f));
ScrollView scrollView = new ScrollView(context);
this.scrollView = scrollView;
scrollView.setFillViewport(true);
frameLayout.addView(this.scrollView, LayoutHelper.createFrame(-1, -1.0f));
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(1);
this.scrollView.addView(linearLayout, LayoutHelper.createScroll(-1, -2, 51));
TextView textView = new TextView(context);
this.titleTextView = textView;
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
this.titleTextView.setTextSize(1, 18.0f);
this.titleTextView.setGravity(1);
this.titleTextView.setPadding(AndroidUtilities.dp(40.0f), 0, AndroidUtilities.dp(40.0f), 0);
linearLayout.addView(this.titleTextView, LayoutHelper.createLinear(-2, -2, 1, 0, 38, 0, 0));
EditTextBoldCursor editTextBoldCursor = new EditTextBoldCursor(context);
this.passwordEditText = editTextBoldCursor;
editTextBoldCursor.setTextSize(1, 20.0f);
this.passwordEditText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
this.passwordEditText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
this.passwordEditText.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
this.passwordEditText.setMaxLines(1);
this.passwordEditText.setLines(1);
this.passwordEditText.setGravity(1);
this.passwordEditText.setSingleLine(true);
this.passwordEditText.setInputType(TsExtractor.TS_STREAM_TYPE_AC3);
this.passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
this.passwordEditText.setTypeface(Typeface.DEFAULT);
this.passwordEditText.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
this.passwordEditText.setCursorSize(AndroidUtilities.dp(20.0f));
this.passwordEditText.setCursorWidth(1.5f);
linearLayout.addView(this.passwordEditText, LayoutHelper.createLinear(-1, 36, 51, 40, 32, 40, 0));
this.passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public final boolean onEditorAction(TextView textView2, int i, KeyEvent keyEvent) {
return TwoStepVerificationActivity.this.lambda$createView$0$TwoStepVerificationActivity(textView2, i, keyEvent);
}
});
this.passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
return false;
}
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
}
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
return false;
}
});
TextView textView2 = new TextView(context);
this.bottomTextView = textView2;
textView2.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
this.bottomTextView.setTextSize(1, 14.0f);
this.bottomTextView.setGravity((LocaleController.isRTL ? 5 : 3) | 48);
this.bottomTextView.setText(LocaleController.getString("YourEmailInfo", R.string.YourEmailInfo));
linearLayout.addView(this.bottomTextView, LayoutHelper.createLinear(-2, -2, (LocaleController.isRTL ? 5 : 3) | 48, 40, 30, 40, 0));
LinearLayout linearLayout2 = new LinearLayout(context);
linearLayout2.setGravity(80);
linearLayout.addView(linearLayout2, LayoutHelper.createLinear(-1, -1));
TextView textView3 = new TextView(context);
this.bottomButton = textView3;
textView3.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
this.bottomButton.setTextSize(1, 14.0f);
this.bottomButton.setGravity((LocaleController.isRTL ? 5 : 3) | 80);
this.bottomButton.setText(LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip));
this.bottomButton.setPadding(0, AndroidUtilities.dp(10.0f), 0, 0);
linearLayout2.addView(this.bottomButton, LayoutHelper.createLinear(-1, -2, (LocaleController.isRTL ? 5 : 3) | 80, 40, 0, 40, 14));
this.bottomButton.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TwoStepVerificationActivity.this.lambda$createView$6$TwoStepVerificationActivity(view);
}
});
int i = this.type;
if (i == 0) {
EmptyTextProgressView emptyTextProgressView = new EmptyTextProgressView(context);
this.emptyView = emptyTextProgressView;
emptyTextProgressView.showProgress();
frameLayout.addView(this.emptyView, LayoutHelper.createFrame(-1, -1.0f));
RecyclerListView recyclerListView = new RecyclerListView(context);
this.listView = recyclerListView;
recyclerListView.setLayoutManager(new LinearLayoutManager(context, 1, false));
this.listView.setEmptyView(this.emptyView);
this.listView.setVerticalScrollBarEnabled(false);
frameLayout.addView(this.listView, LayoutHelper.createFrame(-1, -1.0f));
RecyclerListView recyclerListView2 = this.listView;
ListAdapter listAdapter = new ListAdapter(context);
this.listAdapter = listAdapter;
recyclerListView2.setAdapter(listAdapter);
this.listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
@Override
public final void onItemClick(View view, int i2) {
TwoStepVerificationActivity.this.lambda$createView$9$TwoStepVerificationActivity(view, i2);
}
});
EditTextSettingsCell editTextSettingsCell = new EditTextSettingsCell(context);
this.codeFieldCell = editTextSettingsCell;
editTextSettingsCell.setTextAndHint("", LocaleController.getString("PasswordCode", R.string.PasswordCode), false);
this.codeFieldCell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
EditTextBoldCursor textView4 = this.codeFieldCell.getTextView();
textView4.setInputType(3);
textView4.setImeOptions(6);
textView4.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public final boolean onEditorAction(TextView textView5, int i2, KeyEvent keyEvent) {
return TwoStepVerificationActivity.this.lambda$createView$10$TwoStepVerificationActivity(textView5, i2, keyEvent);
}
});
textView4.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
}
@Override
public void afterTextChanged(Editable editable) {
if (TwoStepVerificationActivity.this.emailCodeLength == 0 || editable.length() != TwoStepVerificationActivity.this.emailCodeLength) {
return;
}
TwoStepVerificationActivity.this.processDone();
}
});
updateRows();
this.actionBar.setTitle(LocaleController.getString("TwoStepVerificationTitle", R.string.TwoStepVerificationTitle));
if (this.delegate != null) {
this.titleTextView.setText(LocaleController.getString("PleaseEnterCurrentPasswordTransfer", R.string.PleaseEnterCurrentPasswordTransfer));
} else {
this.titleTextView.setText(LocaleController.getString("PleaseEnterCurrentPassword", R.string.PleaseEnterCurrentPassword));
}
} else if (i == 1) {
setPasswordSetState(this.passwordSetState);
}
if (this.passwordEntered && this.type != 1) {
this.fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
this.fragmentView.setTag(Theme.key_windowBackgroundGray);
} else {
this.fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
this.fragmentView.setTag(Theme.key_windowBackgroundWhite);
}
return this.fragmentView;
}
public boolean lambda$createView$0$TwoStepVerificationActivity(TextView textView, int i, KeyEvent keyEvent) {
if (i != 5 && i != 6) {
return false;
}
processDone();
return true;
}
public void lambda$createView$6$TwoStepVerificationActivity(View view) {
if (this.type == 0) {
if (this.currentPassword.has_recovery) {
needShowProgress();
ConnectionsManager.getInstance(this.currentAccount).sendRequest(new TLRPC.TL_auth_requestPasswordRecovery(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.this.lambda$null$3$TwoStepVerificationActivity(tLObject, tL_error);
}
}, 10);
return;
} else {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder.setNegativeButton(LocaleController.getString("RestorePasswordResetAccount", R.string.RestorePasswordResetAccount), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
TwoStepVerificationActivity.this.lambda$null$4$TwoStepVerificationActivity(dialogInterface, i);
}
});
builder.setTitle(LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle));
builder.setMessage(LocaleController.getString("RestorePasswordNoEmailText", R.string.RestorePasswordNoEmailText));
showDialog(builder.create());
return;
}
}
if (this.passwordSetState == 4) {
showAlertWithText(LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle), LocaleController.getString("RestoreEmailTroubleText", R.string.RestoreEmailTroubleText));
return;
}
AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity());
builder2.setMessage(LocaleController.getString("YourEmailSkipWarningText", R.string.YourEmailSkipWarningText));
builder2.setTitle(LocaleController.getString("YourEmailSkipWarning", R.string.YourEmailSkipWarning));
builder2.setPositiveButton(LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
TwoStepVerificationActivity.this.lambda$null$5$TwoStepVerificationActivity(dialogInterface, i);
}
});
builder2.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder2.create());
}
public void lambda$null$3$TwoStepVerificationActivity(final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$2$TwoStepVerificationActivity(tL_error, tLObject);
}
});
}
public void lambda$null$2$TwoStepVerificationActivity(TLRPC.TL_error tL_error, TLObject tLObject) {
String formatPluralString;
needHideProgress();
if (tL_error == null) {
final TLRPC.TL_auth_passwordRecovery tL_auth_passwordRecovery = (TLRPC.TL_auth_passwordRecovery) tLObject;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.formatString("RestoreEmailSent", R.string.RestoreEmailSent, tL_auth_passwordRecovery.email_pattern));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
TwoStepVerificationActivity.this.lambda$null$1$TwoStepVerificationActivity(tL_auth_passwordRecovery, dialogInterface, i);
}
});
Dialog showDialog = showDialog(builder.create());
if (showDialog != null) {
showDialog.setCanceledOnTouchOutside(false);
showDialog.setCancelable(false);
return;
}
return;
}
if (tL_error.text.startsWith("FLOOD_WAIT")) {
int intValue = Utilities.parseInt(tL_error.text).intValue();
if (intValue < 60) {
formatPluralString = LocaleController.formatPluralString("Seconds", intValue);
} else {
formatPluralString = LocaleController.formatPluralString("Minutes", intValue / 60);
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, formatPluralString));
return;
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), tL_error.text);
}
public void lambda$null$1$TwoStepVerificationActivity(TLRPC.TL_auth_passwordRecovery tL_auth_passwordRecovery, DialogInterface dialogInterface, int i) {
TwoStepVerificationActivity twoStepVerificationActivity = new TwoStepVerificationActivity(this.currentAccount, 1);
TLRPC.TL_account_password tL_account_password = this.currentPassword;
twoStepVerificationActivity.currentPassword = tL_account_password;
tL_account_password.email_unconfirmed_pattern = tL_auth_passwordRecovery.email_pattern;
twoStepVerificationActivity.currentSecretId = this.currentSecretId;
twoStepVerificationActivity.currentSecret = this.currentSecret;
twoStepVerificationActivity.passwordSetState = 4;
presentFragment(twoStepVerificationActivity);
}
public void lambda$null$4$TwoStepVerificationActivity(DialogInterface dialogInterface, int i) {
Browser.openUrl(getParentActivity(), "https://m12345.cc/deactivate?phone=" + UserConfig.getInstance(this.currentAccount).getClientPhone());
}
public void lambda$null$5$TwoStepVerificationActivity(DialogInterface dialogInterface, int i) {
this.email = "";
setNewPassword(false);
}
public void lambda$createView$9$TwoStepVerificationActivity(View view, int i) {
String string;
if (i == this.setPasswordRow || i == this.changePasswordRow) {
TwoStepVerificationActivity twoStepVerificationActivity = new TwoStepVerificationActivity(this.currentAccount, 1);
twoStepVerificationActivity.currentPasswordHash = this.currentPasswordHash;
twoStepVerificationActivity.currentPassword = this.currentPassword;
twoStepVerificationActivity.currentSecretId = this.currentSecretId;
twoStepVerificationActivity.currentSecret = this.currentSecret;
presentFragment(twoStepVerificationActivity);
return;
}
if (i == this.setRecoveryEmailRow || i == this.changeRecoveryEmailRow) {
TwoStepVerificationActivity twoStepVerificationActivity2 = new TwoStepVerificationActivity(this.currentAccount, 1);
twoStepVerificationActivity2.currentPasswordHash = this.currentPasswordHash;
twoStepVerificationActivity2.currentPassword = this.currentPassword;
twoStepVerificationActivity2.currentSecretId = this.currentSecretId;
twoStepVerificationActivity2.currentSecret = this.currentSecret;
twoStepVerificationActivity2.emailOnly = true;
twoStepVerificationActivity2.passwordSetState = 3;
presentFragment(twoStepVerificationActivity2);
return;
}
if (i == this.turnPasswordOffRow || i == this.abortPasswordRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
if (i == this.abortPasswordRow) {
TLRPC.TL_account_password tL_account_password = this.currentPassword;
if (tL_account_password != null && tL_account_password.has_password) {
string = LocaleController.getString("CancelEmailQuestion", R.string.CancelEmailQuestion);
} else {
string = LocaleController.getString("CancelPasswordQuestion", R.string.CancelPasswordQuestion);
}
} else {
string = LocaleController.getString("TurnPasswordOffQuestion", R.string.TurnPasswordOffQuestion);
if (this.currentPassword.has_secure_values) {
string = string + "\n\n" + LocaleController.getString("TurnPasswordOffPassport", R.string.TurnPasswordOffPassport);
}
}
builder.setMessage(string);
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i2) {
TwoStepVerificationActivity.this.lambda$null$7$TwoStepVerificationActivity(dialogInterface, i2);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
return;
}
if (i == this.resendCodeRow) {
ConnectionsManager.getInstance(this.currentAccount).sendRequest(new TLRPC.TL_account_resendPasswordEmail(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.lambda$null$8(tLObject, tL_error);
}
});
AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity());
builder2.setMessage(LocaleController.getString("ResendCodeInfo", R.string.ResendCodeInfo));
builder2.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(builder2.create());
}
}
public void lambda$null$7$TwoStepVerificationActivity(DialogInterface dialogInterface, int i) {
setNewPassword(true);
}
public boolean lambda$createView$10$TwoStepVerificationActivity(TextView textView, int i, KeyEvent keyEvent) {
if (i != 6) {
return false;
}
processDone();
return true;
}
@Override
public void didReceivedNotification(int i, int i2, Object... objArr) {
if (i == NotificationCenter.didSetTwoStepPassword) {
if (objArr != null && objArr.length > 0 && objArr[0] != null) {
this.currentPasswordHash = (byte[]) objArr[0];
if (this.closeAfterSet && TextUtils.isEmpty((String) objArr[4]) && this.closeAfterSet) {
removeSelfFromStack();
}
}
loadPasswordInfo(false);
updateRows();
}
}
@Override
public void onPause() {
super.onPause();
this.paused = true;
}
@Override
public void onResume() {
EditTextSettingsCell editTextSettingsCell;
super.onResume();
this.paused = false;
int i = this.type;
if (i == 1) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$onResume$11$TwoStepVerificationActivity();
}
}, 200L);
} else if (i == 0 && (editTextSettingsCell = this.codeFieldCell) != null && editTextSettingsCell.getVisibility() == 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$onResume$12$TwoStepVerificationActivity();
}
}, 200L);
}
AndroidUtilities.requestAdjustResize(getParentActivity(), this.classGuid);
}
public void lambda$onResume$11$TwoStepVerificationActivity() {
EditTextBoldCursor editTextBoldCursor = this.passwordEditText;
if (editTextBoldCursor != null) {
editTextBoldCursor.requestFocus();
AndroidUtilities.showKeyboard(this.passwordEditText);
}
}
public void lambda$onResume$12$TwoStepVerificationActivity() {
EditTextSettingsCell editTextSettingsCell = this.codeFieldCell;
if (editTextSettingsCell != null) {
editTextSettingsCell.getTextView().requestFocus();
AndroidUtilities.showKeyboard(this.codeFieldCell.getTextView());
}
}
public void setCloseAfterSet(boolean z) {
this.closeAfterSet = z;
}
public void setCurrentPasswordInfo(byte[] bArr, TLRPC.TL_account_password tL_account_password) {
if (bArr != null) {
this.currentPasswordHash = bArr;
}
this.currentPassword = tL_account_password;
}
public void setDelegate(TwoStepVerificationActivityDelegate twoStepVerificationActivityDelegate) {
this.delegate = twoStepVerificationActivityDelegate;
}
@Override
public void onTransitionAnimationEnd(boolean z, boolean z2) {
EditTextSettingsCell editTextSettingsCell;
if (z) {
int i = this.type;
if (i == 1) {
AndroidUtilities.showKeyboard(this.passwordEditText);
} else if (i == 0 && (editTextSettingsCell = this.codeFieldCell) != null && editTextSettingsCell.getVisibility() == 0) {
AndroidUtilities.showKeyboard(this.codeFieldCell.getTextView());
}
}
}
public static boolean canHandleCurrentPassword(TLRPC.TL_account_password tL_account_password, boolean z) {
return z ? !(tL_account_password.current_algo instanceof TLRPC.TL_passwordKdfAlgoUnknown) : ((tL_account_password.new_algo instanceof TLRPC.TL_passwordKdfAlgoUnknown) || (tL_account_password.current_algo instanceof TLRPC.TL_passwordKdfAlgoUnknown) || (tL_account_password.new_secure_algo instanceof TLRPC.TL_securePasswordKdfAlgoUnknown)) ? false : true;
}
public static void initPasswordNewAlgo(TLRPC.TL_account_password tL_account_password) {
if (tL_account_password.new_algo instanceof TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) {
TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow tL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow = (TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) tL_account_password.new_algo;
byte[] bArr = new byte[tL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow.salt1.length + 32];
Utilities.random.nextBytes(bArr);
System.arraycopy(tL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow.salt1, 0, bArr, 0, tL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow.salt1.length);
tL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow.salt1 = bArr;
}
if (tL_account_password.new_secure_algo instanceof TLRPC.TL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000) {
TLRPC.TL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000 tL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000 = (TLRPC.TL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000) tL_account_password.new_secure_algo;
byte[] bArr2 = new byte[tL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000.salt.length + 32];
Utilities.random.nextBytes(bArr2);
System.arraycopy(tL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000.salt, 0, bArr2, 0, tL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000.salt.length);
tL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000.salt = bArr2;
}
}
private void loadPasswordInfo(final boolean z) {
if (!z) {
this.loading = true;
ListAdapter listAdapter = this.listAdapter;
if (listAdapter != null) {
listAdapter.notifyDataSetChanged();
}
}
ConnectionsManager.getInstance(this.currentAccount).sendRequest(new TLRPC.TL_account_getPassword(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.this.lambda$loadPasswordInfo$14$TwoStepVerificationActivity(z, tLObject, tL_error);
}
}, 10);
}
public void lambda$loadPasswordInfo$14$TwoStepVerificationActivity(final boolean z, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$13$TwoStepVerificationActivity(tL_error, tLObject, z);
}
});
}
public void lambda$null$13$TwoStepVerificationActivity(TLRPC.TL_error tL_error, TLObject tLObject, boolean z) {
TLRPC.TL_account_password tL_account_password;
if (tL_error == null) {
this.loading = false;
TLRPC.TL_account_password tL_account_password2 = (TLRPC.TL_account_password) tLObject;
this.currentPassword = tL_account_password2;
if (!canHandleCurrentPassword(tL_account_password2, false)) {
AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
return;
}
if (!z) {
byte[] bArr = this.currentPasswordHash;
this.passwordEntered = (bArr != null && bArr.length > 0) || !this.currentPassword.has_password;
}
this.waitingForEmail = !TextUtils.isEmpty(this.currentPassword.email_unconfirmed_pattern);
initPasswordNewAlgo(this.currentPassword);
if (!this.paused && this.closeAfterSet && this.currentPassword.has_password) {
TLRPC.PasswordKdfAlgo passwordKdfAlgo = this.currentPassword.current_algo;
TLRPC.SecurePasswordKdfAlgo securePasswordKdfAlgo = this.currentPassword.new_secure_algo;
byte[] bArr2 = this.currentPassword.secure_random;
String str = this.currentPassword.has_recovery ? "1" : null;
String str2 = this.currentPassword.hint != null ? this.currentPassword.hint : "";
if (!this.waitingForEmail && passwordKdfAlgo != null) {
NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.didSetTwoStepPassword);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.didSetTwoStepPassword, null, passwordKdfAlgo, securePasswordKdfAlgo, bArr2, str, str2, null, null);
finishFragment();
}
}
}
if (this.type == 0 && !this.destroyed && this.shortPollRunnable == null && (tL_account_password = this.currentPassword) != null && !TextUtils.isEmpty(tL_account_password.email_unconfirmed_pattern)) {
startShortpoll();
}
updateRows();
}
private void startShortpoll() {
Runnable runnable = this.shortPollRunnable;
if (runnable != null) {
AndroidUtilities.cancelRunOnUIThread(runnable);
}
Runnable runnable2 = new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$startShortpoll$15$TwoStepVerificationActivity();
}
};
this.shortPollRunnable = runnable2;
AndroidUtilities.runOnUIThread(runnable2, DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS);
}
public void lambda$startShortpoll$15$TwoStepVerificationActivity() {
if (this.shortPollRunnable == null) {
return;
}
loadPasswordInfo(true);
this.shortPollRunnable = null;
}
private void setPasswordSetState(int i) {
if (this.passwordEditText == null) {
return;
}
this.passwordSetState = i;
if (i == 0) {
this.actionBar.setTitle(LocaleController.getString("YourPassword", R.string.YourPassword));
if (this.currentPassword.has_password) {
this.titleTextView.setText(LocaleController.getString("PleaseEnterPassword", R.string.PleaseEnterPassword));
} else {
this.titleTextView.setText(LocaleController.getString("PleaseEnterFirstPassword", R.string.PleaseEnterFirstPassword));
}
this.passwordEditText.setImeOptions(5);
this.passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
this.bottomTextView.setVisibility(4);
this.bottomButton.setVisibility(4);
} else if (i == 1) {
this.actionBar.setTitle(LocaleController.getString("YourPassword", R.string.YourPassword));
this.titleTextView.setText(LocaleController.getString("PleaseReEnterPassword", R.string.PleaseReEnterPassword));
this.passwordEditText.setImeOptions(5);
this.passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
this.bottomTextView.setVisibility(4);
this.bottomButton.setVisibility(4);
} else if (i == 2) {
this.actionBar.setTitle(LocaleController.getString("PasswordHint", R.string.PasswordHint));
this.titleTextView.setText(LocaleController.getString("PasswordHintText", R.string.PasswordHintText));
this.passwordEditText.setImeOptions(5);
this.passwordEditText.setTransformationMethod(null);
this.bottomTextView.setVisibility(4);
this.bottomButton.setVisibility(4);
} else if (i == 3) {
this.actionBar.setTitle(LocaleController.getString("RecoveryEmail", R.string.RecoveryEmail));
this.titleTextView.setText(LocaleController.getString("YourEmail", R.string.YourEmail));
this.passwordEditText.setImeOptions(5);
this.passwordEditText.setTransformationMethod(null);
this.passwordEditText.setInputType(33);
this.bottomTextView.setVisibility(0);
this.bottomButton.setVisibility(this.emailOnly ? 4 : 0);
} else if (i == 4) {
this.actionBar.setTitle(LocaleController.getString("PasswordRecovery", R.string.PasswordRecovery));
this.titleTextView.setText(LocaleController.getString("PasswordCode", R.string.PasswordCode));
this.bottomTextView.setText(LocaleController.getString("RestoreEmailSentInfo", R.string.RestoreEmailSentInfo));
TextView textView = this.bottomButton;
Object[] objArr = new Object[1];
objArr[0] = this.currentPassword.email_unconfirmed_pattern != null ? this.currentPassword.email_unconfirmed_pattern : "";
textView.setText(LocaleController.formatString("RestoreEmailTrouble", R.string.RestoreEmailTrouble, objArr));
this.passwordEditText.setImeOptions(6);
this.passwordEditText.setTransformationMethod(null);
this.passwordEditText.setInputType(3);
this.bottomTextView.setVisibility(0);
this.bottomButton.setVisibility(0);
}
this.passwordEditText.setText("");
}
private void updateRows() {
TLRPC.TL_account_password tL_account_password;
StringBuilder sb = new StringBuilder();
sb.append(this.setPasswordRow);
sb.append(this.setPasswordDetailRow);
sb.append(this.changePasswordRow);
sb.append(this.turnPasswordOffRow);
sb.append(this.setRecoveryEmailRow);
sb.append(this.changeRecoveryEmailRow);
sb.append(this.resendCodeRow);
sb.append(this.abortPasswordRow);
sb.append(this.passwordSetupDetailRow);
sb.append(this.passwordCodeFieldRow);
sb.append(this.passwordEnabledDetailRow);
sb.append(this.shadowRow);
sb.append(this.rowCount);
boolean z = this.passwordCodeFieldRow != -1;
this.rowCount = 0;
this.setPasswordRow = -1;
this.setPasswordDetailRow = -1;
this.changePasswordRow = -1;
this.turnPasswordOffRow = -1;
this.setRecoveryEmailRow = -1;
this.changeRecoveryEmailRow = -1;
this.abortPasswordRow = -1;
this.resendCodeRow = -1;
this.passwordSetupDetailRow = -1;
this.passwordCodeFieldRow = -1;
this.passwordEnabledDetailRow = -1;
this.shadowRow = -1;
if (!this.loading && (tL_account_password = this.currentPassword) != null) {
if (this.waitingForEmail) {
int i = 0 + 1;
this.rowCount = i;
this.passwordCodeFieldRow = 0;
int i2 = i + 1;
this.rowCount = i2;
this.passwordSetupDetailRow = i;
int i3 = i2 + 1;
this.rowCount = i3;
this.resendCodeRow = i2;
int i4 = i3 + 1;
this.rowCount = i4;
this.abortPasswordRow = i3;
this.rowCount = i4 + 1;
this.shadowRow = i4;
} else if (tL_account_password.has_password) {
int i5 = this.rowCount;
int i6 = i5 + 1;
this.rowCount = i6;
this.changePasswordRow = i5;
this.rowCount = i6 + 1;
this.turnPasswordOffRow = i6;
if (this.currentPassword.has_recovery) {
int i7 = this.rowCount;
this.rowCount = i7 + 1;
this.changeRecoveryEmailRow = i7;
} else {
int i8 = this.rowCount;
this.rowCount = i8 + 1;
this.setRecoveryEmailRow = i8;
}
int i9 = this.rowCount;
this.rowCount = i9 + 1;
this.passwordEnabledDetailRow = i9;
} else {
int i10 = this.rowCount;
int i11 = i10 + 1;
this.rowCount = i11;
this.setPasswordRow = i10;
this.rowCount = i11 + 1;
this.setPasswordDetailRow = i11;
}
}
StringBuilder sb2 = new StringBuilder();
sb2.append(this.setPasswordRow);
sb2.append(this.setPasswordDetailRow);
sb2.append(this.changePasswordRow);
sb2.append(this.turnPasswordOffRow);
sb2.append(this.setRecoveryEmailRow);
sb2.append(this.changeRecoveryEmailRow);
sb2.append(this.resendCodeRow);
sb2.append(this.abortPasswordRow);
sb2.append(this.passwordSetupDetailRow);
sb2.append(this.passwordCodeFieldRow);
sb2.append(this.passwordEnabledDetailRow);
sb2.append(this.shadowRow);
sb2.append(this.rowCount);
if (this.listAdapter != null && !sb.toString().equals(sb2.toString())) {
this.listAdapter.notifyDataSetChanged();
if (this.passwordCodeFieldRow == -1 && getParentActivity() != null && z) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
this.codeFieldCell.setText("", false);
}
}
if (this.fragmentView != null) {
if (this.loading || this.passwordEntered) {
RecyclerListView recyclerListView = this.listView;
if (recyclerListView != null) {
recyclerListView.setVisibility(0);
this.scrollView.setVisibility(4);
this.listView.setEmptyView(this.emptyView);
}
if (this.waitingForEmail && this.currentPassword != null) {
this.doneItem.setVisibility(0);
} else if (this.passwordEditText != null) {
this.doneItem.setVisibility(8);
this.passwordEditText.setVisibility(4);
this.titleTextView.setVisibility(4);
this.bottomTextView.setVisibility(4);
this.bottomButton.setVisibility(4);
}
this.fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
this.fragmentView.setTag(Theme.key_windowBackgroundGray);
return;
}
RecyclerListView recyclerListView2 = this.listView;
if (recyclerListView2 != null) {
recyclerListView2.setEmptyView(null);
this.listView.setVisibility(4);
this.scrollView.setVisibility(0);
this.emptyView.setVisibility(4);
}
if (this.passwordEditText != null) {
this.doneItem.setVisibility(0);
this.passwordEditText.setVisibility(0);
this.fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
this.fragmentView.setTag(Theme.key_windowBackgroundWhite);
this.titleTextView.setVisibility(0);
this.bottomButton.setVisibility(0);
this.bottomTextView.setVisibility(4);
this.bottomButton.setText(LocaleController.getString("ForgotPassword", R.string.ForgotPassword));
if (!TextUtils.isEmpty(this.currentPassword.hint)) {
this.passwordEditText.setHint(this.currentPassword.hint);
} else {
this.passwordEditText.setHint("");
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$updateRows$16$TwoStepVerificationActivity();
}
}, 200L);
}
}
}
public void lambda$updateRows$16$TwoStepVerificationActivity() {
EditTextBoldCursor editTextBoldCursor;
if (isFinishing() || this.destroyed || (editTextBoldCursor = this.passwordEditText) == null) {
return;
}
editTextBoldCursor.requestFocus();
AndroidUtilities.showKeyboard(this.passwordEditText);
}
private void showDoneProgress(final boolean z) {
AnimatorSet animatorSet = this.doneItemAnimation;
if (animatorSet != null) {
animatorSet.cancel();
}
this.doneItemAnimation = new AnimatorSet();
if (z) {
this.progressView.setVisibility(0);
this.doneItem.setEnabled(false);
this.doneItemAnimation.playTogether(ObjectAnimator.ofFloat(this.doneItem.getContentView(), "scaleX", 0.1f), ObjectAnimator.ofFloat(this.doneItem.getContentView(), "scaleY", 0.1f), ObjectAnimator.ofFloat(this.doneItem.getContentView(), "alpha", 0.0f), ObjectAnimator.ofFloat(this.progressView, "scaleX", 1.0f), ObjectAnimator.ofFloat(this.progressView, "scaleY", 1.0f), ObjectAnimator.ofFloat(this.progressView, "alpha", 1.0f));
} else {
this.doneItem.getContentView().setVisibility(0);
this.doneItem.setEnabled(true);
this.doneItemAnimation.playTogether(ObjectAnimator.ofFloat(this.progressView, "scaleX", 0.1f), ObjectAnimator.ofFloat(this.progressView, "scaleY", 0.1f), ObjectAnimator.ofFloat(this.progressView, "alpha", 0.0f), ObjectAnimator.ofFloat(this.doneItem.getContentView(), "scaleX", 1.0f), ObjectAnimator.ofFloat(this.doneItem.getContentView(), "scaleY", 1.0f), ObjectAnimator.ofFloat(this.doneItem.getContentView(), "alpha", 1.0f));
}
this.doneItemAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
if (TwoStepVerificationActivity.this.doneItemAnimation == null || !TwoStepVerificationActivity.this.doneItemAnimation.equals(animator)) {
return;
}
if (!z) {
TwoStepVerificationActivity.this.progressView.setVisibility(4);
} else {
TwoStepVerificationActivity.this.doneItem.getContentView().setVisibility(4);
}
}
@Override
public void onAnimationCancel(Animator animator) {
if (TwoStepVerificationActivity.this.doneItemAnimation == null || !TwoStepVerificationActivity.this.doneItemAnimation.equals(animator)) {
return;
}
TwoStepVerificationActivity.this.doneItemAnimation = null;
}
});
this.doneItemAnimation.setDuration(150L);
this.doneItemAnimation.start();
}
private void needShowProgress() {
if (getParentActivity() == null || getParentActivity().isFinishing() || this.progressDialog != null) {
return;
}
AlertDialog alertDialog = new AlertDialog(getParentActivity(), 3);
this.progressDialog = alertDialog;
alertDialog.setCanCancel(false);
this.progressDialog.show();
}
public void needHideProgress() {
AlertDialog alertDialog = this.progressDialog;
if (alertDialog == null) {
return;
}
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
this.progressDialog = null;
}
private boolean isValidEmail(String str) {
if (str == null || str.length() < 3) {
return false;
}
int lastIndexOf = str.lastIndexOf(46);
int lastIndexOf2 = str.lastIndexOf(64);
return lastIndexOf2 >= 0 && lastIndexOf >= lastIndexOf2;
}
private void showAlertWithText(String str, String str2) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder.setTitle(str);
builder.setMessage(str2);
showDialog(builder.create());
}
private void setNewPassword(final boolean z) {
TLRPC.TL_account_password tL_account_password;
if (z && this.waitingForEmail && this.currentPassword.has_password) {
needShowProgress();
ConnectionsManager.getInstance(this.currentAccount).sendRequest(new TLRPC.TL_account_cancelPasswordEmail(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.this.lambda$setNewPassword$18$TwoStepVerificationActivity(tLObject, tL_error);
}
});
return;
}
final String str = this.firstPassword;
final TLRPC.TL_account_updatePasswordSettings tL_account_updatePasswordSettings = new TLRPC.TL_account_updatePasswordSettings();
byte[] bArr = this.currentPasswordHash;
if (bArr == null || bArr.length == 0) {
tL_account_updatePasswordSettings.password = new TLRPC.TL_inputCheckPasswordEmpty();
}
tL_account_updatePasswordSettings.new_settings = new TLRPC.TL_account_passwordInputSettings();
if (z) {
UserConfig.getInstance(this.currentAccount).resetSavedPassword();
this.currentSecret = null;
if (this.waitingForEmail) {
tL_account_updatePasswordSettings.new_settings.flags = 2;
tL_account_updatePasswordSettings.new_settings.email = "";
tL_account_updatePasswordSettings.password = new TLRPC.TL_inputCheckPasswordEmpty();
} else {
tL_account_updatePasswordSettings.new_settings.flags = 3;
tL_account_updatePasswordSettings.new_settings.hint = "";
tL_account_updatePasswordSettings.new_settings.new_password_hash = new byte[0];
tL_account_updatePasswordSettings.new_settings.new_algo = new TLRPC.TL_passwordKdfAlgoUnknown();
tL_account_updatePasswordSettings.new_settings.email = "";
}
} else {
if (this.hint == null && (tL_account_password = this.currentPassword) != null) {
this.hint = tL_account_password.hint;
}
if (this.hint == null) {
this.hint = "";
}
if (str != null) {
tL_account_updatePasswordSettings.new_settings.flags |= 1;
tL_account_updatePasswordSettings.new_settings.hint = this.hint;
tL_account_updatePasswordSettings.new_settings.new_algo = this.currentPassword.new_algo;
}
if (this.email.length() > 0) {
TLRPC.TL_account_passwordInputSettings tL_account_passwordInputSettings = tL_account_updatePasswordSettings.new_settings;
tL_account_passwordInputSettings.flags = 2 | tL_account_passwordInputSettings.flags;
tL_account_updatePasswordSettings.new_settings.email = this.email.trim();
}
}
needShowProgress();
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$setNewPassword$25$TwoStepVerificationActivity(tL_account_updatePasswordSettings, z, str);
}
});
}
public void lambda$setNewPassword$18$TwoStepVerificationActivity(TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$17$TwoStepVerificationActivity(tL_error);
}
});
}
public void lambda$null$17$TwoStepVerificationActivity(TLRPC.TL_error tL_error) {
needHideProgress();
if (tL_error == null) {
loadPasswordInfo(false);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.didRemoveTwoStepPassword, new Object[0]);
updateRows();
}
}
public void lambda$setNewPassword$25$TwoStepVerificationActivity(final TLRPC.TL_account_updatePasswordSettings tL_account_updatePasswordSettings, final boolean z, final String str) {
final byte[] bArr;
byte[] bArr2;
byte[] bArr3;
if (tL_account_updatePasswordSettings.password == null) {
tL_account_updatePasswordSettings.password = getNewSrpPassword();
}
if (z || str == null) {
bArr = null;
bArr2 = null;
} else {
byte[] stringBytes = AndroidUtilities.getStringBytes(str);
if (this.currentPassword.new_algo instanceof TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) {
bArr2 = stringBytes;
bArr = SRPHelper.getX(stringBytes, (TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) this.currentPassword.new_algo);
} else {
bArr2 = stringBytes;
bArr = null;
}
}
RequestDelegate requestDelegate = new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.this.lambda$null$24$TwoStepVerificationActivity(z, bArr, tL_account_updatePasswordSettings, str, tLObject, tL_error);
}
};
if (!z) {
if (str != null && (bArr3 = this.currentSecret) != null && bArr3.length == 32 && (this.currentPassword.new_secure_algo instanceof TLRPC.TL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000)) {
TLRPC.TL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000 tL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000 = (TLRPC.TL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000) this.currentPassword.new_secure_algo;
byte[] computePBKDF2 = Utilities.computePBKDF2(bArr2, tL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000.salt);
byte[] bArr4 = new byte[32];
System.arraycopy(computePBKDF2, 0, bArr4, 0, 32);
byte[] bArr5 = new byte[16];
System.arraycopy(computePBKDF2, 32, bArr5, 0, 16);
byte[] bArr6 = new byte[32];
System.arraycopy(this.currentSecret, 0, bArr6, 0, 32);
Utilities.aesCbcEncryptionByteArraySafe(bArr6, bArr4, bArr5, 0, 32, 0, 1);
tL_account_updatePasswordSettings.new_settings.new_secure_settings = new TLRPC.TL_secureSecretSettings();
tL_account_updatePasswordSettings.new_settings.new_secure_settings.secure_algo = tL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000;
tL_account_updatePasswordSettings.new_settings.new_secure_settings.secure_secret = bArr6;
tL_account_updatePasswordSettings.new_settings.new_secure_settings.secure_secret_id = this.currentSecretId;
tL_account_updatePasswordSettings.new_settings.flags |= 4;
}
if (this.currentPassword.new_algo instanceof TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) {
if (str != null) {
tL_account_updatePasswordSettings.new_settings.new_password_hash = SRPHelper.getVBytes(bArr2, (TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) this.currentPassword.new_algo);
if (tL_account_updatePasswordSettings.new_settings.new_password_hash == null) {
TLRPC.TL_error tL_error = new TLRPC.TL_error();
tL_error.text = "ALGO_INVALID";
requestDelegate.run(null, tL_error);
}
}
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_account_updatePasswordSettings, requestDelegate, 10);
return;
}
TLRPC.TL_error tL_error2 = new TLRPC.TL_error();
tL_error2.text = "PASSWORD_HASH_INVALID";
requestDelegate.run(null, tL_error2);
return;
}
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_account_updatePasswordSettings, requestDelegate, 10);
}
public void lambda$null$24$TwoStepVerificationActivity(final boolean z, final byte[] bArr, final TLRPC.TL_account_updatePasswordSettings tL_account_updatePasswordSettings, final String str, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$23$TwoStepVerificationActivity(tL_error, z, tLObject, bArr, tL_account_updatePasswordSettings, str);
}
});
}
public void lambda$null$23$TwoStepVerificationActivity(TLRPC.TL_error tL_error, final boolean z, TLObject tLObject, final byte[] bArr, final TLRPC.TL_account_updatePasswordSettings tL_account_updatePasswordSettings, String str) {
String formatPluralString;
TLRPC.TL_account_password tL_account_password;
if (tL_error != null && "SRP_ID_INVALID".equals(tL_error.text)) {
ConnectionsManager.getInstance(this.currentAccount).sendRequest(new TLRPC.TL_account_getPassword(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error2) {
TwoStepVerificationActivity.this.lambda$null$20$TwoStepVerificationActivity(z, tLObject2, tL_error2);
}
}, 8);
return;
}
needHideProgress();
if (tL_error == null && (tLObject instanceof TLRPC.TL_boolTrue)) {
if (z) {
this.currentPassword = null;
this.currentPasswordHash = new byte[0];
loadPasswordInfo(false);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.didRemoveTwoStepPassword, new Object[0]);
updateRows();
return;
}
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
TwoStepVerificationActivity.this.lambda$null$21$TwoStepVerificationActivity(bArr, tL_account_updatePasswordSettings, dialogInterface, i);
}
});
if (str == null && (tL_account_password = this.currentPassword) != null && tL_account_password.has_password) {
builder.setMessage(LocaleController.getString("YourEmailSuccessText", R.string.YourEmailSuccessText));
} else {
builder.setMessage(LocaleController.getString("YourPasswordSuccessText", R.string.YourPasswordSuccessText));
}
builder.setTitle(LocaleController.getString("YourPasswordSuccess", R.string.YourPasswordSuccess));
Dialog showDialog = showDialog(builder.create());
if (showDialog != null) {
showDialog.setCanceledOnTouchOutside(false);
showDialog.setCancelable(false);
return;
}
return;
}
if (tL_error != null) {
if ("EMAIL_UNCONFIRMED".equals(tL_error.text) || tL_error.text.startsWith("EMAIL_UNCONFIRMED_")) {
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.didSetTwoStepPassword, new Object[0]);
AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity());
builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
TwoStepVerificationActivity.this.lambda$null$22$TwoStepVerificationActivity(bArr, tL_account_updatePasswordSettings, dialogInterface, i);
}
});
builder2.setMessage(LocaleController.getString("YourEmailAlmostThereText", R.string.YourEmailAlmostThereText));
builder2.setTitle(LocaleController.getString("YourEmailAlmostThere", R.string.YourEmailAlmostThere));
Dialog showDialog2 = showDialog(builder2.create());
if (showDialog2 != null) {
showDialog2.setCanceledOnTouchOutside(false);
showDialog2.setCancelable(false);
return;
}
return;
}
if ("EMAIL_INVALID".equals(tL_error.text)) {
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("PasswordEmailInvalid", R.string.PasswordEmailInvalid));
return;
}
if (tL_error.text.startsWith("FLOOD_WAIT")) {
int intValue = Utilities.parseInt(tL_error.text).intValue();
if (intValue < 60) {
formatPluralString = LocaleController.formatPluralString("Seconds", intValue);
} else {
formatPluralString = LocaleController.formatPluralString("Minutes", intValue / 60);
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, formatPluralString));
return;
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), tL_error.text);
}
}
public void lambda$null$20$TwoStepVerificationActivity(final boolean z, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$19$TwoStepVerificationActivity(tL_error, tLObject, z);
}
});
}
public void lambda$null$19$TwoStepVerificationActivity(TLRPC.TL_error tL_error, TLObject tLObject, boolean z) {
if (tL_error == null) {
TLRPC.TL_account_password tL_account_password = (TLRPC.TL_account_password) tLObject;
this.currentPassword = tL_account_password;
initPasswordNewAlgo(tL_account_password);
setNewPassword(z);
}
}
public void lambda$null$21$TwoStepVerificationActivity(byte[] bArr, TLRPC.TL_account_updatePasswordSettings tL_account_updatePasswordSettings, DialogInterface dialogInterface, int i) {
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.didSetTwoStepPassword, bArr, tL_account_updatePasswordSettings.new_settings.new_algo, this.currentPassword.new_secure_algo, this.currentPassword.secure_random, this.email, this.hint, null, this.firstPassword);
finishFragment();
}
public void lambda$null$22$TwoStepVerificationActivity(byte[] bArr, TLRPC.TL_account_updatePasswordSettings tL_account_updatePasswordSettings, DialogInterface dialogInterface, int i) {
if (this.closeAfterSet) {
TwoStepVerificationActivity twoStepVerificationActivity = new TwoStepVerificationActivity(this.currentAccount, 0);
twoStepVerificationActivity.setCloseAfterSet(true);
this.parentLayout.addFragmentToStack(twoStepVerificationActivity, this.parentLayout.fragmentsStack.size() - 1);
}
NotificationCenter notificationCenter = NotificationCenter.getInstance(this.currentAccount);
int i2 = NotificationCenter.didSetTwoStepPassword;
String str = this.email;
notificationCenter.postNotificationName(i2, bArr, tL_account_updatePasswordSettings.new_settings.new_algo, this.currentPassword.new_secure_algo, this.currentPassword.secure_random, str, this.hint, str, this.firstPassword);
finishFragment();
}
public TLRPC.TL_inputCheckPasswordSRP getNewSrpPassword() {
if (!(this.currentPassword.current_algo instanceof TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow)) {
return null;
}
return SRPHelper.startCheck(this.currentPasswordHash, this.currentPassword.srp_id, this.currentPassword.srp_B, (TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) this.currentPassword.current_algo);
}
private boolean checkSecretValues(byte[] bArr, TLRPC.TL_account_passwordSettings tL_account_passwordSettings) {
byte[] computeSHA512;
if (tL_account_passwordSettings.secure_settings != null) {
this.currentSecret = tL_account_passwordSettings.secure_settings.secure_secret;
if (tL_account_passwordSettings.secure_settings.secure_algo instanceof TLRPC.TL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000) {
computeSHA512 = Utilities.computePBKDF2(bArr, ((TLRPC.TL_securePasswordKdfAlgoPBKDF2HMACSHA512iter100000) tL_account_passwordSettings.secure_settings.secure_algo).salt);
} else {
if (!(tL_account_passwordSettings.secure_settings.secure_algo instanceof TLRPC.TL_securePasswordKdfAlgoSHA512)) {
return false;
}
TLRPC.TL_securePasswordKdfAlgoSHA512 tL_securePasswordKdfAlgoSHA512 = (TLRPC.TL_securePasswordKdfAlgoSHA512) tL_account_passwordSettings.secure_settings.secure_algo;
computeSHA512 = Utilities.computeSHA512(tL_securePasswordKdfAlgoSHA512.salt, bArr, tL_securePasswordKdfAlgoSHA512.salt);
}
this.currentSecretId = tL_account_passwordSettings.secure_settings.secure_secret_id;
byte[] bArr2 = new byte[32];
System.arraycopy(computeSHA512, 0, bArr2, 0, 32);
byte[] bArr3 = new byte[16];
System.arraycopy(computeSHA512, 32, bArr3, 0, 16);
byte[] bArr4 = this.currentSecret;
Utilities.aesCbcEncryptionByteArraySafe(bArr4, bArr2, bArr3, 0, bArr4.length, 0, 0);
if (PassportActivity.checkSecret(tL_account_passwordSettings.secure_settings.secure_secret, Long.valueOf(tL_account_passwordSettings.secure_settings.secure_secret_id))) {
return true;
}
TLRPC.TL_account_updatePasswordSettings tL_account_updatePasswordSettings = new TLRPC.TL_account_updatePasswordSettings();
tL_account_updatePasswordSettings.password = getNewSrpPassword();
tL_account_updatePasswordSettings.new_settings = new TLRPC.TL_account_passwordInputSettings();
tL_account_updatePasswordSettings.new_settings.new_secure_settings = new TLRPC.TL_secureSecretSettings();
tL_account_updatePasswordSettings.new_settings.new_secure_settings.secure_secret = new byte[0];
tL_account_updatePasswordSettings.new_settings.new_secure_settings.secure_algo = new TLRPC.TL_securePasswordKdfAlgoUnknown();
tL_account_updatePasswordSettings.new_settings.new_secure_settings.secure_secret_id = 0L;
tL_account_updatePasswordSettings.new_settings.flags |= 4;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_account_updatePasswordSettings, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.lambda$checkSecretValues$26(tLObject, tL_error);
}
});
this.currentSecret = null;
this.currentSecretId = 0L;
return true;
}
this.currentSecret = null;
this.currentSecretId = 0L;
return true;
}
private static byte[] getBigIntegerBytes(BigInteger bigInteger) {
byte[] byteArray = bigInteger.toByteArray();
if (byteArray.length <= 256) {
return byteArray;
}
byte[] bArr = new byte[256];
System.arraycopy(byteArray, 1, bArr, 0, 256);
return bArr;
}
public void processDone() {
int i = this.type;
if (i == 0) {
if (!this.passwordEntered) {
String obj = this.passwordEditText.getText().toString();
if (obj.length() == 0) {
onFieldError(this.passwordEditText, false);
return;
}
final byte[] stringBytes = AndroidUtilities.getStringBytes(obj);
needShowProgress();
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$processDone$33$TwoStepVerificationActivity(stringBytes);
}
});
return;
}
if (!this.waitingForEmail || this.currentPassword == null) {
return;
}
if (this.codeFieldCell.length() == 0) {
onFieldError(this.codeFieldCell.getTextView(), false);
return;
} else {
sendEmailConfirm(this.codeFieldCell.getText());
showDoneProgress(true);
return;
}
}
if (i == 1) {
int i2 = this.passwordSetState;
if (i2 == 0) {
if (this.passwordEditText.getText().length() == 0) {
onFieldError(this.passwordEditText, false);
return;
}
this.titleTextView.setText(LocaleController.getString("ReEnterYourPasscode", R.string.ReEnterYourPasscode));
this.firstPassword = this.passwordEditText.getText().toString();
setPasswordSetState(1);
return;
}
if (i2 == 1) {
if (!this.firstPassword.equals(this.passwordEditText.getText().toString())) {
ToastUtils.show(R.string.PasswordDoNotMatch);
onFieldError(this.passwordEditText, true);
return;
} else {
setPasswordSetState(2);
return;
}
}
if (i2 == 2) {
String obj2 = this.passwordEditText.getText().toString();
this.hint = obj2;
if (obj2.toLowerCase().equals(this.firstPassword.toLowerCase())) {
ToastUtils.show(R.string.PasswordAsHintError);
onFieldError(this.passwordEditText, false);
return;
} else if (!this.currentPassword.has_recovery) {
setPasswordSetState(3);
return;
} else {
this.email = "";
setNewPassword(false);
return;
}
}
if (i2 == 3) {
String obj3 = this.passwordEditText.getText().toString();
this.email = obj3;
if (!isValidEmail(obj3)) {
onFieldError(this.passwordEditText, false);
return;
} else {
setNewPassword(false);
return;
}
}
if (i2 == 4) {
String obj4 = this.passwordEditText.getText().toString();
if (obj4.length() == 0) {
onFieldError(this.passwordEditText, false);
return;
}
TLRPC.TL_auth_recoverPassword tL_auth_recoverPassword = new TLRPC.TL_auth_recoverPassword();
tL_auth_recoverPassword.code = obj4;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_auth_recoverPassword, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.this.lambda$processDone$36$TwoStepVerificationActivity(tLObject, tL_error);
}
}, 10);
}
}
}
public void lambda$processDone$33$TwoStepVerificationActivity(final byte[] bArr) {
TLRPC.TL_account_getPasswordSettings tL_account_getPasswordSettings = new TLRPC.TL_account_getPasswordSettings();
final byte[] x = this.currentPassword.current_algo instanceof TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow ? SRPHelper.getX(bArr, (TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) this.currentPassword.current_algo) : null;
RequestDelegate requestDelegate = new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.this.lambda$null$32$TwoStepVerificationActivity(bArr, x, tLObject, tL_error);
}
};
if (this.currentPassword.current_algo instanceof TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) {
tL_account_getPasswordSettings.password = SRPHelper.startCheck(x, this.currentPassword.srp_id, this.currentPassword.srp_B, (TLRPC.TL_passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) this.currentPassword.current_algo);
if (tL_account_getPasswordSettings.password == null) {
TLRPC.TL_error tL_error = new TLRPC.TL_error();
tL_error.text = "ALGO_INVALID";
requestDelegate.run(null, tL_error);
return;
}
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_account_getPasswordSettings, requestDelegate, 10);
return;
}
TLRPC.TL_error tL_error2 = new TLRPC.TL_error();
tL_error2.text = "PASSWORD_HASH_INVALID";
requestDelegate.run(null, tL_error2);
}
public void lambda$null$32$TwoStepVerificationActivity(final byte[] bArr, final byte[] bArr2, final TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error == null) {
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$28$TwoStepVerificationActivity(bArr, tLObject, bArr2);
}
});
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$31$TwoStepVerificationActivity(tL_error);
}
});
}
}
public void lambda$null$28$TwoStepVerificationActivity(byte[] bArr, TLObject tLObject, final byte[] bArr2) {
final boolean checkSecretValues = checkSecretValues(bArr, (TLRPC.TL_account_passwordSettings) tLObject);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$27$TwoStepVerificationActivity(checkSecretValues, bArr2);
}
});
}
public void lambda$null$27$TwoStepVerificationActivity(boolean z, byte[] bArr) {
if (this.delegate == null || !z) {
needHideProgress();
}
if (z) {
this.currentPasswordHash = bArr;
this.passwordEntered = true;
AndroidUtilities.hideKeyboard(this.passwordEditText);
TwoStepVerificationActivityDelegate twoStepVerificationActivityDelegate = this.delegate;
if (twoStepVerificationActivityDelegate != null) {
twoStepVerificationActivityDelegate.didEnterPassword(getNewSrpPassword());
return;
} else {
updateRows();
return;
}
}
AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
}
public void lambda$null$31$TwoStepVerificationActivity(TLRPC.TL_error tL_error) {
String formatPluralString;
if ("SRP_ID_INVALID".equals(tL_error.text)) {
ConnectionsManager.getInstance(this.currentAccount).sendRequest(new TLRPC.TL_account_getPassword(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error2) {
TwoStepVerificationActivity.this.lambda$null$30$TwoStepVerificationActivity(tLObject, tL_error2);
}
}, 8);
return;
}
needHideProgress();
if ("PASSWORD_HASH_INVALID".equals(tL_error.text)) {
onFieldError(this.passwordEditText, true);
return;
}
if (tL_error.text.startsWith("FLOOD_WAIT")) {
int intValue = Utilities.parseInt(tL_error.text).intValue();
if (intValue < 60) {
formatPluralString = LocaleController.formatPluralString("Seconds", intValue);
} else {
formatPluralString = LocaleController.formatPluralString("Minutes", intValue / 60);
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, formatPluralString));
return;
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), tL_error.text);
}
public void lambda$null$30$TwoStepVerificationActivity(final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$29$TwoStepVerificationActivity(tL_error, tLObject);
}
});
}
public void lambda$null$29$TwoStepVerificationActivity(TLRPC.TL_error tL_error, TLObject tLObject) {
if (tL_error == null) {
TLRPC.TL_account_password tL_account_password = (TLRPC.TL_account_password) tLObject;
this.currentPassword = tL_account_password;
initPasswordNewAlgo(tL_account_password);
processDone();
}
}
public void lambda$processDone$36$TwoStepVerificationActivity(TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$35$TwoStepVerificationActivity(tL_error);
}
});
}
public void lambda$null$35$TwoStepVerificationActivity(TLRPC.TL_error tL_error) {
String formatPluralString;
if (tL_error == null) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
TwoStepVerificationActivity.this.lambda$null$34$TwoStepVerificationActivity(dialogInterface, i);
}
});
builder.setMessage(LocaleController.getString("PasswordReset", R.string.PasswordReset));
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
Dialog showDialog = showDialog(builder.create());
if (showDialog != null) {
showDialog.setCanceledOnTouchOutside(false);
showDialog.setCancelable(false);
return;
}
return;
}
if (tL_error.text.startsWith("CODE_INVALID")) {
onFieldError(this.passwordEditText, true);
return;
}
if (tL_error.text.startsWith("FLOOD_WAIT")) {
int intValue = Utilities.parseInt(tL_error.text).intValue();
if (intValue < 60) {
formatPluralString = LocaleController.formatPluralString("Seconds", intValue);
} else {
formatPluralString = LocaleController.formatPluralString("Minutes", intValue / 60);
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, formatPluralString));
return;
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), tL_error.text);
}
public void lambda$null$34$TwoStepVerificationActivity(DialogInterface dialogInterface, int i) {
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.didSetTwoStepPassword, new Object[0]);
finishFragment();
}
private void sendEmailConfirm(String str) {
TLRPC.TL_account_confirmPasswordEmail tL_account_confirmPasswordEmail = new TLRPC.TL_account_confirmPasswordEmail();
tL_account_confirmPasswordEmail.code = str;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_account_confirmPasswordEmail, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
TwoStepVerificationActivity.this.lambda$sendEmailConfirm$39$TwoStepVerificationActivity(tLObject, tL_error);
}
}, 10);
}
public void lambda$sendEmailConfirm$39$TwoStepVerificationActivity(TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
TwoStepVerificationActivity.this.lambda$null$38$TwoStepVerificationActivity(tL_error);
}
});
}
public void lambda$null$38$TwoStepVerificationActivity(TLRPC.TL_error tL_error) {
String formatPluralString;
if (this.type == 0 && this.waitingForEmail) {
showDoneProgress(false);
}
if (tL_error == null) {
if (getParentActivity() == null) {
return;
}
Runnable runnable = this.shortPollRunnable;
if (runnable != null) {
AndroidUtilities.cancelRunOnUIThread(runnable);
this.shortPollRunnable = null;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
TwoStepVerificationActivity.this.lambda$null$37$TwoStepVerificationActivity(dialogInterface, i);
}
});
TLRPC.TL_account_password tL_account_password = this.currentPassword;
if (tL_account_password != null && tL_account_password.has_password) {
builder.setMessage(LocaleController.getString("YourEmailSuccessText", R.string.YourEmailSuccessText));
} else {
builder.setMessage(LocaleController.getString("YourPasswordSuccessText", R.string.YourPasswordSuccessText));
}
builder.setTitle(LocaleController.getString("YourPasswordSuccess", R.string.YourPasswordSuccess));
Dialog showDialog = showDialog(builder.create());
if (showDialog != null) {
showDialog.setCanceledOnTouchOutside(false);
showDialog.setCancelable(false);
return;
}
return;
}
if (tL_error.text.startsWith("CODE_INVALID")) {
onFieldError(this.waitingForEmail ? this.codeFieldCell.getTextView() : this.passwordEditText, true);
return;
}
if (tL_error.text.startsWith("FLOOD_WAIT")) {
int intValue = Utilities.parseInt(tL_error.text).intValue();
if (intValue < 60) {
formatPluralString = LocaleController.formatPluralString("Seconds", intValue);
} else {
formatPluralString = LocaleController.formatPluralString("Minutes", intValue / 60);
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, formatPluralString));
return;
}
showAlertWithText(LocaleController.getString("AppName", R.string.AppName), tL_error.text);
}
public void lambda$null$37$TwoStepVerificationActivity(DialogInterface dialogInterface, int i) {
if (this.type == 0) {
loadPasswordInfo(false);
this.doneItem.setVisibility(8);
} else {
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.didSetTwoStepPassword, this.currentPasswordHash, this.currentPassword.new_algo, this.currentPassword.new_secure_algo, this.currentPassword.secure_random, this.email, this.hint, null, this.firstPassword);
finishFragment();
}
}
private void onFieldError(TextView textView, boolean z) {
if (getParentActivity() == null) {
return;
}
Vibrator vibrator = (Vibrator) getParentActivity().getSystemService("vibrator");
if (vibrator != null) {
vibrator.vibrate(200L);
}
if (z) {
textView.setText("");
}
AndroidUtilities.shakeView(textView, 2.0f, 0);
}
public class ListAdapter extends RecyclerListView.SelectionAdapter {
private Context mContext;
public ListAdapter(Context context) {
this.mContext = context;
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder viewHolder) {
return viewHolder.getItemViewType() == 0;
}
@Override
public int getItemCount() {
if (TwoStepVerificationActivity.this.loading || TwoStepVerificationActivity.this.currentPassword == null) {
return 0;
}
return TwoStepVerificationActivity.this.rowCount;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View textSettingsCell;
if (i == 0) {
textSettingsCell = new TextSettingsCell(this.mContext);
textSettingsCell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
} else if (i != 1) {
textSettingsCell = TwoStepVerificationActivity.this.codeFieldCell;
if (textSettingsCell.getParent() != null) {
((ViewGroup) textSettingsCell.getParent()).removeView(textSettingsCell);
}
} else {
textSettingsCell = new TextInfoPrivacyCell(this.mContext);
}
return new RecyclerListView.Holder(textSettingsCell);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
int itemViewType = viewHolder.getItemViewType();
if (itemViewType != 0) {
if (itemViewType != 1) {
return;
}
TextInfoPrivacyCell textInfoPrivacyCell = (TextInfoPrivacyCell) viewHolder.itemView;
if (i != TwoStepVerificationActivity.this.setPasswordDetailRow) {
if (i != TwoStepVerificationActivity.this.shadowRow) {
if (i == TwoStepVerificationActivity.this.passwordSetupDetailRow) {
if (TwoStepVerificationActivity.this.currentPassword == null || !TwoStepVerificationActivity.this.currentPassword.has_password) {
Object[] objArr = new Object[1];
objArr[0] = TwoStepVerificationActivity.this.currentPassword.email_unconfirmed_pattern != null ? TwoStepVerificationActivity.this.currentPassword.email_unconfirmed_pattern : "";
textInfoPrivacyCell.setText(LocaleController.formatString("EmailPasswordConfirmText2", R.string.EmailPasswordConfirmText2, objArr));
} else {
Object[] objArr2 = new Object[1];
objArr2[0] = TwoStepVerificationActivity.this.currentPassword.email_unconfirmed_pattern != null ? TwoStepVerificationActivity.this.currentPassword.email_unconfirmed_pattern : "";
textInfoPrivacyCell.setText(LocaleController.formatString("EmailPasswordConfirmText3", R.string.EmailPasswordConfirmText3, objArr2));
}
textInfoPrivacyCell.setBackgroundDrawable(Theme.getThemedDrawable(this.mContext, R.drawable.greydivider_top, Theme.key_windowBackgroundGrayShadow));
return;
}
if (i == TwoStepVerificationActivity.this.passwordEnabledDetailRow) {
textInfoPrivacyCell.setText(LocaleController.getString("EnabledPasswordText", R.string.EnabledPasswordText));
textInfoPrivacyCell.setBackgroundDrawable(Theme.getThemedDrawable(this.mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
return;
}
return;
}
textInfoPrivacyCell.setText("");
textInfoPrivacyCell.setBackgroundDrawable(Theme.getThemedDrawable(this.mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
return;
}
textInfoPrivacyCell.setText(LocaleController.getString("SetAdditionalPasswordInfo", R.string.SetAdditionalPasswordInfo));
textInfoPrivacyCell.setBackgroundDrawable(Theme.getThemedDrawable(this.mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
return;
}
TextSettingsCell textSettingsCell = (TextSettingsCell) viewHolder.itemView;
textSettingsCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
textSettingsCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
if (i != TwoStepVerificationActivity.this.changePasswordRow) {
if (i != TwoStepVerificationActivity.this.setPasswordRow) {
if (i != TwoStepVerificationActivity.this.turnPasswordOffRow) {
if (i == TwoStepVerificationActivity.this.changeRecoveryEmailRow) {
textSettingsCell.setText(LocaleController.getString("ChangeRecoveryEmail", R.string.ChangeRecoveryEmail), TwoStepVerificationActivity.this.abortPasswordRow != -1);
return;
}
if (i != TwoStepVerificationActivity.this.resendCodeRow) {
if (i != TwoStepVerificationActivity.this.setRecoveryEmailRow) {
if (i == TwoStepVerificationActivity.this.abortPasswordRow) {
textSettingsCell.setTag(Theme.key_windowBackgroundWhiteRedText3);
textSettingsCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText3));
if (TwoStepVerificationActivity.this.currentPassword != null && TwoStepVerificationActivity.this.currentPassword.has_password) {
textSettingsCell.setText(LocaleController.getString("AbortEmail", R.string.AbortEmail), false);
return;
} else {
textSettingsCell.setText(LocaleController.getString("AbortPassword", R.string.AbortPassword), false);
return;
}
}
return;
}
textSettingsCell.setText(LocaleController.getString("SetRecoveryEmail", R.string.SetRecoveryEmail), false);
return;
}
textSettingsCell.setText(LocaleController.getString("ResendCode", R.string.ResendCode), true);
return;
}
textSettingsCell.setText(LocaleController.getString("TurnPasswordOff", R.string.TurnPasswordOff), true);
return;
}
textSettingsCell.setText(LocaleController.getString("SetAdditionalPassword", R.string.SetAdditionalPassword), true);
return;
}
textSettingsCell.setText(LocaleController.getString("ChangePassword", R.string.ChangePassword), true);
}
@Override
public int getItemViewType(int i) {
if (i == TwoStepVerificationActivity.this.setPasswordDetailRow || i == TwoStepVerificationActivity.this.shadowRow || i == TwoStepVerificationActivity.this.passwordSetupDetailRow || i == TwoStepVerificationActivity.this.passwordEnabledDetailRow) {
return 1;
}
return i == TwoStepVerificationActivity.this.passwordCodeFieldRow ? 2 : 0;
}
}
@Override
public ThemeDescription[] getThemeDescriptions() {
return new ThemeDescription[]{new ThemeDescription(this.listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{TextSettingsCell.class, EditTextSettingsCell.class}, null, null, null, Theme.key_windowBackgroundWhite), new ThemeDescription(this.fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, null, null, null, null, Theme.key_windowBackgroundWhite), new ThemeDescription(this.fragmentView, ThemeDescription.FLAG_CHECKTAG | ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundGray), new ThemeDescription(this.actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault), new ThemeDescription(this.listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault), new ThemeDescription(this.actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon), new ThemeDescription(this.actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle), new ThemeDescription(this.actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector), new ThemeDescription(this.listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector), new ThemeDescription(this.listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider), new ThemeDescription(this.emptyView, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_progressCircle), new ThemeDescription(this.listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_windowBackgroundWhiteBlackText), new ThemeDescription(this.listView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_windowBackgroundWhiteRedText3), new ThemeDescription(this.listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{EditTextSettingsCell.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_windowBackgroundWhiteBlackText), new ThemeDescription(this.listView, ThemeDescription.FLAG_HINTTEXTCOLOR, new Class[]{EditTextSettingsCell.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_windowBackgroundWhiteHintText), new ThemeDescription(this.listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow), new ThemeDescription(this.listView, 0, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, (Paint[]) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, Theme.key_windowBackgroundWhiteGrayText4), new ThemeDescription(this.titleTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6), new ThemeDescription(this.bottomTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6), new ThemeDescription(this.bottomButton, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueText4), new ThemeDescription(this.passwordEditText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText), new ThemeDescription(this.passwordEditText, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText), new ThemeDescription(this.passwordEditText, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputField), new ThemeDescription(this.passwordEditText, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated)};
}
}