no automatic remote content loading for contact requests (#2469)

* factor out checkmark strings

* no automatic remote content for contact requests

loading remote content in contact requests
now always require explicit consent of the user.
moreover, contact request do not alter
the otherwise used never/once/always settings.
This commit is contained in:
bjoern
2023-02-08 11:03:07 +01:00
committed by GitHub
parent 904efe872b
commit 4f8d6aad05
2 changed files with 26 additions and 11 deletions
@@ -847,6 +847,7 @@ public class ConversationFragment extends MessageSelectorFragment
public void onShowFullClicked(DcMsg messageRecord) {
Intent intent = new Intent(getActivity(), FullMsgActivity.class);
intent.putExtra(FullMsgActivity.MSG_ID_EXTRA, messageRecord.getId());
intent.putExtra(FullMsgActivity.IS_CONTACT_REQUEST, getListAdapter().getChat().isContactRequest());
startActivity(intent);
getActivity().overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
}
@@ -19,9 +19,11 @@ import java.lang.ref.WeakReference;
public class FullMsgActivity extends WebViewActivity
{
public static final String MSG_ID_EXTRA = "msg_id";
public static final String IS_CONTACT_REQUEST = "is_contact_request";
private int msgId;
private DcContext dcContext;
private boolean loadRemoteContent = false;
private boolean isContactRequest;
enum LoadRemoteContent {
NEVER,
@@ -33,7 +35,8 @@ public class FullMsgActivity extends WebViewActivity
protected void onCreate(Bundle state, boolean ready) {
super.onCreate(state, ready);
loadRemoteContent = Prefs.getAlwaysLoadRemoteContent(this);
isContactRequest = getIntent().getBooleanExtra(IS_CONTACT_REQUEST, false);;
loadRemoteContent = !isContactRequest && Prefs.getAlwaysLoadRemoteContent(this);
webView.getSettings().setBlockNetworkLoads(!loadRemoteContent);
// setBuiltInZoomControls() adds pinch-to-zoom as well as two on-screen zoom control buttons.
@@ -115,17 +118,24 @@ public class FullMsgActivity extends WebViewActivity
// would be required as well - probably as the leftmost button which is not that usable in
// not-always-mode where the dialog is used more often. Or [Ok] would mean "Once" as well as "Change checkbox setting",
// which is also a bit weird. Anyway, let's give the three buttons a try :)
final String checkmarkPrefix = DynamicTheme.getCheckmarkEmoji(this) + " ";
if (Prefs.getAlwaysLoadRemoteContent(this)) {
builder.setNeutralButton(checkmarkPrefix + getString(R.string.always), (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.ALWAYS));
builder.setNegativeButton(R.string.never, (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.NEVER));
builder.setPositiveButton(R.string.once, (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.ONCE));
final String checkmark = DynamicTheme.getCheckmarkEmoji(this) + " ";
String alwaysCheckmark = "";
String onceCheckmark = "";
String neverCheckmark = "";
if (!isContactRequest && Prefs.getAlwaysLoadRemoteContent(this)) {
alwaysCheckmark = checkmark;
} else if (loadRemoteContent) {
onceCheckmark = checkmark;
} else {
builder.setNeutralButton(R.string.always, (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.ALWAYS));
builder.setNegativeButton((loadRemoteContent? "" : checkmarkPrefix) + getString(R.string.never), (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.NEVER));
builder.setPositiveButton((loadRemoteContent? checkmarkPrefix : "") + getString(R.string.once), (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.ONCE));
neverCheckmark = checkmark;
}
if (!isContactRequest) {
builder.setNeutralButton(alwaysCheckmark + getString(R.string.always), (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.ALWAYS));
}
builder.setNegativeButton(neverCheckmark + getString(isContactRequest? R.string.no : R.string.never), (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.NEVER));
builder.setPositiveButton(onceCheckmark + getString(R.string.once), (dialog, which) -> onChangeLoadRemoteContent(LoadRemoteContent.ONCE));
builder.show();
return true;
}
@@ -136,11 +146,15 @@ public class FullMsgActivity extends WebViewActivity
switch (loadRemoteContent) {
case NEVER:
this.loadRemoteContent = false;
Prefs.setBooleanPreference(this, Prefs.ALWAYS_LOAD_REMOTE_CONTENT, false);
if (!isContactRequest) {
Prefs.setBooleanPreference(this, Prefs.ALWAYS_LOAD_REMOTE_CONTENT, false);
}
break;
case ONCE:
this.loadRemoteContent = true;
Prefs.setBooleanPreference(this, Prefs.ALWAYS_LOAD_REMOTE_CONTENT, false);
if (!isContactRequest) {
Prefs.setBooleanPreference(this, Prefs.ALWAYS_LOAD_REMOTE_CONTENT, false);
}
break;
case ALWAYS:
this.loadRemoteContent = true;