正在查看: Mantra Counter v25.01 应用的 Authentication.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Mantra Counter v25.01 应用的 Authentication.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.sweetedge.mantracounter.Authentication;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.IntentSenderRequest;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import com.google.android.gms.auth.api.identity.BeginSignInRequest;
import com.google.android.gms.auth.api.identity.BeginSignInResult;
import com.google.android.gms.auth.api.identity.Identity;
import com.google.android.gms.auth.api.identity.SignInClient;
import com.google.android.gms.auth.api.identity.SignInCredential;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.commons.io.IOUtils;
import com.sweetedge.mantracounter.MainActivity;
import com.sweetedge.mantracounter.PAds;
import com.sweetedge.mantracounter.R;
import sweetedge.extra.PLog;
import sweetedge.popup.PDialog;
import sweetedge.preference.PSharedPreference;
import sweetedge.screen.PIntent;
public class Authentication extends AppCompatActivity {
RelativeLayout GmailSignIn;
TextView Help;
TextView WelcomeHeader;
TextView Why;
EditText edtMail;
EditText edtOTP;
RelativeLayout mailLogin;
private SignInClient oneTapClient;
BeginSignInResult result1;
Button sendOTP;
Button signINMail;
private ImageView signInButton;
private BeginSignInRequest signInRequest;
TextView skip;
boolean isReadyGoogleSignIn = false;
private final ActivityResultLauncher<IntentSenderRequest> googleSignInLauncher = registerForActivityResult(new ActivityResultContracts.StartIntentSenderForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
Authentication.this.m279x860e5832((ActivityResult) obj);
}
});
private void setAppTheme(int i) {
AppCompatDelegate.setDefaultNightMode(i);
}
private void loadThemePreference() {
int integer = PSharedPreference.getInteger(this, "THEME_LIGHT_DARK", 1);
if (integer == 1) {
setAppTheme(1);
} else if (integer == 0) {
setAppTheme(2);
} else {
setAppTheme(-1);
}
}
protected void onResume() {
super.onResume();
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.authentication);
loadThemePreference();
this.oneTapClient = Identity.getSignInClient(this);
this.skip = (TextView) findViewById(R.id.skipTxt);
TextView textView = (TextView) findViewById(R.id.welcome);
this.WelcomeHeader = textView;
textView.setVisibility(4);
this.Why = (TextView) findViewById(R.id.why);
this.Help = (TextView) findViewById(R.id.help);
this.Help = (TextView) findViewById(R.id.help);
this.GmailSignIn = (RelativeLayout) findViewById(R.id.GmailSignin);
this.mailLogin = (RelativeLayout) findViewById(R.id.mailLogin);
this.edtMail = (EditText) findViewById(R.id.edt_mail);
this.edtOTP = (EditText) findViewById(R.id.edt_otp);
this.signINMail = (Button) findViewById(R.id.signInMail);
this.sendOTP = (Button) findViewById(R.id.sendOTP);
this.GmailSignIn.setVisibility(0);
this.mailLogin.setVisibility(8);
if (PSharedPreference.getBoolean(this, "GMAILlogin", true)) {
this.GmailSignIn.setVisibility(0);
this.mailLogin.setVisibility(8);
} else {
showMailLoginScreen();
}
this.sendOTP.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String deviceID = Authentication.getDeviceID(Authentication.this);
?? r0 = Authentication.this;
UserWebService.sendOTP(r0, r0.edtMail.getText().toString().trim(), Authentication.this.sendOTP, Authentication.this.edtOTP, Authentication.this.signINMail, Authentication.this.edtMail, deviceID);
}
});
this.signINMail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
?? r3 = Authentication.this;
UserWebService.verifyOTP(r3, r3.edtMail, Authentication.this.edtOTP);
}
});
this.signInRequest = BeginSignInRequest.builder().setGoogleIdTokenRequestOptions(BeginSignInRequest.GoogleIdTokenRequestOptions.builder().setSupported(true).setServerClientId(getString(R.string.default_web_client_id)).setFilterByAuthorizedAccounts(false).build()).setAutoSelectEnabled(true).build();
this.signInButton = (ImageView) findViewById(R.id.btnSignIn);
final String trim = UserDataPref.get(this, "U_phone").trim();
if (trim.length() > 5) {
new CountDownTimer(1000L, 1000L) {
@Override
public void onTick(long j) {
}
@Override
public void onFinish() {
if (Authentication.this.isFinishing() || Authentication.this.isDestroyed()) {
return;
}
DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
};
?? r1 = Authentication.this;
PDialog.showSimple((Context) r1, onClickListener, r1.getResources().getString(R.string.makeLogin), "You already have an account with\nMo. " + trim + ",\n\nAll your data will be restore\nto your new Google account.", Authentication.this.getResources().getString(R.string.Yes), "");
}
}.start();
}
this.Help.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
PAds.helpClick(Authentication.this);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
}
});
this.oneTapClient.beginSignIn(this.signInRequest).addOnSuccessListener(this, new OnSuccessListener<BeginSignInResult>() {
public void onSuccess(BeginSignInResult beginSignInResult) {
try {
Authentication.this.result1 = beginSignInResult;
Authentication.this.isReadyGoogleSignIn = true;
} catch (Exception e) {
PLog.print("Couldn't start One Tap UI: " + e.getMessage());
UserWebService.ErrorReport(Authentication.this, "Couldn't start One Tap UI: " + e.getMessage() + " \n " + e.getStackTrace().toString());
PSharedPreference.setBoolean(Authentication.this, "GMAILlogin", false);
Authentication.this.showMailLoginScreen();
}
}
}).addOnFailureListener(this, new OnFailureListener() {
public void onFailure(Exception exc) {
PLog.print("Google Sign-In failed: " + exc.getMessage());
UserWebService.ErrorReport(Authentication.this, "Sign-in failed " + exc.getMessage() + " \n " + exc.getStackTrace().toString());
AppCompatActivity appCompatActivity = Authentication.this;
StringBuilder sb = new StringBuilder("Sign-in failed ");
sb.append(exc.getMessage());
Toast.makeText((Context) appCompatActivity, (CharSequence) sb.toString(), 0).show();
PSharedPreference.setBoolean(Authentication.this, "GMAILlogin", false);
Authentication.this.showMailLoginScreen();
}
});
this.signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!Authentication.this.isReadyGoogleSignIn) {
Authentication.this.signInWithGoogle();
} else {
Authentication.this.googleSignInLauncher.launch(new IntentSenderRequest.Builder(Authentication.this.result1.getPendingIntent().getIntentSender()).build());
}
}
});
this.skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PIntent.goNewScreenwithFinishedThis(Authentication.this, MainActivity.class);
PSharedPreference.setBoolean(Authentication.this, "GMAILlogin", true);
}
});
this.Why.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
};
PDialog.showSimple(Authentication.this, onClickListener, "Why", Authentication.this.getResources().getString(R.string.descriptionofwhy) + IOUtils.LINE_SEPARATOR_UNIX + Authentication.this.getResources().getString(R.string.benifitsofwhy), Authentication.this.getResources().getString(R.string.ok), "");
}
});
}
public void showMailLoginScreen() {
this.mailLogin.setVisibility(0);
this.GmailSignIn.setVisibility(8);
}
public static String getDeviceID(Context context) {
return Settings.Secure.getString(context.getContentResolver(), "android_id");
}
public void signInWithGoogle() {
this.oneTapClient.beginSignIn(this.signInRequest).addOnSuccessListener(this, new OnSuccessListener<BeginSignInResult>() {
public void onSuccess(BeginSignInResult beginSignInResult) {
try {
Authentication.this.googleSignInLauncher.launch(new IntentSenderRequest.Builder(beginSignInResult.getPendingIntent().getIntentSender()).build());
} catch (Exception e) {
PLog.print("Couldn't start One Tap UI: " + e.getMessage());
UserWebService.ErrorReport(Authentication.this, "Couldn't start One Tap UI: " + e.getMessage() + " \n " + e.getStackTrace().toString());
PSharedPreference.setBoolean(Authentication.this, "GMAILlogin", false);
Authentication.this.showMailLoginScreen();
}
}
}).addOnFailureListener(this, new OnFailureListener() {
public void onFailure(Exception exc) {
UserWebService.ErrorReport(Authentication.this, "Sign-in failed " + exc.getMessage() + " \n " + exc.getStackTrace().toString());
Toast.makeText((Context) Authentication.this, (CharSequence) "Sign-in failed", 0).show();
PSharedPreference.setBoolean(Authentication.this, "GMAILlogin", false);
Authentication.this.showMailLoginScreen();
}
});
}
private void handleSignInResult(SignInCredential signInCredential) {
if (signInCredential.getGoogleIdToken() != null) {
String id = signInCredential.getId();
String displayName = signInCredential.getDisplayName();
PLog.print("Sign n with Email : " + id);
this.WelcomeHeader.setVisibility(0);
this.WelcomeHeader.setText(getResources().getString(R.string.welcome) + ".. " + displayName);
UserWebService.isCreate = true;
UserWebService.createAcc(this, id, displayName);
}
}
void m279x860e5832(ActivityResult activityResult) {
try {
handleSignInResult(this.oneTapClient.getSignInCredentialFromIntent(activityResult.getData()));
} catch (ApiException e) {
PLog.print("Sign-in failed" + e.getMessage());
UserWebService.ErrorReport(this, "Sign-in failed " + e.getMessage() + " \n " + e.getStackTrace().toString());
Toast.makeText((Context) this, (CharSequence) "Sign-in failed", 0).show();
PSharedPreference.setBoolean(this, "GMAILlogin", false);
showMailLoginScreen();
}
}
}