mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 19:34:15 +01:00
Added option to display name or name/email address
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -268,6 +268,31 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/swAvatars"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swNameEmail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/title_advanced_name_email"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swIdenticons"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvNameEmailHint"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="60dp"
|
||||
android:text="@string/title_advanced_name_email_hint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swNameEmail" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swPreview"
|
||||
android:layout_width="match_parent"
|
||||
@@ -277,7 +302,7 @@
|
||||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/title_advanced_preview"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swIdenticons"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvNameEmailHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
<string name="title_advanced_threading">Conversation threading</string>
|
||||
<string name="title_advanced_avatars">Show contact photos</string>
|
||||
<string name="title_advanced_identicons">Show identicons</string>
|
||||
<string name="title_advanced_name_email">Show names and email addresses</string>
|
||||
<string name="title_advanced_preview">Show message preview</string>
|
||||
<string name="title_advanced_addresses">Show address details by default</string>
|
||||
<string name="title_advanced_html">Automatically show original message for known contacts</string>
|
||||
@@ -180,6 +181,7 @@
|
||||
<string name="title_advanced_browse_hint">Fetch more messages when scrolling down</string>
|
||||
<string name="title_advanced_unified_hint">Show unified inbox folders or unified inbox messages</string>
|
||||
<string name="title_advanced_threading_hint">Group messages related to each other</string>
|
||||
<string name="title_advanced_name_email_hint">When disabled only names will be shown when available</string>
|
||||
<string name="title_advanced_preview_hint">Only available when message text was downloaded</string>
|
||||
<string name="title_advanced_autoexpand_hint">Automatically open message when there is just one message or just one unread message in a conversation</string>
|
||||
<string name="title_advanced_autoclose_hint">Automatically close conversations when all messages are archived, sent or trashed</string>
|
||||
|
||||
Reference in New Issue
Block a user