导航菜单

页面标题

页面副标题

Easycash v3.75.13 - SettingActivity.java 源代码

正在查看: Easycash v3.75.13 应用的 SettingActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.lingyue.easycash.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Base64;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import butterknife.BindView;
import butterknife.OnClick;
import com.lingyue.easycash.R;
import com.lingyue.easycash.account.ECChangePasswordActivity;
import com.lingyue.easycash.account.ECSetPasswordActivity;
import com.lingyue.easycash.appconfig.EasycashConfigKey;
import com.lingyue.easycash.appconfig.GeneralConfigManager;
import com.lingyue.easycash.business.quickrepay.ECQuickRepayManageActivity;
import com.lingyue.easycash.commom.EasyCashCommonActivity;
import com.lingyue.easycash.models.UserGlobal;
import com.lingyue.easycash.models.me.MeInfo;
import com.lingyue.easycash.models.me.MeResponse;
import com.lingyue.easycash.models.me.UserProfile;
import com.lingyue.easycash.models.response.ModifyMobileNumberResponse;
import com.lingyue.easycash.net.EasyCashCookieJar;
import com.lingyue.easycash.utils.EasycashUmengEvent;
import com.lingyue.easycash.widght.EasycashConfirmDialog;
import com.lingyue.idnbaselib.framework.lifecycle.LifecycleEvent;
import com.lingyue.idnbaselib.model.IdnBaseResult;
import com.lingyue.idnbaselib.model.IdnObserver;
import com.lingyue.idnbaselib.model.response.BooleanResponse;
import com.lingyue.idnbaselib.utils.EcBiometricManager;
import com.lingyue.idnbaselib.utils.GeneralUtil;
import com.lingyue.idnbaselib.utils.SharedPreferenceWithPhoneUtils;
import com.lingyue.idnbaselib.utils.ThirdPartEventUtils;
import com.lingyue.supertoolkit.widgets.BaseUtils;
import com.lingyue.supertoolkit.widgets.toastcompat.ToastCompat;
import com.sensorsdata.analytics.android.autotrack.aop.SensorsDataAutoTrackHelper;
import com.sensorsdata.analytics.android.sdk.SensorsDataInstrumented;
import com.umeng.analytics.MobclickAgent;
import com.yangqianguan.statistics.AutoTrackHelper;
import io.reactivex.disposables.Disposable;
import java.util.Arrays;
import java.util.HashMap;

public class SettingActivity extends EasyCashCommonActivity {
    private boolean B;
    private boolean C;
    private boolean D;
    private boolean E = true;
    private boolean F;
    private boolean G;

    @BindView(R.id.cl_biometric)
    ConstraintLayout clBiometric;

    @BindView(R.id.cl_user)
    ConstraintLayout clUser;

    @BindView(R.id.cv_profile)
    CardView cvProfile;

    @BindView(R.id.cv_rate_us)
    CardView cvRateUs;

    @BindView(R.id.fl_account_safe)
    FrameLayout flAccountSafe;

    @BindView(R.id.fl_quick_payment)
    FrameLayout flQuickPayment;

    @BindView(R.id.iv_arrow_user)
    ImageView ivArrow;

    @BindView(R.id.iv_biometric_switch)
    ImageView ivBiometricSwitch;

    @BindView(R.id.tv_biometric_new)
    TextView tvBiometricNew;

    @BindView(R.id.tv_email)
    TextView tvEmail;

    @BindView(R.id.tv_notification)
    TextView tvNotification;

    @BindView(R.id.tv_notification_status)
    TextView tvNotificationStatus;

    @BindView(R.id.tv_notification_tip)
    TextView tvNotificationTip;

    @BindView(R.id.tv_phone_number)
    TextView tvPhoneNumber;

