Skip to content

Commit

Permalink
final adjustments for now
Browse files Browse the repository at this point in the history
  • Loading branch information
devycarol committed Jul 4, 2024
1 parent e1746cc commit b3be60f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected static final class GesturePreviewTextParams {

public GesturePreviewTextParams(final TypedArray mainKeyboardViewAttr) {
final Colors colors = Settings.getInstance().getCurrent().mColors;
mGesturePreviewDynamic = Settings.getInstance().getCurrent().mGestureFloatingPreviewDynamic;
mGesturePreviewDynamic = Settings.getInstance().getCurrent().mGestureFloatingPreviewDynamicEnabled;
mGesturePreviewTextSize = mainKeyboardViewAttr.getDimensionPixelSize(
R.styleable.MainKeyboardView_gestureFloatingPreviewTextSize, 0);
mGesturePreviewTextColor = colors.get(ColorType.KEY_TEXT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs_screen_gesture);
setupGestureDynamicPreviewPref();
setupGesturePreviewTimeoutPref();
setupGestureTrailFadeoutPref();
setupGestureFastTypingCooldownPref();
setupGestureTrailFadeoutPref();
setupGesturePreviewTimeoutPref();
refreshSettingsEnablement();
}

Expand Down Expand Up @@ -79,39 +79,37 @@ private void setupGestureDynamicPreviewPref() {
});
}

private void setupGesturePreviewTimeoutPref() {
private void setupGestureFastTypingCooldownPref() {
final SeekBarDialogPreference pref = findPreference(
Settings.PREF_GESTURE_FLOATING_PREVIEW_TIMEOUT);
Settings.PREF_GESTURE_FAST_TYPING_COOLDOWN);
if (pref == null) return;
final SharedPreferences prefs = getSharedPreferences();
final Resources res = getResources();
pref.setInterface(new SeekBarDialogPreference.ValueProxy() {
@Override
public void writeValue(final int value, final String key) {
prefs.edit().putInt(key, value).apply();
needsReload = true;
}

@Override
public void writeDefaultValue(final String key) {
prefs.edit().remove(key).apply();
needsReload = true;
}

@Override
public int readValue(final String key) {
return Settings.readGestureFloatingPreviewTimeout(prefs, res);
return Settings.readGestureFastTypingCooldown(prefs, res);
}

@Override
public int readDefaultValue(final String key) {
return Settings.readDefaultGestureFloatingPreviewTimeout(res);
return Settings.readDefaultGestureFastTypingCooldown(res);
}

@Override
public String getValueText(final int value) {
if (value == 0) {
return res.getString(R.string.gesture_floating_preview_timeout_instant);
return res.getString(R.string.gesture_fast_typing_cooldown_instant);
}
return res.getString(R.string.abbreviation_unit_milliseconds, String.valueOf(value));
}
Expand Down Expand Up @@ -162,37 +160,39 @@ public void feedbackValue(final int value) {}
});
}

