mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-06 17:13:23 +02:00
Ask show images per sender
This commit is contained in:
@@ -190,8 +190,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
private boolean attachments_alt;
|
||||
private boolean contrast;
|
||||
private boolean monospaced;
|
||||
private boolean contact_images;
|
||||
private boolean all_images;
|
||||
private boolean collapse_quotes;
|
||||
private boolean authentication;
|
||||
private static boolean debug;
|
||||
@@ -829,9 +827,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
} else
|
||||
bindContactInfo(info, message);
|
||||
|
||||
if (all_images || (contact_images && message.avatar != null))
|
||||
properties.setValue("images", message.id, true);
|
||||
|
||||
if (viewType == ViewType.THREAD) {
|
||||
if (expanded)
|
||||
bindExpanded(message, false);
|
||||
@@ -1990,17 +1985,20 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
}
|
||||
|
||||
private void onShowImages(final TupleMessageEx message) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (prefs.getBoolean("show_images_confirmed", false)) {
|
||||
onShowImagesConfirmed(message);
|
||||
return;
|
||||
}
|
||||
|
||||
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_ask_again, null);
|
||||
final TextView tvMessage = dview.findViewById(R.id.tvMessage);
|
||||
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
|
||||
tvMessage.setText(context.getText(R.string.title_ask_show_image));
|
||||
if (message.from == null || message.from.length == 0)
|
||||
cbNotAgain.setVisibility(View.GONE);
|
||||
else {
|
||||
List<String> froms = new ArrayList<>();
|
||||
for (Address address : message.from)
|
||||
froms.add(((InternetAddress) address).getAddress());
|
||||
cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again,
|
||||
TextUtils.join(", ", froms)));
|
||||
}
|
||||
|
||||
// TODO: dialog fragment
|
||||
final Dialog dialog = new AlertDialog.Builder(context)
|
||||
@@ -2008,8 +2006,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (cbNotAgain.isChecked())
|
||||
prefs.edit().putBoolean("show_images_confirmed", true).apply();
|
||||
if (cbNotAgain.isChecked()) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
for (Address address : message.from) {
|
||||
String from = ((InternetAddress) address).getAddress();
|
||||
editor.putBoolean(from + ".show_images", true);
|
||||
}
|
||||
editor.apply();
|
||||
}
|
||||
properties.setValue("images", message.id, true);
|
||||
onShowImagesConfirmed(message);
|
||||
}
|
||||
})
|
||||
@@ -2406,6 +2412,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
|
||||
private void loadText(TupleMessageEx message, boolean scroll) {
|
||||
if (message.content) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (message.from != null)
|
||||
for (Address address : message.from) {
|
||||
String from = ((InternetAddress) address).getAddress();
|
||||
if (prefs.getBoolean(from + ".show_images", false)) {
|
||||
properties.setValue("images", message.id, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean show_images = properties.getValue("images", message.id);
|
||||
boolean show_quotes = (properties.getValue("quotes", message.id) || !collapse_quotes);
|
||||
|
||||
@@ -3068,8 +3084,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
|
||||
this.contrast = prefs.getBoolean("contrast", false);
|
||||
this.monospaced = prefs.getBoolean("monospaced", false);
|
||||
this.contact_images = (this.contacts && prefs.getBoolean("contact_images", true));
|
||||
this.all_images = prefs.getBoolean("all_images", false);
|
||||
this.collapse_quotes = prefs.getBoolean("collapse_quotes", false);
|
||||
this.authentication = prefs.getBoolean("authentication", true);
|
||||
|
||||
|
||||
@@ -280,20 +280,6 @@ public class ContactInfo {
|
||||
Log.i("Reading email/uri");
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
|
||||
long untrusted = -1;
|
||||
try (Cursor cursor = resolver.query(
|
||||
ContactsContract.Groups.CONTENT_URI,
|
||||
new String[]{ContactsContract.Groups._ID},
|
||||
ContactsContract.Groups.TITLE + " = ? COLLATE NOCASE",
|
||||
new String[]{"untrusted"},
|
||||
null)) {
|
||||
if (cursor != null && cursor.moveToNext())
|
||||
untrusted = cursor.getLong(0);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
}
|
||||
Log.i("Untrusted group=" + untrusted);
|
||||
|
||||
try (Cursor cursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
||||
new String[]{
|
||||
ContactsContract.CommonDataKinds.Photo.CONTACT_ID,
|
||||
@@ -307,24 +293,6 @@ public class ContactInfo {
|
||||
String lookupKey = cursor.getString(1);
|
||||
String email = cursor.getString(2);
|
||||
|
||||
try (Cursor group = resolver.query(
|
||||
ContactsContract.Data.CONTENT_URI,
|
||||
new String[]{ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID},
|
||||
ContactsContract.Data.MIMETYPE + " = ?" +
|
||||
" AND " + ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID + "= ?" +
|
||||
" AND " + ContactsContract.CommonDataKinds.GroupMembership.CONTACT_ID + " = ?",
|
||||
new String[]{
|
||||
ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE,
|
||||
Long.toString(untrusted),
|
||||
Long.toString(contactId)
|
||||
},
|
||||
null)) {
|
||||
if (group != null && group.moveToNext()) {
|
||||
Log.i("Contact email=" + email + " untrusted");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Uri uri = ContactsContract.Contacts.getLookupUri(contactId, lookupKey);
|
||||
all.put(email, uri);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,7 @@ public class FragmentOptions extends FragmentBase {
|
||||
"subscriptions",
|
||||
"startup", "cards", "date", "threading", "highlight_unread", "avatars", "generated_icons", "identicons", "circular",
|
||||
"name_email", "subject_top", "subject_italic", "flags", "preview", "preview_italic",
|
||||
"addresses", "attachments_alt", "contrast", "monospaced", "inline_images",
|
||||
"contact_images", "all_images", "collapse_quotes", "autocontent", "actionbar",
|
||||
"addresses", "attachments_alt", "contrast", "monospaced", "inline_images", "collapse_quotes", "autocontent", "actionbar",
|
||||
"autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",
|
||||
"experiments", "debug",
|
||||
"biometrics"
|
||||
|
||||
@@ -64,8 +64,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
private SwitchCompat swContrast;
|
||||
private SwitchCompat swMonospaced;
|
||||
private SwitchCompat swImagesInline;
|
||||
private SwitchCompat swImagesContacts;
|
||||
private SwitchCompat swImagesAll;
|
||||
private SwitchCompat swCollapseQuotes;
|
||||
private SwitchCompat swRemoteContent;
|
||||
private SwitchCompat swActionbar;
|
||||
@@ -74,7 +72,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
"theme", "startup", "cards", "date", "threading", "highlight_unread",
|
||||
"avatars", "generated_icons", "identicons", "circular", "name_email", "subject_top", "subject_italic",
|
||||
"flags", "preview", "preview_italic", "addresses", "attachments_alt",
|
||||
"contrast", "monospaced", "inline_images", "contact_images", "all_images", "collapse_quotes", "autocontent", "actionbar",
|
||||
"contrast", "monospaced", "inline_images", "collapse_quotes", "autocontent", "actionbar",
|
||||
};
|
||||
|
||||
@Override
|
||||
@@ -108,8 +106,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
swContrast = view.findViewById(R.id.swContrast);
|
||||
swMonospaced = view.findViewById(R.id.swMonospaced);
|
||||
swImagesInline = view.findViewById(R.id.swImagesInline);
|
||||
swImagesContacts = view.findViewById(R.id.swImagesContacts);
|
||||
swImagesAll = view.findViewById(R.id.swImagesAll);
|
||||
swCollapseQuotes = view.findViewById(R.id.swCollapseQuotes);
|
||||
swRemoteContent = view.findViewById(R.id.swRemoteContent);
|
||||
swActionbar = view.findViewById(R.id.swActionbar);
|
||||
@@ -279,20 +275,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
}
|
||||
});
|
||||
|
||||
swImagesContacts.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("contact_images", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swImagesAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("all_images", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swCollapseQuotes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
@@ -388,8 +370,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
swContrast.setChecked(prefs.getBoolean("contrast", false));
|
||||
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
||||
swImagesInline.setChecked(prefs.getBoolean("inline_images", false));
|
||||
swImagesContacts.setChecked(prefs.getBoolean("contact_images", true));
|
||||
swImagesAll.setChecked(prefs.getBoolean("all_images", false));
|
||||
swCollapseQuotes.setChecked(prefs.getBoolean("collapse_quotes", false));
|
||||
swRemoteContent.setChecked(prefs.getBoolean("autocontent", false));
|
||||
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
|
||||
|
||||
@@ -69,7 +69,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
};
|
||||
|
||||
private final static String[] RESET_QUESTIONS = new String[]{
|
||||
"welcome", "show_html_confirmed", "show_images_confirmed", "print_html_confirmed", "edit_ref_confirmed", "crash_reports_asked"
|
||||
"welcome", "show_html_confirmed", "print_html_confirmed", "edit_ref_confirmed", "crash_reports_asked"
|
||||
};
|
||||
|
||||
@Override
|
||||
@@ -225,25 +225,37 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_default:
|
||||
onMenuDefault(RESET_OPTIONS);
|
||||
onMenuDefault();
|
||||
return true;
|
||||
case R.id.menu_reset_questions:
|
||||
onMenuDefault(RESET_QUESTIONS);
|
||||
onMenuResetQuestions();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void onMenuDefault(String[] options) {
|
||||
private void onMenuDefault() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
for (String option : options)
|
||||
for (String option : RESET_OPTIONS)
|
||||
editor.remove(option);
|
||||
editor.apply();
|
||||
ToastEx.makeText(getContext(), R.string.title_setup_done, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void onMenuResetQuestions() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
for (String option : RESET_QUESTIONS)
|
||||
editor.remove(option);
|
||||
for (String key : prefs.getAll().keySet())
|
||||
if (key.endsWith(".show_images"))
|
||||
editor.remove(key);
|
||||
editor.apply();
|
||||
ToastEx.makeText(getContext(), R.string.title_setup_done, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void onCleanup() {
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user