导航菜单

页面标题

页面副标题

Mint v5.7.3 - EconomistVerifyOtpActivity.java 源代码

正在查看: Mint v5.7.3 应用的 EconomistVerifyOtpActivity.java JAVA 源代码文件

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


package com.htmedia.mint.ui;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.res.ResourcesCompat;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.google.gson.JsonObject;
import com.htmedia.mint.AppController;
import com.htmedia.mint.htsubscription.TokenGenerater;
import com.htmedia.mint.pojo.config.Config;
import com.htmedia.mint.pojo.subscription.EconomistEmailEligibilityPojo;
import com.htmedia.mint.ui.EconomistVerifyOtpActivity;
import com.htmedia.mint.ui.activity.PaymentSuccessfulActivity;
import com.htmedia.mint.utils.f0;
import com.htmedia.sso.fragments.ValidateOtpFragment;
import com.htmedia.sso.helpers.ToastHelper;
import com.htmedia.sso.helpers.Utils;
import com.htmedia.sso.models.UserResponseModel;
import com.htmedia.sso.network.ApiClient;
import com.htmedia.sso.network.ApiServices;
import com.htmedia.sso.network.CustomObserver;
import com.htmedia.sso.network.NetworkHelper;
import com.thoughtbot.expandablerecyclerview.BuildConfig;
import in.juspay.hyper.constants.LogSubCategory;
import in.juspay.hypersdk.core.PaymentConstants;
import java.util.HashMap;
import java.util.Locale;
import k6.x;
import k6.y;
import org.json.JSONException;
import org.json.JSONObject;
import x4.gc;

public class EconomistVerifyOtpActivity extends AppCompatActivity {
    private gc a;
    private boolean b;
    private String c = BuildConfig.FLAVOR;
    private Config d;

    class a implements View.OnClickListener {
        a() {
        }

        @Override
        public void onClick(View view) {
            Utils.showSoftKeyboard(EconomistVerifyOtpActivity.this.a.s);
        }
    }

    class b implements View.OnClickListener {
        b() {
        }

        @Override
        public void onClick(View view) {
            EconomistVerifyOtpActivity.this.finish();
        }
    }

