Added option to disabled generated icons

pull/159/head
M66B 6 years ago
parent bc6555210f
commit 226964e9fc

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

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

@ -38,7 +38,7 @@ public class FragmentOptions extends FragmentBase {
private PagerAdapter adapter; private PagerAdapter adapter;
static String[] OPTIONS_RESTART = new String[]{ 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", "addresses", "attachments_alt", "contrast", "monospaced", "autohtml", "autoimages", "actionbar",
"autoscroll", "swipenav", "autoexpand", "autoclose", "autonext", "autoscroll", "swipenav", "autoexpand", "autoclose", "autonext",
"subscriptions", "debug", "subscriptions", "debug",

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

@ -98,6 +98,18 @@
app:layout_constraintTop_toBottomOf="@id/tvThreadingHint" app:layout_constraintTop_toBottomOf="@id/tvThreadingHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swGeneratedIcons"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_generated_icons"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAvatars"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swIdenticons" android:id="@+id/swIdenticons"
android:layout_width="0dp" android:layout_width="0dp"
@ -106,7 +118,7 @@
android:text="@string/title_advanced_identicons" android:text="@string/title_advanced_identicons"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAvatars" app:layout_constraintTop_toBottomOf="@id/swGeneratedIcons"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -209,6 +209,7 @@
<string name="title_advanced_date_header">Group by date</string> <string name="title_advanced_date_header">Group by date</string>
<string name="title_advanced_threading">Conversation threading</string> <string name="title_advanced_threading">Conversation threading</string>
<string name="title_advanced_avatars">Show contact photos</string> <string name="title_advanced_avatars">Show contact photos</string>
<string name="title_advanced_generated_icons">Show generated icons</string>
<string name="title_advanced_identicons">Show identicons</string> <string name="title_advanced_identicons">Show identicons</string>
<string name="title_advanced_circular">Show round icons</string> <string name="title_advanced_circular">Show round icons</string>
<string name="title_advanced_name_email">Show names and email addresses</string> <string name="title_advanced_name_email">Show names and email addresses</string>

Loading…
Cancel
Save