Ruiyuanjb v2.7.0版本的 MD5 值为:45f663f003665a0ca2d09dcbec30071a
以下内容为反编译后的 LoginContronllerBaseActivity.java 源代码,内容仅作参考
package im.mvtqiwsorf.ui.hui.login;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Property;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import butterknife.internal.DebouncingOnClickListener;
import butterknife.internal.Utils;
import com.blankj.utilcode.util.ScreenUtils;
import im.mvtqiwsorf.messenger.AndroidUtilities;
import im.mvtqiwsorf.messenger.ApplicationLoader;
import im.mvtqiwsorf.messenger.LocaleController;
import im.mvtqiwsorf.messenger.R;
import im.mvtqiwsorf.messenger.UserConfig;
import im.mvtqiwsorf.messenger.utils.RegexUtils;
import im.mvtqiwsorf.tgnet.ConnectionsManager;
import im.mvtqiwsorf.tgnet.TLRPC;
import im.mvtqiwsorf.ui.actionbar.ActionBar;
import im.mvtqiwsorf.ui.actionbar.AlertDialog;
import im.mvtqiwsorf.ui.actionbar.BaseFragment;
import im.mvtqiwsorf.ui.actionbar.Theme;
import im.mvtqiwsorf.ui.components.LayoutHelper;
import im.mvtqiwsorf.ui.components.SlideView;
import im.mvtqiwsorf.ui.components.toast.ToastUtils;
import im.mvtqiwsorf.ui.hviews.MryRoundButton;
import im.mvtqiwsorf.ui.hviews.MryTextView;
import im.mvtqiwsorf.ui.utils.KeyboardChangeListener;
import im.mvtqiwsorf.ui.utils.timer.RunningFlagCountDownTimer;
import java.util.Locale;
public abstract class LoginContronllerBaseActivity extends BaseFragment implements KeyboardChangeListener.KeyBoardListener {
protected FrameLayout actionBarContainer;
protected boolean canBack;
protected FrameLayout contentContainer;
protected int currentViewIndex;
protected boolean keyboardIsShown;
protected KeyboardChangeListener mKeyboardChangeListener;
protected boolean newAccount;
protected ThisView[] pages;
protected FrameLayout rootView;
protected abstract void initPages(int i);
protected abstract void initView();
public class ThisView_ViewBinding implements Unbinder {
private ThisView target;
private View view7f090086;
public ThisView_ViewBinding(ThisView thisView) {
this(thisView, thisView);
}
public ThisView_ViewBinding(final ThisView thisView, View view) {
this.target = thisView;
thisView.tvTitle = (MryTextView) Utils.findRequiredViewAsType(view, 2131297527, "field 'tvTitle'", MryTextView.class);
View findRequiredView = Utils.findRequiredView(view, R.id.btn, "field 'btn' and method 'onClick'");
thisView.btn = (MryRoundButton) Utils.castView(findRequiredView, R.id.btn, "field 'btn'", MryRoundButton.class);
this.view7f090086 = findRequiredView;
findRequiredView.setOnClickListener(new DebouncingOnClickListener() {
@Override
public void doClick(View view2) {
thisView.onClick(view2);
}
});
}
@Override
public void unbind() {
ThisView thisView = this.target;
if (thisView == null) {
throw new IllegalStateException("Bindings already cleared.");
}
this.target = null;
thisView.tvTitle = null;
thisView.btn = null;
this.view7f090086.setOnClickListener(null);
this.view7f090086 = null;
}
}
public LoginContronllerBaseActivity() {
this(UserConfig.selectedAccount, null);
}
public LoginContronllerBaseActivity(int i, Bundle bundle) {
this.canBack = true;
bundle = bundle == null ? new Bundle() : bundle;
bundle.putInt("account", i);
bundle.putBoolean("newAccount", i != UserConfig.selectedAccount);
setArguments(bundle);
}
@Override
public boolean onFragmentCreate() {
if (getArguments() != null) {
this.currentAccount = getArguments().getInt("account");
this.newAccount = getArguments().getBoolean("newAccount", false);
boolean z = getArguments().getBoolean("canBack", true);
this.canBack = z;
if (z) {
int i = 0;
for (int i2 = 0; i2 < 3; i2++) {
if (!UserConfig.getInstance(i2).isClientActivated()) {
i++;
}
}
if (i == 3) {
this.canBack = false;
}
}
}
return super.onFragmentCreate();
}
@Override
public View createView(Context context) {
this.rootView = new FrameLayout(context);
ScrollView scrollView = new ScrollView(context) {
@Override
public boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z) {
rect.bottom += AndroidUtilities.dp(40.0f);
return super.requestChildRectangleOnScreen(view, rect, z);
}
};
scrollView.setFillViewport(true);
this.fragmentView = this.rootView;
this.fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
this.rootView.addView(scrollView, LayoutHelper.createScroll(-1, -1, 51));
KeyboardChangeListener keyboardChangeListener = new KeyboardChangeListener(scrollView);
this.mKeyboardChangeListener = keyboardChangeListener;
keyboardChangeListener.setKeyBoardListener(this);
FrameLayout frameLayout = new FrameLayout(context);
this.contentContainer = frameLayout;
scrollView.addView(frameLayout, LayoutHelper.createFrame(-1, -1, 51));
initActionBar();
initView();
return this.fragmentView;
}
@Override
public void onResume() {
super.onResume();
if (this.newAccount) {
ConnectionsManager.getInstance(this.currentAccount).setAppPaused(false, false);
}
AndroidUtilities.requestAdjustResize(getParentActivity(), this.classGuid);
}
@Override
public void onPause() {
super.onPause();
AndroidUtilities.removeAdjustResize(getParentActivity(), this.classGuid);
if (this.newAccount) {
ConnectionsManager.getInstance(this.currentAccount).setAppPaused(true, false);
}
}
protected void initActionBar() {
this.actionBar.setAddToContainer(false);
this.actionBar.setBackgroundColor(0);
this.actionBar.setCastShadows(false);
FrameLayout frameLayout = new FrameLayout(getParentActivity());
this.actionBarContainer = frameLayout;
frameLayout.setBackgroundColor(0);
this.rootView.addView(this.actionBarContainer, LayoutHelper.createFrame(-1, -2, 51));
this.actionBarContainer.addView(this.actionBar, LayoutHelper.createFrame(-1, -2, 51));
this.actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int i) {
super.onItemClick(i);
if (i == -1 && LoginContronllerBaseActivity.this.onBackPressed()) {
LoginContronllerBaseActivity.this.finishFragment();
}
}
});
}
public void setAcitonBar(int i, ThisView thisView) {
if (this.canBack) {
this.actionBar.setBackButtonImage((thisView.needBackButton() || this.newAccount) ? R.mipmap.ic_back : 0);
}
}
public final void toPage(int i, boolean z, Bundle bundle, boolean z2) {
initPages(i);
ThisView[] thisViewArr = this.pages;
if (thisViewArr[i] == null) {
return;
}
if (this.currentViewIndex == i && thisViewArr[i].getParent() != null) {
this.pages[this.currentViewIndex].setParams(bundle, false);
return;
}
if (this.pages[i].getParent() == null) {
this.contentContainer.addView(this.pages[i], LayoutHelper.createFrame(-1, -1, 51));
}
if (z) {
ThisView[] thisViewArr2 = this.pages;
final ThisView thisView = thisViewArr2[this.currentViewIndex];
final ThisView thisView2 = thisViewArr2[i];
thisView2.setClickable(true);
this.currentViewIndex = i;
thisView2.setParams(bundle, false);
setParentActivityTitle(thisView2.getHeaderName());
setAcitonBar(i, thisView2);
thisView2.onShow();
int i2 = AndroidUtilities.displaySize.x;
if (z2) {
i2 = -i2;
}
thisView2.setX(i2);
thisView2.setVisibility(0);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
thisView.clearFocus();
thisView.setVisibility(8);
thisView.setX(0.0f);
thisView2.onShowEnd();
}
});
Animator[] animatorArr = new Animator[2];
Property property = View.TRANSLATION_X;
float[] fArr = new float[1];
fArr[0] = z2 ? AndroidUtilities.displaySize.x : -AndroidUtilities.displaySize.x;
animatorArr[0] = ObjectAnimator.ofFloat(thisView, (Property<ThisView, Float>) property, fArr);
animatorArr[1] = ObjectAnimator.ofFloat(thisView2, (Property<ThisView, Float>) View.TRANSLATION_X, 0.0f);
animatorSet.playTogether(animatorArr);
animatorSet.setDuration(300L);
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
animatorSet.start();
return;
}
this.pages[this.currentViewIndex].setVisibility(8);
this.currentViewIndex = i;
this.pages[i].setParams(bundle, false);
this.pages[i].setVisibility(0);
this.pages[i].onShow();
this.pages[i].onShowEnd();
setAcitonBar(i, this.pages[i]);
setParentActivityTitle(this.pages[i].getHeaderName());
this.pages[i].onShow();
}
public void parseError(TLRPC.TL_error tL_error, String str) {
if (tL_error == null || TextUtils.isEmpty(tL_error.text)) {
return;
}
if (tL_error.text.contains("PHONE_NUMBER_INVALID")) {
needShowInvalidAlert(str, false);
return;
}
if (tL_error.text.contains("PHONE_PASSWORD_FLOOD")) {
needShowAlert(LocaleController.getString(R.string.FloodWait));
return;
}
if (tL_error.text.contains("PHONE_NUMBER_FLOOD")) {
needShowAlert(LocaleController.getString(R.string.PhoneNumberFlood));
return;
}
if (tL_error.text.contains("PHONE_NUMBER_BANNED") || tL_error.text.contains("ACCOUNT_RESTRICTED")) {
needShowInvalidAlert(str, true);
return;
}
if (tL_error.text.contains("PHONE_CODE_EMPTY") || tL_error.text.contains("PHONE_CODE_INVALID")) {
needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode));
return;
}
if (tL_error.text.contains("PHONE_CODE_EXPIRED")) {
needShowAlert(LocaleController.getString("VerificationcodeExpired", R.string.VerificationcodeExpired));
return;
}
if (tL_error.text.startsWith("FLOOD_WAIT")) {
needShowAlert(LocaleController.getString(R.string.FloodWait));
return;
}
if (tL_error.text.startsWith("CODE_VERIFY_LIMIT")) {
needShowAlert(LocaleController.getString(R.string.CODE_VERIFY_LIMIT));
return;
}
if (tL_error.text.startsWith("CODE_INVALID")) {
needShowAlert(LocaleController.getString(R.string.InvalidCode));
return;
}
if (tL_error.text.startsWith("PASSWORD_ERROR")) {
needShowAlert(LocaleController.getString(R.string.LoginPwdError));
return;
}
if (tL_error.text.startsWith("PHONE_NOT_SIGNUP") || tL_error.text.startsWith("USERNAME_NOT_EXIST")) {
needShowAlert(LocaleController.getString(R.string.UserNotRegistered));
return;
}
if (tL_error.text.startsWith("PHONE_NUMBER_OCCUPIED")) {
needShowAlert(LocaleController.getString(R.string.UsernameAlreadyExists));
return;
}
if (tL_error.text.startsWith("CURRENT_PWD_ERR")) {
needShowAlert(LocaleController.getString(R.string.OldPwdError));
return;
}
if (tL_error.text.startsWith("NOTEQUAL_TAG")) {
needShowAlert(LocaleController.getString(R.string.LoginPwdError));
return;
}
if (tL_error.text.startsWith("PASSWORD_INVALID")) {
needShowAlert(LocaleController.getString(R.string.PasswordDoNotMatch));
return;
}
if (tL_error.text.startsWith("PASSWORD_MANY")) {
needShowAlert(LocaleController.getString(R.string.PWdErrorMany));
return;
}
if (tL_error.text.startsWith("USERNAME_INVALID")) {
needShowAlert(LocaleController.getString(R.string.UsernameInvalid));
return;
}
if (tL_error.text.startsWith("USERNAME_OCCUPIED")) {
needShowAlert(LocaleController.getString(R.string.UsernameInUse));
return;
}
if (tL_error.text.contains("IPORDE_LIMIT")) {
needShowAlert(LocaleController.getString("IpOrDeLimit", R.string.IpOrDeLimit));
return;
}
if (tL_error.text.equals("INTERNAL")) {
needShowAlert(LocaleController.getString("InternalError", R.string.InternalError));
return;
}
needShowAlert(LocaleController.getString(R.string.OperationFailedPleaseTryAgain) + "\n" + tL_error.text);
}
protected void needShowInvalidAlert(final String str, final boolean z) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString(R.string.AppName));
if (z) {
builder.setMessage(LocaleController.getString(R.string.BannedPhoneNumber));
} else {
builder.setMessage(LocaleController.getString(R.string.InvalidPhoneNumber));
}
builder.setNeutralButton(LocaleController.getString(R.string.BotHelp), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
LoginContronllerBaseActivity.this.lambda$needShowInvalidAlert$0$LoginContronllerBaseActivity(z, str, dialogInterface, i);
}
});
builder.setPositiveButton(LocaleController.getString(R.string.OK), null);
showDialog(builder.create());
}
public void lambda$needShowInvalidAlert$0$LoginContronllerBaseActivity(boolean z, String str, DialogInterface dialogInterface, int i) {
try {
PackageInfo packageInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
String format = String.format(Locale.US, "%s (%d)", packageInfo.versionName, Integer.valueOf(packageInfo.versionCode));
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("message/rfc822");
intent.putExtra("android.intent.extra.EMAIL", new String[]{"login@stel.com"});
if (z) {
intent.putExtra("android.intent.extra.SUBJECT", "Banned phone number: " + str);
intent.putExtra("android.intent.extra.TEXT", "I'm trying to use my mobile phone number: " + str + "\nBut mvtqiwsorf says it's banned. Please help.\n\nApp version: " + format + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault());
} else {
intent.putExtra("android.intent.extra.SUBJECT", "Invalid phone number: " + str);
intent.putExtra("android.intent.extra.TEXT", "I'm trying to use my mobile phone number: " + str + "\nBut mvtqiwsorf says it's invalid. Please help.\n\nApp version: " + format + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault());
}
getParentActivity().startActivity(Intent.createChooser(intent, "Send email..."));
} catch (Exception unused) {
needShowAlert(LocaleController.getString(R.string.NoMailInstalled));
}
}
public void needShowAlert(String str) {
if (str == null || getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString(R.string.AppName));
builder.setMessage(str);
builder.setPositiveButton(LocaleController.getString(R.string.OK), null);
showDialog(builder.create());
}
public boolean checkPasswordRule(TextView textView, boolean z) {
if (textView != null && textView.length() != 0) {
String trim = textView.getText().toString().trim();
if (trim.length() >= 8 && trim.length() <= 16 && RegexUtils.hasLetterAndNumber(trim, false)) {
return true;
}
if (z) {
ToastUtils.show(R.string.LoginPwdRule);
}
}
return false;
}
@Override
public void saveSelfArgs(Bundle bundle) {
super.saveSelfArgs(bundle);
bundle.putInt("currentIndex", this.currentViewIndex);
bundle.putBundle("pageArgs", getArguments());
Bundle bundle2 = new Bundle();
if (this.pages == null) {
return;
}
int i = 0;
while (true) {
ThisView[] thisViewArr = this.pages;
if (i >= thisViewArr.length) {
return;
}
ThisView thisView = thisViewArr[i];
if (thisView != null) {
thisView.saveStateParams(bundle2);
bundle.putBundle("currentIndexB" + i, bundle2);
}
i++;
}
}
@Override
public void restoreSelfArgs(Bundle bundle) {
super.restoreSelfArgs(bundle);
this.currentViewIndex = bundle.getInt("currentIndex");
setArguments(bundle.getBundle("pageArgs"));
if (this.pages == null) {
return;
}
int i = 0;
while (true) {
ThisView[] thisViewArr = this.pages;
if (i >= thisViewArr.length) {
return;
}
thisViewArr[i].restoreStateParams(bundle.getBundle("currentIndexB" + i));
i++;
}
}
@Override
public boolean onBackPressed() {
ThisView[] thisViewArr = this.pages;
if (thisViewArr != null) {
int i = this.currentViewIndex;
if (i == 0) {
if (this.canBack) {
for (ThisView thisView : thisViewArr) {
if (thisView != null) {
thisView.onDestroyActivity();
}
}
return true;
}
} else if (i == 1) {
thisViewArr[i].onBackPressed(true);
toPage(0, true, null, true);
} else if (i == 2) {
thisViewArr[i].onBackPressed(true);
toPage(1, true, null, true);
}
}
return false;
}
@Override
public void onKeyboardChange(boolean z, int i) {
this.keyboardIsShown = z;
MryRoundButton mryRoundButton = this.pages[this.currentViewIndex].btn;
if (isFinishing() || mryRoundButton == null || this.actionBar == null || !z || !(this.fragmentView instanceof ScrollView)) {
return;
}
int dp = (i + AndroidUtilities.dp(10.0f)) - (ScreenUtils.getScreenHeight() - mryRoundButton.getBottom());
if (this.newAccount) {
dp += this.actionBar != null ? this.actionBar.getHeight() : 0;
}
((ScrollView) this.fragmentView).smoothScrollBy(0, dp);
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
ThisView[] thisViewArr = this.pages;
if (thisViewArr != null) {
for (ThisView thisView : thisViewArr) {
if (thisView != null) {
thisView.onDestroyActivity();
}
}
this.pages = null;
}
KeyboardChangeListener keyboardChangeListener = this.mKeyboardChangeListener;
if (keyboardChangeListener != null) {
keyboardChangeListener.destroy();
this.mKeyboardChangeListener = null;
}
this.rootView = null;
}
public static class ThisView extends SlideView {
@BindView(R.id.btn)
MryRoundButton btn;
protected RunningFlagCountDownTimer countDownTimer;
protected Bundle params;
@BindView(2131297527)
MryTextView tvTitle;
private Unbinder unbinder;
protected boolean checkEnterInfo(boolean z, boolean z2, boolean z3) {
return true;
}
@Override
public boolean needBackButton() {
return true;
}
public ThisView(Context context) {
super(context);
}
@Override
public void setParams(Bundle bundle, boolean z) {
super.setParams(bundle, z);
if (bundle != null) {
this.params = bundle;
}
}
@Override
public Bundle getParams() {
return this.params;
}
public void initView() {
this.unbinder = ButterKnife.bind(this, this);
this.tvTitle.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
this.btn.setPrimaryRadiusAdjustBoundsFillStyle();
loadSaveState();
}
@Override
public void onShow() {
super.onShow();
}
public void onShowEnd() {
setClickable(true);
}
@OnClick({R.id.btn})
public void onClick(View view) {
if (view.getId() != 2131296390) {
return;
}
checkEnterInfo(false, true, true);
}
@Override
public String getHeaderName() {
return this.tvTitle.getText().toString().trim();
}
@Override
public void saveStateParams(Bundle bundle) {
super.saveStateParams(bundle);
}
protected SharedPreferences getSp() {
return ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", 0);
}
protected void loadSaveState() {
long j = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", 0).getLong("countDownTimer", 0L);
if (j > 0) {
startCountDownTimer(j);
}
}
protected void saveLastSendSmsTime() {
SharedPreferences.Editor edit = getSp().edit();
edit.putLong("last_time", System.currentTimeMillis());
edit.apply();
}
protected long getLastSendSmsTime() {
return getSp().getLong("last_time", 0L);
}
protected void startCountDownTimer(long j) {
if (this.countDownTimer == null) {
RunningFlagCountDownTimer runningFlagCountDownTimer = new RunningFlagCountDownTimer(j, 1000L) {
@Override
public void onTick(long j2) {
super.onTick(j2);
ThisView.this.onTimerTick(j2);
}
@Override
public void onFinish() {
super.onFinish();
ThisView.this.onTimerFinish();
}
};
this.countDownTimer = runningFlagCountDownTimer;
runningFlagCountDownTimer.startInternal();
}
}
protected void onTimerTick(long j) {
MryRoundButton mryRoundButton = this.btn;
if (mryRoundButton != null) {
mryRoundButton.setText(LocaleController.formatString("ResendPhoneCodeCountDown2", R.string.ResendPhoneCodeCountDown2, Long.valueOf(j / 1000)));
this.btn.setEnabled(false);
}
}
protected void onTimerFinish() {
MryRoundButton mryRoundButton = this.btn;
if (mryRoundButton != null) {
mryRoundButton.setText(LocaleController.getString(R.string.SendVerifyCode));
this.btn.setEnabled(true);
}
}
protected void stopTimer() {
try {
if (this.countDownTimer == null || !this.countDownTimer.isRunning()) {
return;
}
this.countDownTimer.cancelInternal();
this.countDownTimer = null;
} catch (Exception unused) {
}
}
@Override
public void onDestroyActivity() {
super.onDestroyActivity();
stopTimer();
Unbinder unbinder = this.unbinder;
if (unbinder != null) {
try {
unbinder.unbind();
} catch (Exception unused) {
}
this.unbinder = null;
}
this.params = null;
}
}
}