Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23
以下内容为反编译后的 LoginActivity.java 源代码,内容仅作参考
package com.perm.kate;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AlertDialog;
import com.perm.kate.account.Account;
import com.perm.kate.api.Auth;
import com.perm.kate.notifications.LoginNotification;
import com.perm.kate.session.Session;
import com.perm.utils.ProxyManager;
import com.perm.utils.Utils;
public class LoginActivity extends BaseActivity {
boolean from_login;
long group_id;
WebView webview;
boolean validation_mode = false;
final Handler handler = new Handler();
final Runnable runnable = new Runnable() {
@Override
public void run() {
LoginActivity loginActivity = LoginActivity.this;
loginActivity.parseUrl(loginActivity.webview.getUrl());
if (LoginActivity.this.isFinishing()) {
return;
}
LoginActivity loginActivity2 = LoginActivity.this;
loginActivity2.handler.postDelayed(loginActivity2.runnable, 1000L);
}
};
private final int REQUEST_LOGIN = 1;
class FacebookWebViewClient extends WebViewClient {
FacebookWebViewClient() {
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
LoginActivity.this.showProgressBar(false);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
super.onPageStarted(webView, str, bitmap);
LoginActivity.this.showProgressBar(true);
LoginActivity.this.parseUrl(str);
}
}
public void lambda$showCantLoginDialog$0(DialogInterface dialogInterface, int i) {
startReserveLogin();
}
public void lambda$showCantLoginDialog$1(DialogInterface dialogInterface, int i) {
showInstructions();
}
public static String[] parseError(String str) {
String extractPattern = Utils.extractPattern(str, "error=(.*?)&");
Log.i("Kate.LoginActivity", "error=" + extractPattern);
return new String[]{extractPattern, str};
}
public void parseUrl(String str) {
Intent intent;
if (str == null) {
return;
}
try {
if (str.startsWith("https://oauth.vk.com/blank.html") || str.startsWith("http://api.vk.com/blank.html")) {
if (!str.contains("error=") && !str.contains("fail=")) {
long j = this.group_id;
String[] strArr = null;
if (j != 0) {
String parseGroupRedirectUrl = Auth.parseGroupRedirectUrl(str, j);
intent = new Intent();
intent.putExtra("access_token", parseGroupRedirectUrl);
} else {
if (!this.validation_mode) {
Account account = new Account();
String[] parseRedirectUrl = Auth.parseRedirectUrl(str);
account.access_token = parseRedirectUrl[0];
account.mid = parseRedirectUrl[1];
KApplication.addAccount(account);
}
intent = null;
}
if (this.validation_mode) {
try {
strArr = Auth.parseRedirectUrl(str);
} catch (Throwable unused) {
}
if (strArr != null && !TextUtils.isEmpty(strArr[0])) {
if (this.from_login) {
Account account2 = new Account();
account2.access_token = strArr[0];
account2.mid = strArr[1];
KApplication.addAccount(account2);
intent = new Intent();
intent.putExtra("account_created", true);
} else {
Session session = KApplication.session;
if (session != null) {
session.setAccessToken(strArr[0]);
KApplication.accountManager.saveAccounts();
}
}
}
}
setResult(-1, intent);
}
if (str.contains("error=")) {
String[] parseError = parseError(str);
Helper.reportError(new Exception(parseError[0]), parseError[1]);
}
this.handler.removeCallbacks(this.runnable);
LoginNotification.cancel(KApplication.current);
finish();
}
} catch (Exception e) {
Helper.reportError(e);
e.printStackTrace();
}
}
private void showCantLoginDialog() {
new AlertDialog.Builder(this).setMessage(R.string.reserve_auth_message).setPositiveButton(R.string.oauth_auth, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
LoginActivity.this.lambda$showCantLoginDialog$0(dialogInterface, i);
}
}).setNegativeButton(getString(R.string.recommendations), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
LoginActivity.this.lambda$showCantLoginDialog$1(dialogInterface, i);
}
}).create().show();
}
private void showInstructions() {
new AlertDialog.Builder(this).setMessage(R.string.login_recommendations).setPositiveButton(R.string.ok, (DialogInterface.OnClickListener) null).create().show();
}
private void startReserveLogin() {
startActivityForResult(new Intent(this, LoginActivity2.class), 1);
}
@Override
protected boolean fillMenuItems(Menu menu) {
menu.add(0, 2, 3000, R.string.cant_login);
return true;
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
if (i == 1 && i2 == -1) {
setResult(-1);
finish();
}
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
try {
setContentView(R.layout.login);
setupMenuButton();
String stringExtra = getIntent().getStringExtra("validation_uri");
if (!TextUtils.isEmpty(stringExtra)) {
this.validation_mode = true;
}
this.from_login = getIntent().getBooleanExtra("from_login", false);
this.group_id = getIntent().getLongExtra("group_id", 0L);
setHeaderTitle(R.string.label_login);
if (this.validation_mode) {
setHeaderTitle(R.string.validation);
}
WebView webView = (WebView) findViewById(R.id.facebookview);
this.webview = webView;
ProxyManager.setProxyIfRequired(webView);
this.webview.getSettings().setJavaScriptEnabled(Build.VERSION.SDK_INT >= 28);
this.webview.clearCache(true);
this.webview.getSettings().setSavePassword(false);
this.webview.setWebViewClient(new FacebookWebViewClient());
CookieSyncManager.createInstance(this);
CookieManager.getInstance().removeAllCookie();
if (this.validation_mode) {
this.webview.loadUrl(stringExtra);
} else {
String settings = Auth.getSettings();
if (this.group_id != 0) {
settings = "messages,photos,docs";
}
String url = Auth.getUrl("2685278", settings);
if (this.group_id != 0) {
url = url + "&group_ids=" + this.group_id;
}
this.webview.loadUrl(url);
}
this.handler.postDelayed(this.runnable, 1000L);
if (this.group_id != 0) {
displayToast(R.string.group_messages_login);
}
if (this.validation_mode) {
return;
}
new AlertDialog.Builder(this).setMessage("Если у вас беспарольный вход, то можно зайти на сайт ВК и там включить двухфакторную авторизацию. Тогда в приложение можно будет входить с паролем как и прежде.").create().show();
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
displayToast(th.toString());
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
fillMenuItems(menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public void onDestroy() {
this.handler.removeCallbacks(null);
super.onDestroy();
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 2) {
showCantLoginDialog();
}
return super.onOptionsItemSelected(menuItem);
}
}