Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23
以下内容为反编译后的 LoginActivity2.java 源代码,内容仅作参考
package com.perm.kate;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import com.perm.kate.account.Account;
import com.perm.kate.api.LoginLogic;
import com.perm.kate.session.CaptchaDialog;
import com.perm.utils.PasswordTransformer;
import com.perm.utils.ProxyManager;
import com.perm.utils.UserAgent;
import com.perm.utils.Utils;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class LoginActivity2 extends BaseActivity {
EditText login;
String login1;
LoginLogic loginLogic;
View loginView;
EditText pass;
String password;
View progressView;
private final View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity2 loginActivity2 = LoginActivity2.this;
loginActivity2.showView(loginActivity2.progressView);
new Thread() {
@Override
public void run() {
LoginActivity2.this.logIn(null, null, false);
}
}.start();
}
};
private final CompoundButton.OnCheckedChangeListener checkedChangeListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
if (z) {
LoginActivity2.this.pass.setTransformationMethod(null);
} else {
LoginActivity2.this.pass.setTransformationMethod(new PasswordTransformationMethod());
}
}
};
private final View.OnClickListener cantLoginListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity2.this.checkTime();
}
};
private final int REQUEST_LOGIN = 1;
private final int REQUEST_VALIDATION = 2;
private final DialogInterface.OnClickListener startReserveClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
LoginActivity2.this.startReserveLogin();
}
};
private final DialogInterface.OnClickListener instructionsClick = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
new AlertDialog.Builder(LoginActivity2.this).setMessage(R.string.login_recommendations).setPositiveButton(R.string.ok, (DialogInterface.OnClickListener) null).create().show();
LoginActivity2.this.reportUrlAvailabilityInThread();
}
};
public static String checkUrl(String str) {
HttpURLConnection httpURLConnection = null;
try {
httpURLConnection = ProxyManager.getConnection(new URL(str));
httpURLConnection.setConnectTimeout(30000);
httpURLConnection.setReadTimeout(30000);
httpURLConnection.setUseCaches(false);
httpURLConnection.setDoOutput(false);
httpURLConnection.setDoInput(true);
String num = Integer.toString(httpURLConnection.getResponseCode());
httpURLConnection.disconnect();
return num;
} catch (Throwable th) {
try {
return th.toString();
} finally {
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
}
}
}
public void done(Object[] objArr) {
Account account = new Account();
account.mid = (String) objArr[2];
account.access_token = (String) objArr[1];
KApplication.addAccount(account);
setResult(-1);
finish();
}
private void htcPasswordFix() {
if (Build.MODEL.startsWith("HTC") && Build.VERSION.SDK_INT <= 19) {
this.pass.setInputType(1);
this.pass.setTransformationMethod(new PasswordTransformationMethod());
}
}
public void logIn(String str, String str2, final boolean z) {
this.login1 = this.login.getText().toString();
String obj = this.pass.getText().toString();
this.password = obj;
if (z) {
this.password = PasswordTransformer.transform(obj);
}
LoginLogic loginLogic = new LoginLogic();
this.loginLogic = loginLogic;
final Object[] logInDirect = loginLogic.logInDirect(this.login1, this.password, str, str2, UserAgent.user_agent);
final int intValue = ((Integer) logInDirect[0]).intValue();
if (intValue == 2) {
final String str3 = (String) logInDirect[2];
CaptchaDialog.display(this, (String) logInDirect[1], new CaptchaDialog.CaptchaCallback() {
@Override
public void complete(final String str4) {
new Thread() {
@Override
public void run() {
AnonymousClass3 anonymousClass3 = AnonymousClass3.this;
LoginActivity2.this.logIn(str3, str4, z);
}
}.start();
}
@Override
public void failedToDisplay() {
}
});
} else if (intValue != 1 || z) {
runOnUiThread(new Runnable() {
@Override
public void run() {
int i = intValue;
if (i == 0) {
if (z) {
Helper.reportError(new Exception("Transformed login worked!"));
}
LoginActivity2.this.done(logInDirect);
} else if (i == 1) {
Toast.makeText(LoginActivity2.this.getApplicationContext(), (int) R.string.login_failed, 1).show();
LoginActivity2 loginActivity2 = LoginActivity2.this;
loginActivity2.showView(loginActivity2.loginView);
} else if (i == 5) {
Toast.makeText(LoginActivity2.this.getApplicationContext(), (int) R.string.network_error, 1).show();
LoginActivity2 loginActivity22 = LoginActivity2.this;
loginActivity22.showView(loginActivity22.loginView);
} else if (i == 7) {
String str4 = (String) logInDirect[1];
if (TextUtils.isEmpty(str4)) {
str4 = LoginActivity2.this.getString(R.string.server_error);
}
Toast.makeText(LoginActivity2.this.getApplicationContext(), str4, 1).show();
LoginActivity2 loginActivity23 = LoginActivity2.this;
loginActivity23.showView(loginActivity23.loginView);
} else if (i == 6) {
Intent intent = new Intent(LoginActivity2.this, LoginActivity.class);
intent.putExtra("validation_uri", (String) logInDirect[1]);
intent.putExtra("from_login", true);
LoginActivity2.this.startActivityForResult(intent, 2);
LoginActivity2 loginActivity24 = LoginActivity2.this;
loginActivity24.showView(loginActivity24.loginView);
}
}
});
} else {
logIn(null, null, true);
}
}
public void reportUrlAvailabilityInThread() {
new Thread() {
@Override
public void run() {
int indexOf;
try {
String checkUrl = LoginActivity2.checkUrl("http://ya.ru");
String checkUrl2 = LoginActivity2.checkUrl("http://vk.com");
String checkUrl3 = LoginActivity2.checkUrl("http://api.vk.com");
String checkUrl4 = LoginActivity2.checkUrl("https://api.vk.com");
if (checkUrl4.indexOf("current time:") != -1) {
checkUrl4 = checkUrl4.substring(0, indexOf + 13) + " xxx";
}
Helper.reportError(new Exception("r1=" + checkUrl + " r2=" + checkUrl2 + " r3=" + checkUrl3 + " r4=" + checkUrl4));
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
}
}
}.start();
}
private void showOnlineSettingsDialog() {
DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
KApplication.online.setOnlineFlag(i == 0);
dialogInterface.dismiss();
if (i == 1) {
DashboardFragment.offlineAlert(LoginActivity2.this);
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.online_title);
builder.setSingleChoiceItems(R.array.online_values, !KApplication.online.isEnabled(), onClickListener);
builder.setNegativeButton(R.string.label_cancel, (DialogInterface.OnClickListener) null);
AlertDialog create = builder.create();
create.setCanceledOnTouchOutside(true);
create.show();
}
public void showReserveLoginDialog() {
new AlertDialog.Builder(this).setMessage(R.string.reserve_auth_message).setPositiveButton(R.string.oauth_auth, this.startReserveClick).setNegativeButton(getString(R.string.recommendations), this.instructionsClick).create().show();
}
public void showReserveLoginDialogOnUiThread() {
runOnUiThread(new Runnable() {
@Override
public void run() {
LoginActivity2.this.showReserveLoginDialog();
}
});
}
public void showTimeDialogOnUiThread() {
runOnUiThread(new Runnable() {
@Override
public void run() {
new AlertDialog.Builder(LoginActivity2.this).setMessage(R.string.check_time).setPositiveButton(R.string.check_now, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
LoginActivity2.this.startActivity(new Intent("android.settings.DATE_SETTINGS"));
}
}).setNegativeButton(LoginActivity2.this.getString(R.string.login_no_effect), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
LoginActivity2.this.showReserveLoginDialog();
}
}).create().show();
}
});
}
public void startReserveLogin() {
startActivityForResult(new Intent(this, LoginActivity.class), 1);
}
void checkTime() {
new Thread() {
@Override
public void run() {
LoginActivity2.this.showProgressBar(true);
long currentTimeMillis = System.currentTimeMillis() / 1000;
long correctTime = LoginActivity2.this.getCorrectTime();
LoginActivity2.this.showProgressBar(false);
if (LoginActivity2.this.isFinishing()) {
return;
}
if (correctTime == 0 || Math.abs(correctTime - currentTimeMillis) <= 2678400) {
LoginActivity2.this.showReserveLoginDialogOnUiThread();
} else {
LoginActivity2.this.showTimeDialogOnUiThread();
}
}
}.start();
}
@Override
protected boolean fillMenuItems(Menu menu) {
menu.add(0, 2, 3050, R.string.online_title);
menu.add(0, 300, 3050, R.string.proxy);
return true;
}
long getCorrectTime() {
HttpURLConnection httpURLConnection;
Throwable th;
IOException e;
HttpURLConnection httpURLConnection2;
try {
try {
httpURLConnection = (HttpURLConnection) new URL("https://currentmillis.com/time/seconds-since-unix-epoch.php").openConnection();
} catch (Throwable th2) {
if (httpURLConnection2 != null) {
httpURLConnection2.disconnect();
}
throw th2;
}
} catch (IOException e2) {
httpURLConnection = null;
e = e2;
} catch (Throwable th3) {
httpURLConnection = null;
th = th3;
}
try {
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setReadTimeout(10000);
httpURLConnection.setUseCaches(false);
httpURLConnection.setDoOutput(false);
httpURLConnection.setDoInput(true);
UserAgent.set(httpURLConnection);
if (httpURLConnection.getResponseCode() == -1) {
httpURLConnection.disconnect();
return 0L;
}
long parseLong = Long.parseLong(Utils.convertStreamToString(new BufferedInputStream(httpURLConnection.getInputStream())));
httpURLConnection.disconnect();
return parseLong;
} catch (IOException e3) {
e = e3;
e.printStackTrace();
} catch (Throwable th4) {
th = th4;
th.printStackTrace();
Helper.reportError(th);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
return 0L;
}
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
if (i == 1 && i2 == -1) {
setResult(-1);
finish();
}
if (i == 2 && i2 == -1 && intent != null && intent.getBooleanExtra("account_created", false)) {
setResult(-1);
finish();
}
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.new_account);
setHeaderTitle(R.string.label_login);
setupMenuButton();
this.loginView = findViewById(R.id.login_view);
this.progressView = findViewById(R.id.progress_view);
this.login = (EditText) findViewById(R.id.username);
this.pass = (EditText) findViewById(R.id.password);
((Button) findViewById(R.id.login_btn)).setOnClickListener(this.listener);
TextView textView = (TextView) findViewById(R.id.forgot_btn);
textView.setText(Html.fromHtml(getString(R.string.forgot_password)));
textView.setMovementMethod(LinkMovementMethod.getInstance());
TextView textView2 = (TextView) findViewById(R.id.terms);
textView2.setText(Html.fromHtml("By clicking Sign in, you confirm that you accepted <a href=\"https://vk.com/terms\">VK Terms of Service</a> when you created VK account."));
textView2.setMovementMethod(LinkMovementMethod.getInstance());
((CheckBox) findViewById(R.id.show_password)).setOnCheckedChangeListener(this.checkedChangeListener);
findViewById(R.id.cant_login).setOnClickListener(this.cantLoginListener);
setButtonsBg();
htcPasswordFix();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
fillMenuItems(menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
int itemId = menuItem.getItemId();
if (itemId == 2) {
showOnlineSettingsDialog();
} else if (itemId == 300) {
startActivity(new Intent(this, ProxyActivity.class));
}
return super.onOptionsItemSelected(menuItem);
}
void showView(View view) {
View view2 = this.loginView;
view2.setVisibility(view == view2 ? 0 : 8);
View view3 = this.progressView;
view3.setVisibility(view != view3 ? 8 : 0);
}
}