Added option to disabled generated icons

This commit is contained in:
M66B
2019-07-22 10:40:03 +02:00
parent bc6555210f
commit 226964e9fc
6 changed files with 42 additions and 16 deletions

View File

@@ -173,7 +173,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean date;
private boolean threading;
private boolean avatars;
private boolean name_email;
private boolean subject_italic;
private boolean flags;
@@ -743,7 +742,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected void onPreExecute(Bundle args) {
Address[] addresses = (Address[]) args.getSerializable("addresses");
ivAvatar.setVisibility(avatars ? View.INVISIBLE : View.GONE);
ivAvatar.setVisibility(View.GONE);
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
}
@@ -869,11 +868,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void bindContactInfo(ContactInfo info, TupleMessageEx message) {
if (info.hasPhoto())
if (info.hasPhoto()) {
ivAvatar.setImageBitmap(info.getPhotoBitmap());
else
ivAvatar.setImageResource(R.drawable.baseline_person_24);
ivAvatar.setVisibility(avatars ? View.VISIBLE : View.GONE);
ivAvatar.setVisibility(View.VISIBLE);
} else
ivAvatar.setVisibility(View.GONE);
tvFrom.setText(info.getDisplayName(name_email));
}
@@ -2941,8 +2940,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.date = prefs.getBoolean("date", true);
this.threading = prefs.getBoolean("threading", true);
this.avatars = (prefs.getBoolean("avatars", true) ||
prefs.getBoolean("identicons", false));
this.name_email = prefs.getBoolean("name_email", !compact);
this.subject_italic = prefs.getBoolean("subject_italic", true);
this.flags = prefs.getBoolean("flags", true);

View File

@@ -159,11 +159,14 @@ public class ContactInfo {
if (info.bitmap == null) {
int dp = Helper.dp2pixels(context, 48);
boolean dark = Helper.isDarkTheme(context);
boolean identicons = prefs.getBoolean("identicons", false);
if (identicons)
info.bitmap = Identicon.icon(key, dp, 5, dark);
else
info.bitmap = Identicon.letter(key, dp, dark);
boolean generated = prefs.getBoolean("generated_icons", true);
if (generated) {
boolean identicons = prefs.getBoolean("identicons", false);
if (identicons)
info.bitmap = Identicon.icon(key, dp, 5, dark);
else
info.bitmap = Identicon.letter(key, dp, dark);
}
}
boolean circular = prefs.getBoolean("circular", true);

View File

@@ -38,7 +38,7 @@ public class FragmentOptions extends FragmentBase {
private PagerAdapter adapter;
static String[] OPTIONS_RESTART = new String[]{
"startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic", "flags", "preview",
"startup", "date", "threading", "avatars", "generated_icons", "identicons", "circular", "name_email", "subject_italic", "flags", "preview",
"addresses", "attachments_alt", "contrast", "monospaced", "autohtml", "autoimages", "actionbar",
"autoscroll", "swipenav", "autoexpand", "autoclose", "autonext",
"subscriptions", "debug",

View File

@@ -47,6 +47,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swDate;
private SwitchCompat swThreading;
private SwitchCompat swAvatars;
private SwitchCompat swGeneratedIcons;
private SwitchCompat swIdenticons;
private SwitchCompat swCircular;
private SwitchCompat swNameEmail;
@@ -65,7 +66,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swActionbar;
private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic",
"theme", "startup", "date", "threading", "avatars", "generated_icons", "identicons", "circular", "name_email", "subject_italic",
"flags", "preview", "addresses", "attachments_alt",
"contrast", "monospaced", "inline_images", "autoimages", "collapse_quotes", "autocontent", "actionbar",
};
@@ -85,6 +86,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDate = view.findViewById(R.id.swDate);
swThreading = view.findViewById(R.id.swThreading);
swAvatars = view.findViewById(R.id.swAvatars);
swGeneratedIcons = view.findViewById(R.id.swGeneratedIcons);
swIdenticons = view.findViewById(R.id.swIdenticons);
swCircular = view.findViewById(R.id.swCircular);
swNameEmail = view.findViewById(R.id.swNameEmail);
@@ -149,6 +151,15 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swGeneratedIcons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("generated_icons", checked).apply();
swIdenticons.setEnabled(checked);
ContactInfo.clearCache();
}
});
swIdenticons.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -314,7 +325,9 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDate.setChecked(prefs.getBoolean("date", true));
swThreading.setChecked(prefs.getBoolean("threading", true));
swAvatars.setChecked(prefs.getBoolean("avatars", true));
swGeneratedIcons.setChecked(prefs.getBoolean("generated_icons", true));
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
swIdenticons.setEnabled(swGeneratedIcons.isChecked());
swCircular.setChecked(prefs.getBoolean("circular", true));
swNameEmail.setChecked(prefs.getBoolean("name_email", !compact));
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));