fix minor issues with user colors

This commit is contained in:
Helium314 2023-07-22 07:53:14 +02:00
parent 7d9e918c7a
commit b5f3639e9f
3 changed files with 34 additions and 40 deletions

View file

@ -557,7 +557,11 @@ public class KeyboardView extends View {
else
icon.clearColorFilter();
} else if (key.isShift()) {
if (keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED || keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED)
if (keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED
|| keyboard.mId.mElementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED
)
icon.setColorFilter(accentColorFilter);
else
icon.setColorFilter(keyTextColorFilter);

View file

@ -16,6 +16,7 @@
package org.dslul.openboard.inputmethod.latin.settings
import android.app.AlertDialog
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.preference.ListPreference
@ -187,14 +188,14 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
.setPositiveButton(android.R.string.ok, null)
.setTitle(R.string.select_color_to_adjust)
.setItems(itemsArray) { _, i ->
val pref = when (i) {
0 -> Settings.PREF_THEME_USER_COLOR_BACKGROUND
1 -> Settings.PREF_THEME_USER_COLOR_TEXT
2 -> Settings.PREF_THEME_USER_COLOR_HINT_TEXT
3 -> Settings.PREF_THEME_USER_COLOR_ACCENT
else -> Settings.PREF_THEME_USER_COLOR_KEYS
val (pref, default) = when (i) {
0 -> Settings.PREF_THEME_USER_COLOR_BACKGROUND to Color.DKGRAY
1 -> Settings.PREF_THEME_USER_COLOR_TEXT to Color.WHITE
2 -> Settings.PREF_THEME_USER_COLOR_HINT_TEXT to Color.WHITE
3 -> Settings.PREF_THEME_USER_COLOR_ACCENT to Color.BLUE
else -> Settings.PREF_THEME_USER_COLOR_KEYS to Color.LTGRAY
}
val d = ColorPickerDialog(activity, items[i], sharedPreferences, pref) { needsReload = true}
val d = ColorPickerDialog(activity, items[i], sharedPreferences, pref, default) { needsReload = true}
d.show()
}
.show()

View file

@ -19,7 +19,6 @@ package org.dslul.openboard.inputmethod.latin.settings;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.PorterDuff;
@ -30,7 +29,8 @@ import android.widget.TextView;
import org.dslul.openboard.inputmethod.latin.R;
public class ColorPickerDialog extends AlertDialog implements SeekBar.OnSeekBarChangeListener {
protected ColorPickerDialog(Context context, String title, SharedPreferences prefs, String colorPref, Runnable onChanged) {
protected ColorPickerDialog(final Context context, final String title, final SharedPreferences prefs,
final String colorPref, final int defaultColor, Runnable onChanged) {
super(context);
setTitle(title);
View view = getLayoutInflater().inflate(R.layout.color_dialog, null);
@ -54,42 +54,31 @@ public class ColorPickerDialog extends AlertDialog implements SeekBar.OnSeekBarC
// init with correct values
// using onShowListener?
setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
int color = prefs.getInt(colorPref, 0);
mSeekBarRed.setProgress(Color.red(color));
mSeekBarGreen.setProgress(Color.green(color));
mSeekBarBlue.setProgress(Color.blue(color));
setHeaderText(color);
}
setOnShowListener(dialogInterface -> {
int color = prefs.getInt(colorPref, defaultColor);
mSeekBarRed.setProgress(Color.red(color));
mSeekBarGreen.setProgress(Color.green(color));
mSeekBarBlue.setProgress(Color.blue(color));
setHeaderText(color);
});
// set on ok and on cancel listeners
setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel), new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dismiss();
}
});
setButton(BUTTON_POSITIVE, context.getText(android.R.string.ok), new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
final int value = Color.rgb(
mSeekBarRed.getProgress(),
mSeekBarGreen.getProgress(),
mSeekBarBlue.getProgress());
prefs.edit().putInt(colorPref, value).apply();
onChanged.run();
dismiss();
}
setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel), (dialogInterface, i) -> dismiss());
setButton(BUTTON_POSITIVE, context.getText(android.R.string.ok), (dialogInterface, i) -> {
final int value = Color.rgb(
mSeekBarRed.getProgress(),
mSeekBarGreen.getProgress(),
mSeekBarBlue.getProgress());
prefs.edit().putInt(colorPref, value).apply();
onChanged.run();
dismiss();
});
}
private TextView mValueView;
private SeekBar mSeekBarRed;
private SeekBar mSeekBarGreen;
private SeekBar mSeekBarBlue;
private final TextView mValueView;
private final SeekBar mSeekBarRed;
private final SeekBar mSeekBarGreen;
private final SeekBar mSeekBarBlue;
@Override
public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {