diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index d9a2808eed..5772c46acd 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -40,7 +40,7 @@ public class FragmentOptions extends FragmentBase { static String[] OPTIONS_RESTART = new String[]{ "subscriptions", "startup", "cards", "date", "threading", "indentation", "highlight_unread", - "avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", + "avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", "name_email", "distinguish_contacts", "authentication", "subject_top", "subject_italic", "subject_ellipsize", "flags", "flags_background", "preview", "preview_italic", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 99807e73cb..6912278bb6 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -63,6 +63,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private ImageView ivBlue; private SeekBar sbSaturation; private SeekBar sbBrightness; + private SeekBar sbThreshold; private SwitchCompat swNameEmail; private SwitchCompat swDistinguishContacts; private SwitchCompat swAuthentication; @@ -86,7 +87,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private final static String[] RESET_OPTIONS = new String[]{ "theme", "startup", "cards", "date", "threading", "indentation", "highlight_unread", - "avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", + "avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", "name_email", "distinguish_contacts", "authentication", "subject_top", "subject_italic", "subject_ellipsize", "flags", "flags_background", "preview", "preview_italic", "addresses", "attachments_alt", @@ -120,6 +121,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer ivBlue = view.findViewById(R.id.ivBlue); sbSaturation = view.findViewById(R.id.sbSaturation); sbBrightness = view.findViewById(R.id.sbBrightness); + sbThreshold = view.findViewById(R.id.sbThreshold); swNameEmail = view.findViewById(R.id.swNameEmail); swDistinguishContacts = view.findViewById(R.id.swDistinguishContacts); swAuthentication = view.findViewById(R.id.swAuthentication); @@ -217,6 +219,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swIdenticons.setEnabled(checked); sbSaturation.setEnabled(swGeneratedIcons.isChecked()); sbBrightness.setEnabled(swGeneratedIcons.isChecked()); + sbThreshold.setEnabled(swGeneratedIcons.isChecked()); ContactInfo.clearCache(); } }); @@ -276,6 +279,25 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer } }); + sbThreshold.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + prefs.edit().putInt("threshold", progress).apply(); + updateColor(); + ContactInfo.clearCache(); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + // Do nothing + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + // Do nothing + } + }); + swNameEmail.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -482,10 +504,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swIdenticons.setChecked(prefs.getBoolean("identicons", false)); swIdenticons.setEnabled(swGeneratedIcons.isChecked()); swCircular.setChecked(prefs.getBoolean("circular", true)); + sbSaturation.setProgress(prefs.getInt("saturation", 100)); sbSaturation.setEnabled(swGeneratedIcons.isChecked()); sbBrightness.setProgress(prefs.getInt("brightness", 100)); sbBrightness.setEnabled(swGeneratedIcons.isChecked()); + sbThreshold.setProgress(prefs.getInt("threshold", 50)); + sbThreshold.setEnabled(swGeneratedIcons.isChecked()); + swNameEmail.setChecked(prefs.getBoolean("name_email", false)); swDistinguishContacts.setChecked(prefs.getBoolean("distinguish_contacts", false)); swAuthentication.setChecked(prefs.getBoolean("authentication", true)); diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java index 9c2d38ea6c..577275f909 100644 --- a/app/src/main/java/eu/faircode/email/ImageHelper.java +++ b/app/src/main/java/eu/faircode/email/ImageHelper.java @@ -124,6 +124,7 @@ class ImageHelper { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); float s = prefs.getInt("saturation", 100) / 100f; float v = prefs.getInt("brightness", 100) / 100f; + float t = prefs.getInt("threshold", 50) / 100f; int bg = Color.HSVToColor(new float[]{h, s, v}); double lum = ColorUtils.calculateLuminance(bg); @@ -133,7 +134,7 @@ class ImageHelper { canvas.drawColor(bg); Paint paint = new Paint(); - paint.setColor(lum < 0.5 ? Color.WHITE : Color.BLACK); + paint.setColor(lum < t ? Color.WHITE : Color.BLACK); paint.setTextSize(size / 2f); paint.setTypeface(Typeface.DEFAULT_BOLD); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index 98f5f1d236..b5b7eb6e21 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -235,7 +235,7 @@ android:layout_height="wrap_content" android:max="100" android:min="0" - android:progress="50" + android:progress="100" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvSaturation" /> @@ -258,11 +258,34 @@ android:layout_height="wrap_content" android:max="100" android:min="0" - android:progress="50" + android:progress="100" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvBrightness" /> + + + + Show round icons Saturation Brightness + Threshold letter color Show names and email addresses Show a warning when the receiving server could not authenticate the message Show subject above sender