正在查看: Delta Chat v1.58.3 应用的 ProxySettingsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Delta Chat v1.58.3 应用的 ProxySettingsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.thoughtcrime.securesms.proxy;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SwitchCompat;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.b44t.messenger.DcLot;
import com.caverock.androidsvg.SVG;
import com.caverock.androidsvg.SVGParseException;
import java.util.LinkedList;
import org.thoughtcrime.securesms.BaseActionBarActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.connect.DcEventCenter;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.proxy.ProxyListAdapter;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.Util;
public class ProxySettingsActivity extends BaseActionBarActivity implements ProxyListAdapter.ItemClickListener, DcEventCenter.DcEventDelegate {
private ProxyListAdapter adapter;
private final DynamicTheme dynamicTheme = new DynamicTheme();
private SwitchCompat proxySwitch;
@Override
public boolean runOnMain() {
return DcEventCenter.DcEventDelegate.CC.$default$runOnMain(this);
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
this.dynamicTheme.onCreate(this);
setContentView(R.layout.proxy_settings_activity);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setTitle(R.string.proxy_settings);
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
ProxyListAdapter proxyListAdapter = new ProxyListAdapter(this);
this.adapter = proxyListAdapter;
proxyListAdapter.setItemClickListener(this);
SwitchCompat findViewById = findViewById(R.id.proxy_switch);
this.proxySwitch = findViewById;
findViewById.setChecked(DcHelper.getInt(this, DcHelper.CONFIG_PROXY_ENABLED) == 1);
this.proxySwitch.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ProxySettingsActivity.this.m1575x88f1332b(view);
}
});
ListView listView = (ListView) findViewById(R.id.proxy_list);
listView.setAdapter((ListAdapter) this.adapter);
listView.addHeaderView(View.inflate(this, R.layout.proxy_list_header, null), null, false);
View inflate = View.inflate(this, R.layout.proxy_list_footer, null);
inflate.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ProxySettingsActivity.this.m1576x8a27860a(view);
}
});
listView.addFooterView(inflate);
this.adapter.changeData(DcHelper.get(this, DcHelper.CONFIG_PROXY_URL));
DcHelper.getEventCenter(this).addObserver(2100, this);
handleOpenProxyUrl();
}
void m1575x88f1332b(View view) {
if (this.proxySwitch.isChecked() && this.adapter.getCount() == 0) {
showAddProxyDialog();
} else {
DcHelper.set(this, DcHelper.CONFIG_PROXY_ENABLED, this.proxySwitch.isChecked() ? "1" : "0");
DcHelper.getContext(this).restartIo();
}
}
void m1576x8a27860a(View view) {
showAddProxyDialog();
}
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleOpenProxyUrl();
}
@Override
public void onResume() {
super.onResume();
this.dynamicTheme.onResume(this);
}
public void onDestroy() {
super.onDestroy();
DcHelper.getEventCenter(this).removeObservers(this);
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
finish();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
@Override
public void onItemClick(String str) {
if (DcHelper.getContext(this).setConfigFromQr(str)) {
DcHelper.getContext(this).restartIo();
this.adapter.setSelectedProxy(str);
this.proxySwitch.setChecked(DcHelper.getInt(this, DcHelper.CONFIG_PROXY_ENABLED) == 1);
return;
}
Toast.makeText((Context) this, R.string.proxy_invalid, 1).show();
}
@Override
public void onItemShare(final String str) {
View inflate = View.inflate(this, R.layout.dialog_share_proxy, null);
try {
inflate.findViewById(R.id.qr_image).setSVG(SVG.getFromString(DcHelper.getContext(this).createQrSvg(str)));
} catch (SVGParseException e) {
e.printStackTrace();
}
new AlertDialog.Builder(this).setView(inflate).setPositiveButton(android.R.string.ok, (DialogInterface.OnClickListener) null).setNeutralButton(R.string.proxy_share_link, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ProxySettingsActivity.this.m1578xf1bbdbd1(str, dialogInterface, i);
}
}).show();
}
void m1578xf1bbdbd1(String str, DialogInterface dialogInterface, int i) {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("text/plain");
intent.putExtra("android.intent.extra.TEXT", str);
startActivity(Intent.createChooser(intent, getString(R.string.chat_share_with_title)));
}
@Override
public void onItemDelete(final String str) {
Util.redPositiveButton(new AlertDialog.Builder(this).setTitle(R.string.proxy_delete).setMessage(getString(R.string.proxy_delete_explain, new Object[]{DcHelper.getContext(this).checkQr(str).getText1()})).setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ProxySettingsActivity.this.m1577x35a69a66(str, dialogInterface, i);
}
}).setNegativeButton(android.R.string.cancel, (DialogInterface.OnClickListener) null).show());
}
void m1577x35a69a66(String str, DialogInterface dialogInterface, int i) {
deleteProxy(str);
}
private void deleteProxy(String str) {
LinkedList linkedList = new LinkedList();
for (String str2 : DcHelper.get(this, DcHelper.CONFIG_PROXY_URL).split("\n")) {
if (!str2.equals(str)) {
linkedList.add(str2);
}
}
if (linkedList.isEmpty()) {
DcHelper.set(this, DcHelper.CONFIG_PROXY_ENABLED, "0");
this.proxySwitch.setChecked(false);
}
String m = ProxySettingsActivity$$ExternalSyntheticBackport0.m("\n", linkedList);
DcHelper.set(this, DcHelper.CONFIG_PROXY_URL, m);
DcHelper.getContext(this).restartIo();
this.adapter.changeData(m);
}
private void showAddProxyDialog() {
View inflate = View.inflate(this, R.layout.single_line_input, null);
final EditText editText = (EditText) inflate.findViewById(R.id.input_field);
editText.setHint(R.string.proxy_add_url_hint);
new AlertDialog.Builder(this).setTitle(R.string.proxy_add).setMessage(R.string.proxy_add_explain).setView(inflate).setPositiveButton(R.string.proxy_use_proxy, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ProxySettingsActivity.this.m1579xc5c77830(editText, dialogInterface, i);
}
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ProxySettingsActivity.this.m1580xc6fdcb0f(dialogInterface, i);
}
}).setCancelable(false).show();
}
void m1579xc5c77830(EditText editText, DialogInterface dialogInterface, int i) {
String trim = editText.getText().toString().trim();
DcContext context = DcHelper.getContext(this);
if (context.checkQr(trim).getState() == 271) {
context.setConfigFromQr(trim);
DcHelper.getContext(this).restartIo();
this.adapter.changeData(DcHelper.get(this, DcHelper.CONFIG_PROXY_URL));
} else {
Toast.makeText((Context) this, R.string.proxy_invalid, 1).show();
}
this.proxySwitch.setChecked(DcHelper.getInt(this, DcHelper.CONFIG_PROXY_ENABLED) == 1);
}
void m1580xc6fdcb0f(DialogInterface dialogInterface, int i) {
if (this.proxySwitch.isChecked() && this.adapter.getCount() == 0) {
this.proxySwitch.setChecked(false);
}
}
private void handleOpenProxyUrl() {
final Uri data;
if (getIntent() == null || !"android.intent.action.VIEW".equals(getIntent().getAction()) || (data = getIntent().getData()) == null) {
return;
}
final DcContext context = DcHelper.getContext(this);
DcLot checkQr = context.checkQr(data.toString());
if (checkQr.getState() == 271) {
new AlertDialog.Builder(this).setTitle(R.string.proxy_use_proxy).setMessage(getString(R.string.proxy_use_proxy_confirm, new Object[]{checkQr.getText1()})).setPositiveButton(R.string.proxy_use_proxy, new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ProxySettingsActivity.this.m1574xd5f21c8d(context, data, dialogInterface, i);
}
}).setNegativeButton(R.string.cancel, (DialogInterface.OnClickListener) null).setCancelable(false).show();
} else {
Toast.makeText((Context) this, R.string.proxy_invalid, 1).show();
}
}
void m1574xd5f21c8d(DcContext dcContext, Uri uri, DialogInterface dialogInterface, int i) {
dcContext.setConfigFromQr(uri.toString());
dcContext.restartIo();
this.adapter.changeData(DcHelper.get(this, DcHelper.CONFIG_PROXY_URL));
this.proxySwitch.setChecked(DcHelper.getInt(this, DcHelper.CONFIG_PROXY_ENABLED) == 1);
}
@Override
public void handleEvent(DcEvent dcEvent) {
if (dcEvent.getId() == 2100) {
this.adapter.refreshConnectivity();
}
}
}