导航菜单

页面标题

页面副标题

Mint v5.7.3 - WhatsappSubscriptionActivity.java 源代码

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

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


package com.htmedia.mint.ui.activity;

import android.app.ProgressDialog;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.Html;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.firebase.perf.network.FirebasePerfUrlConnection;
import com.htmedia.mint.AppController;
import com.htmedia.mint.ui.activity.WhatsappSubscriptionActivity;
import com.htmedia.sso.fragments.CountriesDialogFragment;
import com.htmedia.sso.helpers.SMSBroadcastReceiver;
import com.htmedia.sso.helpers.Utils;
import com.htmedia.sso.models.CountryModel;
import com.htmedia.sso.models.EmailOrMobileModel;
import com.thoughtbot.expandablerecyclerview.BuildConfig;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import javax.net.ssl.HttpsURLConnection;
import y7.x5;

public class WhatsappSubscriptionActivity extends com.htmedia.mint.ui.activity.a implements CountriesDialogFragment.CountriesDialogListener, SMSBroadcastReceiver.OTPReceiveListener {
    public x4.i3 a;
    private x5 b;
    d c;
    private ProgressDialog d;
    private SMSBroadcastReceiver e;
    private boolean f = false;

    class a implements TextWatcher {
        a() {
        }

        public void b() {
            WhatsappSubscriptionActivity.this.a.j.getRoot().findViewById(2131428336).setSelection(WhatsappSubscriptionActivity.this.a.j.getRoot().findViewById(2131428336).getText().length());
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() == 0) {
                WhatsappSubscriptionActivity.this.b.c.setEmailOrMobile(BuildConfig.FLAVOR);
            } else if (!Utils.isNumeric(editable.toString()) || editable.toString().length() <= 14) {
                WhatsappSubscriptionActivity.this.b.c.setEmailOrMobile(editable.toString());
            } else {
                WhatsappSubscriptionActivity.this.a.j.getRoot().findViewById(2131428336).setText(WhatsappSubscriptionActivity.this.b.c.getEmailOrMobile());
                WhatsappSubscriptionActivity.this.a.j.getRoot().findViewById(2131428336).post(new Runnable() {
                    @Override
                    public final void run() {
                        WhatsappSubscriptionActivity.a.this.b();
                    }
                });
            }
        }

        @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 b implements TextWatcher {
        b() {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() == 6) {
                Utils.hideKeyboard(WhatsappSubscriptionActivity.this.a.getRoot());
            }
        }

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

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

    private class c extends AsyncTask<Void, Void, d> {
        private c() {
        }

        c(WhatsappSubscriptionActivity whatsappSubscriptionActivity, a aVar) {
            this();
        }

        @Override
        public d doInBackground(Void... voidArr) {
            URL url = null;
            String locationUrl = (AppController.j().g() == null || TextUtils.isEmpty(AppController.j().g().getLocationUrl())) ? null : AppController.j().g().getLocationUrl();
            try {
            } catch (MalformedURLException e) {
                e.printStackTrace();
                com.htmedia.mint.utils.o0.h(e, locationUrl, e.getMessage());
            }
            if (locationUrl == null) {
                return d.Other;
            }
            url = new URL(locationUrl);
            try {
                HttpsURLConnection httpsURLConnection = (HttpsURLConnection) ((URLConnection) FirebasePerfUrlConnection.instrument(url.openConnection()));
                httpsURLConnection.setRequestMethod("GET");
                httpsURLConnection.setRequestProperty("charset", "utf-8");
                httpsURLConnection.connect();
                if (httpsURLConnection.getResponseCode() == 200) {
                    String headerField = httpsURLConnection.getHeaderField("meta-geo");
                    if (!TextUtils.isEmpty(headerField)) {
                        if (!headerField.startsWith("us") && !headerField.startsWith("US")) {
                            if (headerField.startsWith("in") || headerField.startsWith("IN")) {
                                return d.India;
                            }
                        }
                        return d.US;
                    }
                }
            } catch (ProtocolException e2) {
                e2.printStackTrace();
                com.htmedia.mint.utils.o0.h(e2, locationUrl, e2.getMessage());
            } catch (IOException e3) {
                e3.printStackTrace();
                com.htmedia.mint.utils.o0.h(e3, locationUrl, e3.getMessage());
            } catch (Exception e4) {
                e4.printStackTrace();
                com.htmedia.mint.utils.o0.h(e4, locationUrl, e4.getMessage());
            }
            return d.Other;
        }

