导航菜单

页面标题

页面副标题

SpeedCash v6.5.1482 - OTPCallActivity.java 源代码

正在查看: SpeedCash v6.5.1482 应用的 OTPCallActivity.java JAVA 源代码文件

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


package com.bm.sc.bebasbayar.ui.activity.auth;

import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.text.Html;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.CallSuper;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import com.bm.sc.auth.ui.cs.LiveChatActivity;
import com.bm.sc.bebasbayar.R;
import com.bm.sc.bebasbayar.adapter.entity.TrainScheduleEntity;
import com.bm.sc.bebasbayar.helper.Affinity;
import com.bm.sc.bebasbayar.helper.AuthHelper;
import com.bm.sc.bebasbayar.helper.EventHelper;
import com.bm.sc.bebasbayar.helper.FirebaseHelper;
import com.bm.sc.bebasbayar.iface.BBCallback;
import com.bm.sc.bebasbayar.message.qr.DataMessage;
import com.bm.sc.bebasbayar.service.BBFourDigitReceiver;
import com.bm.sc.bebasbayar.ui.activity.auth.OTPCallActivity;
import com.bm.sc.bebasbayar.ui.activity.ticket.TrainFormActivity;
import com.bm.sc.util.common.Var;
import in.aabhasjindal.otptextview.OTPListener;
import in.aabhasjindal.otptextview.OtpTextView;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

public class OTPCallActivity extends AuthActivity implements View.OnClickListener, OTPListener {
    public static final int STATE_CHANGE_PIN = 3;
    public static final int STATE_LOGIN = 2;
    public static final int STATE_LOGIN_FINGER = 4;
    public static final int STATE_LOGIN_PIN = 6;
    public static final int STATE_LOGIN_WA = 5;
    public static final int STATE_REGISTER = 1;
    public static final int STATE_RESET = 0;
    public String d;
    public String e;
    public String f;
    public String g;
    public String h;
    public String i;
    public String j;
    public int k;
    public Date l;
    public EditText m;
    public TextView n;
    public TextView o;
    public TextView p;
    public CountDownTimer q;
    public OtpTextView r;
    public BBFourDigitReceiver s;
    public final String t = getClass().getSimpleName();

    public class a implements BBFourDigitReceiver.FourDigitReceiverListener {
        public a() {
        }

        @Override
        public void onError(String str) {
            String unused = OTPCallActivity.this.t;
        }

        @Override
        public void onSuccess(String str) {
            String unused = OTPCallActivity.this.t;
            StringBuilder sb = new StringBuilder();
            sb.append("Receive OTP:");
            sb.append(str);
            OTPCallActivity.this.m.setText(str);
        }
    }

    public class b extends ClickableSpan {
        public b() {
        }

        public void b(int i, AuthHelper.OTPResponse oTPResponse) {
            OTPCallActivity.this.m.setText("");
            if (oTPResponse.getRc().equals("00") || (oTPResponse.getRc().equals("404") && OTPCallActivity.this.k == 1)) {
                OTPCallActivity.this.l = oTPResponse.getDate();
                OTPCallActivity.this.o.setText(oTPResponse.getToken());
                OTPCallActivity.this.f = oTPResponse.getToken();
                Intent intent = new Intent();
                if (OTPCallActivity.this.f != null) {
                    intent.putExtra("phoneCaller", OTPCallActivity.this.f);
                }
                OTPCallActivity.this.sendBroadcast(intent);
                Affinity.toast(OTPCallActivity.this, "Panggilan akan dilakukan ke nomor " + OTPCallActivity.this.d);
            } else {
                Affinity.info(OTPCallActivity.this, false, oTPResponse.getMessage());
            }
            OTPCallActivity.this.F();
        }

        @Override
        public void onClick(@NonNull View view) {
            OTPCallActivity oTPCallActivity = OTPCallActivity.this;
            AuthHelper.requestOTPCitCall(oTPCallActivity, oTPCallActivity.d, OTPCallActivity.this.k, new BBCallback() {
                @Override
                public final void do_callback(int i, Object obj) {
                    OTPCallActivity.b.this.b(i, (AuthHelper.OTPResponse) obj);
                }
            });
        }
    }

    public class c extends ClickableSpan {
        public final String a;

        public c(String str) {
            this.a = str;
        }

