mirror of https://github.com/M66B/FairEmail.git
Added option to show round avatars
This commit is contained in:
parent
2a4ff4b49d
commit
d643f1cc48
|
@ -35,6 +35,7 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
|
@ -81,6 +82,8 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
|
||||
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
@ -144,6 +147,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private boolean contacts;
|
||||
private boolean search;
|
||||
private boolean avatars;
|
||||
private boolean circular;
|
||||
private boolean flags;
|
||||
private boolean preview;
|
||||
private boolean autohtml;
|
||||
|
@ -730,9 +734,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
private void bindContactInfo(ContactInfo info, TupleMessageEx message) {
|
||||
if (info.hasPhoto())
|
||||
ivAvatar.setImageBitmap(info.getPhotoBitmap());
|
||||
else
|
||||
if (info.hasPhoto()) {
|
||||
Bitmap bm = info.getPhotoBitmap();
|
||||
if (circular) {
|
||||
RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(context.getResources(), bm);
|
||||
d.setCircular(true);
|
||||
ivAvatar.setImageDrawable(d);
|
||||
} else
|
||||
ivAvatar.setImageBitmap(info.getPhotoBitmap());
|
||||
} else
|
||||
ivAvatar.setImageResource(R.drawable.baseline_person_24);
|
||||
ivAvatar.setVisibility(avatars ? View.VISIBLE : View.GONE);
|
||||
tvFrom.setText(info.getDisplayName(name_email));
|
||||
|
@ -3070,6 +3080,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
||||
this.avatars = (prefs.getBoolean("avatars", true) ||
|
||||
prefs.getBoolean("identicons", false));
|
||||
this.circular = prefs.getBoolean("circular", false);
|
||||
this.flags = prefs.getBoolean("flags", true);
|
||||
this.preview = prefs.getBoolean("preview", false);
|
||||
this.autohtml = prefs.getBoolean("autohtml", false);
|
||||
|
|
|
@ -78,6 +78,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
|||
private SwitchCompat swThreading;
|
||||
private SwitchCompat swAvatars;
|
||||
private SwitchCompat swIdenticons;
|
||||
private SwitchCompat swCircular;
|
||||
private SwitchCompat swNameEmail;
|
||||
private SwitchCompat swSubjectItalic;
|
||||
private SwitchCompat swFlags;
|
||||
|
@ -119,7 +120,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
|||
private Group grpNotification;
|
||||
|
||||
static String[] OPTIONS_RESTART = new String[]{
|
||||
"startup", "date", "threading", "avatars", "identicons", "name_email", "subject_italic", "flags", "preview",
|
||||
"startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic", "flags", "preview",
|
||||
"addresses", "monospaced", "autohtml", "autoimages", "actionbar",
|
||||
"pull", "swipenav", "autoexpand", "autoclose", "autonext",
|
||||
"authentication", "debug"
|
||||
|
@ -128,7 +129,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
|||
private final static String[] ADVANCED_OPTIONS = new String[]{
|
||||
"enabled", "schedule_start", "schedule_end",
|
||||
"metered", "download", "roaming",
|
||||
"startup", "date", "threading", "avatars", "identicons", "name_email", "subject_italic", "flags", "preview",
|
||||
"startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic", "flags", "preview",
|
||||
"addresses", "monospaced", "autohtml", "autoimages", "actionbar",
|
||||
"pull", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove",
|
||||
"autoresize", "resize", "prefix_once", "autosend",
|
||||
|
@ -163,6 +164,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);
|
||||
swCircular = view.findViewById(R.id.swCircular);
|
||||
swNameEmail = view.findViewById(R.id.swNameEmail);
|
||||
swSubjectItalic = view.findViewById(R.id.swSubjectItalic);
|
||||
swFlags = view.findViewById(R.id.swFlags);
|
||||
|
@ -334,6 +336,13 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
|||
}
|
||||
});
|
||||
|
||||
swCircular.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("circular", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swNameEmail.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -678,6 +687,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
|
|||
swThreading.setChecked(prefs.getBoolean("threading", true));
|
||||
swAvatars.setChecked(prefs.getBoolean("avatars", true));
|
||||
swIdenticons.setChecked(prefs.getBoolean("identicons", false));
|
||||
swCircular.setChecked(prefs.getBoolean("circular", false));
|
||||
swNameEmail.setChecked(prefs.getBoolean("name_email", !compact));
|
||||
swSubjectItalic.setChecked(prefs.getBoolean("subject_italic", true));
|
||||
swFlags.setChecked(prefs.getBoolean("flags", true));
|
||||
|
|
|
@ -348,6 +348,18 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swAvatars"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swCircular"
|
||||
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_circular"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swIdenticons"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swNameEmail"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -357,7 +369,7 @@
|
|||
android:layout_marginEnd="12dp"
|
||||
android:text="@string/title_advanced_name_email"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swIdenticons"
|
||||
app:layout_constraintTop_toBottomOf="@id/swCircular"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -168,6 +168,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_circular">Show round icons</string>
|
||||
<string name="title_advanced_name_email">Show names and email addresses</string>
|
||||
<string name="title_advanced_subject_italic">Show subject italic</string>
|
||||
<string name="title_advanced_flags">Show stars (favorites)</string>
|
||||
|
|
Loading…
Reference in New Issue