    class c implements TextWatcher {
        c() {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() >= 6) {
                if (editable.length() == 6) {
                    AppCompatTextView appCompatTextView = EconomistVerifyOtpActivity.this.a.g;
                    EconomistVerifyOtpActivity economistVerifyOtpActivity = EconomistVerifyOtpActivity.this;
                    appCompatTextView.setText(economistVerifyOtpActivity.M(economistVerifyOtpActivity.a.s.getText().toString(), 5));
                    Utils.hideKeyboard(EconomistVerifyOtpActivity.this.a.s);
                    EconomistVerifyOtpActivity economistVerifyOtpActivity2 = EconomistVerifyOtpActivity.this;
                    economistVerifyOtpActivity2.R(economistVerifyOtpActivity2.a, EconomistVerifyOtpActivity.this.a.s, EconomistVerifyOtpActivity.this);
                    return;
                }
                return;
            }
            AppCompatTextView appCompatTextView2 = EconomistVerifyOtpActivity.this.a.f;
            EconomistVerifyOtpActivity economistVerifyOtpActivity3 = EconomistVerifyOtpActivity.this;
            appCompatTextView2.setText(economistVerifyOtpActivity3.M(economistVerifyOtpActivity3.a.s.getText().toString(), 0));
            AppCompatTextView appCompatTextView3 = EconomistVerifyOtpActivity.this.a.i;
            EconomistVerifyOtpActivity economistVerifyOtpActivity4 = EconomistVerifyOtpActivity.this;
            appCompatTextView3.setText(economistVerifyOtpActivity4.M(economistVerifyOtpActivity4.a.s.getText().toString(), 1));
            AppCompatTextView appCompatTextView4 = EconomistVerifyOtpActivity.this.a.h;
            EconomistVerifyOtpActivity economistVerifyOtpActivity5 = EconomistVerifyOtpActivity.this;
            appCompatTextView4.setText(economistVerifyOtpActivity5.M(economistVerifyOtpActivity5.a.s.getText().toString(), 2));
            AppCompatTextView appCompatTextView5 = EconomistVerifyOtpActivity.this.a.e;
            EconomistVerifyOtpActivity economistVerifyOtpActivity6 = EconomistVerifyOtpActivity.this;
            appCompatTextView5.setText(economistVerifyOtpActivity6.M(economistVerifyOtpActivity6.a.s.getText().toString(), 3));
            AppCompatTextView appCompatTextView6 = EconomistVerifyOtpActivity.this.a.d;
            EconomistVerifyOtpActivity economistVerifyOtpActivity7 = EconomistVerifyOtpActivity.this;
            appCompatTextView6.setText(economistVerifyOtpActivity7.M(economistVerifyOtpActivity7.a.s.getText().toString(), 4));
            EconomistVerifyOtpActivity.this.a.g.setText(BuildConfig.FLAVOR);
            if (EconomistVerifyOtpActivity.this.b) {
                EconomistVerifyOtpActivity.this.a.f.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.i.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.h.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.e.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.d.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.g.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.C.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.D.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.E.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.F.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.G.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.H.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100814));
                EconomistVerifyOtpActivity.this.a.w.setVisibility(8);
                return;
            }
            EconomistVerifyOtpActivity.this.a.f.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.i.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.h.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.e.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.d.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.g.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.C.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.D.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.E.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.F.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.G.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.H.setBackgroundColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131100820));
            EconomistVerifyOtpActivity.this.a.w.setVisibility(8);
        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }
    }

    class d extends CustomObserver<UserResponseModel> {
        final gc a;
        final Context b;

        d(Context context, boolean z, gc gcVar, Context context2) {
            super(context, z);
            this.a = gcVar;
            this.b = context2;
        }

        @Override
        public void onNext(UserResponseModel userResponseModel) {
            super.onNext((d) userResponseModel);
            if (userResponseModel.isSuccess()) {
                EconomistVerifyOtpActivity.this.P();
                return;
            }
            this.a.f.setTextColor(this.b.getResources().getColor(2131100825));
            this.a.i.setTextColor(this.b.getResources().getColor(2131100825));
            this.a.h.setTextColor(this.b.getResources().getColor(2131100825));
            this.a.e.setTextColor(this.b.getResources().getColor(2131100825));
            this.a.d.setTextColor(this.b.getResources().getColor(2131100825));
            this.a.g.setTextColor(this.b.getResources().getColor(2131100825));
            this.a.C.setBackgroundColor(this.b.getResources().getColor(2131100825));
            this.a.D.setBackgroundColor(this.b.getResources().getColor(2131100825));
            this.a.E.setBackgroundColor(this.b.getResources().getColor(2131100825));
            this.a.F.setBackgroundColor(this.b.getResources().getColor(2131100825));
            this.a.G.setBackgroundColor(this.b.getResources().getColor(2131100825));
            this.a.H.setBackgroundColor(this.b.getResources().getColor(2131100825));
            this.a.w.setVisibility(0);
        }
    }

    class e implements y {
        e() {
        }

        @Override
        public void c(EconomistEmailEligibilityPojo economistEmailEligibilityPojo) {
            if (economistEmailEligibilityPojo != null) {
                if (!economistEmailEligibilityPojo.isEmailEligible() || economistEmailEligibilityPojo.getStatus().equalsIgnoreCase("failed")) {
                    Toast.makeText((Context) EconomistVerifyOtpActivity.this, (CharSequence) "economist login failed", 1).show();
                } else if (economistEmailEligibilityPojo.isEmailEligible() || economistEmailEligibilityPojo.getStatus().equalsIgnoreCase("success")) {
                    EconomistVerifyOtpActivity.this.startActivityForResult(new Intent((Context) EconomistVerifyOtpActivity.this, (Class<?>) EconomistThankyouActivity.class), PaymentSuccessfulActivity.h);
                }
            }
        }

        @Override
        public void onError(String str, String str2) {
        }
    }

    class f extends CountDownTimer {

        class a implements View.OnClickListener {
            a() {
            }

            @Override
            public void onClick(View view) {
                EconomistVerifyOtpActivity.this.onClickResend(view);
            }
        }

        f(long j, long j2) {
            super(j, j2);
        }

        @Override
        public void onFinish() {
            EconomistVerifyOtpActivity.this.a.z.setEnabled(true);
            EconomistVerifyOtpActivity.this.a.u.setVisibility(8);
            EconomistVerifyOtpActivity.this.a.z.setTextColor(EconomistVerifyOtpActivity.this.getResources().getColor(2131099986));
            EconomistVerifyOtpActivity.this.a.z.setOnClickListener(new a());
        }

        @Override
        public void onTick(long j) {
            EconomistVerifyOtpActivity.this.a.u.setVisibility(0);
            EconomistVerifyOtpActivity.this.a.u.setText("00:" + String.format(Locale.ENGLISH, "%1$02d", Long.valueOf((j / 1000) + 1)));
        }
    }

    class g extends CustomObserver<UserResponseModel> {
        final Context a;

        g(Context context, boolean z, Context context2) {
            super(context, z);
            this.a = context2;
        }

        @Override
        public void onNext(UserResponseModel userResponseModel) {
            super.onNext((g) userResponseModel);
            if (userResponseModel == null || userResponseModel.getMessage() == null || TextUtils.isEmpty(userResponseModel.getMessage().getText())) {
                return;
            }
            ToastHelper.showToast(this.a, userResponseModel.getMessage().getText());
        }
    }

    private JsonObject N() {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("otp", this.a.s.getText().toString());
        jsonObject.addProperty("referrer", "LM");
        jsonObject.addProperty("email", this.c);
        jsonObject.addProperty("newsletterConsent", Boolean.TRUE);
        jsonObject.addProperty("name", Utils.getNameFromEmailOrMobile(this.c));
        jsonObject.addProperty("type", "app");
        jsonObject.addProperty("os", LogSubCategory.LifeCycle.ANDROID);
        jsonObject.addProperty("source", "S");
        jsonObject.addProperty("otpFor", "SIGN_UP");
        return jsonObject;
    }

    private String O() {
        Config config = this.d;
        String str = BuildConfig.FLAVOR;
        if (config == null || config.getSso() == null) {
            return BuildConfig.FLAVOR;
        }
        String ssoBaseUrl = !TextUtils.isEmpty(this.d.getSso().getSsoBaseUrl()) ? this.d.getSso().getSsoBaseUrl() : BuildConfig.FLAVOR;
        if (this.d.getSso().getMobileSSO() != null && !TextUtils.isEmpty(this.d.getSso().getMobileSSO().getLinkEmailViaOtp())) {
            str = this.d.getSso().getMobileSSO().getLinkEmailViaOtp();
        }
        return ssoBaseUrl + str;
    }

    public boolean Q(TextView textView, int i, KeyEvent keyEvent) {
        if (i != 6) {
            return false;
        }
        R(this.a, textView, this);
        return true;
    }

    private void S() {
        this.a.s.addTextChangedListener(new c());
        this.a.s.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public final boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                boolean Q;
                Q = EconomistVerifyOtpActivity.this.Q(textView, i, keyEvent);
                return Q;
            }
        });
    }

    private void setupDarkMode() {
        this.a.z.setTextColor(getResources().getColor(2131099712));
        if (f0.Z1()) {
            getWindow().setStatusBarColor(-16777216);
            getWindow().getDecorView().setSystemUiVisibility(0);
            this.a.r.setTextColor(getResources().getColor(2131100814));
            this.a.A.setTextColor(getResources().getColor(2131100814));
            this.a.t.setBackgroundDrawable(getResources().getDrawable(2131234213));
            this.a.o.setBackgroundResource(2131234211);
            this.a.I.setBackgroundColor(getResources().getColor(2131100914));
            this.a.v.setBackgroundColor(getResources().getColor(2131100008));
            this.a.v.setTitleTextColor(ResourcesCompat.getColor(getResources(), 2131101009, (Resources.Theme) null));
            this.a.s.setTextColor(getResources().getColor(2131100955));
            this.a.f.setTextColor(getResources().getColor(2131100814));
            this.a.i.setTextColor(getResources().getColor(2131100814));
            this.a.h.setTextColor(getResources().getColor(2131100814));
            this.a.e.setTextColor(getResources().getColor(2131100814));
            this.a.d.setTextColor(getResources().getColor(2131100814));
            this.a.g.setTextColor(getResources().getColor(2131100814));
            this.a.C.setBackgroundColor(getResources().getColor(2131100814));
            this.a.D.setBackgroundColor(getResources().getColor(2131100814));
            this.a.E.setBackgroundColor(getResources().getColor(2131100814));
            this.a.F.setBackgroundColor(getResources().getColor(2131100814));
            this.a.G.setBackgroundColor(getResources().getColor(2131100814));
            this.a.H.setBackgroundColor(getResources().getColor(2131100814));
            return;
        }
        getWindow().setStatusBarColor(-1);
        getWindow().getDecorView().setSystemUiVisibility(8192);
        this.a.A.setTextColor(getResources().getColor(2131100820));
        this.a.s.setTextColor(getResources().getColor(2131100955));
        this.a.r.setTextColor(getResources().getColor(2131100820));
        this.a.v.setBackgroundColor(getResources().getColor(2131100007));
        this.a.v.setBackgroundColor(getResources().getColor(2131101002));
        this.a.v.setTitleTextColor(ResourcesCompat.getColor(getResources(), 2131101008, (Resources.Theme) null));
        this.a.t.setBackgroundColor(getResources().getColor(2131100826));
        this.a.o.setBackgroundResource(2131234212);
        this.a.I.setBackgroundColor(getResources().getColor(2131100913));
        this.a.f.setTextColor(getResources().getColor(2131100820));
        this.a.i.setTextColor(getResources().getColor(2131100820));
        this.a.h.setTextColor(getResources().getColor(2131100820));
        this.a.e.setTextColor(getResources().getColor(2131100820));
        this.a.d.setTextColor(getResources().getColor(2131100820));
        this.a.g.setTextColor(getResources().getColor(2131100820));
        this.a.C.setBackgroundColor(getResources().getColor(2131100820));
        this.a.D.setBackgroundColor(getResources().getColor(2131100820));
        this.a.E.setBackgroundColor(getResources().getColor(2131100820));
        this.a.F.setBackgroundColor(getResources().getColor(2131100820));
        this.a.G.setBackgroundColor(getResources().getColor(2131100820));
        this.a.H.setBackgroundColor(getResources().getColor(2131100820));
    }

    private void setupToolbar() {
        this.a.v.setContentInsetStartWithNavigation(0);
        setSupportActionBar(this.a.v);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayShowTitleEnabled(false);
            getSupportActionBar().setDisplayHomeAsUpEnabled(false);
            getSupportActionBar().setDisplayShowHomeEnabled(false);
        }
        this.a.v.setTitle(BuildConfig.FLAVOR);
    }

    public void L(View view, Context context) {
        Utils.hideKeyboard(view);
        try {
            JsonObject jsonObject = new JsonObject();
            jsonObject.addProperty("referrer", "LM");
            Config config = this.d;
            String str = BuildConfig.FLAVOR;
            if (config != null && config.getSso() != null) {
                String ssoBaseUrl = !TextUtils.isEmpty(this.d.getSso().getSsoBaseUrl()) ? this.d.getSso().getSsoBaseUrl() : BuildConfig.FLAVOR;
                if (this.d.getSso().getMobileSSO() != null && !TextUtils.isEmpty(this.d.getSso().getMobileSSO().getLinkEmailGenerateOtp())) {
                    str = this.d.getSso().getMobileSSO().getLinkEmailGenerateOtp();
                }
                str = ssoBaseUrl + str;
            }
            jsonObject.addProperty("email", this.c);
            String jsonElement = jsonObject.toString();
            String doGenerateTokenSSO = TokenGenerater.doGenerateTokenSSO(jsonElement);
            jsonObject.addProperty("authPayload", jsonElement);
            HashMap<String, String> hashMap = new HashMap<>();
            hashMap.put("X-Authorization", doGenerateTokenSSO);
            hashMap.put("X-Platform", "Android");
            ((ApiServices) ApiClient.getClient().create(ApiServices.class)).home(hashMap, str, jsonObject).s(sg.a.b()).k(ag.a.a()).a(new g(context, true, context));
        } catch (Exception e2) {
            e2.printStackTrace();
            ToastHelper.showToast(context, NetworkHelper.getErrorMessage(context, e2));
        }
    }

    public String M(String str, int i) {
        return str.length() > i ? String.valueOf(str.charAt(i)) : BuildConfig.FLAVOR;
    }

    void P() {
        x xVar = new x(this, new e());
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("email", this.c);
            jSONObject.put("isRenewal", false);
            jSONObject.put(PaymentConstants.CLIENT_ID_CAMEL, f0.G1(this, "userClient"));
            jSONObject.put("ref", "LM");
            jSONObject.put("flow", "email_login");
            jSONObject.put("country", "IN");
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("userSsoLoginToken", f0.G1(this, "userToken"));
        Config config = this.d;
        xVar.a((config == null || config.getSso() == null || TextUtils.isEmpty(this.d.getSso().getEcoEmailCheck())) ? BuildConfig.FLAVOR : this.d.getSso().getEcoEmailCheck(), jSONObject, hashMap, false, true);
    }

    public void R(gc gcVar, View view, Context context) {
        Utils.hideKeyboard(view);
        try {
            gcVar.w.setVisibility(8);
            ((ApiServices) ApiClient.getClient().create(ApiServices.class)).verifyOtp(O(), N()).s(sg.a.b()).k(ag.a.a()).a(new d(context, true, gcVar, context));
            T(this);
        } catch (Exception e2) {
            e2.printStackTrace();
            gcVar.w.setVisibility(0);
            ToastHelper.showToast(context, NetworkHelper.getErrorMessage(context, e2));
        }
    }

    public void T(Context context) {
        FragmentManager supportFragmentManager = ((AppCompatActivity) context).getSupportFragmentManager();
        int backStackEntryCount = supportFragmentManager.getBackStackEntryCount() - 1;
        if (backStackEntryCount >= 0) {
            Fragment findFragmentByTag = supportFragmentManager.findFragmentByTag(supportFragmentManager.getBackStackEntryAt(backStackEntryCount).getName());
            if (findFragmentByTag instanceof ValidateOtpFragment) {
                ValidateOtpFragment validateOtpFragment = (ValidateOtpFragment) findFragmentByTag;
                validateOtpFragment.unregisterSmsRetriever();
                validateOtpFragment.registerSmsRetriever();
            }
        }
        new f(30000L, 500L).start();
        this.a.z.setEnabled(false);
    }

    protected void onActivityResult(int i, int i2, @Nullable Intent intent) {
        super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i2, intent);
        if (i == PaymentSuccessfulActivity.h && i2 == -1) {
            setResult(-1);
            finish();
        }
    }

    public void onClickResend(View view) {
        this.a.f.setText(BuildConfig.FLAVOR);
        this.a.i.setText(BuildConfig.FLAVOR);
        this.a.h.setText(BuildConfig.FLAVOR);
        this.a.e.setText(BuildConfig.FLAVOR);
        this.a.d.setText(BuildConfig.FLAVOR);
        this.a.g.setText(BuildConfig.FLAVOR);
        L(view, this);
    }

    protected void onCreate(Bundle bundle) {
        super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
        this.a = DataBindingUtil.setContentView(this, 2131624244);
        this.d = AppController.j().g();
        setupToolbar();
        if (getIntent() != null && getIntent().hasExtra("email")) {
            this.c = getIntent().getStringExtra("email");
        }
        this.b = f0.Z1();
        S();
        setupDarkMode();
        if (TextUtils.isEmpty(this.c)) {
            this.a.B.setVisibility(8);
        } else {
            this.a.B.setText(this.c);
            this.a.B.setVisibility(0);
        }
        this.a.q.setOnClickListener(new a());
        this.a.x.setOnClickListener(new b());
    }
}