From a5d4cb7769dce162c35573a806533af585063a82 Mon Sep 17 00:00:00 2001 From: Jatin Matani Date: Wed, 10 Sep 2014 10:25:43 +0900 Subject: [PATCH] Add a user preference for split layout within Appearance & Layouts Note The preference is flag protected. Change-Id: I1be219ba961f002897b7b13ff9f200e2f142b2d8 --- java/res/values/strings.xml | 3 +++ java/res/xml/prefs_screen_appearance.xml | 5 +++++ .../latin/settings/AppearanceSettingsFragment.java | 7 ++++++- .../android/inputmethod/latin/settings/Settings.java | 1 + .../inputmethod/latin/settings/SettingsValues.java | 12 ++++++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index e5341f67a..73fb7bd7a 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -51,6 +51,9 @@ Theme + + Enable split keyboard + Switch to other input methods diff --git a/java/res/xml/prefs_screen_appearance.xml b/java/res/xml/prefs_screen_appearance.xml index 7719c058b..036b66553 100644 --- a/java/res/xml/prefs_screen_appearance.xml +++ b/java/res/xml/prefs_screen_appearance.xml @@ -26,4 +26,9 @@ android:fragment="com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment" android:key="custom_input_styles" android:title="@string/custom_input_styles_title" /> + diff --git a/java/src/com/android/inputmethod/latin/settings/AppearanceSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/AppearanceSettingsFragment.java index f5e4d33a2..a9884ba13 100644 --- a/java/src/com/android/inputmethod/latin/settings/AppearanceSettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/settings/AppearanceSettingsFragment.java @@ -19,6 +19,7 @@ package com.android.inputmethod.latin.settings; import android.os.Bundle; import com.android.inputmethod.latin.R; +import com.android.inputmethod.latin.define.ProductionFlags; /** @@ -29,6 +30,10 @@ public final class AppearanceSettingsFragment extends SubScreenFragment { public void onCreate(final Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.prefs_screen_appearance); + if (!ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED + || !Settings.getInstance().getCurrent().isTablet()) { + removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD); + } } @Override @@ -38,4 +43,4 @@ public final class AppearanceSettingsFragment extends SubScreenFragment { findPreference(Settings.PREF_CUSTOM_INPUT_STYLES)); ThemeSettingsFragment.updateKeyboardThemeSummary(findPreference(Settings.SCREEN_THEME)); } -} +} \ No newline at end of file diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 0de2d8831..529f8a093 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -83,6 +83,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang "pref_include_other_imes_in_language_switch_list"; public static final String PREF_KEYBOARD_THEME = "pref_keyboard_theme"; public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles"; + public static final String PREF_ENABLE_SPLIT_KEYBOARD = "pref_split_keyboard"; // TODO: consolidate key preview dismiss delay with the key preview animation parameters. public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY = "pref_key_preview_popup_dismiss_delay"; diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java index 270b22a4a..57610221c 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java @@ -25,6 +25,7 @@ import android.util.Log; import android.view.inputmethod.EditorInfo; import com.android.inputmethod.compat.AppWorkaroundsUtils; +import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.InputAttributes; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.RichInputMethodManager; @@ -79,6 +80,9 @@ public class SettingsValues { public final int mKeyLongpressTimeout; public final boolean mEnableMetricsLogging; public final boolean mShouldShowUiToAcceptTypedWord; + // Use split layout for keyboard. + public final boolean mIsSplitKeyboardEnabled; + public final int mScreenMetrics; // From the input box public final InputAttributes mInputAttributes; @@ -157,6 +161,9 @@ public class SettingsValues { mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout); mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration()); mEnableMetricsLogging = prefs.getBoolean(Settings.PREF_ENABLE_METRICS_LOGGING, true); + mIsSplitKeyboardEnabled = prefs.getBoolean(Settings.PREF_ENABLE_SPLIT_KEYBOARD, false); + mScreenMetrics = res.getInteger(R.integer.config_screen_metrics); + mShouldShowUiToAcceptTypedWord = Settings.HAS_UI_TO_ACCEPT_TYPED_WORD && prefs.getBoolean(DebugSettings.PREF_SHOW_UI_TO_ACCEPT_TYPED_WORD, true); // Compute other readable settings @@ -225,6 +232,11 @@ public class SettingsValues { return mEnableMetricsLogging; } + public boolean isTablet() { + return mScreenMetrics == Constants.SCREEN_METRICS_SMALL_TABLET + || mScreenMetrics == Constants.SCREEN_METRICS_LARGE_TABLET; + } + public boolean isApplicationSpecifiedCompletionsOn() { return mInputAttributes.mApplicationSpecifiedCompletionOn; }