aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java39
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java168
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java47
-rw-r--r--java/src/com/android/inputmethod/latin/settings/Settings.java23
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsFragment.java21
5 files changed, 234 insertions, 64 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index a6b293f2f..5abc9ab38 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -44,8 +44,6 @@ import com.android.inputmethod.latin.utils.ResourceUtils;
public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private static final String TAG = KeyboardSwitcher.class.getSimpleName();
- public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916";
-
static final class KeyboardTheme {
public final int mThemeId;
public final int mStyleId;
@@ -58,13 +56,14 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
}
}
- private static final int INDEX_THEME_ICS = 0;
- private static final int INDEX_THEME_GB = 1;
- private static final int INDEX_THEME_KLP = 2;
- private static final KeyboardTheme[] KEYBOARD_THEMES = {
- new KeyboardTheme(INDEX_THEME_ICS, R.style.KeyboardTheme_ICS),
- new KeyboardTheme(INDEX_THEME_GB, R.style.KeyboardTheme_GB),
- new KeyboardTheme(INDEX_THEME_KLP, R.style.KeyboardTheme_KLP),
+ public static final int THEME_INDEX_ICS = 0;
+ public static final int THEME_INDEX_GB = 1;
+ public static final int THEME_INDEX_KLP = 2;
+ public static final int THEME_INDEX_DEFAULT = THEME_INDEX_KLP;
+ public static final KeyboardTheme[] KEYBOARD_THEMES = {
+ new KeyboardTheme(THEME_INDEX_ICS, R.style.KeyboardTheme_ICS),
+ new KeyboardTheme(THEME_INDEX_GB, R.style.KeyboardTheme_GB),
+ new KeyboardTheme(THEME_INDEX_KLP, R.style.KeyboardTheme_KLP),
};
private SubtypeSwitcher mSubtypeSwitcher;
@@ -86,7 +85,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
* what user actually typed. */
private boolean mIsAutoCorrectionActive;
- private KeyboardTheme mKeyboardTheme = KEYBOARD_THEMES[INDEX_THEME_KLP];
+ private KeyboardTheme mKeyboardTheme = KEYBOARD_THEMES[THEME_INDEX_DEFAULT];
private Context mThemeContext;
private static final KeyboardSwitcher sInstance = new KeyboardSwitcher();
@@ -124,19 +123,15 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private static KeyboardTheme getKeyboardTheme(final Context context,
final SharedPreferences prefs) {
- final String defaultIndex = context.getString(R.string.config_default_keyboard_theme_index);
- final String themeIndex = prefs.getString(PREF_KEYBOARD_LAYOUT, defaultIndex);
- try {
- final int index = Integer.valueOf(themeIndex);
- if (index >= 0 && index < KEYBOARD_THEMES.length) {
- return KEYBOARD_THEMES[index];
- }
- } catch (NumberFormatException e) {
- // Format error, keyboard theme is default to 0.
+ final Resources res = context.getResources();
+ final int index = Settings.readKeyboardThemeIndex(prefs, res);
+ if (index >= 0 && index < KEYBOARD_THEMES.length) {
+ return KEYBOARD_THEMES[index];
}
- Log.w(TAG, "Illegal keyboard theme in preference: " + themeIndex + ", default to "
- + defaultIndex);
- return KEYBOARD_THEMES[Integer.valueOf(defaultIndex)];
+ final int defaultThemeIndex = Settings.resetAndGetDefaultKeyboardThemeIndex(prefs, res);
+ Log.w(TAG, "Illegal keyboard theme in preference: " + index + ", default to "
+ + defaultThemeIndex);
+ return KEYBOARD_THEMES[defaultThemeIndex];
}
private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context,
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 5ade70793..0fe245561 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -16,7 +16,10 @@
package com.android.inputmethod.keyboard;
+import android.animation.Animator;
import android.animation.AnimatorInflater;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.SharedPreferences;
@@ -40,6 +43,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodSubtype;
import android.widget.TextView;
@@ -157,6 +162,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private final SlidingKeyInputPreview mSlidingKeyInputPreview;
// Key preview
+ private static final boolean FADE_OUT_KEY_TOP_LETTER_WHEN_KEY_IS_PRESSED = false;
private final int mKeyPreviewLayoutId;
private final int mKeyPreviewOffset;
private final int mKeyPreviewHeight;
@@ -167,6 +173,15 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private final KeyPreviewDrawParams mKeyPreviewDrawParams = new KeyPreviewDrawParams();
private boolean mShowKeyPreviewPopup = true;
private int mKeyPreviewLingerTimeout;
+ private int mKeyPreviewZoomInDuration;
+ private int mKeyPreviewZoomOutDuration;
+ private static final float KEY_PREVIEW_START_ZOOM_IN_SCALE = 0.7f;
+ private static final float KEY_PREVIEW_END_ZOOM_IN_SCALE = 1.0f;
+ private static final float KEY_PREVIEW_END_ZOOM_OUT_SCALE = 0.7f;
+ private static final AccelerateInterpolator ACCELERATE_INTERPOLATOR =
+ new AccelerateInterpolator();
+ private static final DecelerateInterpolator DECELERATE_INTERPOLATOR =
+ new DecelerateInterpolator();
// More keys keyboard
private final Paint mBackgroundDimAlphaPaint = new Paint();
@@ -388,17 +403,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
if (mainKeyboardView == null) return;
switch (msg.what) {
case MSG_DISMISS_KEY_PREVIEW:
- final Key key = (Key)msg.obj;
- if (key != null) {
- final TextView previewTextView =
- mainKeyboardView.mShowingKeyPreviewTextViews.remove(key);
- if (previewTextView != null) {
- previewTextView.setVisibility(INVISIBLE);
- mainKeyboardView.mFreeKeyPreviewTextViews.add(previewTextView);
- }
- // To redraw key top letter.
- mainKeyboardView.invalidateKey(key);
- }
+ mainKeyboardView.dismissKeyPreviewWithoutDelay((Key)msg.obj);
break;
case MSG_DISMISS_GESTURE_FLOATING_PREVIEW_TEXT:
mainKeyboardView.showGestureFloatingPreviewText(SuggestedWords.EMPTY);
@@ -412,6 +417,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private void cancelAllDismissKeyPreviews() {
removeMessages(MSG_DISMISS_KEY_PREVIEW);
+ final MainKeyboardView mainKeyboardView = getOuterInstance();
+ if (mainKeyboardView == null) return;
+ mainKeyboardView.dismissAllKeyPreviews();
}
public void dismissGestureFloatingPreviewText(final long delay) {
@@ -486,6 +494,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
if (mKeyPreviewLayoutId == 0) {
mShowKeyPreviewPopup = false;
}
+ mKeyPreviewZoomInDuration = mainKeyboardViewAttr.getInt(
+ R.styleable.MainKeyboardView_keyPreviewZoomInDuration, 0);
+ mKeyPreviewZoomOutDuration = mainKeyboardViewAttr.getInt(
+ R.styleable.MainKeyboardView_keyPreviewZoomOutDuration, 0);
final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
@@ -711,11 +723,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private void dismissAllKeyPreviews() {
for (final Key key : new HashSet<Key>(mShowingKeyPreviewTextViews.keySet())) {
- final TextView previewTextView = mShowingKeyPreviewTextViews.remove(key);
- if (previewTextView != null) {
- previewTextView.setVisibility(INVISIBLE);
- mFreeKeyPreviewTextViews.add(previewTextView);
- }
+ dismissKeyPreviewWithoutDelay(key);
}
PointerTracker.setReleasedKeyGraphicsToAllKeys();
}
@@ -741,6 +749,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private static final int STATE_NORMAL = 0;
private static final int STATE_HAS_MOREKEYS = 1;
+ // TODO: Take this method out of this class.
@Override
public void showKeyPreview(final Key key) {
// If key is invalid or IME is already closed, we must not show key preview.
@@ -818,13 +827,129 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
}
ViewLayoutUtils.placeViewAt(
previewTextView, previewX, previewY, previewWidth, previewHeight);
- previewTextView.setVisibility(VISIBLE);
- mShowingKeyPreviewTextViews.put(key, previewTextView);
+
+ if (!isHardwareAccelerated()) {
+ previewTextView.setVisibility(VISIBLE);
+ mShowingKeyPreviewTextViews.put(key, previewTextView);
+ return;
+ }
+ previewTextView.setPivotX(previewWidth / 2.0f);
+ previewTextView.setPivotY(previewHeight);
+
+ final Animator zoomIn = createZoomInAniation(key, previewTextView);
+ final Animator zoomOut = createZoomOutAnimation(key, previewTextView);
+ final KeyPreviewAnimations animation = new KeyPreviewAnimations(zoomIn, zoomOut);
+ previewTextView.setTag(animation);
+ animation.startZoomIn();
+ }
+
+ // TODO: Move this internal class out to a separate external class.
+ private static class KeyPreviewAnimations extends AnimatorListenerAdapter {
+ private final Animator mZoomIn;
+ private final Animator mZoomOut;
+
+ public KeyPreviewAnimations(final Animator zoomIn, final Animator zoomOut) {
+ mZoomIn = zoomIn;
+ mZoomOut = zoomOut;
+ }
+
+ public void startZoomIn() {
+ mZoomIn.start();
+ }
+
+ public void startZoomOut() {
+ if (mZoomIn.isRunning()) {
+ mZoomIn.addListener(this);
+ return;
+ }
+ mZoomOut.start();
+ }
+
+ @Override
+ public void onAnimationEnd(final Animator animation) {
+ mZoomOut.start();
+ }
+ }
+
+ // TODO: Take this method out of this class.
+ private Animator createZoomInAniation(final Key key, final TextView previewTextView) {
+ final ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(
+ previewTextView, SCALE_X, KEY_PREVIEW_START_ZOOM_IN_SCALE,
+ KEY_PREVIEW_END_ZOOM_IN_SCALE);
+ final ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(
+ previewTextView, SCALE_Y, KEY_PREVIEW_START_ZOOM_IN_SCALE,
+ KEY_PREVIEW_END_ZOOM_IN_SCALE);
+ final AnimatorSet zoomInAnimation = new AnimatorSet();
+ zoomInAnimation.play(scaleXAnimation).with(scaleYAnimation);
+ // TODO: Implement preference option to control key preview animation duration.
+ zoomInAnimation.setDuration(mKeyPreviewZoomInDuration);
+ zoomInAnimation.setInterpolator(DECELERATE_INTERPOLATOR);
+ zoomInAnimation.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(final Animator animation) {
+ previewTextView.setVisibility(VISIBLE);
+ mShowingKeyPreviewTextViews.put(key, previewTextView);
+ }
+ });
+ return zoomInAnimation;
+ }
+
+ // TODO: Take this method out of this class.
+ private Animator createZoomOutAnimation(final Key key, final TextView previewTextView) {
+ final ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(
+ previewTextView, SCALE_X, KEY_PREVIEW_END_ZOOM_OUT_SCALE);
+ final ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(
+ previewTextView, SCALE_Y, KEY_PREVIEW_END_ZOOM_OUT_SCALE);
+ final AnimatorSet zoomOutAnimation = new AnimatorSet();
+ zoomOutAnimation.play(scaleXAnimation).with(scaleYAnimation);
+ // TODO: Implement preference option to control key preview animation duration.
+ zoomOutAnimation.setDuration(mKeyPreviewZoomOutDuration);
+ zoomOutAnimation.setInterpolator(ACCELERATE_INTERPOLATOR);
+ zoomOutAnimation.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(final Animator animation) {
+ dismissKeyPreviewWithoutDelay(key);
+ }
+ });
+ return zoomOutAnimation;
+ }
+
+ // TODO: Take this method out of this class.
+ private void dismissKeyPreviewWithoutDelay(final Key key) {
+ if (key == null) {
+ return;
+ }
+ final TextView previewTextView = mShowingKeyPreviewTextViews.remove(key);
+ if (previewTextView != null) {
+ final Object tag = previewTextView.getTag();
+ if (tag instanceof Animator) {
+ ((Animator)tag).cancel();
+ }
+ previewTextView.setTag(null);
+ previewTextView.setVisibility(INVISIBLE);
+ mFreeKeyPreviewTextViews.add(previewTextView);
+ }
+ // To redraw key top letter.
+ invalidateKey(key);
}
+ // TODO: Take this method out of this class.
@Override
public void dismissKeyPreview(final Key key) {
- mDrawingHandler.dismissKeyPreview(mKeyPreviewLingerTimeout, key);
+ final TextView previewTextView = mShowingKeyPreviewTextViews.get(key);
+ if (previewTextView == null) {
+ return;
+ }
+ if (!isHardwareAccelerated()) {
+ // TODO: Implement preference option to control key preview method and duration.
+ mDrawingHandler.dismissKeyPreview(mKeyPreviewLingerTimeout, key);
+ return;
+ }
+ final Object tag = previewTextView.getTag();
+ if (tag instanceof KeyPreviewAnimations) {
+ final KeyPreviewAnimations animation = (KeyPreviewAnimations)tag;
+ animation.startZoomOut();
+ }
}
public void setSlidingKeyInputPreviewEnabled(final boolean enabled) {
@@ -983,6 +1108,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
final int pointY = key.getY() + mKeyPreviewDrawParams.mPreviewVisibleOffset;
moreKeysPanel.showMoreKeysPanel(this, this, pointX, pointY, mKeyboardActionListener);
tracker.onShowMoreKeysPanel(moreKeysPanel);
+ // TODO: Implement zoom in animation of more keys panel.
+ dismissKeyPreviewWithoutDelay(key);
}
public boolean isInDraggingFinger() {
@@ -1177,7 +1304,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
}
// Don't draw key top letter when key preview is showing.
- if (mShowingKeyPreviewTextViews.containsKey(key)) {
+ if (FADE_OUT_KEY_TOP_LETTER_WHEN_KEY_IS_PRESSED
+ && mShowingKeyPreviewTextViews.containsKey(key)) {
// TODO: Fade out animation for the key top letter, and fade in animation for the key
// background color when the user presses the key.
return;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 842c658e1..3dd0a4f59 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2152,13 +2152,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// This should never happen.
Log.e(TAG, "Backspace when we don't know the selection position");
}
- final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
- if (codePointBeforeCursor == Constants.NOT_A_CODE) {
- // Nothing to delete before the cursor.
- return;
- }
- final int lengthToDelete =
- Character.isSupplementaryCodePoint(codePointBeforeCursor) ? 2 : 1;
if (mAppWorkAroundsUtils.isBeforeJellyBean() ||
currentSettings.mInputAttributes.isTypeNull()) {
// There are two possible reasons to send a key event: either the field has
@@ -2169,23 +2162,33 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// applications are relying on this behavior so we continue to support it for
// older apps, so we retain this behavior if the app has target SDK < JellyBean.
sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
+ if (mDeleteCount > DELETE_ACCELERATE_AT) {
+ sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
+ }
} else {
+ final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
+ if (codePointBeforeCursor == Constants.NOT_A_CODE) {
+ // Nothing to delete before the cursor.
+ return;
+ }
+ final int lengthToDelete =
+ Character.isSupplementaryCodePoint(codePointBeforeCursor) ? 2 : 1;
mConnection.deleteSurroundingText(lengthToDelete, 0);
- }
- if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
- ResearchLogger.latinIME_handleBackspace(lengthToDelete,
- true /* shouldUncommitLogUnit */);
- }
- if (mDeleteCount > DELETE_ACCELERATE_AT) {
- final int codePointBeforeCursorToDeleteAgain =
- mConnection.getCodePointBeforeCursor();
- if (codePointBeforeCursorToDeleteAgain != Constants.NOT_A_CODE) {
- final int lengthToDeleteAgain = Character.isSupplementaryCodePoint(
- codePointBeforeCursorToDeleteAgain) ? 2 : 1;
- mConnection.deleteSurroundingText(lengthToDeleteAgain, 0);
- if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
- ResearchLogger.latinIME_handleBackspace(lengthToDeleteAgain,
- true /* shouldUncommitLogUnit */);
+ if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
+ ResearchLogger.latinIME_handleBackspace(lengthToDelete,
+ true /* shouldUncommitLogUnit */);
+ }
+ if (mDeleteCount > DELETE_ACCELERATE_AT) {
+ final int codePointBeforeCursorToDeleteAgain =
+ mConnection.getCodePointBeforeCursor();
+ if (codePointBeforeCursorToDeleteAgain != Constants.NOT_A_CODE) {
+ final int lengthToDeleteAgain = Character.isSupplementaryCodePoint(
+ codePointBeforeCursorToDeleteAgain) ? 2 : 1;
+ mConnection.deleteSurroundingText(lengthToDeleteAgain, 0);
+ if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
+ ResearchLogger.latinIME_handleBackspace(lengthToDeleteAgain,
+ true /* shouldUncommitLogUnit */);
+ }
}
}
}
diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java
index dc005bbdf..df2c6907f 100644
--- a/java/src/com/android/inputmethod/latin/settings/Settings.java
+++ b/java/src/com/android/inputmethod/latin/settings/Settings.java
@@ -65,6 +65,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
"pref_show_language_switch_key";
public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =
"pref_include_other_imes_in_language_switch_list";
+ public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916";
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY =
"pref_key_preview_popup_dismiss_delay";
@@ -262,6 +263,28 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return prefs.getBoolean(PREF_SHOW_LANGUAGE_SWITCH_KEY, true);
}
+ public static int readKeyboardThemeIndex(final SharedPreferences prefs, final Resources res) {
+ final String defaultThemeIndex = res.getString(
+ R.string.config_default_keyboard_theme_index);
+ final String themeIndex = prefs.getString(PREF_KEYBOARD_LAYOUT, defaultThemeIndex);
+ try {
+ return Integer.valueOf(themeIndex);
+ } catch (final NumberFormatException e) {
+ // Format error, returns default keyboard theme index.
+ Log.e(TAG, "Illegal keyboard theme in preference: " + themeIndex + ", default to "
+ + defaultThemeIndex, e);
+ return Integer.valueOf(defaultThemeIndex);
+ }
+ }
+
+ public static int resetAndGetDefaultKeyboardThemeIndex(final SharedPreferences prefs,
+ final Resources res) {
+ final String defaultThemeIndex = res.getString(
+ R.string.config_default_keyboard_theme_index);
+ prefs.edit().putString(PREF_KEYBOARD_LAYOUT, defaultThemeIndex).apply();
+ return Integer.valueOf(defaultThemeIndex);
+ }
+
public static String readPrefAdditionalSubtypes(final SharedPreferences prefs,
final Resources res) {
final String predefinedPrefSubtypes = AdditionalSubtypeUtils.createPrefSubtypes(
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java
index cb7dda655..5c60a7350 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsFragment.java
@@ -255,6 +255,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
}
updateShowCorrectionSuggestionsSummary();
updateKeyPreviewPopupDelaySummary();
+ updateColorSchemeSummary(prefs, getResources());
updateCustomInputStylesSummary();
}
@@ -288,6 +289,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
ensureConsistencyOfAutoCorrectionSettings();
updateShowCorrectionSuggestionsSummary();
updateKeyPreviewPopupDelaySummary();
+ updateColorSchemeSummary(prefs, res);
refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, getResources());
}
@@ -305,6 +307,25 @@ public final class SettingsFragment extends InputMethodSettingsFragment
mShowCorrectionSuggestionsPreference.getValue())]);
}
+ private void updateColorSchemeSummary(final SharedPreferences prefs, final Resources res) {
+ // Because the "%s" summary trick of {@link ListPreference} doesn't work properly before
+ // KitKat, we need to update the summary by code.
+ final Preference preference = findPreference(Settings.PREF_KEYBOARD_LAYOUT);
+ if (!(preference instanceof ListPreference)) {
+ Log.w(TAG, "Can't find Keyboard Color Scheme preference");
+ return;
+ }
+ final ListPreference colorSchemePreference = (ListPreference)preference;
+ final int themeIndex = Settings.readKeyboardThemeIndex(prefs, res);
+ int entryIndex = colorSchemePreference.findIndexOfValue(Integer.toString(themeIndex));
+ if (entryIndex < 0) {
+ final int defaultThemeIndex = Settings.resetAndGetDefaultKeyboardThemeIndex(prefs, res);
+ entryIndex = colorSchemePreference.findIndexOfValue(
+ Integer.toString(defaultThemeIndex));
+ }
+ colorSchemePreference.setSummary(colorSchemePreference.getEntries()[entryIndex]);
+ }
+
private void updateCustomInputStylesSummary() {
final PreferenceScreen customInputStyles =
(PreferenceScreen)findPreference(Settings.PREF_CUSTOM_INPUT_STYLES);