正在查看: Delta Chat v1.58.3 应用的 FullMsgActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Delta Chat v1.58.3 应用的 FullMsgActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.thoughtcrime.securesms;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import androidx.appcompat.app.AlertDialog;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.rpc.HttpResponse;
import com.b44t.messenger.rpc.Rpc;
import java.io.ByteArrayInputStream;
import java.lang.ref.WeakReference;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.Prefs;
import org.thoughtcrime.securesms.util.Util;
public class FullMsgActivity extends WebViewActivity {
public static final String BLOCK_LOADING_REMOTE = "block_loading_remote";
public static final String MSG_ID_EXTRA = "msg_id";
private boolean blockLoadingRemote;
private DcContext dcContext;
private boolean loadRemoteContent = false;
private int msgId;
private Rpc rpc;
enum LoadRemoteContent {
NEVER,
ONCE,
ALWAYS
}
@Override
protected void onPreCreate() {
super.onPreCreate();
toggleFakeProxy(true);
}
@Override
protected void onCreate(Bundle bundle, boolean z) {
super.onCreate(bundle, z);
boolean booleanExtra = getIntent().getBooleanExtra(BLOCK_LOADING_REMOTE, false);
this.blockLoadingRemote = booleanExtra;
this.loadRemoteContent = !booleanExtra && Prefs.getAlwaysLoadRemoteContent(this);
this.webView.getSettings().setBlockNetworkLoads(!this.loadRemoteContent);
this.webView.getSettings().setBuiltInZoomControls(true);
this.webView.getSettings().setDisplayZoomControls(false);
this.webView.getSettings().setJavaScriptEnabled(false);
this.webView.getSettings().setPluginState(WebSettings.PluginState.OFF);
this.webView.getSettings().setAllowContentAccess(false);
this.webView.getSettings().setAllowFileAccess(false);
this.dcContext = DcHelper.getContext(this);
this.rpc = DcHelper.getRpc(this);
int intExtra = getIntent().getIntExtra("msg_id", 0);
this.msgId = intExtra;
String subject = this.dcContext.getMsg(intExtra).getSubject();
if (subject.isEmpty()) {
subject = getString(R.string.chat_input_placeholder);
}
getSupportActionBar().setTitle(subject);
loadHtmlAsync(new WeakReference(this));
}
private static void loadHtmlAsync(final WeakReference<FullMsgActivity> weakReference) {
Util.runOnBackground(new Runnable() {
@Override
public final void run() {
FullMsgActivity.lambda$loadHtmlAsync$1(weakReference);
}
});
}
static void lambda$loadHtmlAsync$1(final WeakReference weakReference) {
try {
FullMsgActivity fullMsgActivity = (FullMsgActivity) weakReference.get();
final String msgHtml = fullMsgActivity.dcContext.getMsgHtml(fullMsgActivity.msgId);
fullMsgActivity.runOnUiThread(new Runnable() {
@Override
public final void run() {
FullMsgActivity.lambda$loadHtmlAsync$0(weakReference, msgHtml);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
static void lambda$loadHtmlAsync$0(WeakReference weakReference, String str) {
try {
((FullMsgActivity) weakReference.get()).webView.loadDataWithBaseURL("file://index.html", str, "text/html", null, null);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onPause() {
super.onPause();
if (isFinishing()) {
overridePendingTransition(R.anim.fade_scale_in, R.anim.slide_to_right);
}
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
getMenuInflater().inflate(R.menu.full_msg, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
String str;
super.onOptionsItemSelected(menuItem);
if (menuItem.getItemId() != R.id.load_remote_content) {
return false;
}
AlertDialog.Builder message = new AlertDialog.Builder(this).setTitle(R.string.load_remote_content).setMessage(R.string.load_remote_content_ask);
String str2 = DynamicTheme.getCheckmarkEmoji(this) + " ";
String str3 = "";
if (!this.blockLoadingRemote && Prefs.getAlwaysLoadRemoteContent(this)) {
str = "";
} else if (this.loadRemoteContent) {
str = str2;
str2 = "";
} else {
str = "";
str3 = str2;
str2 = str;
}
if (!this.blockLoadingRemote) {
message.setNeutralButton(str2 + getString(R.string.always), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
FullMsgActivity.this.m1235xa5b05bb1(dialogInterface, i);
}
});
}
StringBuilder sb = new StringBuilder();
sb.append(str3);
sb.append(getString(this.blockLoadingRemote ? R.string.no : R.string.never));
message.setNegativeButton(sb.toString(), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
FullMsgActivity.this.m1236x689cc510(dialogInterface, i);
}
});
message.setPositiveButton(str + getString(R.string.once), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
FullMsgActivity.this.m1237x2b892e6f(dialogInterface, i);
}
});
message.show();
return true;
}
void m1235xa5b05bb1(DialogInterface dialogInterface, int i) {
onChangeLoadRemoteContent(LoadRemoteContent.ALWAYS);
}
void m1236x689cc510(DialogInterface dialogInterface, int i) {
onChangeLoadRemoteContent(LoadRemoteContent.NEVER);
}
void m1237x2b892e6f(DialogInterface dialogInterface, int i) {
onChangeLoadRemoteContent(LoadRemoteContent.ONCE);
}
static class AnonymousClass1 {
static final int[] $SwitchMap$org$thoughtcrime$securesms$FullMsgActivity$LoadRemoteContent;
static {
int[] iArr = new int[LoadRemoteContent.values().length];
$SwitchMap$org$thoughtcrime$securesms$FullMsgActivity$LoadRemoteContent = iArr;
try {
iArr[LoadRemoteContent.NEVER.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$org$thoughtcrime$securesms$FullMsgActivity$LoadRemoteContent[LoadRemoteContent.ONCE.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$org$thoughtcrime$securesms$FullMsgActivity$LoadRemoteContent[LoadRemoteContent.ALWAYS.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
}
}
private void onChangeLoadRemoteContent(LoadRemoteContent loadRemoteContent) {
int i = AnonymousClass1.$SwitchMap$org$thoughtcrime$securesms$FullMsgActivity$LoadRemoteContent[loadRemoteContent.ordinal()];
if (i == 1) {
this.loadRemoteContent = false;
if (!this.blockLoadingRemote) {
Prefs.setBooleanPreference(this, Prefs.ALWAYS_LOAD_REMOTE_CONTENT, false);
}
} else if (i == 2) {
this.loadRemoteContent = true;
if (!this.blockLoadingRemote) {
Prefs.setBooleanPreference(this, Prefs.ALWAYS_LOAD_REMOTE_CONTENT, false);
}
} else if (i == 3) {
this.loadRemoteContent = true;
Prefs.setBooleanPreference(this, Prefs.ALWAYS_LOAD_REMOTE_CONTENT, true);
}
this.webView.getSettings().setBlockNetworkLoads(!this.loadRemoteContent);
this.webView.reload();
}
@Override
protected WebResourceResponse interceptRequest(String str) {
try {
if (!this.loadRemoteContent) {
throw new Exception("loading remote content disabled");
}
if (str == null) {
throw new Exception("no url specified");
}
HttpResponse httpResponse = this.rpc.getHttpResponse(this.dcContext.getAccountId(), str);
String mimetype = httpResponse.getMimetype();
if (mimetype == null) {
mimetype = MediaUtil.OCTET;
}
return new WebResourceResponse(mimetype, httpResponse.getEncoding(), new ByteArrayInputStream(httpResponse.getBlob()));
} catch (Exception e) {
e.printStackTrace();
return new WebResourceResponse("text/plain", "UTF-8", new ByteArrayInputStream(("Error: " + e.getMessage()).getBytes()));
}
}
}