private void setupGestureFastTypingCooldownPref() {
private void setupGesturePreviewTimeoutPref() {
final SeekBarDialogPreference pref = findPreference(
Settings.PREF_GESTURE_FAST_TYPING_COOLDOWN);
Settings.PREF_GESTURE_FLOATING_PREVIEW_TIMEOUT);
if (pref == null) return;
final SharedPreferences prefs = getSharedPreferences();
final Resources res = getResources();
pref.setInterface(new SeekBarDialogPreference.ValueProxy() {
@Override
public void writeValue(final int value, final String key) {
prefs.edit().putInt(key, value).apply();
needsReload = true;
}

@Override
public void writeDefaultValue(final String key) {
prefs.edit().remove(key).apply();
needsReload = true;
}

@Override
public int readValue(final String key) {
return Settings.readGestureFastTypingCooldown(prefs, res);
return Settings.readGestureFloatingPreviewTimeout(prefs, res);
}

@Override
public int readDefaultValue(final String key) {
return Settings.readDefaultGestureFastTypingCooldown(res);
return Settings.readDefaultGestureFloatingPreviewTimeout(res);
}

@Override
public String getValueText(final int value) {
if (value == 0) {
return res.getString(R.string.gesture_fast_typing_cooldown_instant);
return res.getString(R.string.gesture_floating_preview_timeout_instant);
}
return res.getString(R.string.abbreviation_unit_milliseconds, String.valueOf(value));
}
Expand Down
24 changes: 12 additions & 12 deletions app/src/main/java/helium314/keyboard/latin/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_KEY_LONGPRESS_TIMEOUT = "key_longpress_timeout";
public static final String PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY = "enable_emoji_alt_physical_key";
public static final String PREF_GESTURE_PREVIEW_TRAIL = "gesture_preview_trail";
public static final String PREF_GESTURE_TRAIL_FADEOUT_DURATION = "gesture_trail_fadeout_duration";
public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = "gesture_floating_preview_text";
public static final String PREF_GESTURE_FLOATING_PREVIEW_DYNAMIC = "gesture_floating_preview_dynamic";
public static final String PREF_GESTURE_DYNAMIC_PREVIEW_MANUALLY_SET = "gesture_dynamic_preview_manually_set";
public static final String PREF_GESTURE_FLOATING_PREVIEW_TIMEOUT = "gesture_floating_preview_timeout";
public static final String PREF_GESTURE_SPACE_AWARE = "gesture_space_aware";
public static final String PREF_GESTURE_FAST_TYPING_COOLDOWN = "gesture_fast_typing_cooldown";
public static final String PREF_GESTURE_TRAIL_FADEOUT_DURATION = "gesture_trail_fadeout_duration";
public static final String PREF_GESTURE_FLOATING_PREVIEW_TIMEOUT = "gesture_floating_preview_timeout";
public static final String PREF_SHOW_SETUP_WIZARD_ICON = "show_setup_wizard_icon";
public static final String PREF_USE_CONTACTS = "use_contacts";
public static final String PREFS_LONG_PRESS_SYMBOLS_FOR_NUMPAD = "long_press_symbols_for_numpad";
Expand Down Expand Up @@ -323,15 +323,15 @@ public static boolean readGestureDynamicPreviewEnabled(final SharedPreferences p
: defValue;
}

public static int readGestureFloatingPreviewTimeout(final SharedPreferences prefs, final Resources res) {
public static int readGestureFastTypingCooldown(final SharedPreferences prefs, final Resources res) {
final int milliseconds = prefs.getInt(
PREF_GESTURE_FLOATING_PREVIEW_TIMEOUT, UNDEFINED_PREFERENCE_VALUE_INT);
PREF_GESTURE_FAST_TYPING_COOLDOWN, UNDEFINED_PREFERENCE_VALUE_INT);
return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds
: readDefaultGestureFloatingPreviewTimeout(res);
: readDefaultGestureFastTypingCooldown(res);
}

public static int readDefaultGestureFloatingPreviewTimeout(final Resources res) {
return res.getInteger(R.integer.config_gesture_floating_preview_timeout_default);
public static int readDefaultGestureFastTypingCooldown(final Resources res) {
return res.getInteger(R.integer.config_gesture_static_time_threshold_after_fast_typing);
}

public static int readGestureTrailFadeoutDuration(final SharedPreferences prefs, final Resources res) {
Expand All @@ -345,15 +345,15 @@ public static int readDefaultGestureTrailFadeoutDuration(final Resources res) {
return res.getInteger(R.integer.config_gesture_trail_fadeout_duration_default);
}

public static int readGestureFastTypingCooldown(final SharedPreferences prefs, final Resources res) {
public static int readGestureFloatingPreviewTimeout(final SharedPreferences prefs, final Resources res) {
final int milliseconds = prefs.getInt(
PREF_GESTURE_FAST_TYPING_COOLDOWN, UNDEFINED_PREFERENCE_VALUE_INT);
PREF_GESTURE_FLOATING_PREVIEW_TIMEOUT, UNDEFINED_PREFERENCE_VALUE_INT);
return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds
: readDefaultGestureFastTypingCooldown(res);
: readDefaultGestureFloatingPreviewTimeout(res);
}

public static int readDefaultGestureFastTypingCooldown(final Resources res) {
return res.getInteger(R.integer.config_gesture_static_time_threshold_after_fast_typing);
public static int readDefaultGestureFloatingPreviewTimeout(final Resources res) {
return res.getInteger(R.integer.config_gesture_floating_preview_timeout_default);
}

public static boolean readKeyPreviewPopupEnabled(final SharedPreferences prefs, final Resources res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public class SettingsValues {
public final boolean mCenterSuggestionTextToEnter;
public final boolean mGestureInputEnabled;
public final boolean mGestureTrailEnabled;
public final int mGestureTrailFadeoutDuration;
public final boolean mGestureFloatingPreviewTextEnabled;
public final boolean mGestureFloatingPreviewDynamic;
public final int mGestureFloatingPreviewTimeout;
public final boolean mGestureFloatingPreviewDynamicEnabled;
public final int mGestureFastTypingCooldown;
public final int mGestureTrailFadeoutDuration;
public final int mGestureFloatingPreviewTimeout;
public final boolean mSlidingKeyInputPreviewEnabled;
public final int mKeyLongpressTimeout;
public final boolean mEnableEmojiAltPhysicalKey;
Expand Down Expand Up @@ -202,7 +202,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
mGestureTrailEnabled = prefs.getBoolean(Settings.PREF_GESTURE_PREVIEW_TRAIL, true);
mGestureFloatingPreviewTextEnabled = !mInputAttributes.mDisableGestureFloatingPreviewText
&& prefs.getBoolean(Settings.PREF_GESTURE_FLOATING_PREVIEW_TEXT, true);
mGestureFloatingPreviewDynamic = Settings.readGestureDynamicPreviewEnabled(prefs, context);
mGestureFloatingPreviewDynamicEnabled = Settings.readGestureDynamicPreviewEnabled(prefs, context);
mGestureFastTypingCooldown = Settings.readGestureFastTypingCooldown(prefs, res);
mGestureTrailFadeoutDuration = Settings.readGestureTrailFadeoutDuration(prefs, res);
mGestureFloatingPreviewTimeout = Settings.readGestureFloatingPreviewTimeout(prefs, res);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
<!-- Title of the setting to adjust the gesture floating preview linger timeout [CHAR LIMIT=35]-->
<string name="gesture_floating_preview_timeout">Preview lingering time</string>
<!-- The text that represents no delay [CHAR LIMIT=25]-->
<string name="gesture_floating_preview_timeout_instant">Instant</string>
<string name="gesture_floating_preview_timeout_instant">Dismiss instantly</string>
<!-- Preferences item for enabling clipboard history -->
<string name="enable_clipboard_history">Enable clipboard history</string>
<!-- Description for enabling/disabling clipboard history mentioning that if disabled, clipboard content is pasted -->
Expand Down

0 comments on commit b3be60f

Please sign in to comment.