正在查看: EFFICIENT POS v1.5.7 应用的 OtpActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: EFFICIENT POS v1.5.7 应用的 OtpActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package dev.gtr.pos.activity;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.android.material.textfield.TextInputEditText;
import dev.gtr.pos.R;
import dev.gtr.pos.api.ApiClient;
import dev.gtr.pos.config.EdittextOtp;
import es.dmoral.toasty.Toasty;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class OtpActivity extends AppCompatActivity implements View.OnKeyListener, View.OnClickListener, TextWatcher {
Button btnOtp;
Button buttonUpdate;
ConstraintLayout constraintLayoutOtp;
ConstraintLayout constraintLayoutPass;
EditText editTextFour;
EditText editTextOne;
EditText editTextThree;
EditText editTextTwo;
String email;
ImageView imageViewBack;
String phone;
StringBuilder stringBuilderOtp = new StringBuilder();
String tempOtp;
TextInputEditText textInputEditTextConPass;
TextInputEditText textInputEditTextPass;
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_otp);
this.btnOtp = (Button) findViewById(R.id.button_login_otp);
this.editTextOne = (EditText) findViewById(R.id.editText_otp_one);
this.editTextTwo = (EditText) findViewById(R.id.editText_otp_two);
this.editTextThree = (EditText) findViewById(R.id.editText_otp_three);
this.editTextFour = (EditText) findViewById(R.id.editText_otp_four);
this.buttonUpdate = (Button) findViewById(R.id.button_update);
this.textInputEditTextConPass = (TextInputEditText) findViewById(R.id.textInputEditText_conpass);
this.textInputEditTextPass = (TextInputEditText) findViewById(R.id.textInputEditText_pass);
this.constraintLayoutOtp = findViewById(R.id.constraintLayout_otp);
this.constraintLayoutPass = findViewById(R.id.constraintLayout_password);
this.editTextOne.addTextChangedListener(new EdittextOtp(this.editTextOne, this.editTextTwo));
this.editTextTwo.addTextChangedListener(new EdittextOtp(this.editTextTwo, this.editTextThree));
this.editTextThree.addTextChangedListener(new EdittextOtp(this.editTextThree, this.editTextFour));
this.editTextOne.setOnKeyListener(this);
this.editTextTwo.setOnKeyListener(this);
this.editTextThree.setOnKeyListener(this);
this.editTextFour.setOnKeyListener(this);
this.btnOtp.setOnClickListener(this);
this.buttonUpdate.setOnClickListener(this);
this.editTextFour.addTextChangedListener(this);
Intent intent = getIntent();
this.tempOtp = intent.getStringExtra("Otp");
this.email = intent.getStringExtra("email");
this.phone = intent.getStringExtra("phone");
}
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if (view.getId() == this.editTextFour.getId()) {
if (i != 67 || keyEvent.getAction() != 0) {
return false;
}
this.editTextFour.setText("");
this.editTextThree.requestFocus();
return true;
}
if (view.getId() == this.editTextThree.getId()) {
if (i != 67 || keyEvent.getAction() != 0) {
return false;
}
this.editTextThree.setText("");
this.editTextTwo.requestFocus();
return true;
}
if (view.getId() != this.editTextTwo.getId() || i != 67 || keyEvent.getAction() != 0) {
return false;
}
this.editTextTwo.setText("");
this.editTextOne.requestFocus();
return true;
}
public boolean isOnline() {
try {
NetworkInfo activeNetworkInfo = ((ConnectivityManager) getApplicationContext().getSystemService("connectivity")).getActiveNetworkInfo();
if (activeNetworkInfo.equals(null)) {
return false;
}
return activeNetworkInfo.isConnected();
} catch (Exception unused) {
Toasty.error(getApplicationContext(), "Check your network connectivity", 0).show();
return false;
}
}
@Override
public void afterTextChanged(Editable editable) {
if (this.editTextOne.getText().toString().isEmpty() || this.editTextTwo.getText().toString().isEmpty() || this.editTextThree.getText().toString().isEmpty() || this.editTextFour.getText().toString().isEmpty()) {
return;
}
StringBuilder sb = this.stringBuilderOtp;
sb.delete(0, sb.length());
this.stringBuilderOtp.append(this.editTextOne.getText().toString());
this.stringBuilderOtp.append(this.editTextTwo.getText().toString());
this.stringBuilderOtp.append(this.editTextThree.getText().toString());
this.stringBuilderOtp.append(this.editTextFour.getText().toString());
if (this.stringBuilderOtp.toString().isEmpty() || this.stringBuilderOtp.length() != 4) {
return;
}
if (this.stringBuilderOtp.toString().equals(this.tempOtp)) {
this.constraintLayoutOtp.setVisibility(8);
this.constraintLayoutPass.setVisibility(0);
Toasty.success(getApplicationContext(), "Verified", 0).show();
return;
}
Toasty.error(getApplicationContext(), "Not Matched", 0).show();
}
private void updatePass() {
ApiClient.getInstance(getApplicationContext()).getApi().passReset(this.email, this.phone, this.tempOtp, this.textInputEditTextConPass.getText().toString()).enqueue(new Callback<String>() {
@Override
public void onFailure(Call<String> call, Throwable th) {
}
@Override
public void onResponse(Call<String> call, Response<String> response) {
if (response.isSuccessful()) {
if (response.body().toString().equals("true")) {
Toasty.success(OtpActivity.this.getApplicationContext(), "Password Reset Successfully", 0).show();
OtpActivity.this.setResult(-1);
OtpActivity.this.finish();
return;
}
Toasty.error(OtpActivity.this.getApplicationContext(), "Password can't update", 0).show();
}
}
});
}
@Override
public void onClick(View view) {
if (view == this.btnOtp && this.stringBuilderOtp.length() == 4) {
if (this.stringBuilderOtp.toString().equals(this.tempOtp)) {
Toast.makeText(getApplicationContext(), "" + this.stringBuilderOtp.length(), 0).show();
this.constraintLayoutOtp.setVisibility(8);
this.constraintLayoutPass.setVisibility(0);
Toasty.success(getApplicationContext(), "Verified", 0).show();
} else {
Toasty.error(getApplicationContext(), "Not Matched", 0).show();
}
}
if (view != this.buttonUpdate || this.textInputEditTextPass.getText().toString().isEmpty() || this.textInputEditTextConPass.getText().toString().isEmpty()) {
return;
}
if (this.textInputEditTextConPass.getText().toString().equals(this.textInputEditTextPass.getText().toString())) {
updatePass();
} else {
Toasty.error(getApplicationContext(), "Password not matched", 0).show();
}
}
}