        public void b(int i, AuthHelper.OTPResponse oTPResponse) {
            OTPCallActivity.this.r.setOTP("");
            if (oTPResponse.getRc().equals("00")) {
                OTPCallActivity.this.l = oTPResponse.getDate();
                Affinity.toast(OTPCallActivity.this, "SMS akan dikirimkan ke nomor " + OTPCallActivity.this.d);
            } else {
                Affinity.info(OTPCallActivity.this, false, oTPResponse.getMessage());
            }
            OTPCallActivity.this.F();
        }

        @Override
        public void onClick(@NonNull View view) {
            OTPCallActivity oTPCallActivity = OTPCallActivity.this;
            AuthHelper.requestOTPv2(oTPCallActivity, oTPCallActivity.d, OTPCallActivity.this.k, this.a, new BBCallback() {
                @Override
                public final void do_callback(int i, Object obj) {
                    OTPCallActivity.c.this.b(i, (AuthHelper.OTPResponse) obj);
                }
            });
        }
    }

    public class d extends ClickableSpan {
        public d() {
        }

        @Override
        public void onClick(@NonNull View view) {
            OTPCallActivity.this.onBackPressed();
        }
    }

    public class e extends CountDownTimer {
        public e(long j, long j2) {
            super(j, j2);
        }

        @Override
        public void onFinish() {
            OTPCallActivity.this.n.setVisibility(8);
            OTPCallActivity.this.p.setVisibility(0);
        }

        @Override
        public void onTick(long j) {
            TimeUnit timeUnit = TimeUnit.MILLISECONDS;
            long minutes = timeUnit.toMinutes(j);
            OTPCallActivity.this.n.setText(OTPCallActivity.this.getString(R.string.bonjour_label_sms_countdown, String.format(Locale.getDefault(), "%02d:%02d", Long.valueOf(minutes), Long.valueOf(timeUnit.toSeconds(j) - TimeUnit.MINUTES.toSeconds(minutes)))));
        }
    }

    public static void A(int i, String str) {
    }

    public void B(String str, int i, int i2, AuthHelper.OTPResponse oTPResponse) {
        if (!oTPResponse.getRc().equals("00")) {
            if ((oTPResponse.getRc().isEmpty() || oTPResponse.getRc().equals(TrainScheduleEntity.CLASS_INVALID)) && i <= 10) {
                y(str, i + 1);
                return;
            } else {
                this.m.setText("");
                Affinity.info(this, false, oTPResponse.getMessage());
                return;
            }
        }
        int i3 = this.k;
        if (i3 == 0 || i3 == 3) {
            Affinity.launch(this, GantiPINActivity.class, GantiPINActivity.getBundle(this, this.d, str, i3, ""));
            finish();
        } else if (i3 != 1) {
            AuthHelper.doRegister(this, this.d, this.i, this.g, this.h, this.e, str, new BBCallback() {
                @Override
                public final void do_callback(int i4, Object obj) {
                    OTPCallActivity.A(i4, (String) obj);
                }
            });
        } else {
            Affinity.launch(this, RegisterActivity.class, RegisterActivity.getBundle(this, this.d, str, ""));
            finish();
        }
    }

    public void C(int i, AuthHelper.LoginMessageNew loginMessageNew) {
        this.m.setText("");
        Affinity.info(this, true, loginMessageNew.getMessage());
    }

    public void D(int i, Boolean bool) {
        finish();
    }

    public void E() {
        this.m.requestFocus();
    }

    public static Bundle getBundle(AuthActivity authActivity, String str, int i, Date date, String str2) {
        Bundle bundle = new Bundle();
        bundle.putString("phone", str);
        bundle.putInt("state", i);
        bundle.putSerializable("next_receive", date);
        bundle.putString("phoneCaller", str2);
        bundle.putAll(authActivity.getGPSBundle());
        return bundle;
    }

    public final void F() {
        Date date = this.l;
        if (date == null || !date.after(new Date())) {
            this.n.setVisibility(8);
            this.p.setVisibility(0);
            return;
        }
        this.n.setVisibility(0);
        this.p.setVisibility(8);
        CountDownTimer countDownTimer = this.q;
        if (countDownTimer != null) {
            countDownTimer.cancel();
        }
        e eVar = new e(this.l.getTime() - new Date().getTime(), 1000L);
        this.q = eVar;
        eVar.start();
    }

    @Override
    @LayoutRes
    public int getLayoutResource() {
        return R.layout.activity_otp_call;
    }

    @Override
    public int getRootLayoutId() {
        return R.id.layout_root;
    }

