mirror of https://github.com/M66B/FairEmail.git
Added letter color treshold setting
This commit is contained in:
parent
0f74e3caeb
commit
2cb077da3b
|
@ -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",
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvThreshold"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="48dp"
|
||||
android:text="@string/title_advanced_color_threshold"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/sbBrightness" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/sbThreshold"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="100"
|
||||
android:min="0"
|
||||
android:progress="50"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvThreshold" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swNameEmail"
|
||||
android:layout_width="0dp"
|
||||
|
@ -271,7 +294,7 @@
|
|||
android:text="@string/title_advanced_name_email"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/sbBrightness"
|
||||
app:layout_constraintTop_toBottomOf="@id/sbThreshold"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -252,6 +252,7 @@
|
|||
<string name="title_advanced_circular">Show round icons</string>
|
||||
<string name="title_advanced_color_saturation">Saturation</string>
|
||||
<string name="title_advanced_color_value">Brightness</string>
|
||||
<string name="title_advanced_color_threshold">Threshold letter color</string>
|
||||
<string name="title_advanced_name_email">Show names and email addresses</string>
|
||||
<string name="title_advanced_authentication">Show a warning when the receiving server could not authenticate the message</string>
|
||||
<string name="title_advanced_subject_top">Show subject above sender</string>
|
||||
|
|
Loading…
Reference in New Issue