Add a preference to resize the keyboard height.
The keyboard height is controlled by a slider in the debug preferences. Without access to debug preferences, this change is a no-op. Bug: 6867494 Change-Id: I984064ed1cab752876615f5ed582818474d6041b
This commit is contained in:
parent
80980574ac
commit
bb9400aebc
9 changed files with 91 additions and 1 deletions
|
@ -43,6 +43,10 @@
|
||||||
<string name="prefs_key_popup_dismiss_end_y_scale_settings">Key popup dismiss end Y scale</string>
|
<string name="prefs_key_popup_dismiss_end_y_scale_settings">Key popup dismiss end Y scale</string>
|
||||||
<!-- Title of the settings for reading an external dictionary file -->
|
<!-- Title of the settings for reading an external dictionary file -->
|
||||||
<string name="prefs_read_external_dictionary">Read external dictionary file</string>
|
<string name="prefs_read_external_dictionary">Read external dictionary file</string>
|
||||||
|
<!-- Title of the settings to enable keyboard resizing -->
|
||||||
|
<string name="prefs_resize_keyboard">Enable keyboard resizing</string>
|
||||||
|
<!-- Title of the settings for setting keyboard height -->
|
||||||
|
<string name="prefs_keyboard_height_scale">Keyboard height scale</string>
|
||||||
<!-- Message to show when there are no files to install as an external dictionary [CHAR LIMIT=100] -->
|
<!-- Message to show when there are no files to install as an external dictionary [CHAR LIMIT=100] -->
|
||||||
<string name="read_external_dictionary_no_files_message">No dictionary files in the Downloads folder</string>
|
<string name="read_external_dictionary_no_files_message">No dictionary files in the Downloads folder</string>
|
||||||
<!-- Title of the dialog that selects a file to install as an external dictionary [CHAR LIMIT=50] -->
|
<!-- Title of the dialog that selects a file to install as an external dictionary [CHAR LIMIT=50] -->
|
||||||
|
|
|
@ -76,6 +76,17 @@
|
||||||
android:key="pref_key_preview_dismiss_duration"
|
android:key="pref_key_preview_dismiss_duration"
|
||||||
android:title="@string/prefs_key_popup_dismiss_duration_settings"
|
android:title="@string/prefs_key_popup_dismiss_duration_settings"
|
||||||
latin:maxValue="100" /> <!-- milliseconds -->
|
latin:maxValue="100" /> <!-- milliseconds -->
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="pref_resize_keyboard"
|
||||||
|
android:title="@string/prefs_resize_keyboard"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:persistent="true" />
|
||||||
|
<com.android.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
|
||||||
android:key="read_external_dictionary"
|
android:key="read_external_dictionary"
|
||||||
android:title="@string/prefs_read_external_dictionary" />
|
android:title="@string/prefs_read_external_dictionary" />
|
||||||
|
|
|
@ -110,7 +110,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mThemeContext, editorInfo);
|
mThemeContext, editorInfo);
|
||||||
final Resources res = mThemeContext.getResources();
|
final Resources res = mThemeContext.getResources();
|
||||||
final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
||||||
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
final int keyboardHeight = ResourceUtils.getKeyboardHeight(res, settingsValues);
|
||||||
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
|
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
|
||||||
builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype());
|
builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype());
|
||||||
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
|
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
|
||||||
|
|
|
@ -29,6 +29,8 @@ public final class DebugSettings {
|
||||||
public static final String PREF_FORCE_NON_DISTINCT_MULTITOUCH = "force_non_distinct_multitouch";
|
public static final String PREF_FORCE_NON_DISTINCT_MULTITOUCH = "force_non_distinct_multitouch";
|
||||||
public static final String PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS =
|
public static final String PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS =
|
||||||
"pref_has_custom_key_preview_animation_params";
|
"pref_has_custom_key_preview_animation_params";
|
||||||
|
public static final String PREF_RESIZE_KEYBOARD = "pref_resize_keyboard";
|
||||||
|
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "pref_keyboard_height_scale";
|
||||||
public static final String PREF_KEY_PREVIEW_DISMISS_DURATION =
|
public static final String PREF_KEY_PREVIEW_DISMISS_DURATION =
|
||||||
"pref_key_preview_dismiss_duration";
|
"pref_key_preview_dismiss_duration";
|
||||||
public static final String PREF_KEY_PREVIEW_DISMISS_END_X_SCALE =
|
public static final String PREF_KEY_PREVIEW_DISMISS_END_X_SCALE =
|
||||||
|
|
|
@ -89,6 +89,8 @@ public final class DebugSettingsFragment extends SubScreenFragment
|
||||||
defaultKeyPreviewDismissEndScale);
|
defaultKeyPreviewDismissEndScale);
|
||||||
setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_Y_SCALE,
|
setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_Y_SCALE,
|
||||||
defaultKeyPreviewDismissEndScale);
|
defaultKeyPreviewDismissEndScale);
|
||||||
|
setupKeyboardHeight(
|
||||||
|
DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE);
|
||||||
|
|
||||||
mServiceNeedsRestart = false;
|
mServiceNeedsRestart = false;
|
||||||
mDebugMode = (TwoStatePreference) findPreference(DebugSettings.PREF_DEBUG_MODE);
|
mDebugMode = (TwoStatePreference) findPreference(DebugSettings.PREF_DEBUG_MODE);
|
||||||
|
@ -250,4 +252,51 @@ public final class DebugSettingsFragment extends SubScreenFragment
|
||||||
public void feedbackValue(final int value) {}
|
public void feedbackValue(final int value) {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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, key, 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) {}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,14 @@ public class LocalSettingsConstants {
|
||||||
DebugSettings.PREF_DEBUG_MODE,
|
DebugSettings.PREF_DEBUG_MODE,
|
||||||
DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH,
|
DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH,
|
||||||
DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS,
|
DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS,
|
||||||
|
DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE,
|
||||||
DebugSettings.PREF_KEY_PREVIEW_DISMISS_DURATION,
|
DebugSettings.PREF_KEY_PREVIEW_DISMISS_DURATION,
|
||||||
DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_X_SCALE,
|
DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_X_SCALE,
|
||||||
DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_Y_SCALE,
|
DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_Y_SCALE,
|
||||||
DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_DURATION,
|
DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_DURATION,
|
||||||
DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_START_X_SCALE,
|
DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_START_X_SCALE,
|
||||||
DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_START_Y_SCALE,
|
DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_START_Y_SCALE,
|
||||||
|
DebugSettings.PREF_RESIZE_KEYBOARD,
|
||||||
DebugSettings.PREF_SHOULD_SHOW_LXX_SUGGESTION_UI,
|
DebugSettings.PREF_SHOULD_SHOW_LXX_SUGGESTION_UI,
|
||||||
DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW
|
DebugSettings.PREF_SLIDING_KEY_INPUT_PREVIEW
|
||||||
};
|
};
|
||||||
|
|
|
@ -363,6 +363,12 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds : defaultValue;
|
return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float readKeyboardHeight(final SharedPreferences prefs,
|
||||||
|
final String prefKey, final float defaultValue) {
|
||||||
|
final float percentage = prefs.getFloat(prefKey, UNDEFINED_PREFERENCE_VALUE_FLOAT);
|
||||||
|
return (percentage != UNDEFINED_PREFERENCE_VALUE_FLOAT) ? percentage : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean readUseFullscreenMode(final Resources res) {
|
public static boolean readUseFullscreenMode(final Resources res) {
|
||||||
return res.getBoolean(R.bool.config_use_fullscreen_mode);
|
return res.getBoolean(R.bool.config_use_fullscreen_mode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class SettingsValues {
|
||||||
private static final String FLOAT_MAX_VALUE_MARKER_STRING = "floatMaxValue";
|
private static final String FLOAT_MAX_VALUE_MARKER_STRING = "floatMaxValue";
|
||||||
private static final String FLOAT_NEGATIVE_INFINITY_MARKER_STRING = "floatNegativeInfinity";
|
private static final String FLOAT_NEGATIVE_INFINITY_MARKER_STRING = "floatNegativeInfinity";
|
||||||
private static final int TIMEOUT_TO_GET_TARGET_PACKAGE = 5; // seconds
|
private static final int TIMEOUT_TO_GET_TARGET_PACKAGE = 5; // seconds
|
||||||
|
public static final float DEFAULT_SIZE_SCALE = 1.0f; // 100%
|
||||||
|
|
||||||
// From resources:
|
// From resources:
|
||||||
public final SpacingAndPunctuations mSpacingAndPunctuations;
|
public final SpacingAndPunctuations mSpacingAndPunctuations;
|
||||||
|
@ -110,6 +111,8 @@ public class SettingsValues {
|
||||||
// Debug settings
|
// Debug settings
|
||||||
public final boolean mIsInternal;
|
public final boolean mIsInternal;
|
||||||
public final boolean mHasCustomKeyPreviewAnimationParams;
|
public final boolean mHasCustomKeyPreviewAnimationParams;
|
||||||
|
public final boolean mHasKeyboardResize;
|
||||||
|
public final float mKeyboardHeightScale;
|
||||||
public final int mKeyPreviewShowUpDuration;
|
public final int mKeyPreviewShowUpDuration;
|
||||||
public final int mKeyPreviewDismissDuration;
|
public final int mKeyPreviewDismissDuration;
|
||||||
public final float mKeyPreviewShowUpStartXScale;
|
public final float mKeyPreviewShowUpStartXScale;
|
||||||
|
@ -185,6 +188,9 @@ public class SettingsValues {
|
||||||
mIsInternal = Settings.isInternal(prefs);
|
mIsInternal = Settings.isInternal(prefs);
|
||||||
mHasCustomKeyPreviewAnimationParams = prefs.getBoolean(
|
mHasCustomKeyPreviewAnimationParams = prefs.getBoolean(
|
||||||
DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS, false);
|
DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS, false);
|
||||||
|
mHasKeyboardResize = prefs.getBoolean(DebugSettings.PREF_RESIZE_KEYBOARD, false);
|
||||||
|
mKeyboardHeightScale = Settings.readKeyboardHeight(
|
||||||
|
prefs, DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, DEFAULT_SIZE_SCALE);
|
||||||
mKeyPreviewShowUpDuration = Settings.readKeyPreviewAnimationDuration(
|
mKeyPreviewShowUpDuration = Settings.readKeyPreviewAnimationDuration(
|
||||||
prefs, DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_DURATION,
|
prefs, DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_DURATION,
|
||||||
res.getInteger(R.integer.config_key_preview_show_up_duration));
|
res.getInteger(R.integer.config_key_preview_show_up_duration));
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.util.TypedValue;
|
||||||
|
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -186,6 +187,15 @@ public final class ResourceUtils {
|
||||||
return dm.widthPixels;
|
return dm.widthPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getKeyboardHeight(final Resources res, final SettingsValues settingsValues) {
|
||||||
|
final int defaultKeyboardHeight = getDefaultKeyboardHeight(res);
|
||||||
|
if (settingsValues.mHasKeyboardResize) {
|
||||||
|
// mKeyboardHeightScale Ranges from [.5,1.2], from xml/prefs_screen_debug.xml
|
||||||
|
return (int)(defaultKeyboardHeight * settingsValues.mKeyboardHeightScale);
|
||||||
|
}
|
||||||
|
return defaultKeyboardHeight;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getDefaultKeyboardHeight(final Resources res) {
|
public static int getDefaultKeyboardHeight(final Resources res) {
|
||||||
final DisplayMetrics dm = res.getDisplayMetrics();
|
final DisplayMetrics dm = res.getDisplayMetrics();
|
||||||
final String keyboardHeightInDp = getDeviceOverrideValue(
|
final String keyboardHeightInDp = getDeviceOverrideValue(
|
||||||
|
|
Loading…
Reference in a new issue