正在查看: Clash Legends v0.0.1 应用的 MainActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 MainActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clash.legends.ui.activities;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.core.app.ActivityCompat;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.VolleyLog;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.clash.legends.models.CurrentUser;
import com.clash.legends.ui.activities.MainActivity;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.textfield.TextInputLayout;
import com.google.firebase.FirebaseException;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.auth.PhoneAuthCredential;
import com.google.firebase.auth.PhoneAuthOptions;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.firebase.messaging.FirebaseMessaging;
import com.mukesh.OnOtpCompletionListener;
import com.mukesh.OtpView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends AppCompatActivity {
static final boolean $assertionsDisabled = false;
Dialog builder;
Context context;
TextView createNewAccount;
Button google;
CardView googlecv;
LoadingDialog loadingDialog;
TextView logintitle;
private FirebaseAuth mAuth;
PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallback;
private GoogleSignInClient mGoogleSignInClient;
RequestQueue mQueue;
TextView mobileview;
OtpView otpView;
EditText passwordtext;
TextView resend;
TextView resetPassword;
Resources resources;
Button signinMain;
List<String> spinnerArrayCountryCode;
List<String> spinnerArrayCountryId;
List<String> spinnerArrayCountryName;
UserLocalStore userLocalStore;
EditText usernametext;
Boolean doubleBackToExitPressedOnce = false;
String firstname = "";
String lastname = "";
int RC_SIGN_IN = 23;
String selectedCode = "";
String selectedMobile = "";
String selectedMemberid = "";
String selectedUsername = "";
String selectedId = "";
String selectedEmail = "";
String selectedApitoken = "";
String selectedCountryId = "";
String selectedPromo = "";
String selectedFirstname = "";
String selectedLastname = "";
String fireabasetoken = "";
String playerId = "";
final int PERMISSION_REQUEST_CODE = 112;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(2131558457);
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener() {
public final void onComplete(Task task) {
MainActivity.this.m92lambda$onCreate$0$comclashlegendsuiactivitiesMainActivity(task);
}
});
FirebaseMessaging.getInstance().subscribeToTopic("all").addOnCompleteListener(new OnCompleteListener<Void>() {
public void onComplete(Task<Void> task) {
if (!task.isSuccessful()) {
}
}
});
if (Build.VERSION.SDK_INT > 32 && !shouldShowRequestPermissionRationale("112")) {
getNotificationPermission();
}
SharedPreferences sppi = getSharedPreferences("PLAYER_ID", 0);
SharedPreferences.Editor editorpi = sppi.edit();
try {
editorpi.putString("player_id", this.fireabasetoken);
editorpi.apply();
this.playerId = this.fireabasetoken;
while (TextUtils.equals(this.fireabasetoken, "null")) {
this.playerId = this.fireabasetoken;
}
} catch (Exception e) {
}
Context locale = LocaleHelper.setLocale(this);
this.context = locale;
this.resources = locale.getResources();
this.usernametext = (EditText) findViewById(2131363727);
this.passwordtext = (EditText) findViewById(2131362986);
this.usernametext.setHint(this.resources.getString(2131887059));
this.passwordtext.setHint(this.resources.getString(2131886665));
this.logintitle = (TextView) findViewById(2131362639);
this.spinnerArrayCountryCode = new ArrayList();
this.spinnerArrayCountryName = new ArrayList();
this.spinnerArrayCountryId = new ArrayList();
Dialog dialog = new Dialog(this);
this.builder = dialog;
dialog.setContentView(2131558689);
this.mobileview = (TextView) this.builder.findViewById(2131362732);
this.otpView = this.builder.findViewById(2131362962);
this.resend = (TextView) this.builder.findViewById(2131363162);
viewallcountry();
SharedPreferences.Editor editor = getSharedPreferences("first_time", 0).edit();
editor.putBoolean("f_t", false);
editor.apply();
this.googlecv = findViewById(2131362399);
SharedPreferences sp = getSharedPreferences("SMINFO", 0);
if (TextUtils.equals(sp.getString("google", "no"), "no")) {
this.googlecv.setVisibility(8);
} else {
this.googlecv.setVisibility(0);
}
this.loadingDialog = new LoadingDialog(this);
RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
this.mQueue = newRequestQueue;
newRequestQueue.getCache().clear();
this.userLocalStore = new UserLocalStore(this);
this.createNewAccount = (TextView) findViewById(2131362195);
this.signinMain = (Button) findViewById(2131363345);
this.resetPassword = (TextView) findViewById(2131363167);
this.mAuth = FirebaseAuth.getInstance();
this.google = (Button) findViewById(2131362400);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken(getString(2131886411)).requestEmail().build();
this.mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
this.google.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MainActivity.this.m93lambda$onCreate$1$comclashlegendsuiactivitiesMainActivity(view);
}
});
new SpannableString(this.resources.getString(2131886458));
new ClickableSpan() {
@Override
public void onClick(View textView) {
}
@Override
public void updateDrawState(TextPaint ds) {
}
};
this.resetPassword.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MainActivity.this.m94lambda$onCreate$2$comclashlegendsuiactivitiesMainActivity(view);
}
});
this.createNewAccount.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MainActivity.this.m95lambda$onCreate$3$comclashlegendsuiactivitiesMainActivity(view);
}
});
this.signinMain.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MainActivity.this.m96lambda$onCreate$4$comclashlegendsuiactivitiesMainActivity(view);
}
});
this.mCallback = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
MainActivity.this.loadingDialog.dismiss();
MainActivity mainActivity = MainActivity.this;
mainActivity.updateMobile(mainActivity.selectedMemberid, MainActivity.this.selectedUsername, MainActivity.this.selectedId, MainActivity.this.selectedEmail, MainActivity.this.selectedApitoken, MainActivity.this.selectedCode, MainActivity.this.selectedMobile, MainActivity.this.selectedCountryId, MainActivity.this.selectedPromo, MainActivity.this.selectedFirstname, MainActivity.this.selectedLastname);
}
public void onVerificationFailed(FirebaseException e2) {
e2.printStackTrace();
Log.d("failed", e2.getMessage());
MainActivity.this.loadingDialog.dismiss();
Toast.makeText((Context) MainActivity.this, (CharSequence) "Something went wrong, Please try again", 0).show();
}
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
MainActivity.this.loadingDialog.dismiss();
Log.d("codesent", s);
Toast.makeText(MainActivity.this.getApplicationContext(), MainActivity.this.resources.getString(2131886663), 0).show();
MainActivity.this.openotpdialog(s);
}
};
}
void m92lambda$onCreate$0$comclashlegendsuiactivitiesMainActivity(Task task) {
if (!task.isSuccessful()) {
Log.d("FIREBASE TOKEN EXCEPTION", "ERROR");
} else {
Log.d("FIREBASE TOKEN", "LENGTH" + ((String) task.getResult()).length() + " : " + ((String) task.getResult()));
this.fireabasetoken = (String) task.getResult();
}
}
void m93lambda$onCreate$1$comclashlegendsuiactivitiesMainActivity(View v) {
Intent signInIntent = this.mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, this.RC_SIGN_IN);
}
void m94lambda$onCreate$2$comclashlegendsuiactivitiesMainActivity(View view) {
resetPassword();
}
void m95lambda$onCreate$3$comclashlegendsuiactivitiesMainActivity(View view) {
startActivity(new Intent(getApplicationContext(), (Class<?>) CreateNewAccount.class));
}
void m96lambda$onCreate$4$comclashlegendsuiactivitiesMainActivity(View view) {
String username = this.usernametext.getText().toString();
String password = this.passwordtext.getText().toString();
if (TextUtils.isEmpty(this.usernametext.getText().toString())) {
Toast.makeText(this.context, this.resources.getString(2131887060), 0).show();
} else if (TextUtils.isEmpty(password)) {
Toast.makeText(this.context, this.resources.getString(2131886668), 0).show();
} else {
loginUser(username, password, "login");
}
}
public void getNotificationPermission() {
try {
if (Build.VERSION.SDK_INT > 32) {
ActivityCompat.requestPermissions(this, new String[]{"android.permission.POST_NOTIFICATIONS"}, 112);
}
} catch (Exception e) {
}
}
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case 112:
if (grantResults.length > 0) {
int i = grantResults[0];
break;
}
break;
}
}
public void resetPassword() {
final Dialog builder = new Dialog(this);
builder.setContentView(2131558768);
EditText fpemail = (EditText) builder.findViewById(2131362366);
Button fpsendemail = (Button) builder.findViewById(2131362367);
Button fpcancel = (Button) builder.findViewById(2131362365);
fpsendemail.setOnClickListener(new AnonymousClass4(fpemail, builder));
fpcancel.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
builder.dismiss();
}
});
builder.show();
}
class AnonymousClass4 implements View.OnClickListener {
final Dialog val$builder;
final EditText val$fpemail;
AnonymousClass4(EditText editText, Dialog dialog) {
this.val$fpemail = editText;
this.val$builder = dialog;
}
@Override
public void onClick(View view) {
if (TextUtils.isEmpty(this.val$fpemail.getText().toString())) {
this.val$fpemail.setError("Enter Email or Mobile No.");
return;
}
MainActivity.this.loadingDialog.show();
this.val$builder.dismiss();
MainActivity mainActivity = MainActivity.this;
mainActivity.mQueue = Volley.newRequestQueue(mainActivity.getApplicationContext());
String url = MainActivity.this.resources.getString(2131886167) + "sendOTP";
HashMap<String, String> params = new HashMap<>();
params.put("email_mobile", this.val$fpemail.getText().toString().trim());
JSONObject jSONObject = new JSONObject(params);
final EditText editText = this.val$fpemail;
JsonObjectRequest request = new JsonObjectRequest(url, jSONObject, new Response.Listener() {
public final void onResponse(Object obj) {
MainActivity.AnonymousClass4.this.m104lambda$onClick$0$comclashlegendsuiactivitiesMainActivity$4(editText, (JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
Log.e("**VolleyError", "error" + volleyError.getMessage());
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
CurrentUser user = MainActivity.this.userLocalStore.getLoggedInUser();
String credentials = user.getUsername() + ":" + user.getPassword();
String str = "Basic " + Base64.encodeToString(credentials.getBytes(), 2);
String token = "Bearer " + user.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
headers.put("x-localization", LocaleHelper.getPersist(MainActivity.this.context));
return headers;
}
};
MainActivity.this.mQueue.add(request);
}
void m104lambda$onClick$0$comclashlegendsuiactivitiesMainActivity$4(EditText fpemail, JSONObject response) {
MainActivity.this.loadingDialog.dismiss();
Log.d("fpresponse", response.toString());
try {
Toast.makeText(MainActivity.this.getApplicationContext(), response.getString("message"), 0).show();
if (TextUtils.equals(response.getString("status"), "true")) {
Intent intent = new Intent((Context) MainActivity.this, (Class<?>) FpOtpVerificationActivity.class);
intent.putExtra("EP", fpemail.getText().toString().trim());
intent.putExtra("MID", response.getString("member_id"));
intent.putExtra("OTP", response.getString("otp"));
MainActivity.this.startActivity(intent);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
public void loginUser(final String user_name, final String password, String submit) {
this.loadingDialog.show();
String URL = this.resources.getString(2131886167) + "login";
HashMap<String, String> params = new HashMap<>();
params.put("user_name", user_name);
params.put("password", password);
params.put("player_id", this.fireabasetoken);
params.put("submit", submit);
Log.d(URL, new JSONObject(params).toString());
JsonObjectRequest request_json = new JsonObjectRequest(URL, new JSONObject(params), new Response.Listener() {
public final void onResponse(Object obj) {
MainActivity.this.m90lambda$loginUser$6$comclashlegendsuiactivitiesMainActivity(user_name, password, (JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
VolleyLog.e("Error: ", new Object[]{volleyError.getMessage()});
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
headers.put("x-localization", LocaleHelper.getPersist(MainActivity.this.context));
return headers;
}
};
request_json.setShouldCache(false);
this.mQueue.add(request_json);
}
void m90lambda$loginUser$6$comclashlegendsuiactivitiesMainActivity(String user_name, String password, JSONObject response) {
SharedPreferences.Editor editor;
Log.d("login response", response.toString());
try {
String status = response.getString("status");
String message = response.getString("message");
JSONObject msgobj = response.getJSONObject("message");
String token = msgobj.getString("api_token");
if (!TextUtils.equals(status, "true")) {
this.loadingDialog.dismiss();
return;
}
JSONObject obj = new JSONObject(message);
String member_id = obj.getString("member_id");
String email = obj.getString("email_id");
String phone = obj.getString("mobile_no");
String firstname = obj.getString("first_name");
String lastName = obj.getString("last_name");
CurrentUser cUser = new CurrentUser(member_id, user_name, password, email, phone, token, firstname, lastName);
UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
userLocalStore.storeUserData(cUser);
SharedPreferences sppi = getSharedPreferences("PLAYER_ID", 0);
SharedPreferences.Editor editor2 = sppi.edit();
try {
editor = editor2;
try {
editor.putString("player_id", this.fireabasetoken);
editor.apply();
} catch (Exception e) {
}
} catch (Exception e2) {
editor = editor2;
}
this.loadingDialog.dismiss();
Toast.makeText((Context) this, (CharSequence) this.resources.getString(2131886517), 0).show();
startActivity(new Intent(getApplicationContext(), (Class<?>) HomeActivity.class));
} catch (JSONException e3) {
this.loadingDialog.dismiss();
try {
String message2 = response.getString("message");
Toast.makeText((Context) this, (CharSequence) message2, 0).show();
} catch (JSONException ex) {
ex.printStackTrace();
}
e3.printStackTrace();
}
}
public void onBackPressed() {
if (this.doubleBackToExitPressedOnce.booleanValue()) {
finishAffinity();
super.onBackPressed();
} else {
this.doubleBackToExitPressedOnce = true;
Toast.makeText((Context) this, (CharSequence) this.resources.getString(2131886919), 0).show();
new Handler().postDelayed(new Runnable() {
@Override
public final void run() {
MainActivity.this.m91x72a79973();
}
}, 1500L);
}
}
void m91x72a79973() {
this.doubleBackToExitPressedOnce = false;
}
protected void onActivityResult(int requestCode, int responseCode, Intent data) {
super.onActivityResult(requestCode, responseCode, data);
this.loadingDialog.show();
if (requestCode == this.RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {
GoogleSignInAccount account = (GoogleSignInAccount) task.getResult(ApiException.class);
firebaseAuthWithGoogle(account.getIdToken());
return;
} catch (ApiException e) {
this.loadingDialog.dismiss();
Log.w("google failed", "Google sign in failed", e);
return;
}
}
this.loadingDialog.dismiss();
}
private void firebaseAuthWithGoogle(String idToken) {
AuthCredential credential = GoogleAuthProvider.getCredential(idToken, (String) null);
this.mAuth.signInWithCredential(credential).addOnCompleteListener(this, new OnCompleteListener() {
public final void onComplete(Task task) {
MainActivity.this.m89xde70a386(task);
}
});
}
void m89xde70a386(Task task) {
String p_;
if (task.isSuccessful()) {
Log.d("google succesws", "signInWithCredential:success");
FirebaseUser user = this.mAuth.getCurrentUser();
if (user == null) {
throw new AssertionError();
}
Log.d("google name", user.getDisplayName());
Log.d("google email", user.getEmail());
Log.d("google uuid", user.getUid());
String[] name = ((String) Objects.requireNonNull(user.getDisplayName())).split("\\s+");
Log.d("google firstname", name[0]);
try {
p_ = user.getPhoneNumber();
Log.d("google phone number", user.getPhoneNumber());
} catch (Exception e) {
p_ = "";
}
if (TextUtils.equals(p_, null)) {
p_ = "";
}
if (name.length == 1) {
RegisterGoogle(name[0], "", user.getDisplayName(), user.getEmail(), p_, user.getUid(), "google_login");
} else {
RegisterGoogle(name[0], name[1], user.getDisplayName(), user.getEmail(), p_, user.getUid(), "google_login");
}
SharedPreferences sppi = getSharedPreferences("PLAYER_ID", 0);
SharedPreferences.Editor editor = sppi.edit();
try {
editor.putString("player_id", this.fireabasetoken);
editor.apply();
return;
} catch (Exception e2) {
return;
}
}
Log.w("google err final", "signInWithCredential:failure", task.getException());
SharedPreferences sppi2 = getSharedPreferences("PLAYER_ID", 0);
SharedPreferences.Editor editor2 = sppi2.edit();
try {
editor2.putString("player_id", this.fireabasetoken);
editor2.apply();
} catch (Exception e3) {
}
}
public void RegisterGoogle(final String first_name, final String last_name, String user_name, final String email, String phone, final String gid, String submit) {
this.loadingDialog.show();
String URL = this.resources.getString(2131886167) + "registerGoogle";
HashMap<String, String> params = new HashMap<>();
params.put("first_name", first_name);
params.put("last_name", last_name);
params.put("user_name", first_name);
params.put("player_id", this.fireabasetoken);
params.put("email_id", email);
params.put("mobile_no", phone);
params.put("g_id", gid);
params.put("submit", submit);
Log.d(URL, new JSONObject(params).toString());
JsonObjectRequest request_json = new JsonObjectRequest(URL, new JSONObject(params), new Response.Listener() {
public final void onResponse(Object obj) {
MainActivity.this.m88xe4c8061c(gid, email, first_name, last_name, (JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
VolleyLog.e("Error: ", new Object[]{volleyError.getMessage()});
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
headers.put("x-localization", LocaleHelper.getPersist(MainActivity.this.context));
return headers;
}
};
request_json.setShouldCache(false);
this.mQueue.add(request_json);
}
void m88xe4c8061c(String gid, String email, String first_name, String last_name, JSONObject response) {
Log.d("google response", response.toString());
try {
String status = response.getString("status");
String message = response.getString("message");
if (TextUtils.equals(status, "true")) {
if (TextUtils.equals(response.getJSONObject("message").getString("mobile_no"), "")) {
this.loadingDialog.dismiss();
String member_id = response.getJSONObject("message").getString("member_id");
openMobileDialog(member_id, response.getJSONObject("message").getString("user_name"), gid, response.getJSONObject("message").getString("email_id"), response.getJSONObject("message").getString("api_token"), response.getJSONObject("message").getString("new_user"));
} else {
String member_id2 = response.getJSONObject("message").getString("member_id");
CurrentUser cUser = new CurrentUser(member_id2, response.getJSONObject("message").getString("user_name"), gid, email, response.getJSONObject("message").getString("mobile_no"), response.getJSONObject("message").getString("api_token"), first_name, last_name);
UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
userLocalStore.storeUserData(cUser);
this.loadingDialog.dismiss();
Toast.makeText((Context) this, (CharSequence) this.resources.getString(2131886517), 0).show();
startActivity(new Intent(getApplicationContext(), (Class<?>) HomeActivity.class));
}
} else {
Toast.makeText((Context) this, (CharSequence) message, 0).show();
this.loadingDialog.dismiss();
}
} catch (JSONException e) {
this.loadingDialog.dismiss();
e.printStackTrace();
}
}
public void openMobileDialog(String memberid, String username, String id, String email, String apitoken, String newuser) {
Dialog builder = new Dialog(this);
builder.setContentView(2131558591);
final TextView countrycode = (TextView) builder.findViewById(2131362190);
TextView mobilenumber = (TextView) builder.findViewById(2131362284);
TextView promocode = (TextView) builder.findViewById(2131362349);
TextInputLayout promocodetil = builder.findViewById(2131362350);
Button submit = (Button) builder.findViewById(2131362285);
if (TextUtils.equals(newuser, "Yes")) {
promocodetil.setVisibility(0);
} else {
promocodetil.setVisibility(8);
}
countrycode.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MainActivity.this.m98xb2e35670(countrycode, view);
}
});
submit.setOnClickListener(new AnonymousClass7(mobilenumber, builder, memberid, username, id, email, apitoken, promocode));
builder.create();
try {
builder.show();
} catch (Exception e) {
}
}
void m98xb2e35670(final TextView countrycode, View v) {
final Dialog builder1 = new Dialog(this);
builder1.getWindow().setBackgroundDrawable(new ColorDrawable(0));
builder1.setCancelable(false);
WindowManager.LayoutParams wlmp = builder1.getWindow().getAttributes();
builder1.getWindow().setAttributes(wlmp);
builder1.setContentView(2131558785);
ImageView cancel = (ImageView) builder1.findViewById(2131363369);
LinearLayout ll = (LinearLayout) builder1.findViewById(2131363371);
for (int i = 0; i < this.spinnerArrayCountryCode.size(); i++) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(-1, -2);
View view = getLayoutInflater().inflate(2131558784, (ViewGroup) null);
view.setLayoutParams(lparams);
TextView tv = (TextView) view.findViewById(2131363558);
tv.setText(this.spinnerArrayCountryCode.get(i) + " (" + this.spinnerArrayCountryName.get(i) + ")");
final int finalI = i;
tv.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
MainActivity.this.m97x3ff43b32(countrycode, finalI, builder1, view2);
}
});
ll.addView(view);
}
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
builder1.dismiss();
}
});
builder1.create();
builder1.show();
}
void m97x3ff43b32(TextView countrycode, int finalI, Dialog builder1, View v12) {
countrycode.setText(this.spinnerArrayCountryCode.get(finalI));
this.selectedCode = this.spinnerArrayCountryCode.get(finalI);
this.selectedCountryId = this.spinnerArrayCountryId.get(finalI);
builder1.dismiss();
}
class AnonymousClass7 implements View.OnClickListener {
final String val$apitoken;
final Dialog val$builder;
final String val$email;
final String val$id;
final String val$memberid;
final TextView val$mobilenumber;
final TextView val$promocode;
final String val$username;
AnonymousClass7(TextView textView, Dialog dialog, String str, String str2, String str3, String str4, String str5, TextView textView2) {
this.val$mobilenumber = textView;
this.val$builder = dialog;
this.val$memberid = str;
this.val$username = str2;
this.val$id = str3;
this.val$email = str4;
this.val$apitoken = str5;
this.val$promocode = textView2;
}
@Override
public void onClick(View v) {
if (TextUtils.equals(MainActivity.this.selectedCode.trim(), "")) {
Toast.makeText(MainActivity.this.getApplicationContext(), MainActivity.this.resources.getString(2131886912), 0).show();
return;
}
if (TextUtils.isEmpty(this.val$mobilenumber.getText().toString().trim())) {
this.val$mobilenumber.setError(MainActivity.this.resources.getString(2131886568));
return;
}
if (this.val$mobilenumber.getText().toString().trim().length() < 7 || this.val$mobilenumber.getText().toString().trim().length() > 15) {
this.val$mobilenumber.setError(MainActivity.this.resources.getString(2131887095));
return;
}
MainActivity.this.loadingDialog.show();
SharedPreferences sp = MainActivity.this.getSharedPreferences("SMINFO", 0);
if (TextUtils.equals(sp.getString("otp", "no"), "no")) {
this.val$builder.dismiss();
MainActivity mainActivity = MainActivity.this;
mainActivity.updateMobile(this.val$memberid, this.val$username, this.val$id, this.val$email, this.val$apitoken, mainActivity.selectedCode, this.val$mobilenumber.getText().toString().trim(), MainActivity.this.selectedCountryId, MainActivity.this.selectedPromo, MainActivity.this.firstname, MainActivity.this.lastname);
return;
}
MainActivity.this.selectedMobile = this.val$mobilenumber.getText().toString().trim();
MainActivity.this.selectedPromo = this.val$promocode.getText().toString().trim();
MainActivity.this.selectedMemberid = this.val$memberid;
MainActivity.this.selectedUsername = this.val$username;
MainActivity.this.selectedId = this.val$id;
MainActivity.this.selectedEmail = this.val$email;
MainActivity.this.selectedApitoken = this.val$apitoken;
MainActivity mainActivity2 = MainActivity.this;
mainActivity2.mQueue = Volley.newRequestQueue(mainActivity2.getApplicationContext());
MainActivity.this.mQueue.getCache().clear();
String URL = MainActivity.this.resources.getString(2131886167) + "checkMobileNumber";
HashMap<String, String> params = new HashMap<>();
params.put("mobile_no", MainActivity.this.selectedMobile);
params.put("promo_code", MainActivity.this.selectedPromo);
Log.d(URL, new JSONObject(params).toString());
JSONObject jSONObject = new JSONObject(params);
final Dialog dialog = this.val$builder;
JsonObjectRequest request_json = new JsonObjectRequest(1, URL, jSONObject, new Response.Listener() {
public final void onResponse(Object obj) {
MainActivity.AnonymousClass7.this.m105lambda$onClick$0$comclashlegendsuiactivitiesMainActivity$7(dialog, (JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
MainActivity.AnonymousClass7.lambda$onClick$1(volleyError);
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
headers.put("x-localization", LocaleHelper.getPersist(MainActivity.this.context));
return headers;
}
};
request_json.setShouldCache(false);
MainActivity.this.mQueue.add(request_json);
}
void m105lambda$onClick$0$comclashlegendsuiactivitiesMainActivity$7(Dialog builder, JSONObject response) {
Log.d("send otp", response.toString());
try {
String status = response.getString("status");
if (TextUtils.equals(status, "true")) {
builder.dismiss();
PhoneAuthOptions options = PhoneAuthOptions.newBuilder(MainActivity.this.mAuth).setPhoneNumber(MainActivity.this.selectedCode + MainActivity.this.selectedMobile).setTimeout(60L, TimeUnit.SECONDS).setActivity(MainActivity.this).setCallbacks(MainActivity.this.mCallback).build();
PhoneAuthProvider.verifyPhoneNumber(options);
} else {
MainActivity.this.loadingDialog.dismiss();
Toast.makeText(MainActivity.this.getApplicationContext(), response.getString("message"), 0).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
static void lambda$onClick$1(VolleyError error) {
VolleyLog.e("Error: ", new Object[]{error.getMessage()});
NetworkResponse response = error.networkResponse;
if (response != null && response.data != null) {
String errorString = new String(response.data);
Log.d("erorostring ", errorString);
}
}
}
public void viewallcountry() {
RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
this.mQueue = newRequestQueue;
newRequestQueue.getCache().clear();
String url = this.resources.getString(2131886167) + "all_country";
new UserLocalStore(getApplicationContext());
JsonObjectRequest request = new JsonObjectRequest(0, url, null, new Response.Listener() {
public final void onResponse(Object obj) {
MainActivity.this.m103xf082be95((JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
Log.e("**VolleyError", "error" + volleyError.getMessage());
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
headers.put("x-localization", LocaleHelper.getPersist(MainActivity.this.context));
return headers;
}
};
request.setShouldCache(false);
this.mQueue.add(request);
}
void m103xf082be95(JSONObject response) {
try {
JSONArray arr = response.getJSONArray("all_country");
TextUtils.equals(response.getString("all_country"), "[]");
JSON_PARSE_DATA_AFTER_WEBCALL(arr);
} catch (JSONException e) {
e.printStackTrace();
}
this.loadingDialog.dismiss();
}
public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array) {
for (int i = 0; i < array.length(); i++) {
try {
JSONObject json = array.getJSONObject(i);
this.spinnerArrayCountryCode.add(json.getString("p_code"));
this.spinnerArrayCountryName.add(json.getString("country_name"));
this.spinnerArrayCountryId.add(json.getString("country_id"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
public void updateMobile(final String memberid, final String username, final String id, final String email, final String apitoken, String code, final String mobile, String countryId, String promo, final String firstname, final String lastname) {
this.loadingDialog.show();
String URL = this.resources.getString(2131886167) + "update_mobile_no";
HashMap<String, String> params = new HashMap<>();
params.put("member_id", memberid);
params.put("mobile_no", mobile);
params.put("country_code", code);
params.put("country_id", countryId);
params.put("promo_code", promo);
Log.d(URL, new JSONObject(params).toString());
JsonObjectRequest request_json = new JsonObjectRequest(URL, new JSONObject(params), new Response.Listener() {
public final void onResponse(Object obj) {
MainActivity.this.m102x98bd62a4(memberid, username, id, email, mobile, apitoken, firstname, lastname, (JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
VolleyLog.e("Error: ", new Object[]{volleyError.getMessage()});
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
headers.put("x-localization", LocaleHelper.getPersist(MainActivity.this.context));
return headers;
}
};
request_json.setShouldCache(false);
this.mQueue.add(request_json);
}
void m102x98bd62a4(String memberid, String username, String id, String email, String mobile, String apitoken, String firstname, String lastname, JSONObject response) {
try {
String status = response.getString("status");
if (TextUtils.equals(status, "true")) {
CurrentUser cUser = new CurrentUser(memberid, username, id, email, mobile, apitoken, firstname, lastname);
this.loadingDialog.dismiss();
UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
userLocalStore.storeUserData(cUser);
Toast.makeText((Context) this, (CharSequence) this.resources.getString(2131886517), 0).show();
startActivity(new Intent(getApplicationContext(), (Class<?>) HomeActivity.class));
} else {
String message = response.getString("message");
Toast.makeText((Context) this, (CharSequence) message, 0).show();
this.loadingDialog.dismiss();
}
} catch (JSONException e) {
this.loadingDialog.dismiss();
e.printStackTrace();
}
}
public void openotpdialog(final String fotp) {
new CountDownTimer(60000L, 1000L) {
@Override
public void onTick(long millisUntilFinished) {
MainActivity.this.resend.setText(String.valueOf(millisUntilFinished / 1000));
}
@Override
public void onFinish() {
MainActivity.this.resend.setText(MainActivity.this.resources.getString(2131886954));
MainActivity.this.resend.setClickable(true);
MainActivity.this.resend.setEnabled(true);
}
}.start();
this.mobileview.setText(this.resources.getString(2131887076) + this.selectedCode + this.selectedMobile);
this.resend.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MainActivity.this.m99xa5752c66(view);
}
});
this.otpView.setShowSoftInputOnFocus(true);
this.otpView.setOtpCompletionListener(new OnOtpCompletionListener() {
public final void onOtpCompleted(String str) {
MainActivity.this.m100x95bb5810(fotp, str);
}
});
this.builder.create();
this.builder.show();
}
void m99xa5752c66(View view) {
this.builder.dismiss();
this.loadingDialog.show();
PhoneAuthOptions options = PhoneAuthOptions.newBuilder(this.mAuth).setPhoneNumber(this.selectedCode + this.selectedMobile).setTimeout(60L, TimeUnit.SECONDS).setActivity(this).setCallbacks(this.mCallback).build();
PhoneAuthProvider.verifyPhoneNumber(options);
}
void m100x95bb5810(String fotp, String otp) {
this.loadingDialog.show();
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(fotp, otp);
signInWithPhoneAuthCredential(credential);
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
this.mAuth.signInWithCredential(credential).addOnCompleteListener(this, new OnCompleteListener() {
public final void onComplete(Task task) {
MainActivity.this.m101x2bfc02eb(task);
}
});
}
void m101x2bfc02eb(Task task) {
if (task.isSuccessful()) {
this.builder.dismiss();
Toast.makeText(getApplicationContext(), this.resources.getString(2131886569), 0).show();
updateMobile(this.selectedMemberid, this.selectedUsername, this.selectedId, this.selectedEmail, this.selectedApitoken, this.selectedCode, this.selectedMobile, this.selectedCountryId, this.selectedPromo, this.selectedFirstname, this.selectedLastname);
return;
}
Log.w("TAG", "signInWithCredential:failure", task.getException());
Toast.makeText(getApplicationContext(), this.resources.getString(2131886449), 0).show();
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
Toast.makeText(getApplicationContext(), this.resources.getString(2131887096), 0).show();
this.otpView.setText("");
this.loadingDialog.dismiss();
}
}
}