aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java12
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java16
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java9
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java24
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeysCache.java50
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/UniqueKeysCache.java81
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java19
-rw-r--r--java/src/com/android/inputmethod/latin/NgramContext.java2
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputMethodManager.java54
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java9
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java37
-rw-r--r--java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java2
-rw-r--r--java/src/com/android/inputmethod/latin/settings/DebugSettings.java3
-rw-r--r--java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java12
-rw-r--r--java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java1
-rw-r--r--java/src/com/android/inputmethod/latin/settings/Settings.java2
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsValues.java12
-rw-r--r--java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java2
-rw-r--r--java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingExactMatchesAndSuggestions.java2
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ResourceUtils.java55
22 files changed, 268 insertions, 142 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
index 5d9b8a712..d71dc5956 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
@@ -34,7 +34,7 @@ import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardParams;
-import com.android.inputmethod.keyboard.internal.KeysCache;
+import com.android.inputmethod.keyboard.internal.UniqueKeysCache;
import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodSubtype;
@@ -86,7 +86,7 @@ public final class KeyboardLayoutSet {
private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache =
new HashMap<>();
@Nonnull
- private static final KeysCache sKeysCache = new KeysCache();
+ private static final UniqueKeysCache sUniqueKeysCache = UniqueKeysCache.newInstance();
private final static HashMap<InputMethodSubtype, Integer> sScriptIdsForSubtypes =
new HashMap<>();
@@ -144,7 +144,7 @@ public final class KeyboardLayoutSet {
private static void clearKeyboardCache() {
sKeyboardCache.clear();
- sKeysCache.clear();
+ sUniqueKeysCache.clear();
}
public static int getScriptId(final Resources resources,
@@ -219,10 +219,8 @@ public final class KeyboardLayoutSet {
}
final KeyboardBuilder<KeyboardParams> builder =
- new KeyboardBuilder<>(mContext, new KeyboardParams());
- if (id.isAlphabetKeyboard()) {
- builder.setAutoGenerate(sKeysCache);
- }
+ new KeyboardBuilder<>(mContext, new KeyboardParams(sUniqueKeysCache));
+ sUniqueKeysCache.setEnabled(id.isAlphabetKeyboard());
builder.setAllowRedundantMoreKes(elementParams.mAllowRedundantMoreKeys);
final int keyboardXmlId = elementParams.mKeyboardXmlId;
builder.load(keyboardXmlId, id);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 5e3a5f17c..d19f506ab 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -22,7 +22,9 @@ import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
+import android.widget.LinearLayout;
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
import com.android.inputmethod.event.Event;
@@ -64,7 +66,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private KeyboardTheme mKeyboardTheme;
private Context mThemeContext;
-
+ private View mHorizontalKeyboardFrame;
private static final KeyboardSwitcher sInstance = new KeyboardSwitcher();
public static KeyboardSwitcher getInstance() {
@@ -111,8 +113,16 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
mThemeContext, editorInfo);
final Resources res = mThemeContext.getResources();
- final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
+ final ViewGroup.MarginLayoutParams p =
+ (ViewGroup.MarginLayoutParams) mHorizontalKeyboardFrame.getLayoutParams();
+
+ final int keyboardLeftMargin = ResourceUtils.getKeyboardLeftMargin(res, settingsValues);
+ final int keyboardRightMargin = ResourceUtils.getKeyboardRightMargin(res, settingsValues);
+ final int keyboardBottomMargin = ResourceUtils.getKeyboardBottomMargin(res, settingsValues);
+ p.setMargins(keyboardLeftMargin, 0, keyboardRightMargin, keyboardBottomMargin);
+
final int keyboardHeight = ResourceUtils.getKeyboardHeight(res, settingsValues);
+ final int keyboardWidth = ResourceUtils.getKeyboardWidth(res, settingsValues);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
builder.setSubtype(RichInputMethodManager.getInstance().getCurrentSubtype());
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
@@ -411,6 +421,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
mEmojiPalettesView.setHardwareAcceleratedDrawingEnabled(
isHardwareAcceleratedDrawingEnabled);
mEmojiPalettesView.setKeyboardActionListener(mLatinIME);
+ mHorizontalKeyboardFrame = (LinearLayout)mCurrentInputView.findViewById(
+ R.id.horizontal_keyboard_frame);
return mCurrentInputView;
}
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
index 582e09124..2ac79975d 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
@@ -39,7 +39,7 @@ final class EmojiLayoutParams {
public EmojiLayoutParams(final Resources res) {
final int defaultKeyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
- final int defaultKeyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
+ final int defaultKeyboardWidth = ResourceUtils.getKeyboardFrameWidth(res);
mKeyVerticalGap = (int) res.getFraction(R.fraction.config_key_vertical_gap_holo,
defaultKeyboardHeight, defaultKeyboardHeight);
mBottomPadding = (int) res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
index cf4dd3db3..223947e38 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
@@ -50,6 +50,8 @@ import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.common.Constants;
+import com.android.inputmethod.latin.settings.Settings;
+import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.utils.ResourceUtils;
import java.util.concurrent.TimeUnit;
@@ -113,9 +115,10 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
context, null /* editorInfo */);
final Resources res = context.getResources();
mEmojiLayoutParams = new EmojiLayoutParams(res);
+ final SettingsValues s = Settings.getInstance().getCurrent();
builder.setSubtype(RichInputMethodSubtype.getEmojiSubtype());
- builder.setKeyboardGeometry(ResourceUtils.getDefaultKeyboardWidth(res),
- mEmojiLayoutParams.mEmojiKeyboardHeight);
+ builder.setKeyboardGeometry(ResourceUtils.getKeyboardWidth(res, s),
+ ResourceUtils.getKeyboardHeight(res, s));
final KeyboardLayoutSet layoutSet = builder.build();
final TypedArray emojiPalettesViewAttr = context.obtainStyledAttributes(attrs,
R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView);
@@ -140,7 +143,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final Resources res = getContext().getResources();
// The main keyboard expands to the entire this {@link KeyboardView}.
- final int width = ResourceUtils.getDefaultKeyboardWidth(res)
+ final int width = ResourceUtils.getKeyboardFrameWidth(res)
+ getPaddingLeft() + getPaddingRight();
final int height = ResourceUtils.getDefaultKeyboardHeight(res)
+ res.getDimensionPixelSize(R.dimen.config_suggestions_strip_height)
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
index 5743ef967..2b07e1d46 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
@@ -161,10 +161,6 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
params.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height);
}
- public void setAutoGenerate(final KeysCache keysCache) {
- mParams.mKeysCache = keysCache;
- }
-
public void setAllowRedundantMoreKes(final boolean enabled) {
mParams.mAllowRedundantMoreKeys = enabled;
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
index 432687635..738d6a400 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
@@ -77,9 +77,8 @@ public class KeyboardParams {
@Nonnull
public final KeyStylesSet mKeyStyles = new KeyStylesSet(mTextsSet);
- // TODO: Make this @Nonnull
- @Nullable
- public KeysCache mKeysCache;
+ @Nonnull
+ private final UniqueKeysCache mUniqueKeysCache;
public boolean mAllowRedundantMoreKeys;
public int mMostCommonKeyHeight = 0;
@@ -103,6 +102,14 @@ public class KeyboardParams {
}
};
+ public KeyboardParams() {
+ this(UniqueKeysCache.NO_CACHE);
+ }
+
+ public KeyboardParams(@Nonnull final UniqueKeysCache keysCache) {
+ mUniqueKeysCache = keysCache;
+ }
+
protected void clearKeys() {
mSortedKeys.clear();
mShiftKeys.clear();
@@ -110,9 +117,7 @@ public class KeyboardParams {
}
public void onAddKey(@Nonnull final Key newKey) {
- // To avoid possible null pointer access.
- final KeysCache keysCache = mKeysCache;
- final Key key = (keysCache != null) ? keysCache.get(newKey) : newKey;
+ final Key key = mUniqueKeysCache.getUniqueKey(newKey);
final boolean isSpacer = key.isSpacer();
if (isSpacer && key.getWidth() == 0) {
// Ignore zero width {@link Spacer}.
@@ -140,16 +145,11 @@ public class KeyboardParams {
for (final Key key : mSortedKeys) {
lettersOnBaseLayout.addLetter(key);
}
- // To avoid possible null pointer access.
- final KeysCache keysCache = mKeysCache;
final ArrayList<Key> allKeys = new ArrayList<>(mSortedKeys);
mSortedKeys.clear();
for (final Key key : allKeys) {
final Key filteredKey = Key.removeRedundantMoreKeys(key, lettersOnBaseLayout);
- if (keysCache != null) {
- keysCache.replace(key, filteredKey);
- }
- mSortedKeys.add(filteredKey);
+ mSortedKeys.add(mUniqueKeysCache.getUniqueKey(filteredKey));
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeysCache.java b/java/src/com/android/inputmethod/keyboard/internal/KeysCache.java
deleted file mode 100644
index 6ad450c29..000000000
--- a/java/src/com/android/inputmethod/keyboard/internal/KeysCache.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.keyboard.internal;
-
-import com.android.inputmethod.keyboard.Key;
-
-import java.util.HashMap;
-
-// TODO: Rename more appropriate name.
-public final class KeysCache {
- private final HashMap<Key, Key> mMap = new HashMap<>();
-
- public void clear() {
- mMap.clear();
- }
-
- // TODO: Rename more descriptive name.
- public Key get(final Key key) {
- final Key existingKey = mMap.get(key);
- if (existingKey != null) {
- // Reuse the existing element that equals to "key" without adding "key" to the map.
- return existingKey;
- }
- mMap.put(key, key);
- return key;
- }
-
- // TODO: Rename more descriptive name.
- public Key replace(final Key oldKey, final Key newKey) {
- if (oldKey.equals(newKey)) {
- return oldKey;
- }
- mMap.remove(oldKey);
- return get(newKey);
- }
-}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/UniqueKeysCache.java b/java/src/com/android/inputmethod/keyboard/internal/UniqueKeysCache.java
new file mode 100644
index 000000000..5b329dce4
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/UniqueKeysCache.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.keyboard.Key;
+
+import java.util.HashMap;
+
+import javax.annotation.Nonnull;
+
+public abstract class UniqueKeysCache {
+ public abstract void setEnabled(boolean enabled);
+ public abstract void clear();
+ public abstract @Nonnull Key getUniqueKey(@Nonnull Key key);
+
+ @Nonnull
+ public static final UniqueKeysCache NO_CACHE = new UniqueKeysCache() {
+ @Override
+ public void setEnabled(boolean enabled) {}
+
+ @Override
+ public void clear() {}
+
+ @Override
+ public Key getUniqueKey(Key key) { return key; }
+ };
+
+ @Nonnull
+ public static UniqueKeysCache newInstance() {
+ return new UniqueKeysCacheImpl();
+ }
+
+ private static final class UniqueKeysCacheImpl extends UniqueKeysCache {
+ private final HashMap<Key, Key> mCache;
+
+ private boolean mEnabled;
+
+ UniqueKeysCacheImpl() {
+ mCache = new HashMap<>();
+ }
+
+ @Override
+ public void setEnabled(final boolean enabled) {
+ mEnabled = enabled;
+ }
+
+ @Override
+ public void clear() {
+ mCache.clear();
+ }
+
+ @Override
+ public Key getUniqueKey(final Key key) {
+ if (!mEnabled) {
+ return key;
+ }
+ final Key existingKey = mCache.get(key);
+ if (existingKey != null) {
+ // Reuse the existing object that equals to "key" without adding "key" to
+ // the cache.
+ return existingKey;
+ }
+ mCache.put(key, key);
+ return key;
+ }
+ }
+}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 66746cb6a..bd660c5f3 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -100,6 +100,7 @@ import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
import com.android.inputmethod.latin.utils.IntentUtils;
import com.android.inputmethod.latin.utils.JniUtils;
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
+import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.StatsUtils;
import com.android.inputmethod.latin.utils.StatsUtilsManager;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@@ -590,7 +591,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO: Resolve mutual dependencies of {@link #loadSettings()} and
// {@link #resetDictionaryFacilitatorIfNecessary()}.
loadSettings();
- mSubtypeSwitcher.onSubtypeChanged(mRichImm.getCurrentRawSubtype());
resetDictionaryFacilitatorIfNecessary();
// Register to receive ringer mode change and network state change.
@@ -731,6 +731,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
unregisterReceiver(mDictionaryPackInstallReceiver);
unregisterReceiver(mDictionaryDumpBroadcastReceiver);
mStatsUtilsManager.onDestroy();
+ DictionaryDecayBroadcastReciever.cancelIntervalAlarmForDictionaryDecaying(this);
super.onDestroy();
}
@@ -865,7 +866,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onCurrentInputMethodSubtypeChanged(final InputMethodSubtype subtype) {
// Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged()
// is not guaranteed. It may even be called at the same time on a different thread.
- mSubtypeSwitcher.onSubtypeChanged(subtype);
+ mRichImm.onSubtypeChanged(subtype);
+ mSubtypeSwitcher.onSubtypeChanged(mRichImm.getCurrentSubtype());
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype),
mSettings.getCurrent());
loadKeyboard();
@@ -881,8 +883,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Switch to the null consumer to handle cases leading to early exit below, for which we
// also wouldn't be consuming gesture data.
mGestureConsumer = GestureConsumer.NULL_GESTURE_CONSUMER;
- mRichImm.clearSubtypeCaches();
- mSubtypeSwitcher.onSubtypeChanged(mRichImm.getCurrentRawSubtype());
+ mRichImm.refreshSubtypeCaches();
+ mSubtypeSwitcher.onSubtypeChanged(mRichImm.getCurrentSubtype());
final KeyboardSwitcher switcher = mKeyboardSwitcher;
switcher.updateKeyboardTheme();
final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
@@ -1210,6 +1212,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return;
}
final SettingsValues settingsValues = mSettings.getCurrent();
+ final Resources res = getResources();
final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
if (visibleKeyboardView == null || !hasSuggestionStripView()) {
return;
@@ -1227,13 +1230,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final int suggestionsHeight = (!mKeyboardSwitcher.isShowingEmojiPalettes()
&& mSuggestionStripView.getVisibility() == View.VISIBLE)
? mSuggestionStripView.getHeight() : 0;
- final int visibleTopY = inputHeight - visibleKeyboardView.getHeight() - suggestionsHeight;
+ final int visibleTopY = inputHeight
+ - ResourceUtils.getKeyboardFrameHeight(res, settingsValues)
+ - suggestionsHeight;
mSuggestionStripView.setMoreSuggestionsHeight(visibleTopY);
// Need to set expanded touchable region only if a keyboard view is being shown.
if (visibleKeyboardView.isShown()) {
final int touchLeft = 0;
final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
- final int touchRight = visibleKeyboardView.getWidth();
+ final int touchRight = ResourceUtils.getKeyboardFrameWidth(res);
final int touchBottom = inputHeight
// Extend touchable region below the keyboard.
+ EXTENDED_TOUCHABLE_REGION_HEIGHT;
@@ -1448,7 +1453,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// completely replace #onCodeInput.
public void onEvent(@Nonnull final Event event) {
if (Constants.CODE_SHORTCUT == event.mKeyCode) {
- mRichImm.switchToShortcutIME(this);
+ mRichImm.switchToShortcutIme(this);
}
final InputTransaction completeInputTransaction =
mInputLogic.onCodeInput(mSettings.getCurrent(), event,
diff --git a/java/src/com/android/inputmethod/latin/NgramContext.java b/java/src/com/android/inputmethod/latin/NgramContext.java
index 82a13274d..b47731229 100644
--- a/java/src/com/android/inputmethod/latin/NgramContext.java
+++ b/java/src/com/android/inputmethod/latin/NgramContext.java
@@ -133,7 +133,7 @@ public class NgramContext {
// n is 1-indexed.
@UsedForTesting
- public boolean isNthPrevWordBeginningOfSontence(final int n) {
+ public boolean isNthPrevWordBeginningOfSentence(final int n) {
if (n <= 0 || n > mPrevWordsCount) {
return false;
}
diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
index 686c3a4b2..462121789 100644
--- a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
+++ b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
@@ -111,7 +111,11 @@ public class RichInputMethodManager {
// Initialize additional subtypes.
SubtypeLocaleUtils.init(context);
final InputMethodSubtype[] additionalSubtypes = getAdditionalSubtypes();
- setAdditionalInputMethodSubtypes(additionalSubtypes);
+ mImmWrapper.mImm.setAdditionalInputMethodSubtypes(
+ getInputMethodIdOfThisIme(), additionalSubtypes);
+
+ // Initialize the current input method subtype and the shortcut IME.
+ refreshSubtypeCaches();
final ConnectivityManager connectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -324,23 +328,22 @@ public class RichInputMethodManager {
return INDEX_NOT_FOUND;
}
- @Nonnull
- public RichInputMethodSubtype onSubtypeChanged(@Nonnull final InputMethodSubtype newSubtype) {
- final RichInputMethodSubtype richSubtype = createCurrentRichInputMethodSubtype(newSubtype);
+ public void onSubtypeChanged(@Nonnull final InputMethodSubtype newSubtype) {
+ updateCurrentSubtype(newSubtype);
+ updateShortcutIme();
if (DEBUG) {
- Log.w(TAG, "onSubtypeChanged: " + richSubtype.getNameForLogging());
+ Log.w(TAG, "onSubtypeChanged: " + mCurrentRichInputMethodSubtype.getNameForLogging());
}
- mCurrentRichInputMethodSubtype = richSubtype;
- return richSubtype;
}
private static RichInputMethodSubtype sForcedSubtypeForTesting = null;
@UsedForTesting
- static void forceSubtype(final InputMethodSubtype subtype) {
+ static void forceSubtype(@Nonnull final InputMethodSubtype subtype) {
sForcedSubtypeForTesting = new RichInputMethodSubtype(subtype);
}
+ @Nonnull
public Locale[] getCurrentSubtypeLocales() {
if (null != sForcedSubtypeForTesting) {
return sForcedSubtypeForTesting.getLocales();
@@ -348,6 +351,7 @@ public class RichInputMethodManager {
return getCurrentSubtype().getLocales();
}
+ @Nonnull
public RichInputMethodSubtype getCurrentSubtype() {
if (null != sForcedSubtypeForTesting) {
return sForcedSubtypeForTesting;
@@ -360,18 +364,6 @@ public class RichInputMethodManager {
return SubtypeLocaleUtils.getCombiningRulesExtraValue(getCurrentSubtype().getRawSubtype());
}
- @Nonnull
- public InputMethodSubtype getCurrentRawSubtype() {
- return mImmWrapper.mImm.getCurrentInputMethodSubtype();
- }
-
- @Nonnull
- public RichInputMethodSubtype createCurrentRichInputMethodSubtype(
- @Nonnull final InputMethodSubtype rawSubtype) {
- return AdditionalFeaturesSettingUtils.createRichInputMethodSubtype(this, rawSubtype,
- mContext);
- }
-
public boolean hasMultipleEnabledIMEsOrSubtypes(final boolean shouldIncludeAuxiliarySubtypes) {
final List<InputMethodInfo> enabledImis = mImmWrapper.mImm.getEnabledInputMethodList();
return hasMultipleEnabledSubtypes(shouldIncludeAuxiliarySubtypes, enabledImis);
@@ -457,7 +449,7 @@ public class RichInputMethodManager {
getInputMethodIdOfThisIme(), subtypes);
// Clear the cache so that we go read the {@link InputMethodInfo} of this IME and list of
// subtypes again next time.
- clearSubtypeCaches();
+ refreshSubtypeCaches();
}
private List<InputMethodSubtype> getEnabledInputMethodSubtypeList(final InputMethodInfo imi,
@@ -474,10 +466,12 @@ public class RichInputMethodManager {
return result;
}
- public void clearSubtypeCaches() {
+ public void refreshSubtypeCaches() {
mSubtypeListCacheWithImplicitlySelectedSubtypes.clear();
mSubtypeListCacheWithoutImplicitlySelectedSubtypes.clear();
mInputMethodInfoCache.clear();
+ updateCurrentSubtype(mImmWrapper.mImm.getCurrentInputMethodSubtype());
+ updateShortcutIme();
}
public boolean shouldOfferSwitchingToNextInputMethod(final IBinder binder,
@@ -516,8 +510,13 @@ public class RichInputMethodManager {
return true;
}
- // TODO: Make this private
- void updateShortcutIME() {
+ private void updateCurrentSubtype(@Nonnull final InputMethodSubtype subtype) {
+ final RichInputMethodSubtype richSubtype = AdditionalFeaturesSettingUtils
+ .createRichInputMethodSubtype(this, subtype, mContext);
+ mCurrentRichInputMethodSubtype = richSubtype;
+ }
+
+ private void updateShortcutIme() {
if (DEBUG) {
Log.d(TAG, "Update shortcut IME from : "
+ (mShortcutInputMethodInfo == null
@@ -549,7 +548,7 @@ public class RichInputMethodManager {
}
}
- public void switchToShortcutIME(final InputMethodService context) {
+ public void switchToShortcutIme(final InputMethodService context) {
if (mShortcutInputMethodInfo == null) {
return;
}
@@ -575,19 +574,16 @@ public class RichInputMethodManager {
}
public boolean isShortcutImeEnabled() {
- updateShortcutIME();
if (mShortcutInputMethodInfo == null) {
return false;
}
if (mShortcutSubtype == null) {
return true;
}
- return checkIfSubtypeBelongsToImeAndEnabled(
- mShortcutInputMethodInfo, mShortcutSubtype);
+ return checkIfSubtypeBelongsToImeAndEnabled(mShortcutInputMethodInfo, mShortcutSubtype);
}
public boolean isShortcutImeReady() {
- updateShortcutIME();
if (mShortcutInputMethodInfo == null) {
return false;
}
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index 23e348bff..92ba6c2d9 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -57,7 +57,7 @@ public final class SubtypeSwitcher {
mResources = context.getResources();
mRichImm = RichInputMethodManager.getInstance();
- onSubtypeChanged(mRichImm.getCurrentRawSubtype());
+ onSubtypeChanged(mRichImm.getCurrentSubtype());
updateParametersOnStartInputView();
}
@@ -69,17 +69,14 @@ public final class SubtypeSwitcher {
final List<InputMethodSubtype> enabledSubtypesOfThisIme =
mRichImm.getMyEnabledInputMethodSubtypeList(true);
mLanguageOnSpacebarHelper.onUpdateEnabledSubtypes(enabledSubtypesOfThisIme);
- mRichImm.updateShortcutIME();
}
// Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function.
- public void onSubtypeChanged(@Nonnull final InputMethodSubtype newSubtype) {
- final RichInputMethodSubtype richSubtype = mRichImm.onSubtypeChanged(newSubtype);
+ public void onSubtypeChanged(@Nonnull final RichInputMethodSubtype richSubtype) {
final boolean implicitlyEnabledSubtype = mRichImm
- .checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(newSubtype);
+ .checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(richSubtype.getRawSubtype());
mLanguageOnSpacebarHelper.onSubtypeChanged(
richSubtype, implicitlyEnabledSubtype, mResources.getConfiguration().locale);
- mRichImm.updateShortcutIME();
}
public int getLanguageOnSpacebarFormatType(final RichInputMethodSubtype subtype) {
diff --git a/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java b/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java
index 221bb9a8f..e974f3320 100644
--- a/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java
+++ b/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java
@@ -43,17 +43,40 @@ public class DictionaryDecayBroadcastReciever extends BroadcastReceiver {
/**
* Interval to update for decaying dictionaries.
*/
- /* package */ static final long DICTIONARY_DECAY_INTERVAL = TimeUnit.MINUTES.toMillis(60);
+ static final long DICTIONARY_DECAY_INTERVAL_IN_MILLIS = TimeUnit.MINUTES.toMillis(60);
- public static void setUpIntervalAlarmForDictionaryDecaying(Context context) {
- AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
+ private static PendingIntent getPendingIntentForDictionaryDecay(final Context context) {
final Intent updateIntent = new Intent(DICTIONARY_DECAY_INTENT_ACTION);
updateIntent.setClass(context, DictionaryDecayBroadcastReciever.class);
- final long alarmTime = System.currentTimeMillis() + DICTIONARY_DECAY_INTERVAL;
- final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0 /* requestCode */,
+ return PendingIntent.getBroadcast(context, 0 /* requestCode */,
updateIntent, PendingIntent.FLAG_CANCEL_CURRENT);
- if (null != alarmManager) alarmManager.setInexactRepeating(AlarmManager.RTC,
- alarmTime, DICTIONARY_DECAY_INTERVAL, pendingIntent);
+ }
+
+ /**
+ * Set up interval alarm for dynamic dictionaries.
+ */
+ public static void setUpIntervalAlarmForDictionaryDecaying(final Context context) {
+ final AlarmManager alarmManager =
+ (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
+ if (null == alarmManager) {
+ return;
+ }
+ final long alarmTriggerTimeInMillis =
+ System.currentTimeMillis() + DICTIONARY_DECAY_INTERVAL_IN_MILLIS;
+ alarmManager.setInexactRepeating(AlarmManager.RTC, alarmTriggerTimeInMillis,
+ DICTIONARY_DECAY_INTERVAL_IN_MILLIS, getPendingIntentForDictionaryDecay(context));
+ }
+
+ /**
+ * Cancel interval alarm that has been set up.
+ */
+ public static void cancelIntervalAlarmForDictionaryDecaying(final Context context) {
+ final AlarmManager alarmManager =
+ (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
+ if (null == alarmManager) {
+ return;
+ }
+ alarmManager.cancel(getPendingIntentForDictionaryDecay(context));
}
@Override
diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java
index 8c5eb0aa7..74196dd6d 100644
--- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java
+++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java
@@ -74,7 +74,7 @@ public class PersonalizationHelper {
private static int sCurrentTimestampForTesting = 0;
public static void currentTimeChangedForTesting(final int currentTimestamp) {
if (TimeUnit.MILLISECONDS.toSeconds(
- DictionaryDecayBroadcastReciever.DICTIONARY_DECAY_INTERVAL)
+ DictionaryDecayBroadcastReciever.DICTIONARY_DECAY_INTERVAL_IN_MILLIS)
< currentTimestamp - sCurrentTimestampForTesting) {
runGCOnAllOpenedUserHistoryDictionaries();
runGCOnAllOpenedPersonalizationDictionaries();
diff --git a/java/src/com/android/inputmethod/latin/settings/DebugSettings.java b/java/src/com/android/inputmethod/latin/settings/DebugSettings.java
index 6fffb8e9d..eff7bde5d 100644
--- a/java/src/com/android/inputmethod/latin/settings/DebugSettings.java
+++ b/java/src/com/android/inputmethod/latin/settings/DebugSettings.java
@@ -31,6 +31,9 @@ public final class DebugSettings {
"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_KEYBOARD_BOTTOM_MARGIN = "pref_keyboard_bottom_margin";
+ public static final String PREF_KEYBOARD_LEFT_MARGIN = "pref_keyboard_left_margin";
+ public static final String PREF_KEYBOARD_RIGHT_MARGIN = "pref_keyboard_right_margin";
public static final String PREF_KEY_PREVIEW_DISMISS_DURATION =
"pref_key_preview_dismiss_duration";
public static final String PREF_KEY_PREVIEW_DISMISS_END_X_SCALE =
diff --git a/java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java
index 068f56df1..779bf47c9 100644
--- a/java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/DebugSettingsFragment.java
@@ -89,8 +89,14 @@ public final class DebugSettingsFragment extends SubScreenFragment
defaultKeyPreviewDismissEndScale);
setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_Y_SCALE,
defaultKeyPreviewDismissEndScale);
- setupKeyboardHeight(
+ setupKeyboardScale(
DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE);
+ setupKeyboardScale(
+ DebugSettings.PREF_KEYBOARD_BOTTOM_MARGIN, SettingsValues.DEFAULT_MARGIN_SCALE);
+ setupKeyboardScale(
+ DebugSettings.PREF_KEYBOARD_LEFT_MARGIN, SettingsValues.DEFAULT_MARGIN_SCALE);
+ setupKeyboardScale(
+ DebugSettings.PREF_KEYBOARD_RIGHT_MARGIN, SettingsValues.DEFAULT_MARGIN_SCALE);
mServiceNeedsRestart = false;
mDebugMode = (TwoStatePreference) findPreference(DebugSettings.PREF_DEBUG_MODE);
@@ -253,7 +259,7 @@ public final class DebugSettingsFragment extends SubScreenFragment
});
}
- private void setupKeyboardHeight(final String prefKey, final float defaultValue) {
+ private void setupKeyboardScale(final String prefKey, final float defaultValue) {
final SharedPreferences prefs = getSharedPreferences();
final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(prefKey);
if (pref == null) {
@@ -282,7 +288,7 @@ public final class DebugSettingsFragment extends SubScreenFragment
@Override
public int readValue(final String key) {
return getPercentageFromValue(
- Settings.readKeyboardHeight(prefs, key, defaultValue));
+ Settings.readKeyboardScale(prefs, key, defaultValue));
}
@Override
diff --git a/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java
index c0ceb8857..975396d2d 100644
--- a/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java
@@ -71,6 +71,7 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
super.onResume();
final Preference voiceInputKeyOption = findPreference(Settings.PREF_VOICE_INPUT_KEY);
if (voiceInputKeyOption != null) {
+ RichInputMethodManager.getInstance().refreshSubtypeCaches();
final boolean isShortcutImeEnabled = RichInputMethodManager.getInstance()
.isShortcutImeEnabled();
voiceInputKeyOption.setEnabled(isShortcutImeEnabled);
diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java
index 490fa827c..196fef4cd 100644
--- a/java/src/com/android/inputmethod/latin/settings/Settings.java
+++ b/java/src/com/android/inputmethod/latin/settings/Settings.java
@@ -367,7 +367,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return (milliseconds != UNDEFINED_PREFERENCE_VALUE_INT) ? milliseconds : defaultValue;
}
- public static float readKeyboardHeight(final SharedPreferences prefs,
+ public static float readKeyboardScale(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;
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
index c3755792c..99e0565ca 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
@@ -50,6 +50,7 @@ public class SettingsValues {
private static final String FLOAT_NEGATIVE_INFINITY_MARKER_STRING = "floatNegativeInfinity";
private static final int TIMEOUT_TO_GET_TARGET_PACKAGE = 5; // seconds
public static final float DEFAULT_SIZE_SCALE = 1.0f; // 100%
+ public static final float DEFAULT_MARGIN_SCALE = 0.0f; // 0%
// From resources:
public final SpacingAndPunctuations mSpacingAndPunctuations;
@@ -113,6 +114,9 @@ public class SettingsValues {
public final boolean mHasCustomKeyPreviewAnimationParams;
public final boolean mHasKeyboardResize;
public final float mKeyboardHeightScale;
+ public final float mKeyboardBottomMarginScale;
+ public final float mKeyboardLeftMarginScale;
+ public final float mKeyboardRightMarginScale;
public final int mKeyPreviewShowUpDuration;
public final int mKeyPreviewDismissDuration;
public final float mKeyPreviewShowUpStartXScale;
@@ -190,8 +194,14 @@ public class SettingsValues {
mHasCustomKeyPreviewAnimationParams = prefs.getBoolean(
DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS, false);
mHasKeyboardResize = prefs.getBoolean(DebugSettings.PREF_RESIZE_KEYBOARD, false);
- mKeyboardHeightScale = Settings.readKeyboardHeight(
+ mKeyboardHeightScale = Settings.readKeyboardScale(
prefs, DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, DEFAULT_SIZE_SCALE);
+ mKeyboardBottomMarginScale = Settings.readKeyboardScale(
+ prefs, DebugSettings.PREF_KEYBOARD_BOTTOM_MARGIN, DEFAULT_MARGIN_SCALE);
+ mKeyboardLeftMarginScale = Settings.readKeyboardScale(
+ prefs, DebugSettings.PREF_KEYBOARD_LEFT_MARGIN, DEFAULT_MARGIN_SCALE);
+ mKeyboardRightMarginScale = Settings.readKeyboardScale(
+ prefs, DebugSettings.PREF_KEYBOARD_RIGHT_MARGIN, DEFAULT_MARGIN_SCALE);
mKeyPreviewShowUpDuration = Settings.readKeyPreviewAnimationDuration(
prefs, DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_DURATION,
res.getInteger(R.integer.config_key_preview_show_up_duration));
diff --git a/java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java b/java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java
index 8699f2ce7..476c13406 100644
--- a/java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java
@@ -88,7 +88,7 @@ public class CombinedFormatUtils {
for (int i = 0; i < ngramProperty.mNgramContext.getPrevWordCount(); i++) {
builder.append(" " + NGRAM_PREV_WORD_TAG + "[" + i + "]="
+ ngramProperty.mNgramContext.getNthPrevWord(i + 1));
- if (ngramProperty.mNgramContext.isNthPrevWordBeginningOfSontence(i + 1)) {
+ if (ngramProperty.mNgramContext.isNthPrevWordBeginningOfSentence(i + 1)) {
builder.append("," + BEGINNING_OF_SENTENCE_TAG + "=true");
}
builder.append("\n");
diff --git a/java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingExactMatchesAndSuggestions.java b/java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingExactMatchesAndSuggestions.java
index 9c6a94810..0c01a737c 100644
--- a/java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingExactMatchesAndSuggestions.java
+++ b/java/src/com/android/inputmethod/latin/utils/DistracterFilterCheckingExactMatchesAndSuggestions.java
@@ -143,7 +143,7 @@ public class DistracterFilterCheckingExactMatchesAndSuggestions implements Distr
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
mContext, editorInfo);
final Resources res = mContext.getResources();
- final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
+ final int keyboardWidth = ResourceUtils.getKeyboardFrameWidth(res);
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
builder.setSubtype(new RichInputMethodSubtype(subtype));
diff --git a/java/src/com/android/inputmethod/latin/utils/ResourceUtils.java b/java/src/com/android/inputmethod/latin/utils/ResourceUtils.java
index cc0d470df..0a757877a 100644
--- a/java/src/com/android/inputmethod/latin/utils/ResourceUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ResourceUtils.java
@@ -182,18 +182,63 @@ public final class ResourceUtils {
return matchedAll;
}
- public static int getDefaultKeyboardWidth(final Resources res) {
+ public static int getKeyboardFrameWidth(final Resources res) {
final DisplayMetrics dm = res.getDisplayMetrics();
return dm.widthPixels;
}
+ public static int getKeyboardWidth(final Resources res, final SettingsValues settingsValues) {
+ final int frameWidth = getKeyboardFrameWidth(res);
+ if (settingsValues.mHasKeyboardResize) {
+ final float widthFraction = 1f - settingsValues.mKeyboardLeftMarginScale
+ - settingsValues.mKeyboardRightMarginScale;
+ return (int)(frameWidth * widthFraction);
+ }
+ return frameWidth;
+ }
+
+ public static int getKeyboardFrameHeight(final Resources res,
+ final SettingsValues settingsValues) {
+ if (settingsValues.mHasKeyboardResize) {
+ return getKeyboardHeight(res, settingsValues)
+ + getKeyboardBottomMargin(res, settingsValues);
+ }
+ return getDefaultKeyboardHeight(res);
+ }
+
public static int getKeyboardHeight(final Resources res, final SettingsValues settingsValues) {
- final int defaultKeyboardHeight = getDefaultKeyboardHeight(res);
+ final int keyboardHeight = getDefaultKeyboardHeight(res);
+ if (settingsValues.mHasKeyboardResize) {
+ return (int)(keyboardHeight * settingsValues.mKeyboardHeightScale);
+ }
+ return keyboardHeight;
+ }
+
+ public static int getKeyboardLeftMargin(
+ final Resources res, final SettingsValues settingsValues) {
+ if (settingsValues.mHasKeyboardResize) {
+ final int frameWidth = getKeyboardFrameWidth(res);
+ return (int)(frameWidth * settingsValues.mKeyboardLeftMarginScale);
+ }
+ return 0;
+ }
+
+ public static int getKeyboardRightMargin(
+ final Resources res, final SettingsValues settingsValues) {
+ if (settingsValues.mHasKeyboardResize) {
+ final int frameWidth = getKeyboardFrameWidth(res);
+ return (int)(frameWidth * settingsValues.mKeyboardRightMarginScale);
+ }
+ return 0;
+ }
+
+ public static int getKeyboardBottomMargin(
+ final Resources res, final SettingsValues settingsValues) {
if (settingsValues.mHasKeyboardResize) {
- // mKeyboardHeightScale Ranges from [.5,1.2], from xml/prefs_screen_debug.xml
- return (int)(defaultKeyboardHeight * settingsValues.mKeyboardHeightScale);
+ final int defaultHeight = getDefaultKeyboardHeight(res);
+ return (int)(defaultHeight * settingsValues.mKeyboardBottomMarginScale);
}
- return defaultKeyboardHeight;
+ return 0;
}
public static int getDefaultKeyboardHeight(final Resources res) {