        @Override
        public void onPostExecute(d dVar) {
            super.onPostExecute(dVar);
            WhatsappSubscriptionActivity.this.dismissProgressDialog();
            WhatsappSubscriptionActivity whatsappSubscriptionActivity = WhatsappSubscriptionActivity.this;
            whatsappSubscriptionActivity.c = dVar;
            whatsappSubscriptionActivity.a.c(Boolean.valueOf(d.India != dVar));
            WhatsappSubscriptionActivity.this.a.j.h.setText((AppController.j().g() == null || AppController.j().g().getSso() == null || AppController.j().g().getSso().getMobileSSO() == null || AppController.j().g().getSso().getMobileSSO().getMobileLocationDisclaimer() == null) ? WhatsappSubscriptionActivity.this.getString(2131952429) : AppController.j().g().getSso().getMobileSSO().getMobileLocationDisclaimer());
        }
    }

    public enum d {
        US,
        India,
        Other
    }

    public void R(Exception exc) {
        Utils.showSoftKeyboard(this.a.getRoot());
    }

    public boolean S(TextView textView, int i, KeyEvent keyEvent) {
        if (i != 6 || !this.b.e.getSendWhatsappUpdates()) {
            return false;
        }
        this.b.onClickContinue(this.a.c, this);
        return true;
    }

    public void T(View view, boolean z) {
        if (z) {
            this.a.j.getRoot().findViewById(2131428337).setBackground(ContextCompat.getDrawable(this, 2131231519));
        }
        this.b.c.setShowError(false);
    }

    public void U() {
        if (AppController.j().E()) {
            this.a.j.getRoot().findViewById(2131428337).setBackground(ContextCompat.getDrawable(this, 2131231534));
            this.a.j.getRoot().findViewById(2131428139).setBackgroundColor(ContextCompat.getColor(this, 2131100829));
        } else {
            this.a.j.getRoot().findViewById(2131428337).setBackground(ContextCompat.getDrawable(this, 2131231530));
            this.a.j.getRoot().findViewById(2131428139).setBackgroundColor(ContextCompat.getColor(this, 2131100828));
        }
    }

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

    public void W(View view) {
        this.a.t.requestFocus();
        this.b.onClickOtp(view);
    }

