aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java2
-rw-r--r--java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java2
-rw-r--r--java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java11
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java (renamed from java/src/com/android/inputmethod/keyboard/internal/Key.java)26
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyDetector.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java3
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java41
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java35
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java24
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboard.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/MiniKeyboard.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java13
-rw-r--r--java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java3
-rw-r--r--java/src/com/android/inputmethod/keyboard/PopupPanel.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java21
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java16
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java129
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java11
22 files changed, 226 insertions, 131 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index 1adef9057..96f7fc9f2 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -27,10 +27,10 @@ import android.view.accessibility.AccessibilityEvent;
import com.android.inputmethod.compat.AccessibilityEventCompatUtils;
import com.android.inputmethod.compat.MotionEventCompatUtils;
+import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.PointerTracker;
-import com.android.inputmethod.keyboard.internal.Key;
public class AccessibleKeyboardViewProxy {
private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName();
diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
index 5e6f10b04..154f4af91 100644
--- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
+++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
@@ -20,9 +20,9 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
+import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.latin.R;
import java.util.HashMap;
diff --git a/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java b/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java
index 46499f19a..523bf7d0e 100644
--- a/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java
@@ -16,6 +16,7 @@
package com.android.inputmethod.compat;
+import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.FrameLayout;
@@ -49,4 +50,14 @@ public class FrameLayoutCompatUtils {
+ placer.getClass().getName());
}
}
+
+ public static void placeViewAt(View view, int x, int y, int w, int h) {
+ final ViewGroup.LayoutParams lp = view.getLayoutParams();
+ if (lp instanceof MarginLayoutParams) {
+ final MarginLayoutParams marginLayoutParams = (MarginLayoutParams)lp;
+ marginLayoutParams.width = w;
+ marginLayoutParams.height = h;
+ marginLayoutParams.setMargins(x, y, 0, 0);
+ }
+ }
}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index ebd80be5e..2850c95df 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -14,7 +14,7 @@
* the License.
*/
-package com.android.inputmethod.keyboard.internal;
+package com.android.inputmethod.keyboard;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -23,7 +23,11 @@ import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Xml;
-import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.internal.KeyStyles;
+import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
+import com.android.inputmethod.keyboard.internal.KeyboardParser;
+import com.android.inputmethod.keyboard.internal.PopupCharactersParser;
+import com.android.inputmethod.keyboard.internal.Row;
import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle;
import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException;
import com.android.inputmethod.latin.R;
@@ -97,11 +101,11 @@ public class Key {
private final Keyboard mKeyboard;
/** The current pressed state of this key */
- public boolean mPressed;
+ private boolean mPressed;
/** If this is a sticky key, is its highlight on? */
- public boolean mHighlightOn;
+ private boolean mHighlightOn;
/** Key is enabled and responds on press */
- public boolean mEnabled = true;
+ private boolean mEnabled = true;
// keyWidth constants
private static final int KEYWIDTH_FILL_RIGHT = 0;
@@ -377,6 +381,18 @@ public class Key {
mPressed = false;
}
+ public void setHighlightOn(boolean highlightOn) {
+ mHighlightOn = highlightOn;
+ }
+
+ public boolean isEnabled() {
+ return mEnabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ mEnabled = enabled;
+ }
+
/**
* Detects if a point falls on this key.
* @param x the x-coordinate of the point
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index 818f3f925..7add43a6d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -18,8 +18,6 @@ package com.android.inputmethod.keyboard;
import android.util.Log;
-import com.android.inputmethod.keyboard.internal.Key;
-
import java.util.Arrays;
import java.util.List;
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 889d54bf3..20327c5b2 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -21,7 +21,6 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.util.Log;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParser;
import com.android.inputmethod.keyboard.internal.KeyboardShiftState;
@@ -297,7 +296,7 @@ public class Keyboard {
public boolean setShiftLocked(boolean newShiftLockState) {
final Map<Key, Drawable> shiftedIcons = getShiftedIcons();
for (final Key key : getShiftKeys()) {
- key.mHighlightOn = newShiftLockState;
+ key.setHighlightOn(newShiftLockState);
key.setIcon(newShiftLockState ? shiftedIcons.get(key) : mNormalShiftIcons.get(key));
}
mShiftState.setShiftLocked(newShiftLockState);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index b91134dd6..9c63c198c 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -37,6 +37,11 @@ public class KeyboardId {
public static final int MODE_PHONE = 4;
public static final int MODE_NUMBER = 5;
+ public static final int F2KEY_MODE_NONE = 0;
+ public static final int F2KEY_MODE_SETTINGS = 1;
+ public static final int F2KEY_MODE_SHORTCUT_IME = 2;
+ public static final int F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS = 3;
+
public final Locale mLocale;
public final int mOrientation;
public final int mWidth;
@@ -44,7 +49,10 @@ public class KeyboardId {
public final int mXmlId;
public final boolean mNavigateAction;
public final boolean mPasswordInput;
+ // TODO: Clean up these booleans and modes.
public final boolean mHasSettingsKey;
+ public final int mF2KeyMode;
+ public final boolean mClobberSettingsKey;
public final boolean mVoiceKeyEnabled;
public final boolean mHasVoiceKey;
public final int mImeAction;
@@ -56,8 +64,9 @@ public class KeyboardId {
private final int mHashCode;
public KeyboardId(String xmlName, int xmlId, Locale locale, int orientation, int width,
- int mode, EditorInfo attribute, boolean hasSettingsKey, boolean voiceKeyEnabled,
- boolean hasVoiceKey, boolean enableShiftLock) {
+ int mode, EditorInfo attribute, boolean hasSettingsKey, int f2KeyMode,
+ boolean clobberSettingsKey, boolean voiceKeyEnabled, boolean hasVoiceKey,
+ boolean enableShiftLock) {
final int inputType = (attribute != null) ? attribute.inputType : 0;
final int imeOptions = (attribute != null) ? attribute.imeOptions : 0;
this.mLocale = locale;
@@ -72,6 +81,8 @@ public class KeyboardId {
this.mPasswordInput = InputTypeCompatUtils.isPasswordInputType(inputType)
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType);
this.mHasSettingsKey = hasSettingsKey;
+ this.mF2KeyMode = f2KeyMode;
+ this.mClobberSettingsKey = clobberSettingsKey;
this.mVoiceKeyEnabled = voiceKeyEnabled;
this.mHasVoiceKey = hasVoiceKey;
// We are interested only in {@link EditorInfo#IME_MASK_ACTION} enum value and
@@ -92,6 +103,8 @@ public class KeyboardId {
mNavigateAction,
mPasswordInput,
hasSettingsKey,
+ f2KeyMode,
+ clobberSettingsKey,
voiceKeyEnabled,
hasVoiceKey,
mImeAction,
@@ -101,14 +114,16 @@ public class KeyboardId {
public KeyboardId cloneWithNewLayout(String xmlName, int xmlId) {
return new KeyboardId(xmlName, xmlId, mLocale, mOrientation, mWidth, mMode, mAttribute,
- mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
+ mHasSettingsKey, mF2KeyMode, mClobberSettingsKey, mVoiceKeyEnabled, mHasVoiceKey,
+ mEnableShiftLock);
}
public KeyboardId cloneWithNewGeometry(int width) {
if (mWidth == width)
return this;
return new KeyboardId(mXmlName, mXmlId, mLocale, mOrientation, width, mMode, mAttribute,
- mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
+ mHasSettingsKey, mF2KeyMode, mClobberSettingsKey, mVoiceKeyEnabled, mHasVoiceKey,
+ mEnableShiftLock);
}
public int getXmlId() {
@@ -149,6 +164,8 @@ public class KeyboardId {
&& other.mNavigateAction == this.mNavigateAction
&& other.mPasswordInput == this.mPasswordInput
&& other.mHasSettingsKey == this.mHasSettingsKey
+ && other.mF2KeyMode == this.mF2KeyMode
+ && other.mClobberSettingsKey == this.mClobberSettingsKey
&& other.mVoiceKeyEnabled == this.mVoiceKeyEnabled
&& other.mHasVoiceKey == this.mHasVoiceKey
&& other.mImeAction == this.mImeAction
@@ -162,12 +179,14 @@ public class KeyboardId {
@Override
public String toString() {
- return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s]",
+ return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s%s%s]",
mXmlName,
mLocale,
(mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode),
EditorInfoCompatUtils.imeOptionsName(mImeAction),
+ f2KeyModeName(mF2KeyMode),
+ (mClobberSettingsKey ? " clobberSettingsKey" : ""),
(mNavigateAction ? " navigateAction" : ""),
(mPasswordInput ? " passwordInput" : ""),
(mHasSettingsKey ? " hasSettingsKey" : ""),
@@ -185,7 +204,17 @@ public class KeyboardId {
case MODE_IM: return "im";
case MODE_PHONE: return "phone";
case MODE_NUMBER: return "number";
+ default: return null;
+ }
+ }
+
+ public static String f2KeyModeName(int f2KeyMode) {
+ switch (f2KeyMode) {
+ case F2KEY_MODE_NONE: return "none";
+ case F2KEY_MODE_SETTINGS: return "settings";
+ case F2KEY_MODE_SHORTCUT_IME: return "shortcutIme";
+ case F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS: return "shortcutImeOrSettings";
+ default: return null;
}
- return null;
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 1ad5b08eb..275e9d1fe 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -28,7 +28,6 @@ import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.ModifierKeyState;
import com.android.inputmethod.keyboard.internal.ShiftKeyState;
import com.android.inputmethod.latin.LatinIME;
@@ -285,6 +284,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
}
final boolean hasSettingsKey = hasSettingsKey(attribute);
+ final int f2KeyMode = getF2KeyMode(mPrefs, mInputMethodService, attribute);
+ final boolean clobberSettingsKey = Utils.inPrivateImeOptions(
+ mInputMethodService.getPackageName(), LatinIME.IME_OPTION_NO_SETTINGS_KEY,
+ attribute);
final Resources res = mInputMethodService.getResources();
final int orientation = res.getConfiguration().orientation;
if (mKeyboardWidth == 0)
@@ -292,7 +295,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
final Locale locale = mSubtypeSwitcher.getInputLocale();
return new KeyboardId(
res.getResourceEntryName(xmlId), xmlId, locale, orientation, mKeyboardWidth,
- mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock);
+ mode, attribute, hasSettingsKey, f2KeyMode, clobberSettingsKey, mVoiceKeyEnabled,
+ hasVoiceKey, enableShiftLock);
}
private KeyboardId makeSiblingKeyboardId(KeyboardId base, int alphabet, int phone) {
@@ -806,16 +810,16 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
private static boolean getSettingsKeyMode(SharedPreferences prefs, Context context) {
- Resources resources = context.getResources();
- final boolean showSettingsKeyOption = resources.getBoolean(
+ final Resources res = context.getResources();
+ final boolean showSettingsKeyOption = res.getBoolean(
R.bool.config_enable_show_settings_key_option);
if (showSettingsKeyOption) {
final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY,
- resources.getString(DEFAULT_SETTINGS_KEY_MODE));
+ res.getString(DEFAULT_SETTINGS_KEY_MODE));
// We show the settings key when 1) SETTINGS_KEY_MODE_ALWAYS_SHOW or
// 2) SETTINGS_KEY_MODE_AUTO and there are two or more enabled IMEs on the system
- if (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))
- || (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_AUTO))
+ if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))
+ || (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO))
&& Utils.hasMultipleEnabledIMEsOrSubtypes(
(InputMethodManagerCompatWrapper.getInstance(context))))) {
return true;
@@ -825,4 +829,21 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
// If the show settings key option is disabled, we always try showing the settings key.
return true;
}
+
+ private static int getF2KeyMode(SharedPreferences prefs, Context context,
+ EditorInfo attribute) {
+ final boolean clobberSettingsKey = Utils.inPrivateImeOptions(
+ context.getPackageName(), LatinIME.IME_OPTION_NO_SETTINGS_KEY, attribute);
+ final Resources res = context.getResources();
+ final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY,
+ res.getString(DEFAULT_SETTINGS_KEY_MODE));
+ if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO))) {
+ return clobberSettingsKey ? KeyboardId.F2KEY_MODE_SHORTCUT_IME
+ : KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS;
+ } else if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))) {
+ return clobberSettingsKey ? KeyboardId.F2KEY_MODE_NONE : KeyboardId.F2KEY_MODE_SETTINGS;
+ } else { // SETTINGS_KEY_MODE_ALWAYS_HIDE
+ return KeyboardId.F2KEY_MODE_SHORTCUT_IME;
+ }
+ }
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index a6aef27e0..9dc019c61 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -41,7 +41,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
-import android.view.ViewGroup.MarginLayoutParams;
import android.view.accessibility.AccessibilityEvent;
import android.widget.PopupWindow;
import android.widget.TextView;
@@ -49,7 +48,6 @@ import android.widget.TextView;
import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.compat.FrameLayoutCompatUtils;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.MiniKeyboardBuilder;
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.keyboard.internal.SwipeTracker;
@@ -132,10 +130,10 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
// Key preview
private boolean mInForeground;
private TextView mPreviewText;
+ private Drawable mPreviewBackground;
private float mPreviewTextRatio;
private int mPreviewTextSize;
private boolean mShowKeyPreviewPopup = true;
- private int mKeyPreviewPopupDisplayedY = -1;
private final int mDelayBeforePreview;
private int mDelayAfterPreview;
private ViewGroup mPreviewPlacer;
@@ -360,6 +358,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
if (previewLayout != 0) {
mPreviewText = (TextView) LayoutInflater.from(context).inflate(previewLayout, null);
+ mPreviewBackground = mPreviewText.getBackground();
mPreviewTextRatio = getRatio(res, R.fraction.key_preview_text_ratio);
} else {
mShowKeyPreviewPopup = false;
@@ -745,7 +744,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
} else {
paint.setColor(mKeyTextColor);
}
- if (key.mEnabled) {
+ if (key.isEnabled()) {
// Set a drop shadow for the text
paint.setShadowLayer(mShadowRadius, 0, 0, mShadowColor);
} else {
@@ -935,8 +934,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
// Dismiss key preview (in this case, slide language switcher) without any delay.
mPreviewText.setVisibility(View.INVISIBLE);
}
- // Clear key preview display position.
- mKeyPreviewPopupDisplayedY = -1;
}
private void addKeyPreview(TextView keyPreview) {
@@ -987,6 +984,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
previewIcon != null ? previewIcon : key.getIcon());
previewText.setText(null);
}
+ if (key.mCode == Keyboard.CODE_SPACE) {
+ previewText.setBackgroundColor(Color.TRANSPARENT);
+ } else {
+ previewText.setBackgroundDrawable(mPreviewBackground);
+ }
// Set the preview background state
previewText.getBackground().setState(
key.mPopupCharacters != null ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
@@ -999,15 +1001,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
getLocationInWindow(mCoordinates);
final int previewX = keyDrawX - (previewWidth - keyDrawWidth) / 2 + mCoordinates[0];
final int previewY = key.mY - previewHeight + mCoordinates[1] + mPreviewOffset;
- // Record key preview position to display mini-keyboard later at the same position
- mKeyPreviewPopupDisplayedY = previewY;
// Place the key preview.
// TODO: Adjust position of key previews which touch screen edges
- final MarginLayoutParams lp = (MarginLayoutParams)previewText.getLayoutParams();
- lp.width = previewWidth;
- lp.height = previewHeight;
- lp.setMargins(previewX, previewY, 0, 0);
+ FrameLayoutCompatUtils.placeViewAt(
+ previewText, previewX, previewY, previewWidth, previewHeight);
previewText.setVisibility(VISIBLE);
}
@@ -1151,7 +1149,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mPopupWindow.setClippingEnabled(false);
}
mPopupMiniKeyboardPanel = popupPanel;
- popupPanel.showPanel(this, parentKey, tracker, mKeyPreviewPopupDisplayedY, mPopupWindow);
+ popupPanel.showPanel(this, parentKey, tracker, mPopupWindow);
invalidateAllKeys();
return true;
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
index 0329ee2b3..00bf348f2 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
@@ -33,7 +33,6 @@ import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.SlidingLocaleDrawable;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
@@ -141,7 +140,7 @@ public class LatinKeyboard extends Keyboard {
// The threshold is "key width" x 1.25
mSpacebarLanguageSwitchThreshold = (getMostCommonKeyWidth() * 5) / 4;
- if (mSpaceKey != null) {
+ if (mSpaceKey != null && mSpacePreviewIcon != null) {
final int slidingIconWidth = Math.max(mSpaceKey.mWidth,
(int)(getMinWidth() * SPACEBAR_POPUP_MIN_RATIO));
final int spaceKeyheight = mSpacePreviewIcon.getIntrinsicHeight();
@@ -175,7 +174,7 @@ public class LatinKeyboard extends Keyboard {
public void updateShortcutKey(boolean available, LatinKeyboardView view) {
if (mShortcutKey == null)
return;
- mShortcutKey.mEnabled = available;
+ mShortcutKey.setEnabled(available);
mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon);
if (view != null)
view.invalidateKey(mShortcutKey);
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index d25d1f098..901df6ab7 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -24,7 +24,6 @@ import android.util.Log;
import android.view.MotionEvent;
import com.android.inputmethod.deprecated.VoiceProxy;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.Utils;
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
index d3d3fa59f..2d6766f2d 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
@@ -18,8 +18,6 @@ package com.android.inputmethod.keyboard;
import android.content.Context;
-import com.android.inputmethod.keyboard.internal.Key;
-
import java.util.List;
public class MiniKeyboard extends Keyboard {
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java
index 9170c3bd1..cc5c3bbfe 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java
@@ -16,8 +16,6 @@
package com.android.inputmethod.keyboard;
-import com.android.inputmethod.keyboard.internal.Key;
-
import java.util.List;
public class MiniKeyboardKeyDetector extends KeyDetector {
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 1d70481f4..c7620f946 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -22,7 +22,6 @@ import android.util.Log;
import android.view.MotionEvent;
import com.android.inputmethod.keyboard.KeyboardView.UIHandler;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.keyboard.internal.PointerTrackerKeyState;
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.latin.LatinImeLogger;
@@ -150,7 +149,7 @@ public class PointerTracker {
+ " ignoreModifier=" + ignoreModifierKey);
if (ignoreModifierKey)
return false;
- if (key.mEnabled) {
+ if (key.isEnabled()) {
mListener.onPress(key.mCode, withSliding);
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
mKeyboardLayoutHasBeenChanged = false;
@@ -169,14 +168,14 @@ public class PointerTracker {
+ " ignoreModifier=" + ignoreModifierKey);
if (ignoreModifierKey)
return;
- if (key.mEnabled)
+ if (key.isEnabled())
mListener.onCodeInput(primaryCode, keyCodes, x, y);
}
private void callListenerOnTextInput(Key key) {
if (DEBUG_LISTENER)
Log.d(TAG, "onTextInput: text=" + key.mOutputText);
- if (key.mEnabled)
+ if (key.isEnabled())
mListener.onTextInput(key.mOutputText);
}
@@ -189,7 +188,7 @@ public class PointerTracker {
+ withSliding + " ignoreModifier=" + ignoreModifierKey);
if (ignoreModifierKey)
return;
- if (key.mEnabled)
+ if (key.isEnabled())
mListener.onRelease(primaryCode, withSliding);
}
@@ -269,7 +268,7 @@ public class PointerTracker {
private void setPressedKeyGraphics(int keyIndex) {
final Key key = getKey(keyIndex);
- if (key != null && key.mEnabled) {
+ if (key != null && key.isEnabled()) {
key.onPressed();
mProxy.invalidateKey(key);
}
@@ -618,7 +617,7 @@ public class PointerTracker {
// The modifier key, such as shift key, should not show its key preview.
private boolean isKeyPreviewNotRequired(int keyIndex) {
final Key key = getKey(keyIndex);
- if (key == null || !key.mEnabled)
+ if (key == null || !key.isEnabled())
return true;
// Such as spacebar sliding language switch.
if (mKeyboard.needSpacebarPreview(keyIndex))
diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
index 6180f09c1..3b8c36487 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
@@ -25,7 +25,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.PopupWindow;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.latin.R;
/**
@@ -67,7 +66,7 @@ public class PopupMiniKeyboardView extends KeyboardView implements PopupPanel {
@Override
public void showPanel(KeyboardView parentKeyboardView, Key parentKey,
- PointerTracker tracker, int keyPreviewY, PopupWindow window) {
+ PointerTracker tracker, PopupWindow window) {
final View container = (View)getParent();
final MiniKeyboard miniKeyboard = (MiniKeyboard)getKeyboard();
final Keyboard parentKeyboard = parentKeyboardView.getKeyboard();
diff --git a/java/src/com/android/inputmethod/keyboard/PopupPanel.java b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
index 48454679e..386e11f2c 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupPanel.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
@@ -19,20 +19,16 @@ package com.android.inputmethod.keyboard;
import android.view.MotionEvent;
import android.widget.PopupWindow;
-import com.android.inputmethod.keyboard.internal.Key;
-
public interface PopupPanel {
/**
* Show popup panel.
* @param parentKeyboardView the parent KeyboardView that has the parent key.
* @param parentKey the parent key that is the source of this popup panel
* @param tracker the pointer tracker that pressesd the parent key
- * @param keyPreviewY the Y-coordinate of key preview
* @param window PopupWindow to be used to show this popup panel
*/
- // TODO: Remove keyPreviewY from argument.
public void showPanel(KeyboardView parentKeyboardView, Key parentKey,
- PointerTracker tracker, int keyPreviewY, PopupWindow window);
+ PointerTracker tracker, PopupWindow window);
/**
* Check if the pointer is in siding key input mode.
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index a6a07e518..33acc6907 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -16,7 +16,6 @@
package com.android.inputmethod.keyboard;
-import com.android.inputmethod.keyboard.internal.Key;
import com.android.inputmethod.latin.Utils;
import java.util.Arrays;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
index d5b364818..a6708171f 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
@@ -26,6 +26,7 @@ import android.util.Xml;
import android.view.InflateException;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
+import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.latin.R;
@@ -331,7 +332,7 @@ public class KeyboardParser {
} else {
Key key = new Key(mResources, row, mCurrentX, mCurrentY, parser, mKeyStyles);
if (DEBUG) Log.d(TAG, String.format("<%s%s keyLabel=%s code=%d popupCharacters=%s />",
- TAG_KEY, (key.mEnabled ? "" : " disabled"), key.mLabel, key.mCode,
+ TAG_KEY, (key.isEnabled() ? "" : " disabled"), key.mLabel, key.mCode,
Arrays.toString(key.mPopupCharacters)));
checkEndTag(TAG_KEY, parser);
keys.add(key);
@@ -487,8 +488,12 @@ public class KeyboardParser {
R.styleable.Keyboard_Case_navigateAction, id.mNavigateAction);
final boolean passwordInputMatched = matchBoolean(a,
R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput);
- final boolean settingsKeyMatched = matchBoolean(a,
+ final boolean hasSettingsKeyMatched = matchBoolean(a,
R.styleable.Keyboard_Case_hasSettingsKey, id.mHasSettingsKey);
+ final boolean f2KeyModeMatched = matchInteger(a,
+ R.styleable.Keyboard_Case_f2KeyMode, id.mF2KeyMode);
+ final boolean clobberSettingsKeyMatched = matchBoolean(a,
+ R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
final boolean voiceEnabledMatched = matchBoolean(a,
R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled);
final boolean voiceKeyMatched = matchBoolean(a,
@@ -506,15 +511,19 @@ public class KeyboardParser {
final boolean countryCodeMatched = matchString(a,
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
final boolean selected = modeMatched && navigateActionMatched && passwordInputMatched
- && settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched
- && imeActionMatched && localeCodeMatched && languageCodeMatched
- && countryCodeMatched;
+ && hasSettingsKeyMatched && f2KeyModeMatched && clobberSettingsKeyMatched
+ && voiceEnabledMatched && voiceKeyMatched && imeActionMatched &&
+ localeCodeMatched && languageCodeMatched && countryCodeMatched;
- if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE,
+ if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE,
textAttr(a.getString(R.styleable.Keyboard_Case_mode), "mode"),
booleanAttr(a, R.styleable.Keyboard_Case_navigateAction, "navigateAction"),
booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),
+ textAttr(KeyboardId.f2KeyModeName(
+ a.getInt(R.styleable.Keyboard_Case_f2KeyMode, -1)), "f2KeyMode"),
+ booleanAttr(a, R.styleable.Keyboard_Case_clobberSettingsKey,
+ "clobberSettingsKey"),
booleanAttr(a, R.styleable.Keyboard_Case_voiceKeyEnabled, "voiceKeyEnabled"),
booleanAttr(a, R.styleable.Keyboard_Case_hasVoiceKey, "hasVoiceKey"),
textAttr(EditorInfoCompatUtils.imeOptionsName(
diff --git a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
index 01faae61d..040c16ded 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
@@ -21,6 +21,7 @@ import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Rect;
+import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.MiniKeyboard;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java b/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java
index df4b575f1..f8c81adfb 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java
@@ -58,7 +58,7 @@ public class SlidingLocaleDrawable extends Drawable {
public SlidingLocaleDrawable(Context context, Drawable background, int width, int height) {
mBackground = background;
- Keyboard.setDefaultBounds(mBackground);
+ Keyboard.setDefaultBounds(background);
mWidth = width;
mHeight = height;
final TextPaint textPaint = new TextPaint();
@@ -68,7 +68,7 @@ public class SlidingLocaleDrawable extends Drawable {
textPaint.setTextAlign(Align.CENTER);
textPaint.setAntiAlias(true);
mTextPaint = textPaint;
- mMiddleX = (mWidth - mBackground.getIntrinsicWidth()) / 2;
+ mMiddleX = (background != null) ? (mWidth - mBackground.getIntrinsicWidth()) / 2 : 0;
final TypedArray a = context.obtainStyledAttributes(
null, R.styleable.LatinKeyboard, R.attr.latinKeyboardStyle, R.style.LatinKeyboard);
@@ -119,11 +119,13 @@ public class SlidingLocaleDrawable extends Drawable {
canvas.drawText(mNextLanguage, diff - width / 2, baseline, paint);
canvas.drawText(mPrevLanguage, diff + width + width / 2, baseline, paint);
- Keyboard.setDefaultBounds(lArrow);
- rArrow.setBounds(width - rArrow.getIntrinsicWidth(), 0, width,
- rArrow.getIntrinsicHeight());
- lArrow.draw(canvas);
- rArrow.draw(canvas);
+ if (lArrow != null && rArrow != null) {
+ Keyboard.setDefaultBounds(lArrow);
+ rArrow.setBounds(width - rArrow.getIntrinsicWidth(), 0, width,
+ rArrow.getIntrinsicHeight());
+ lArrow.draw(canvas);
+ rArrow.draw(canvas);
+ }
}
if (mBackground != null) {
canvas.translate(mMiddleX, 0);
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index 09b356d65..09fd3b473 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -74,6 +74,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private ViewGroup mCandidatesPaneContainer;
private View mKeyboardView;
private final ArrayList<TextView> mWords = new ArrayList<TextView>();
+ private final ArrayList<TextView> mInfos = new ArrayList<TextView>();
private final ArrayList<View> mDividers = new ArrayList<View>();
private final int mCandidatePadding;
private final int mCandidateStripHeight;
@@ -177,29 +178,32 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mCandidatePadding = res.getDimensionPixelOffset(R.dimen.candidate_padding);
mCandidateStripHeight = res.getDimensionPixelOffset(R.dimen.candidate_strip_height);
for (int i = 0; i < MAX_SUGGESTIONS; i++) {
- final TextView tv;
+ final TextView word, info;
switch (i) {
case 0:
- tv = (TextView)findViewById(R.id.candidate_left);
- tv.setPadding(mCandidatePadding, 0, 0, 0);
+ word = (TextView)findViewById(R.id.word_left);
+ word.setPadding(mCandidatePadding, 0, 0, 0);
+ info = (TextView)findViewById(R.id.info_left);
break;
case 1:
- tv = (TextView)findViewById(R.id.candidate_center);
+ word = (TextView)findViewById(R.id.word_center);
+ info = (TextView)findViewById(R.id.info_center);
break;
case 2:
- tv = (TextView)findViewById(R.id.candidate_right);
+ word = (TextView)findViewById(R.id.word_right);
+ info = (TextView)findViewById(R.id.info_right);
break;
default:
- tv = (TextView)inflater.inflate(R.layout.candidate, null);
+ word = (TextView)inflater.inflate(R.layout.candidate_word, null);
+ info = (TextView)inflater.inflate(R.layout.candidate_info, null);
break;
}
- if (i < NUM_CANDIDATES_IN_STRIP)
- setLayoutWeight(tv, 1.0f);
- tv.setTag(i);
- tv.setOnClickListener(this);
+ word.setTag(i);
+ word.setOnClickListener(this);
if (i == 0)
- tv.setOnLongClickListener(this);
- mWords.add(tv);
+ word.setOnLongClickListener(this);
+ mWords.add(word);
+ mInfos.add(info);
if (i > 0) {
final View divider = inflater.inflate(R.layout.candidate_divider, null);
divider.measure(UNSPECIFIED_MEASURESPEC, UNSPECIFIED_MEASURESPEC);
@@ -263,15 +267,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
}
- private static void setLayoutWeight(View v, float weight) {
- ViewGroup.LayoutParams lp = v.getLayoutParams();
- if (lp instanceof LinearLayout.LayoutParams) {
- LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp;
- llp.width = 0;
- llp.weight = weight;
- }
- }
-
private CharSequence getStyledCandidateWord(CharSequence word, boolean isAutoCorrect) {
if (!isAutoCorrect)
return word;
@@ -308,6 +303,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
clear();
final int paneWidth = getWidth();
final int dividerWidth = mDividers.get(0).getMeasuredWidth();
+ final int dividerHeight = mDividers.get(0).getMeasuredHeight();
int x = 0;
int y = 0;
int fromIndex = NUM_CANDIDATES_IN_STRIP;
@@ -315,10 +311,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
closeCandidatesPane();
mExpandCandidatesPane.setEnabled(count >= NUM_CANDIDATES_IN_STRIP);
for (int i = 0; i < count; i++) {
- final CharSequence word = suggestions.getWord(i);
- if (word == null) continue;
+ final CharSequence suggestion = suggestions.getWord(i);
+ if (suggestion == null) continue;
- final SuggestedWordInfo info = (suggestedWordInfoList != null)
+ final SuggestedWordInfo suggestionInfo = (suggestedWordInfoList != null)
? suggestedWordInfoList.get(i) : null;
final boolean isAutoCorrect = suggestions.mHasMinimalSuggestion
&& ((i == 1 && !suggestions.mTypedWordValid)
@@ -327,18 +323,37 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
// and there are multiple suggestions, such as the default punctuation list.
// TODO: Need to revisit this logic with bigram suggestions
final boolean isSuggestedCandidate = (i != 0);
- final boolean isPunctuationSuggestions = (word.length() == 1 && count > 1);
+ final boolean isPunctuationSuggestions = (suggestion.length() == 1 && count > 1);
- final TextView tv = mWords.get(i);
+ final TextView word = mWords.get(i);
// TODO: Reorder candidates in strip as appropriate. The center candidate should hold
// the word when space is typed (valid typed word or auto corrected word).
- tv.setTextColor(getCandidateTextColor(isAutoCorrect,
- isSuggestedCandidate || isPunctuationSuggestions, info));
- tv.setText(getStyledCandidateWord(word, isAutoCorrect));
+ word.setTextColor(getCandidateTextColor(isAutoCorrect,
+ isSuggestedCandidate || isPunctuationSuggestions, suggestionInfo));
+ word.setText(getStyledCandidateWord(suggestion, isAutoCorrect));
// TODO: call TextView.setTextScaleX() to fit the candidate in single line.
- if (i >= NUM_CANDIDATES_IN_STRIP) {
- tv.measure(UNSPECIFIED_MEASURESPEC, UNSPECIFIED_MEASURESPEC);
- final int width = tv.getMeasuredWidth();
+ word.measure(UNSPECIFIED_MEASURESPEC, UNSPECIFIED_MEASURESPEC);
+ final int width = word.getMeasuredWidth();
+ final int height = word.getMeasuredHeight();
+
+ final TextView info;
+ if (DBG && suggestionInfo != null
+ && !TextUtils.isEmpty(suggestionInfo.getDebugString())) {
+ info = mInfos.get(i);
+ info.setText(suggestionInfo.getDebugString());
+ info.setVisibility(View.VISIBLE);
+ info.measure(UNSPECIFIED_MEASURESPEC, UNSPECIFIED_MEASURESPEC);
+ } else {
+ info = null;
+ }
+
+ if (i < NUM_CANDIDATES_IN_STRIP) {
+ if (info != null) {
+ final int infoWidth = info.getMeasuredWidth();
+ FrameLayoutCompatUtils.placeViewAt(
+ info, x + width - infoWidth, y, infoWidth, info.getMeasuredHeight());
+ }
+ } else {
// TODO: Handle overflow case.
if (dividerWidth + x + width >= paneWidth) {
centeringCandidates(fromIndex, i - 1, x, paneWidth);
@@ -348,23 +363,23 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
if (x != 0) {
final View divider = mDividers.get(i - NUM_CANDIDATES_IN_STRIP);
- addCandidateAt(divider, x, y);
+ mCandidatesPane.addView(divider);
+ FrameLayoutCompatUtils.placeViewAt(
+ divider, x, y + (mCandidateStripHeight - dividerHeight) / 2,
+ dividerWidth, dividerHeight);
x += dividerWidth;
}
- addCandidateAt(tv, x, y);
+ mCandidatesPane.addView(word);
+ FrameLayoutCompatUtils.placeViewAt(
+ word, x, y + (mCandidateStripHeight - height) / 2, width, height);
+ if (info != null) {
+ mCandidatesPane.addView(info);
+ final int infoWidth = info.getMeasuredWidth();
+ FrameLayoutCompatUtils.placeViewAt(
+ info, x + width - infoWidth, y, infoWidth, info.getMeasuredHeight());
+ }
x += width;
}
-
- if (DBG && info != null) {
- final TextView dv = new TextView(getContext(), null);
- dv.setTextSize(10.0f);
- dv.setTextColor(0xff808080);
- dv.setText(info.getDebugString());
- // TODO: debug view for candidate strip needed.
-// mCandidatesPane.addView(dv);
-// LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)dv.getLayoutParams();
-// lp.gravity = Gravity.BOTTOM;
- }
}
if (x != 0) {
// Centering last candidates row.
@@ -372,19 +387,15 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
}
- private void addCandidateAt(View v, int x, int y) {
- final int width = v.getMeasuredWidth();
- final int height = v.getMeasuredHeight();
- final MarginLayoutParams marginLayoutParams = FrameLayoutCompatUtils.newLayoutParam(
- mCandidatesPane, width, height);
- marginLayoutParams.setMargins(x, y + (mCandidateStripHeight - height) / 2, 0, 0);
- mCandidatesPane.addView(v, marginLayoutParams);
- }
-
private void centeringCandidates(int from, int to, int width, int paneWidth) {
final ViewGroup pane = mCandidatesPane;
final int fromIndex = pane.indexOfChild(mWords.get(from));
- final int toIndex = pane.indexOfChild(mWords.get(to));
+ final int toIndex;
+ if (mInfos.get(to).getParent() != null) {
+ toIndex = pane.indexOfChild(mInfos.get(to));
+ } else {
+ toIndex = pane.indexOfChild(mWords.get(to));
+ }
final int offset = (paneWidth - width) / 2;
for (int index = fromIndex; index <= toIndex; index++) {
offsetMargin(pane.getChildAt(index), offset, 0);
@@ -394,9 +405,9 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private static void offsetMargin(View v, int dx, int dy) {
if (v == null)
return;
- ViewGroup.LayoutParams lp = v.getLayoutParams();
+ final ViewGroup.LayoutParams lp = v.getLayoutParams();
if (lp instanceof ViewGroup.MarginLayoutParams) {
- ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)lp;
+ final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)lp;
mlp.setMargins(mlp.leftMargin + dx, mlp.topMargin + dy, 0, 0);
}
}
@@ -458,8 +469,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
public void clear() {
mShowingAddToDictionary = false;
mShowingAutoCorrectionInverted = false;
- for (int i = 0; i < NUM_CANDIDATES_IN_STRIP; i++)
+ for (int i = 0; i < NUM_CANDIDATES_IN_STRIP; i++) {
mWords.get(i).setText(null);
+ mInfos.get(i).setVisibility(View.GONE);
+ }
mCandidatesPane.removeAllViews();
}
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 3ad2a5965..6c515c845 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -25,6 +25,7 @@ import com.android.inputmethod.compat.VibratorCompatWrapper;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.backup.BackupManager;
+import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -65,6 +66,7 @@ public class Settings extends PreferenceActivity
public static final String PREF_SELECTED_LANGUAGES = "selected_languages";
public static final String PREF_SUBTYPES = "subtype_settings";
+ public static final String PREF_CONFIGURE_DICTIONARIES_KEY = "configure_dictionaries_key";
public static final String PREF_CORRECTION_SETTINGS_KEY = "correction_settings";
public static final String PREF_QUICK_FIXES = "quick_fixes";
public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting";
@@ -424,6 +426,15 @@ public class Settings extends PreferenceActivity
}
mKeyPreviewPopupDismissDelay.setEnabled(
Settings.Values.isKeyPreviewPopupEnabled(prefs, res));
+
+ final PreferenceScreen dictionaryLink =
+ (PreferenceScreen) findPreference(PREF_CONFIGURE_DICTIONARIES_KEY);
+ final Intent intent = dictionaryLink.getIntent();
+
+ final int number = getPackageManager().queryIntentActivities(intent, 0).size();
+ if (0 >= number) {
+ textCorrectionGroup.removePreference(dictionaryLink);
+ }
}
@Override