    private void b0() {
        EasycashConfirmDialog.f(this).g(R.string.confirm_logout).q("dialog_logout").m(new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                SettingActivity.this.i0(dialogInterface, i);
            }
        }).show();
    }

    private void c0() {
        EasycashConfirmDialog m = EasycashConfirmDialog.f(this).g(R.string.easycash_setup_biometric_login_message).q("dialog_setup_biometric_login").k(R.string.logout).n(R.string.easycash_enable).j(new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                SettingActivity.this.k0(dialogInterface, i);
            }
        }).m(new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                SettingActivity.this.l0(dialogInterface, i);
            }
        });
        m.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public final void onShow(DialogInterface dialogInterface) {
                SettingActivity.this.m0(dialogInterface);
            }
        });
        m.show();
    }

    private boolean d0(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        return SharedPreferenceWithPhoneUtils.f(this, Base64.encodeToString(str.getBytes(), 2), "sp_have_click_biometric_login_with_phone");
    }

    private void e0() {
        showLoadingDialog();
        new GeneralConfigManager(this).h(Arrays.asList(EasycashConfigKey.DISPLAY_APP_STORE, "app_config.display_user_delete_tab", EasycashConfigKey.BIOMETRIC_LOGIN_SHOW_ENTRANCE), new GeneralConfigManager.Callback() {
            @Override
            public void a() {
                SettingActivity.this.cvRateUs.setVisibility(8);
                SettingActivity.this.C = false;
                SettingActivity.this.G = false;
                SettingActivity.this.s0();
            }

            @Override
            public void b(@NonNull HashMap<String, String> hashMap) {
                if (!Boolean.parseBoolean(hashMap.get(EasycashConfigKey.DISPLAY_APP_STORE)) || TextUtils.isEmpty(SettingActivity.this.userSession.f().appStoreUrl)) {
                    SettingActivity.this.cvRateUs.setVisibility(8);
                } else {
                    SettingActivity.this.cvRateUs.setVisibility(0);
                }
                SettingActivity.this.C = Boolean.parseBoolean(hashMap.get("app_config.display_user_delete_tab"));
                SettingActivity.this.G = Boolean.parseBoolean(hashMap.get(EasycashConfigKey.BIOMETRIC_LOGIN_SHOW_ENTRANCE));
                SettingActivity.this.s0();
            }
        });
    }

    private boolean f0() {
        return this.userSession.b().biometricCredentialInfo != null && this.userSession.b().biometricCredentialInfo.enabled && EcBiometricManager.i(this, this.userSession.b().mobileNumber);
    }

    private boolean g0() {
        return this.G && EcBiometricManager.j(this);
    }

    public void h0(DialogInterface dialogInterface) {
        dialogInterface.dismiss();
        dismissLoadingDialog();
        logout();
        jumpToMainPage();
    }

    @SensorsDataInstrumented
    public void i0(final DialogInterface dialogInterface, int i) {
        z0();
        showLoadingDialog();
        getWindow().getDecorView().postDelayed(new Runnable() {
            @Override
            public final void run() {
                SettingActivity.this.h0(dialogInterface);
            }
        }, 500L);
        SensorsDataAutoTrackHelper.trackDialog(dialogInterface, i);
        AutoTrackHelper.trackViewOnClick(dialogInterface, i);
    }

    public void j0(DialogInterface dialogInterface) {
        dialogInterface.dismiss();
        dismissLoadingDialog();
        logout();
        jumpToMainPage();
    }

    @SensorsDataInstrumented
    public void k0(final DialogInterface dialogInterface, int i) {
        z0();
        showLoadingDialog();
        getWindow().getDecorView().postDelayed(new Runnable() {
            @Override
            public final void run() {
                SettingActivity.this.j0(dialogInterface);
            }
        }, 500L);
        ThirdPartEventUtils.D(this, EasycashUmengEvent.P3, null);
        SensorsDataAutoTrackHelper.trackDialog(dialogInterface, i);
        AutoTrackHelper.trackViewOnClick(dialogInterface, i);
    }

    @SensorsDataInstrumented
    public void l0(DialogInterface dialogInterface, int i) {
        dialogInterface.dismiss();
        SetupBiometricLoginActivity.startSetupBiometricLoginActivity(this);
        ThirdPartEventUtils.D(this, EasycashUmengEvent.O3, null);
        SensorsDataAutoTrackHelper.trackDialog(dialogInterface, i);
        AutoTrackHelper.trackViewOnClick(dialogInterface, i);
    }

    public void m0(DialogInterface dialogInterface) {
        ThirdPartEventUtils.D(this, EasycashUmengEvent.N3, null);
    }

    public void n0(ModifyMobileNumberResponse modifyMobileNumberResponse) {
        ThirdPartEventUtils.y(this, modifyMobileNumberResponse.body.canModify ? EasycashUmengEvent.W1 : EasycashUmengEvent.X1);
        this.D = modifyMobileNumberResponse.body.canModify;
        p0();
    }

    public void o0(MeResponse meResponse) {
        this.userSession.b().userProfile = meResponse.body.userProfile;
        UserGlobal b = this.userSession.b();
        MeInfo meInfo = meResponse.body;
        b.biometricCredentialInfo = meInfo.biometricCredentialInfo;
        UserProfile userProfile = meInfo.userProfile;
        if (userProfile != null && !TextUtils.isEmpty(userProfile.mobileNumber)) {
            this.userSession.b().mobileNumber = meResponse.body.userProfile.mobileNumber.replaceAll("\\s", "");
        }
        t0();
        q0();
    }

    private void p0() {
        this.flAccountSafe.setVisibility((this.D || this.C) ? 0 : 8);
    }

    private void q0() {
        if (!g0()) {
            this.clBiometric.setVisibility(8);
            return;
        }
        this.clBiometric.setVisibility(0);
        if (f0()) {
            this.ivBiometricSwitch.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.easycash_shape_checked));
        } else {
            this.ivBiometricSwitch.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.easycash_shape_unchecked));
            EcBiometricManager.l(this, this.userSession.b().mobileNumber);
        }
        boolean d02 = d0(this.userSession.b().mobileNumber);
        this.F = d02;
        this.tvBiometricNew.setVisibility(d02 ? 8 : 0);
        ThirdPartEventUtils.D(this, EasycashUmengEvent.K3, null);
    }

    private void r0() {
        boolean a = ToastCompat.a(this);
        this.B = a;
        if (a) {
            this.tvNotificationStatus.setCompoundDrawablesWithIntrinsicBounds((Drawable) null, (Drawable) null, (Drawable) null, (Drawable) null);
            this.tvNotificationStatus.setTypeface(Typeface.DEFAULT);
            this.tvNotificationStatus.setTextColor(getResources().getColor(2131099787));
            this.tvNotificationStatus.setText(2131886848);
            this.tvNotificationTip.setVisibility(8);
            return;
        }
        this.tvNotificationStatus.setCompoundDrawablesWithIntrinsicBounds((Drawable) null, (Drawable) null, ContextCompat.getDrawable(this, R.drawable.easycash_ic_arrow_mid_gray), (Drawable) null);
        this.tvNotificationStatus.setTypeface(Typeface.DEFAULT_BOLD);
        this.tvNotificationStatus.setTextColor(getResources().getColor(2131099780));
        this.tvNotificationStatus.setText(2131886784);
        this.tvNotificationTip.setVisibility(0);
    }

    public void s0() {
        q0();
        u0();
        w0();
    }

    public static void startSettingActivity(Activity activity) {
        activity.startActivity(new Intent(activity, (Class<?>) SettingActivity.class));
    }

    private void t0() {
        if (this.userSession.b().userProfile == null) {
            this.cvProfile.setVisibility(8);
            return;
        }
        this.cvProfile.setVisibility(0);
        if (TextUtils.isEmpty(this.userSession.b().userProfile.profileUrl)) {
            this.ivArrow.setVisibility(8);
            this.clUser.setClickable(false);
        } else {
            this.ivArrow.setVisibility(0);
            this.clUser.setClickable(true);
        }
        this.tvPhoneNumber.setText(this.userSession.b().userProfile.mobileNumber);
        if (TextUtils.isEmpty(this.userSession.b().userProfile.emailContent)) {
            this.tvEmail.setVisibility(8);
            return;
        }
        this.tvEmail.setVisibility(0);
        this.tvEmail.setText(this.userSession.b().userProfile.emailContent);
        if (TextUtils.isEmpty(this.userSession.b().userProfile.emailColor) || !this.userSession.b().userProfile.emailColor.startsWith("#")) {
            return;
        }
        this.tvEmail.setTextColor(Color.parseColor(this.userSession.b().userProfile.emailColor));
    }

    private void u0() {
        this.flQuickPayment.setVisibility(this.userSession.b().showDirectDebitEntrance ? 0 : 8);
    }

    private void v0(String str) {
        if (this.F || TextUtils.isEmpty(str)) {
            return;
        }
        SharedPreferenceWithPhoneUtils.h(this, Base64.encodeToString(str.getBytes(), 2), Boolean.TRUE, "sp_have_click_biometric_login_with_phone");
        this.F = true;
    }

    private void w0() {
        this.apiHelper.a().s2().a(new IdnObserver<ModifyMobileNumberResponse>(getCallBack()) {
            @Override
            public void onError(Throwable th, ModifyMobileNumberResponse modifyMobileNumberResponse) {
                SettingActivity.this.dismissLoadingDialog();
            }

            @Override
            public void onSuccess(ModifyMobileNumberResponse modifyMobileNumberResponse) {
                SettingActivity.this.n0(modifyMobileNumberResponse);
                SettingActivity.this.dismissLoadingDialog();
            }
        });
    }

    private void x0() {
        showLoadingDialog();
        this.apiHelper.a().N1().a(new IdnObserver<BooleanResponse>(getCallBack()) {
            @Override
            public void onSuccess(BooleanResponse booleanResponse) {
                SettingActivity.this.dismissLoadingDialog();
                ?? r3 = SettingActivity.this;
                r3.ivBiometricSwitch.setImageDrawable(ContextCompat.getDrawable((Context) r3, R.drawable.easycash_shape_unchecked));
                SettingActivity settingActivity = SettingActivity.this;
                EcBiometricManager.l(settingActivity, settingActivity.userSession.b().mobileNumber);
            }
        });
    }

    private void y0() {
        showLoadingDialog();
        this.apiHelper.a().i1().a(new IdnObserver<MeResponse>(this) {
            @Override
            public void onError(Throwable th, MeResponse meResponse) {
                SettingActivity.this.dismissLoadingDialog();
            }

            @Override
            public void onSuccess(MeResponse meResponse) {
                SettingActivity.this.o0(meResponse);
                SettingActivity.this.dismissLoadingDialog();
            }
        });
    }

    private void z0() {
        this.apiHelper.a().logout().a(new IdnObserver<IdnBaseResult>(getCallBack()) {
            @Override
            public void onSuccess(IdnBaseResult idnBaseResult) {
                ?? r2 = SettingActivity.this;
                EasyCashCookieJar.j(r2, r2.userSession).c();
            }

            @Override
            protected boolean superShowErrorToast() {
                return false;
            }
        });
    }

    @Override
    protected void D() {
        super.D();
        e0();
        t0();
    }

    @OnClick({R.id.iv_biometric_switch})
    protected void clickBiometricSwitch() {
        if (!BaseUtils.l() && g0()) {
            if (f0()) {
                x0();
                ThirdPartEventUtils.D(this, EasycashUmengEvent.M3, null);
            } else {
                SetupBiometricLoginActivity.startSetupBiometricLoginActivity(this);
                ThirdPartEventUtils.D(this, EasycashUmengEvent.L3, null);
            }
            v0(this.userSession.b().mobileNumber);
        }
    }

    @OnClick({R.id.tv_logout})
    protected void clickLogout() {
        if (BaseUtils.l()) {
            return;
        }
        ThirdPartEventUtils.y(this, EasycashUmengEvent.f46g0);
        if (!g0() || f0()) {
            b0();
        } else {
            c0();
        }
    }

    @OnClick({R.id.tv_manage_bank})
    public void clickManageBank() {
        if (BaseUtils.l()) {
            return;
        }
        ThirdPartEventUtils.y(this, EasycashUmengEvent.Y);
        RepayBankCardListActivity.startBankCardListActivity(this);
    }

    @OnClick({R.id.cl_notification})
    public void clickOpenNotification() {
        if (BaseUtils.l() || this.B) {
            return;
        }
        GeneralUtil.b(this);
    }

    @OnClick({R.id.fl_privacy_policy})
    protected void clickPrivacyPolicy() {
        if (BaseUtils.l()) {
            return;
        }
        openProtocol("webview/static-agreement/EASYCASH_IDN_REGISTER");
    }

    @OnClick({R.id.fl_terms_of_use})
    protected void clickTermsOfUse() {
        if (BaseUtils.l()) {
            return;
        }
        openProtocol("webview/static-agreement/EASYCASH_TERMS_OF_USE");
    }

    @Override
    public int getLayoutID() {
        return R.layout.layout_activity_setting;
    }

    @OnClick({R.id.tv_account_safe})
    protected void goAccountSafe() {
        if (BaseUtils.l()) {
            return;
        }
        AccountSafeActivity.startAccountSafeActivity(this, this.C, this.D);
    }

    @OnClick({R.id.tv_password})
    protected void goManagePassword() {
        if (BaseUtils.l()) {
            return;
        }
        if (!this.userSession.b().hasPassword) {
            ECSetPasswordActivity.startECSetPasswordActivity(this);
        } else {
            ThirdPartEventUtils.y(this, EasycashUmengEvent.f43d0);
            ECChangePasswordActivity.startECChangePasswordActivity(this);
        }
    }

    @OnClick({R.id.fl_quick_payment})
    protected void goQuickPayment() {
        if (BaseUtils.l()) {
            return;
        }
        ECQuickRepayManageActivity.startQuickPaymentActivity(this);
    }

    @OnClick({R.id.tv_rate_us})
    protected void goRateUs() {
        if (BaseUtils.l()) {
            return;
        }
        ThirdPartEventUtils.y(this, EasycashUmengEvent.f45f0);
        try {
            startActivity(new Intent("android.intent.action.VIEW", Uri.parse(this.userSession.f().appStoreUrl)));
        } catch (Exception e) {
            MobclickAgent.reportError((Context) this, (Throwable) e);
        }
    }

    @OnClick({R.id.cl_user})
    protected void goUserProfile() {
        if (this.userSession.b().userProfile == null || BaseUtils.l() || TextUtils.isEmpty(this.userSession.b().userProfile.profileUrl)) {
            return;
        }
        jumpToWebPage(this.userSession.b().userProfile.profileUrl);
    }

    public void onBackPressed() {
        super/*androidx.activity.ComponentActivity*/.onBackPressed();
        ThirdPartEventUtils.y(this, EasycashUmengEvent.p1);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (!this.E) {
            y0();
        }
        this.E = false;
        r0();
    }

    public void openProtocol(String str) {
        jumpToWebPage(Uri.parse(this.appGlobal.a.a().toString()).buildUpon().path(str).build().toString());
    }

    @Override
    public Disposable runOnActiveEvent(Runnable runnable) {
        return com.lingyue.idnbaselib.framework.lifecycle.m.a(this, runnable);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnCreated(@NonNull Runnable runnable) {
        return com.lingyue.idnbaselib.framework.lifecycle.m.b(this, runnable);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnDestroy(@NonNull Runnable runnable) {
        return com.lingyue.idnbaselib.framework.lifecycle.m.c(this, runnable);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnEvent(@NonNull LifecycleEvent lifecycleEvent, @Nullable Runnable runnable) {
        return com.lingyue.idnbaselib.framework.lifecycle.m.d(this, lifecycleEvent, runnable);
    }

    @Override
    public Disposable runOnEvents(@NonNull LifecycleEvent[] lifecycleEventArr, @Nullable Runnable runnable) {
        return com.lingyue.idnbaselib.framework.lifecycle.m.e(this, lifecycleEventArr, runnable);
    }

    @Override
    protected void z() {
        super.z();
        if (this.userSession.b().userProfile == null || this.userSession.b().biometricCredentialInfo == null || TextUtils.isEmpty(this.userSession.b().mobileNumber)) {
            y0();
        }
    }
}