    private void Y() {
        this.a.j.getRoot().findViewById(2131428338).setTextSize(16.0f);
        this.a.j.getRoot().findViewById(2131428338).setTypeface(Typeface.DEFAULT);
        this.a.j.getRoot().findViewById(2131428336).setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public final boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                boolean S;
                S = WhatsappSubscriptionActivity.this.S(textView, i, keyEvent);
                return S;
            }
        });
        this.a.j.getRoot().findViewById(2131428336).addTextChangedListener(new a());
        this.a.j.getRoot().findViewById(2131428336).setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public final void onFocusChange(View view, boolean z) {
                WhatsappSubscriptionActivity.this.T(view, z);
            }
        });
        new Handler().postDelayed(new Runnable() {
            @Override
            public final void run() {
                WhatsappSubscriptionActivity.this.U();
            }
        }, 50L);
    }

    private void Z() {
        this.a.t.addTextChangedListener(new b());
        this.a.t.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public final boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                boolean V;
                V = WhatsappSubscriptionActivity.this.V(textView, i, keyEvent);
                return V;
            }
        });
        this.a.u.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                WhatsappSubscriptionActivity.this.W(view);
            }
        });
    }

    private void initCountryAndPlans() {
        new c(this, null).execute(new Void[0]);
        initProgressDialogAndShow();
    }

    private void initProgressDialogAndShow() {
        ProgressDialog progressDialog = this.d;
        if (progressDialog != null && !progressDialog.isShowing()) {
            this.d.show();
            return;
        }
        if (this.d == null) {
            ProgressDialog progressDialog2 = new ProgressDialog(this);
            this.d = progressDialog2;
            progressDialog2.setMessage("Please wait...!");
            this.d.setCancelable(false);
            if (this.d.isShowing()) {
                return;
            }
            this.d.show();
        }
    }

    public void lambda$setupToolbar$0(View view) {
        onBackPressed();
    }

    public void lambda$setupToolbar$1(View view) {
        onBackPressed();
    }

    private void setupDarkMode() {
        this.a.d(Boolean.valueOf(AppController.j().E()));
        if (!AppController.j().E()) {
            getWindow().setStatusBarColor(-1);
            getWindow().getDecorView().setSystemUiVisibility(8192);
            this.a.C.setTitleTextColor(ResourcesCompat.getColor(getResources(), 2131101008, (Resources.Theme) null));
            if (!this.b.a.equalsIgnoreCase("onboarding")) {
                this.a.C.setNavigationIcon(2131231330);
            }
            this.a.E.setBackgroundColor(getResources().getColor(2131100913));
            this.a.a.setTextColor(getResources().getColor(2131101012));
            return;
        }
        getWindow().setStatusBarColor(-16777216);
        getWindow().getDecorView().setSystemUiVisibility(0);
        this.a.C.setBackgroundColor(getResources().getColor(2131100008));
        this.a.C.setTitleTextColor(ResourcesCompat.getColor(getResources(), 2131101009, (Resources.Theme) null));
        if (!this.b.a.equalsIgnoreCase("onboarding")) {
            this.a.C.setNavigationIcon(2131231333);
        }
        this.a.E.setBackgroundColor(getResources().getColor(2131100008));
        this.a.s.setBackgroundColor(getResources().getColor(2131099906));
        this.a.p.setTextColor(getResources().getColor(2131101002));
        this.a.b.setTextColor(getResources().getColor(2131101002));
        this.a.j.getRoot().findViewById(2131428338).setTextColor(getResources().getColor(2131100834));
        this.a.j.getRoot().findViewById(2131428143).setTextColor(getResources().getColor(2131101002));
        this.a.j.getRoot().findViewById(2131428141).setTextColor(getResources().getColor(2131101002));
        this.a.j.getRoot().findViewById(2131428336).setTextColor(getResources().getColor(2131101002));
        this.a.z.setTextColor(getResources().getColor(2131101002));
        this.a.o.setTextColor(getResources().getColor(2131100834));
        this.a.t.setTextColor(getResources().getColor(2131099906));
        this.a.f.setTextColor(getResources().getColor(2131101002));
        this.a.i.setTextColor(getResources().getColor(2131101002));
        this.a.h.setTextColor(getResources().getColor(2131101002));
        this.a.e.setTextColor(getResources().getColor(2131101002));
        this.a.d.setTextColor(getResources().getColor(2131101002));
        this.a.g.setTextColor(getResources().getColor(2131101002));
        this.a.a.setTextColor(getResources().getColor(2131100905));
    }

    private void setupToolbar() {
        this.a.C.setContentInsetStartWithNavigation(0);
        setSupportActionBar(this.a.C);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayShowTitleEnabled(false);
            if (this.b.a.equalsIgnoreCase("onboarding")) {
                getSupportActionBar().setDisplayHomeAsUpEnabled(false);
                getSupportActionBar().setDisplayShowHomeEnabled(false);
                this.a.C.setTitle(BuildConfig.FLAVOR);
                return;
            }
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
            this.a.C.setTitle("Back");
            this.a.C.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    WhatsappSubscriptionActivity.this.lambda$setupToolbar$0(view);
                }
            });
            if (this.a.C.getTitle() != null) {
                String charSequence = this.a.C.getTitle().toString();
                for (int i = 0; i < this.a.C.getChildCount(); i++) {
                    AppCompatTextView childAt = this.a.C.getChildAt(i);
                    if ("androidx.appcompat.widget.AppCompatTextView".equals(childAt.getClass().getName())) {
                        AppCompatTextView appCompatTextView = childAt;
                        if (appCompatTextView.getText().equals(charSequence)) {
                            appCompatTextView.setTypeface(ResourcesCompat.getFont(this, 2131296270));
                            appCompatTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
                            appCompatTextView.setCompoundDrawablePadding(0);
                            childAt.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public final void onClick(View view) {
                                    WhatsappSubscriptionActivity.this.lambda$setupToolbar$1(view);
                                }
                            });
                        }
                    }
                }
            }
        }
    }

    private void setupViewModel() {
        x5 x5Var = (x5) new ViewModelProvider(this).get(x5.class);
        this.b = x5Var;
        x5Var.a = getIntent().getStringExtra("whatsapp_origin");
        if (getIntent().hasExtra("campaign")) {
            this.b.b = getIntent().getStringExtra("campaign");
        }
        this.a.j.getRoot().findViewById(2131428338).setText("Please enter phone number");
        this.b.c.setType(EmailOrMobileModel.FieldType.MOBILE);
        this.b.c.setShowName(false);
        this.a.j.getRoot().findViewById(2131428336).setInputType(2);
        this.b.c.setSelectedCountry(new CountryModel("India", "IN", "+91"));
        this.a.e(this.b);
        this.a.b.setText(com.htmedia.mint.utils.f0.V3(Html.fromHtml("Dear Reader, Share your mobile number<br>for instant updates on <b>WhatsApp</b>")));
    }

    public void X() {
        SmsRetriever.getClient(this).startSmsRetriever().addOnFailureListener(new OnFailureListener() {
            public final void onFailure(Exception exc) {
                WhatsappSubscriptionActivity.this.R(exc);
            }
        });
        SMSBroadcastReceiver sMSBroadcastReceiver = new SMSBroadcastReceiver();
        this.e = sMSBroadcastReceiver;
        sMSBroadcastReceiver.initOTPListener(this);
        this.f = true;
        if (Build.VERSION.SDK_INT >= 34) {
            registerReceiver(this.e, new IntentFilter("com.google.android.gms.auth.api.phone.SMS_RETRIEVED"), 2);
        } else {
            registerReceiver(this.e, new IntentFilter("com.google.android.gms.auth.api.phone.SMS_RETRIEVED"));
        }
    }

    public void a0() {
        SMSBroadcastReceiver sMSBroadcastReceiver = this.e;
        if (sMSBroadcastReceiver == null || !this.f) {
            return;
        }
        try {
            this.f = false;
            unregisterReceiver(sMSBroadcastReceiver);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void dismissProgressDialog() {
        try {
            ProgressDialog progressDialog = this.d;
            if (progressDialog != null && progressDialog.isShowing()) {
                this.d.dismiss();
            }
        } catch (IllegalArgumentException unused) {
        } catch (Throwable th) {
            this.d = null;
            throw th;
        }
        this.d = null;
    }

    public void onBackPressed() {
        if (!this.b.e.isShowOtpLayout()) {
            if (!getIntent().hasExtra("whatsapp_origin") || !getIntent().getStringExtra("whatsapp_origin").equalsIgnoreCase("onboarding")) {
                super/*androidx.activity.ComponentActivity*/.onBackPressed();
                return;
            } else {
                setResult(-1);
                finish();
                return;
            }
        }
        Utils.hideKeyboard(this.a.getRoot());
        this.b.e.setShowOtpLayout(false);
        this.b.e.setOtp(BuildConfig.FLAVOR);
        a0();
        if (getIntent().hasExtra("whatsapp_origin") && getIntent().getStringExtra("whatsapp_origin").equalsIgnoreCase("onboarding")) {
            this.a.y.setVisibility(0);
        }
    }

    public void onConfigurationChanged(@NonNull Configuration configuration) {
        super.onConfigurationChanged(configuration);
        AppController.e(getIntent(), this);
    }

    @Override
    public void onCountrySelected(CountryModel countryModel) {
        this.b.c.setSelectedCountry(countryModel);
    }

    protected void onCreate(Bundle bundle) {
        super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
        this.a = DataBindingUtil.setContentView(this, 2131624032);
        com.htmedia.mint.utils.f0.b = false;
        SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(this).edit();
        edit.putString("whatsapp_popup_date", new SimpleDateFormat("dd-MMM-yyyy", Locale.getDefault()).format(new Date()));
        edit.apply();
        setupViewModel();
        setupDarkMode();
        setupToolbar();
        Y();
        Z();
        if (this.b.a.equalsIgnoreCase("onboarding")) {
            this.a.y.setVisibility(0);
        }
        initCountryAndPlans();
    }

    public void onDestroy() {
        super.onDestroy();
        a0();
    }

    @Override
    public void onOTPReceived(String str) {
        this.a.t.setText(BuildConfig.FLAVOR);
        this.a.t.append(str);
    }

    @Override
    public void onOTPTimeOut() {
        Utils.showSoftKeyboard(this.a.getRoot());
    }
}