    public void initRetryButton(String str, String str2) {
        if (str.isEmpty()) {
            return;
        }
        SpannableString spannableString = new SpannableString(str);
        Object bVar = str2.equalsIgnoreCase("call") ? new b() : str2.equalsIgnoreCase("sms") ? new c(str2) : null;
        d dVar = new d();
        spannableString.setSpan(bVar, 21, 32, 0);
        spannableString.setSpan(dVar, 39, spannableString.length(), 0);
        spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(this, R.color.new_background_color)), 21, 32, 0);
        spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(this, R.color.new_background_color)), 39, spannableString.length(), 0);
        spannableString.setSpan(new UnderlineSpan(), 21, 32, 0);
        spannableString.setSpan(new UnderlineSpan(), 39, spannableString.length(), 0);
        spannableString.setSpan(new StyleSpan(1), 21, 32, 0);
        spannableString.setSpan(new StyleSpan(1), 39, spannableString.length(), 0);
        this.p.setMovementMethod(LinkMovementMethod.getInstance());
        this.p.setText(spannableString, TextView.BufferType.SPANNABLE);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() != 2131362417) {
            if (view.getId() == 2131362176) {
                Affinity.launch(this, LiveChatActivity.class);
            }
        } else {
            String var = Var.toString(this.m.getText(), "");
            if (var.length() == 4) {
                y(var, 1);
            } else {
                Affinity.toast(this, "Kode OTP harus berjumlah 4 angka!");
            }
        }
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        int color = ResourcesCompat.getColor(getResources(), R.color.colorTransparent, (Resources.Theme) null);
        Toolbar toolbar = this.bb_toolbar;
        if (toolbar != null) {
            toolbar.setBackgroundColor(color);
            this.bb_toolbar.setNavigationIcon(R.drawable.ic_chevron_left_primary_24dp);
            Drawable navigationIcon = this.bb_toolbar.getNavigationIcon();
            Objects.requireNonNull(navigationIcon);
            navigationIcon.setColorFilter(getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.SRC_ATOP);
            this.bb_toolbar.setTitle("");
        }
        EventHelper.sendAllEvents(this, FirebaseHelper.EVENT_SCREEN_VIEW, getClass().getSimpleName().replace("Activity", ""));
        if (bundle != null) {
            this.d = bundle.getString("phone", "");
            this.e = bundle.getString(DataMessage.PIN, "");
            this.g = bundle.getString(TrainFormActivity.K_EMAIL, "");
            this.h = bundle.getString("upline", "");
            this.i = bundle.getString("name", "");
            this.k = bundle.getInt("state", 1);
            this.l = (Date) bundle.getSerializable("next_receive");
            this.f = bundle.getString("phoneCaller", "");
            this.j = bundle.getString("type", "");
        } else if (getIntent().getExtras() != null) {
            Bundle extras = getIntent().getExtras();
            this.d = extras.getString("phone", "");
            this.e = extras.getString(DataMessage.PIN, "");
            this.g = extras.getString(TrainFormActivity.K_EMAIL, "");
            this.h = extras.getString("upline", "");
            this.i = extras.getString("name", "");
            this.k = extras.getInt("state", 1);
            this.l = (Date) extras.getSerializable("next_receive");
            this.f = extras.getString("phoneCaller", "");
            this.j = extras.getString("type", "");
        }
        if (Var.toString(this.d, "").isEmpty()) {
            Affinity.info(this, -1, "Informasi", "Nomor HP tidak boleh kosong", new BBCallback() {
                @Override
                public final void do_callback(int i, Object obj) {
                    OTPCallActivity.this.D(i, (Boolean) obj);
                }
            });
        } else {
            this.n = (TextView) findViewById(R.id.label_countdown);
            this.p = (TextView) findViewById(R.id.otp_option);
            if (this.l == null) {
                this.n.setVisibility(8);
                this.p.setVisibility(0);
            }
            this.r = findViewById(R.id.input_otp_others);
            z(this.j.equalsIgnoreCase("call"));
            TextView textView = (TextView) findViewById(R.id.bonjour_cs_phone);
            textView.setText(Html.fromHtml(getString(R.string.bonjour_title_help)));
            textView.setOnClickListener(this);
            EditText editText = (EditText) findViewById(R.id.input_otp_call);
            this.m = editText;
            editText.requestFocus();
            this.m.setLetterSpacing(0.8f);
            findViewById(R.id.btn_send_otp).setOnClickListener(this);
        }
        initRetryButton(Var.toString(this.p.getText().toString(), ""), this.j);
        HashMap hashMap = new HashMap();
        hashMap.put("app_latitude", "0");
        hashMap.put("app_longitude", "0");
        hashMap.put("app_gps_state", "0");
        hashMap.put("app_uri", Var.toString(getApp_uri(), ""));
        hashMap.put("state", Var.toString(Integer.valueOf(this.k), ""));
        hashMap.put("upline", this.h);
        hashMap.put("name", this.i);
        hashMap.put("phonecaller", this.f);
        FirebaseHelper.sendEventBoard(this, this.d, this.g, getClass().getSimpleName().replace("Activity", "") + "Input", hashMap);
        BBFourDigitReceiver bBFourDigitReceiver = new BBFourDigitReceiver();
        this.s = bBFourDigitReceiver;
        bBFourDigitReceiver.setFourDigitReceiverListener(new a());
    }

    public void onInteractionListener() {
    }

    @Override
    @CallSuper
    public void onKeyboardVisibilityChanged(boolean z) {
        super.onKeyboardVisibilityChanged(z);
    }

    public void onOTPComplete(String str) {
        StringBuilder sb = new StringBuilder();
        sb.append("onOTPComplete: ");
        sb.append(str);
    }

    public void onPause() {
        super/*androidx.fragment.app.FragmentActivity*/.onPause();
        try {
            BBFourDigitReceiver bBFourDigitReceiver = this.s;
            if (bBFourDigitReceiver != null) {
                unregisterReceiver(bBFourDigitReceiver);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public void onResume() {
        super/*androidx.fragment.app.FragmentActivity*/.onResume();
        F();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.last_four_digit");
        if (Build.VERSION.SDK_INT >= 33) {
            registerReceiver(this.s, intentFilter, 2);
        } else {
            registerReceiver(this.s, intentFilter);
        }
        new Handler().postDelayed(new Runnable() {
            @Override
            public final void run() {
                OTPCallActivity.this.E();
            }
        }, 500L);
    }

    @Override
    @CallSuper
    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putString("phone", this.d);
        bundle.putString(DataMessage.PIN, this.e);
        bundle.putInt("state", this.k);
        bundle.putSerializable("next_receive", this.l);
    }

    public final void y(final String str, final int i) {
        if (str == null) {
            Affinity.info(this, false, "Silakan isi 4 digit OTP");
            return;
        }
        int i2 = this.k;
        if (i2 == 0 || i2 == 1 || i2 == 3) {
            AuthHelper.checkOTPCitCall(this, this.d, str, i2, new BBCallback() {
                @Override
                public final void do_callback(int i3, Object obj) {
                    OTPCallActivity.this.B(str, i, i3, (AuthHelper.OTPResponse) obj);
                }
            });
        } else {
            AuthHelper.doLogin(this, this.d, this.e, str, 2, new BBCallback() {
                @Override
                public final void do_callback(int i3, Object obj) {
                    OTPCallActivity.this.C(i3, (AuthHelper.LoginMessageNew) obj);
                }
            });
        }
    }

    public final void z(boolean z) {
        if (!z) {
            findViewById(R.id.input_otp_call_line).setVisibility(8);
            findViewById(R.id.info_otp_call_tv).setVisibility(8);
            findViewById(R.id.btn_send_otp).setVisibility(8);
            findViewById(R.id.input_otp_others_line).setVisibility(0);
            this.r.setOtpListener(this);
            return;
        }
        findViewById(R.id.input_otp_call_line).setVisibility(0);
        findViewById(R.id.info_otp_call_tv).setVisibility(0);
        findViewById(R.id.btn_send_otp).setVisibility(0);
        findViewById(R.id.input_otp_others_line).setVisibility(8);
        this.o = (TextView) findViewById(R.id.phone_otp_label);
        if (!this.f.isEmpty()) {
            this.o.setText(this.f);
        } else {
            this.n.setVisibility(8);
            this.p.setVisibility(0);
        }
    }

    public static Bundle getBundle(AuthActivity authActivity, String str, String str2, Date date, String str3) {
        Bundle bundle = getBundle(authActivity, str, 2, date, str3);
        bundle.putString(DataMessage.PIN, str2);
        return bundle;
    }

    public static Bundle getBundle(AuthActivity authActivity, String str, String str2, String str3, String str4, String str5, Date date, String str6, String str7) {
        Bundle bundle = getBundle(authActivity, str, 1, date, str6);
        bundle.putString(DataMessage.PIN, str2);
        bundle.putString(TrainFormActivity.K_EMAIL, str3);
        bundle.putString("upline", str4);
        bundle.putString("name", str5);
        bundle.putString("type", str7);
        return bundle;
    }
}