Added option to display name or name/email address

This commit is contained in:
M66B
2019-02-08 08:27:17 +00:00
parent 79102e1ed9
commit 21b7313bf9
5 changed files with 51 additions and 7 deletions

View File

@@ -132,6 +132,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private LifecycleOwner owner;
private ViewType viewType;
private boolean compact;
private boolean name_email;
private int zoom;
private String sort;
private boolean internet;
@@ -699,7 +700,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
else
ivAvatar.setImageResource(R.drawable.baseline_person_24);
ivAvatar.setVisibility(avatars ? View.VISIBLE : View.GONE);
tvFrom.setText(info.getDisplayName(compact));
tvFrom.setText(info.getDisplayName(name_email));
}
private void bindExpanded(final TupleMessageEx message) {
@@ -2465,17 +2466,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
AdapterMessage(Context context, LifecycleOwner owner,
ViewType viewType, boolean compact, int zoom, String sort, IProperties properties) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.context = context;
this.owner = owner;
this.inflater = LayoutInflater.from(context);
this.viewType = viewType;
this.compact = compact;
this.name_email = prefs.getBoolean("name_email", !compact);
this.zoom = zoom;
this.sort = sort;
this.internet = (Helper.isMetered(context, false) != null);
this.properties = properties;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.date = prefs.getBoolean("date", true);
this.threading = prefs.getBoolean("threading", true);
@@ -2530,7 +2533,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
void setCompact(boolean compact) {
if (this.compact != compact) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.compact = compact;
this.name_email = prefs.getBoolean("name_email", !compact);
notifyDataSetChanged();
}
}

View File

@@ -41,8 +41,8 @@ public class ContactInfo {
return bitmap;
}
String getDisplayName(boolean compact) {
if (compact && displayName != null)
String getDisplayName(boolean name_email) {
if (!name_email && displayName != null)
return displayName;
else if (displayName == null)
return (email == null ? "" : email);

View File

@@ -67,6 +67,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private SwitchCompat swThreading;
private SwitchCompat swAvatars;
private SwitchCompat swIdenticons;
private SwitchCompat swNameEmail;
private SwitchCompat swPreview;
private SwitchCompat swAddresses;
private SwitchCompat swHtml;
@@ -93,7 +94,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private Group grpNotification;
static String[] OPTIONS_RESTART = new String[]{
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages", "actionbar",
"unified", "date", "threading", "avatars", "identicons", "name_email", "preview", "addresses", "autoimages", "actionbar",
"pull", "swipenav", "autoexpand", "autoclose", "autonext",
"debug"
};
@@ -101,7 +102,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private final static String[] ADVANCED_OPTIONS = new String[]{
"enabled", "updates",
"metered", "download",
"unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages", "actionbar",
"unified", "date", "threading", "avatars", "identicons", "name_email", "preview", "addresses", "autoimages", "actionbar",
"pull", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove", "sender", "autoresize", "autosend",
"light", "sound",
"debug",
@@ -130,6 +131,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swThreading = view.findViewById(R.id.swThreading);
swAvatars = view.findViewById(R.id.swAvatars);
swIdenticons = view.findViewById(R.id.swIdenticons);
swNameEmail = view.findViewById(R.id.swNameEmail);
swPreview = view.findViewById(R.id.swPreview);
swAddresses = view.findViewById(R.id.swAddresses);
swHtml = view.findViewById(R.id.swHtml);
@@ -258,6 +260,13 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
}
});
swNameEmail.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("name_email", checked).apply();
}
});
swPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -475,11 +484,14 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
break;
}
boolean compact = prefs.getBoolean("compact", false);
swUnified.setChecked(prefs.getBoolean("unified", true));
swDate.setChecked(prefs.getBoolean("date", true));
swThreading.setChecked(prefs.getBoolean("threading", true));
swAvatars.setChecked(prefs.getBoolean("avatars", true));
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
swNameEmail.setChecked(prefs.getBoolean("name_email", !compact));
swPreview.setChecked(prefs.getBoolean("preview", false));
swAddresses.setChecked(prefs.getBoolean("addresses", true));
swHtml.setChecked(prefs.getBoolean("autohtml", false));