mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-23 17:40:54 +00:00
Add preference for custom keyboard height
This commit is contained in:
parent
f19e7dfe14
commit
85b5b3c309
4 changed files with 66 additions and 2 deletions
|
@ -16,12 +16,15 @@
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.latin.settings;
|
package org.dslul.openboard.inputmethod.latin.settings;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.R;
|
import org.dslul.openboard.inputmethod.latin.R;
|
||||||
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
import org.dslul.openboard.inputmethod.latin.common.Constants;
|
||||||
import org.dslul.openboard.inputmethod.latin.define.ProductionFlags;
|
import org.dslul.openboard.inputmethod.latin.define.ProductionFlags;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Appearance" settings sub screen.
|
* "Appearance" settings sub screen.
|
||||||
*/
|
*/
|
||||||
|
@ -34,6 +37,8 @@ public final class AppearanceSettingsFragment extends SubScreenFragment {
|
||||||
Constants.isPhone(Settings.readScreenMetrics(getResources()))) {
|
Constants.isPhone(Settings.readScreenMetrics(getResources()))) {
|
||||||
removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD);
|
removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD);
|
||||||
}
|
}
|
||||||
|
setupKeyboardHeight(
|
||||||
|
Settings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,4 +48,50 @@ public final class AppearanceSettingsFragment extends SubScreenFragment {
|
||||||
findPreference(Settings.PREF_CUSTOM_INPUT_STYLES));
|
findPreference(Settings.PREF_CUSTOM_INPUT_STYLES));
|
||||||
ThemeSettingsFragment.updateKeyboardThemeSummary(findPreference(Settings.SCREEN_THEME));
|
ThemeSettingsFragment.updateKeyboardThemeSummary(findPreference(Settings.SCREEN_THEME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupKeyboardHeight(final String prefKey, final float defaultValue) {
|
||||||
|
final SharedPreferences prefs = getSharedPreferences();
|
||||||
|
final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(prefKey);
|
||||||
|
if (pref == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pref.setInterface(new SeekBarDialogPreference.ValueProxy() {
|
||||||
|
private static final float PERCENTAGE_FLOAT = 100.0f;
|
||||||
|
private float getValueFromPercentage(final int percentage) {
|
||||||
|
return percentage / PERCENTAGE_FLOAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getPercentageFromValue(final float floatValue) {
|
||||||
|
return (int)(floatValue * PERCENTAGE_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeValue(final int value, final String key) {
|
||||||
|
prefs.edit().putFloat(key, getValueFromPercentage(value)).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeDefaultValue(final String key) {
|
||||||
|
prefs.edit().remove(key).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int readValue(final String key) {
|
||||||
|
return getPercentageFromValue(Settings.readKeyboardHeight(prefs, defaultValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int readDefaultValue(final String key) {
|
||||||
|
return getPercentageFromValue(defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValueText(final int value) {
|
||||||
|
return String.format(Locale.ROOT, "%d%%", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void feedbackValue(final int value) {}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
"pref_include_other_imes_in_language_switch_list";
|
"pref_include_other_imes_in_language_switch_list";
|
||||||
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
|
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
|
||||||
public static final String PREF_ENABLE_SPLIT_KEYBOARD = "pref_split_keyboard";
|
public static final String PREF_ENABLE_SPLIT_KEYBOARD = "pref_split_keyboard";
|
||||||
|
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "pref_keyboard_height_scale";
|
||||||
// TODO: consolidate key preview dismiss delay with the key preview animation parameters.
|
// TODO: consolidate key preview dismiss delay with the key preview animation parameters.
|
||||||
public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY =
|
public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY =
|
||||||
"pref_key_preview_popup_dismiss_delay";
|
"pref_key_preview_popup_dismiss_delay";
|
||||||
|
@ -350,7 +351,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
public static float readKeyboardHeight(final SharedPreferences prefs,
|
public static float readKeyboardHeight(final SharedPreferences prefs,
|
||||||
final float defaultValue) {
|
final float defaultValue) {
|
||||||
final float percentage = prefs.getFloat(
|
final float percentage = prefs.getFloat(
|
||||||
DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, UNDEFINED_PREFERENCE_VALUE_FLOAT);
|
Settings.PREF_KEYBOARD_HEIGHT_SCALE, UNDEFINED_PREFERENCE_VALUE_FLOAT);
|
||||||
return (percentage != UNDEFINED_PREFERENCE_VALUE_FLOAT) ? percentage : defaultValue;
|
return (percentage != UNDEFINED_PREFERENCE_VALUE_FLOAT) ? percentage : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@
|
||||||
|
|
||||||
<!-- Common key top visual configuration. -->
|
<!-- Common key top visual configuration. -->
|
||||||
<dimen name="config_key_popup_hint_letter_padding">2dp</dimen>
|
<dimen name="config_key_popup_hint_letter_padding">2dp</dimen>
|
||||||
|
z
|
||||||
<!-- Common suggestion strip configuration. -->
|
<!-- Common suggestion strip configuration. -->
|
||||||
<integer name="config_suggestions_count_in_strip">3</integer>
|
<integer name="config_suggestions_count_in_strip">3</integer>
|
||||||
<fraction name="config_center_suggestion_percentile">36%</fraction>
|
<fraction name="config_center_suggestion_percentile">36%</fraction>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:latin="http://schemas.android.com/apk/res/org.dslul.openboard.inputmethod.latin"
|
||||||
android:key="screen_appearance"
|
android:key="screen_appearance"
|
||||||
android:title="@string/settings_screen_appearance">
|
android:title="@string/settings_screen_appearance">
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
|
@ -31,4 +32,15 @@
|
||||||
android:title="@string/enable_split_keyboard"
|
android:title="@string/enable_split_keyboard"
|
||||||
android:persistent="true"
|
android:persistent="true"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="pref_resize_keyboard"
|
||||||
|
android:title="@string/prefs_resize_keyboard"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:persistent="true" />
|
||||||
|
<org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference
|
||||||
|
android:dependency="pref_resize_keyboard"
|
||||||
|
android:key="pref_keyboard_height_scale"
|
||||||
|
android:title="@string/prefs_keyboard_height_scale"
|
||||||
|
latin:minValue="50"
|
||||||
|
latin:maxValue="120" /> <!-- percentage -->
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue