aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com')
-rw-r--r--java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java52
-rw-r--r--java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyDetector.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java10
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java29
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java14
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java42
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboard.java2
-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.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/PopupPanel.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/Key.java (renamed from java/src/com/android/inputmethod/keyboard/Key.java)27
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java (renamed from java/src/com/android/inputmethod/keyboard/KeyStyles.java)38
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java155
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java (renamed from java/src/com/android/inputmethod/keyboard/KeyboardParser.java)29
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java (renamed from java/src/com/android/inputmethod/keyboard/KeyboardShiftState.java)4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java (renamed from java/src/com/android/inputmethod/keyboard/MiniKeyboardBuilder.java)9
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/ModifierKeyState.java (renamed from java/src/com/android/inputmethod/keyboard/ModifierKeyState.java)4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/PointerTrackerKeyState.java (renamed from java/src/com/android/inputmethod/keyboard/PointerTrackerKeyState.java)7
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java (renamed from java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java)4
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java (renamed from java/src/com/android/inputmethod/keyboard/PopupCharactersParser.java)29
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/Row.java (renamed from java/src/com/android/inputmethod/keyboard/Row.java)7
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/ShiftKeyState.java (renamed from java/src/com/android/inputmethod/keyboard/ShiftKeyState.java)2
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java (renamed from java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java)6
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/SwipeTracker.java (renamed from java/src/com/android/inputmethod/keyboard/SwipeTracker.java)2
-rw-r--r--java/src/com/android/inputmethod/latin/CandidateView.java25
30 files changed, 362 insertions, 161 deletions
diff --git a/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java b/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java
new file mode 100644
index 000000000..46499f19a
--- /dev/null
+++ b/java/src/com/android/inputmethod/compat/FrameLayoutCompatUtils.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.compat;
+
+import android.view.ViewGroup;
+import android.view.ViewGroup.MarginLayoutParams;
+import android.widget.FrameLayout;
+import android.widget.RelativeLayout;
+
+public class FrameLayoutCompatUtils {
+ private static final boolean NEEDS_FRAME_LAYOUT_HACK = (
+ android.os.Build.VERSION.SDK_INT < 11 /* Honeycomb */);
+
+ public static ViewGroup getPlacer(ViewGroup container) {
+ if (NEEDS_FRAME_LAYOUT_HACK) {
+ // Insert RelativeLayout to be able to setMargin because pre-Honeycomb FrameLayout
+ // could not handle setMargin properly.
+ final ViewGroup placer = new RelativeLayout(container.getContext());
+ container.addView(placer);
+ return placer;
+ } else {
+ return container;
+ }
+ }
+
+ public static MarginLayoutParams newLayoutParam(ViewGroup placer, int width, int height) {
+ if (placer instanceof FrameLayout) {
+ return new FrameLayout.LayoutParams(width, height);
+ } else if (placer instanceof RelativeLayout) {
+ return new RelativeLayout.LayoutParams(width, height);
+ } else if (placer == null) {
+ throw new NullPointerException("placer is null");
+ } else {
+ throw new IllegalArgumentException("placer is neither FrameLayout nor RelativeLayout: "
+ + placer.getClass().getName());
+ }
+ }
+}
diff --git a/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java b/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java
index fe70eef96..cf6cd0f5e 100644
--- a/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java
+++ b/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java
@@ -16,7 +16,7 @@
package com.android.inputmethod.deprecated.languageswitcher;
-import com.android.inputmethod.keyboard.KeyboardParser;
+import com.android.inputmethod.keyboard.internal.KeyboardParser;
import com.android.inputmethod.latin.DictionaryFactory;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.Settings;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index 7add43a6d..818f3f925 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -18,6 +18,8 @@ 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 58629ba51..889d54bf3 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -21,6 +21,10 @@ 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;
import com.android.inputmethod.latin.R;
import org.xmlpull.v1.XmlPullParserException;
@@ -51,7 +55,7 @@ import java.util.Map;
* </pre>
*/
public class Keyboard {
- private static final String TAG = "Keyboard";
+ private static final String TAG = Keyboard.class.getSimpleName();
public static final int EDGE_LEFT = 0x01;
public static final int EDGE_RIGHT = 0x02;
@@ -130,6 +134,8 @@ public class Keyboard {
public final KeyboardId mId;
+ public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
+
// Variables for pre-computing nearest keys.
// TODO: Change GRID_WIDTH and GRID_HEIGHT to private.
@@ -448,7 +454,7 @@ public class Keyboard {
}
}
- protected static void setDefaultBounds(Drawable drawable) {
+ public static void setDefaultBounds(Drawable drawable) {
if (drawable != null)
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight());
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index d97bb6730..2497eeb7b 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -42,7 +42,6 @@ public class KeyboardId {
public final int mWidth;
public final int mMode;
public final int mXmlId;
- public final int mColorScheme;
public final boolean mNavigateAction;
public final boolean mPasswordInput;
public final boolean mHasSettingsKey;
@@ -56,9 +55,9 @@ public class KeyboardId {
private final int mHashCode;
- public KeyboardId(String xmlName, int xmlId, int colorScheme, Locale locale, int orientation,
- int width, int mode, EditorInfo attribute, boolean hasSettingsKey,
- boolean voiceKeyEnabled, boolean hasVoiceKey, boolean enableShiftLock) {
+ public KeyboardId(String xmlName, int xmlId, Locale locale, int orientation, int width,
+ int mode, EditorInfo attribute, boolean hasSettingsKey, 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;
@@ -66,7 +65,6 @@ public class KeyboardId {
this.mWidth = width;
this.mMode = mode;
this.mXmlId = xmlId;
- this.mColorScheme = colorScheme;
// Note: Turn off checking navigation flag to show TAB key for now.
this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType);
// || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions)
@@ -91,7 +89,6 @@ public class KeyboardId {
width,
mode,
xmlId,
- colorScheme,
mNavigateAction,
mPasswordInput,
hasSettingsKey,
@@ -103,15 +100,15 @@ public class KeyboardId {
}
public KeyboardId cloneWithNewLayout(String xmlName, int xmlId) {
- return new KeyboardId(xmlName, xmlId, mColorScheme, mLocale, mOrientation, mWidth, mMode,
- mAttribute, mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
+ return new KeyboardId(xmlName, xmlId, mLocale, mOrientation, mWidth, mMode, mAttribute,
+ mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
}
public KeyboardId cloneWithNewGeometry(int width) {
if (mWidth == width)
return this;
- return new KeyboardId(mXmlName, mXmlId, mColorScheme, mLocale, mOrientation, width, mMode,
- mAttribute, mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
+ return new KeyboardId(mXmlName, mXmlId, mLocale, mOrientation, width, mMode, mAttribute,
+ mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
}
public int getXmlId() {
@@ -145,7 +142,6 @@ public class KeyboardId {
&& other.mWidth == this.mWidth
&& other.mMode == this.mMode
&& other.mXmlId == this.mXmlId
- && other.mColorScheme == this.mColorScheme
&& other.mNavigateAction == this.mNavigateAction
&& other.mPasswordInput == this.mPasswordInput
&& other.mHasSettingsKey == this.mHasSettingsKey
@@ -162,13 +158,12 @@ public class KeyboardId {
@Override
public String toString() {
- return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s%s]",
+ return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s]",
mXmlName,
mLocale,
(mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode),
EditorInfoCompatUtils.imeOptionsName(mImeAction),
- colorSchemeName(mColorScheme),
(mNavigateAction ? " navigateAction" : ""),
(mPasswordInput ? " passwordInput" : ""),
(mHasSettingsKey ? " hasSettingsKey" : ""),
@@ -189,12 +184,4 @@ public class KeyboardId {
}
return null;
}
-
- public static String colorSchemeName(int colorScheme) {
- switch (colorScheme) {
- case KeyboardView.COLOR_SCHEME_WHITE: return "white";
- case KeyboardView.COLOR_SCHEME_BLACK: return "black";
- }
- return null;
- }
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 1218a5abd..7c7016840 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -27,6 +27,9 @@ import android.view.View;
import android.view.inputmethod.EditorInfo;
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;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
@@ -255,7 +258,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private KeyboardId getKeyboardId(EditorInfo attribute, boolean isSymbols) {
final int mode = Utils.getKeyboardMode(attribute);
final boolean hasVoiceKey = hasVoiceKey(isSymbols);
- final int charColorId = getColorScheme();
final int xmlId;
final boolean enableShiftLock;
@@ -288,9 +290,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mKeyboardWidth = res.getDisplayMetrics().widthPixels;
final Locale locale = mSubtypeSwitcher.getInputLocale();
return new KeyboardId(
- res.getResourceEntryName(xmlId), xmlId, charColorId, locale, orientation,
- mKeyboardWidth, mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey,
- enableShiftLock);
+ res.getResourceEntryName(xmlId), xmlId, locale, orientation, mKeyboardWidth,
+ mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock);
}
private KeyboardId makeSiblingKeyboardId(KeyboardId base, int alphabet, int phone) {
@@ -785,11 +786,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
}
- private int getColorScheme() {
- return (mKeyboardView != null)
- ? mKeyboardView.getColorScheme() : KeyboardView.COLOR_SCHEME_WHITE;
- }
-
public void onAutoCorrectionStateChanged(boolean isAutoCorrection) {
if (mIsAutoCorrectionActive != isAutoCorrection) {
mIsAutoCorrectionActive = isAutoCorrection;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index f73cdc083..4b162142d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -42,11 +42,14 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
+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;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
@@ -59,7 +62,6 @@ import java.util.WeakHashMap;
* presses and touch movements.
*
* @attr ref R.styleable#KeyboardView_backgroundDimAmount
- * @attr ref R.styleable#KeyboardView_colorScheme
* @attr ref R.styleable#KeyboardView_keyBackground
* @attr ref R.styleable#KeyboardView_keyHysteresisDistance
* @attr ref R.styleable#KeyboardView_keyLetterRatio
@@ -88,9 +90,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private static final boolean ENABLE_CAPSLOCK_BY_LONGPRESS = true;
private static final boolean ENABLE_CAPSLOCK_BY_DOUBLETAP = true;
- public static final int COLOR_SCHEME_WHITE = 0;
- public static final int COLOR_SCHEME_BLACK = 1;
-
// Timing constants
private final int mKeyRepeatInterval;
@@ -106,7 +105,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private final float mKeyLabelRatio;
private final float mKeyHintLetterRatio;
private final float mKeyUppercaseLetterRatio;
- private final int mColorScheme;
private final int mShadowColor;
private final float mShadowRadius;
private final Drawable mKeyBackground;
@@ -353,7 +351,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f);
// TODO: Use Theme (android.R.styleable.Theme_backgroundDimAmount)
mBackgroundDimAmount = a.getFloat(R.styleable.KeyboardView_backgroundDimAmount, 0.5f);
- mColorScheme = a.getInt(R.styleable.KeyboardView_colorScheme, COLOR_SCHEME_WHITE);
a.recycle();
final Resources res = getResources();
@@ -562,10 +559,6 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
return mShowKeyPreviewPopup;
}
- public int getColorScheme() {
- return mColorScheme;
- }
-
/**
* When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key
* codes for adjacent keys. When disabled, only the primary key code will be
@@ -942,27 +935,12 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
}
private void addKeyPreview(TextView keyPreview) {
- ViewGroup placer = mPreviewPlacer;
- if (placer == null) {
- final FrameLayout screenContent = (FrameLayout) getRootView().findViewById(
- android.R.id.content);
- if (android.os.Build.VERSION.SDK_INT >= /* HONEYCOMB */11) {
- placer = screenContent;
- } else {
- // Insert LinearLayout to be able to setMargin because pre-Honeycomb FrameLayout
- // could not handle setMargin properly.
- placer = new LinearLayout(getContext());
- screenContent.addView(placer);
- }
- mPreviewPlacer = placer;
- }
- if (placer instanceof FrameLayout) {
- // Honeycomb or later.
- placer.addView(keyPreview, new FrameLayout.LayoutParams(0, 0));
- } else {
- // Gingerbread or ealier.
- placer.addView(keyPreview, new LinearLayout.LayoutParams(0, 0));
+ if (mPreviewPlacer == null) {
+ mPreviewPlacer = FrameLayoutCompatUtils.getPlacer(
+ (ViewGroup)getRootView().findViewById(android.R.id.content));
}
+ final ViewGroup placer = mPreviewPlacer;
+ placer.addView(keyPreview, FrameLayoutCompatUtils.newLayoutParam(placer, 0, 0));
}
// TODO: Introduce minimum duration for displaying key previews
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
index 020fb56ca..e741625ca 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
@@ -33,6 +33,8 @@ 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;
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 901df6ab7..d25d1f098 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -24,6 +24,7 @@ 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 2d6766f2d..d3d3fa59f 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java
@@ -18,6 +18,8 @@ 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 cc5c3bbfe..9170c3bd1 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboardKeyDetector.java
@@ -16,6 +16,8 @@
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 0a727ad42..1d70481f4 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -16,16 +16,19 @@
package com.android.inputmethod.keyboard;
-import com.android.inputmethod.keyboard.KeyboardView.UIHandler;
-import com.android.inputmethod.latin.LatinImeLogger;
-import com.android.inputmethod.latin.R;
-import com.android.inputmethod.latin.SubtypeSwitcher;
-
import android.content.res.Resources;
import android.os.SystemClock;
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;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.SubtypeSwitcher;
+
import java.util.Arrays;
import java.util.List;
diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
index ff64c73cd..2085404dc 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
@@ -25,6 +25,7 @@ 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;
/**
diff --git a/java/src/com/android/inputmethod/keyboard/PopupPanel.java b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
index 6f2b16148..72fa7406a 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupPanel.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupPanel.java
@@ -19,6 +19,8 @@ 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.
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 33acc6907..a6a07e518 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -16,6 +16,7 @@
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/Key.java b/java/src/com/android/inputmethod/keyboard/internal/Key.java
index e5ee272a2..5470067dc 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/Key.java
@@ -14,11 +14,7 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
-
-import com.android.inputmethod.keyboard.KeyStyles.KeyStyle;
-import com.android.inputmethod.keyboard.KeyboardParser.ParseException;
-import com.android.inputmethod.latin.R;
+package com.android.inputmethod.keyboard.internal;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -27,6 +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.KeyStyle;
+import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException;
+import com.android.inputmethod.latin.R;
+
import java.util.ArrayList;
/**
@@ -164,7 +165,7 @@ public class Key {
mLabel = PopupCharactersParser.getLabel(popupSpecification);
mOutputText = PopupCharactersParser.getOutputText(popupSpecification);
mCode = PopupCharactersParser.getCode(res, popupSpecification);
- mIcon = PopupCharactersParser.getIcon(res, popupSpecification);
+ mIcon = keyboard.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpecification));
// Horizontal gap is divided equally to both sides of the key.
mX = x + mGap / 2;
mY = y;
@@ -262,13 +263,18 @@ public class Key {
mEdgeFlags = style.getFlag(keyAttr, R.styleable.Keyboard_Key_keyEdgeFlags, 0)
| row.mRowEdgeFlags;
+ final KeyboardIconsSet iconsSet = mKeyboard.mIconsSet;
mVisualInsetsLeft = KeyboardParser.getDimensionOrFraction(keyAttr,
R.styleable.Keyboard_Key_visualInsetsLeft, mKeyboard.getDisplayHeight(), 0);
mVisualInsetsRight = KeyboardParser.getDimensionOrFraction(keyAttr,
R.styleable.Keyboard_Key_visualInsetsRight, mKeyboard.getDisplayHeight(), 0);
- mPreviewIcon = style.getDrawable(keyAttr, R.styleable.Keyboard_Key_iconPreview);
+ mPreviewIcon = iconsSet.getIcon(style.getInt(
+ keyAttr, R.styleable.Keyboard_Key_keyIconPreview,
+ KeyboardIconsSet.ICON_UNDEFINED));
Keyboard.setDefaultBounds(mPreviewIcon);
- mIcon = style.getDrawable(keyAttr, R.styleable.Keyboard_Key_keyIcon);
+ mIcon = iconsSet.getIcon(style.getInt(
+ keyAttr, R.styleable.Keyboard_Key_keyIcon,
+ KeyboardIconsSet.ICON_UNDEFINED));
Keyboard.setDefaultBounds(mIcon);
mHintLetter = style.getText(keyAttr, R.styleable.Keyboard_Key_keyHintLetter);
@@ -287,8 +293,9 @@ public class Key {
mCode = Keyboard.CODE_DUMMY;
}
- final Drawable shiftedIcon = style.getDrawable(keyAttr,
- R.styleable.Keyboard_Key_shiftedIcon);
+ final Drawable shiftedIcon = iconsSet.getIcon(style.getInt(
+ keyAttr, R.styleable.Keyboard_Key_keyIconShifted,
+ KeyboardIconsSet.ICON_UNDEFINED));
if (shiftedIcon != null)
mKeyboard.getShiftedIcons().put(this, shiftedIcon);
} finally {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
index ce5ee5495..983f0649d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyStyles.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
@@ -14,16 +14,15 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
-
-import com.android.inputmethod.keyboard.KeyboardParser.ParseException;
-import com.android.inputmethod.latin.R;
+package com.android.inputmethod.keyboard.internal;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
-import android.graphics.drawable.Drawable;
import android.util.Log;
+import com.android.inputmethod.keyboard.internal.KeyboardParser.ParseException;
+import com.android.inputmethod.latin.R;
+
import java.util.ArrayList;
import java.util.HashMap;
@@ -37,7 +36,6 @@ public class KeyStyles {
public interface KeyStyle {
public CharSequence[] getTextArray(TypedArray a, int index);
- public Drawable getDrawable(TypedArray a, int index);
public CharSequence getText(TypedArray a, int index);
public int getInt(TypedArray a, int index, int defaultValue);
public int getFlag(TypedArray a, int index, int defaultValue);
@@ -55,11 +53,6 @@ public class KeyStyles {
}
@Override
- public Drawable getDrawable(TypedArray a, int index) {
- return a.getDrawable(index);
- }
-
- @Override
public CharSequence getText(TypedArray a, int index) {
return a.getText(index);
}
@@ -140,12 +133,6 @@ public class KeyStyles {
}
@Override
- public Drawable getDrawable(TypedArray a, int index) {
- return a.hasValue(index)
- ? super.getDrawable(a, index) : (Drawable)mAttributes.get(index);
- }
-
- @Override
public CharSequence getText(TypedArray a, int index) {
return a.hasValue(index)
? super.getText(a, index) : (CharSequence)mAttributes.get(index);
@@ -177,25 +164,20 @@ public class KeyStyles {
// TODO: Currently not all Key attributes can be declared as style.
readInt(keyAttr, R.styleable.Keyboard_Key_code);
readText(keyAttr, R.styleable.Keyboard_Key_keyLabel);
- readFlag(keyAttr, R.styleable.Keyboard_Key_keyLabelOption);
- readTextArray(keyAttr, R.styleable.Keyboard_Key_popupCharacters);
- readInt(keyAttr, R.styleable.Keyboard_Key_maxPopupKeyboardColumn);
readText(keyAttr, R.styleable.Keyboard_Key_keyOutputText);
- readDrawable(keyAttr, R.styleable.Keyboard_Key_keyIcon);
- readDrawable(keyAttr, R.styleable.Keyboard_Key_iconPreview);
readText(keyAttr, R.styleable.Keyboard_Key_keyHintLetter);
- readDrawable(keyAttr, R.styleable.Keyboard_Key_shiftedIcon);
+ readTextArray(keyAttr, R.styleable.Keyboard_Key_popupCharacters);
+ readFlag(keyAttr, R.styleable.Keyboard_Key_keyLabelOption);
+ readInt(keyAttr, R.styleable.Keyboard_Key_keyIcon);
+ readInt(keyAttr, R.styleable.Keyboard_Key_keyIconPreview);
+ readInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted);
+ readInt(keyAttr, R.styleable.Keyboard_Key_maxPopupKeyboardColumn);
readBoolean(keyAttr, R.styleable.Keyboard_Key_isFunctional);
readBoolean(keyAttr, R.styleable.Keyboard_Key_isSticky);
readBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable);
readBoolean(keyAttr, R.styleable.Keyboard_Key_enabled);
}
- private void readDrawable(TypedArray a, int index) {
- if (a.hasValue(index))
- mAttributes.put(index, a.getDrawable(index));
- }
-
private void readText(TypedArray a, int index) {
if (a.hasValue(index))
mAttributes.put(index, a.getText(index));
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
new file mode 100644
index 000000000..9916af5da
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2011 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 android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.util.Log;
+
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.R;
+
+public class KeyboardIconsSet {
+ private static final String TAG = KeyboardIconsSet.class.getSimpleName();
+
+ public static final int ICON_UNDEFINED = 0;
+
+ // This should be aligned with Keyboard.keyIcon enum.
+ private static final int ICON_SHIFT_KEY = 1;
+ private static final int ICON_TO_SYMBOL_KEY = 2;
+ private static final int ICON_TO_SYMBOL_KEY_WITH_SHORTCUT = 3;
+ private static final int ICON_DELETE_KEY = 4;
+ private static final int ICON_SETTINGS_KEY = 5;
+ private static final int ICON_SHORTCUT_KEY = 6;
+ private static final int ICON_SPACE_KEY = 7;
+ private static final int ICON_RETURN_KEY = 8;
+ private static final int ICON_SEARCH_KEY = 9;
+ private static final int ICON_TAB_KEY = 10;
+ private static final int ICON_NUM1_KEY = 11;
+ private static final int ICON_NUM2_KEY = 12;
+ private static final int ICON_NUM3_KEY = 13;
+ private static final int ICON_NUM4_KEY = 14;
+ private static final int ICON_NUM5_KEY = 15;
+ private static final int ICON_NUM6_KEY = 16;
+ private static final int ICON_NUM7_KEY = 17;
+ private static final int ICON_NUM8_KEY = 18;
+ private static final int ICON_NUM9_KEY = 19;
+ private static final int ICON_NUM0_KEY = 20;
+ private static final int ICON_NUM_STAR_KEY = 21;
+ private static final int ICON_NUM_POUND_KEY = 22;
+ private static final int ICON_NUM_ALT_KEY = 23;
+ // This should be aligned with Keyboard.keyIconShifted enum.
+ private static final int ICON_SHIFTED_SHIFT_KEY = 24;
+ // This should be aligned with Keyboard.keyIconPreview enum.
+ private static final int ICON_PREVIEW_SPACE_KEY = 25;
+ private static final int ICON_PREVIEW_TAB_KEY = 26;
+ private static final int ICON_PREVIEW_SETTINGS_KEY = 27;
+ private static final int ICON_PREVIEW_SHORTCUT_KEY = 28;
+
+ private static final int ICON_LAST = 28;
+
+ private final Drawable mIcons[] = new Drawable[ICON_LAST + 1];
+
+ private static final int getIconId(int attrIndex) {
+ switch (attrIndex) {
+ case R.styleable.Keyboard_iconShiftKey:
+ return ICON_SHIFT_KEY;
+ case R.styleable.Keyboard_iconToSymbolKey:
+ return ICON_TO_SYMBOL_KEY;
+ case R.styleable.Keyboard_iconToSymbolKeyWithShortcut:
+ return ICON_TO_SYMBOL_KEY_WITH_SHORTCUT;
+ case R.styleable.Keyboard_iconDeleteKey:
+ return ICON_DELETE_KEY;
+ case R.styleable.Keyboard_iconSettingsKey:
+ return ICON_SETTINGS_KEY;
+ case R.styleable.Keyboard_iconShortcutKey:
+ return ICON_SHORTCUT_KEY;
+ case R.styleable.Keyboard_iconSpaceKey:
+ return ICON_SPACE_KEY;
+ case R.styleable.Keyboard_iconReturnKey:
+ return ICON_RETURN_KEY;
+ case R.styleable.Keyboard_iconSearchKey:
+ return ICON_SEARCH_KEY;
+ case R.styleable.Keyboard_iconTabKey:
+ return ICON_TAB_KEY;
+ case R.styleable.Keyboard_iconNum1Key:
+ return ICON_NUM1_KEY;
+ case R.styleable.Keyboard_iconNum2Key:
+ return ICON_NUM2_KEY;
+ case R.styleable.Keyboard_iconNum3Key:
+ return ICON_NUM3_KEY;
+ case R.styleable.Keyboard_iconNum4Key:
+ return ICON_NUM4_KEY;
+ case R.styleable.Keyboard_iconNum5Key:
+ return ICON_NUM5_KEY;
+ case R.styleable.Keyboard_iconNum6Key:
+ return ICON_NUM6_KEY;
+ case R.styleable.Keyboard_iconNum7Key:
+ return ICON_NUM7_KEY;
+ case R.styleable.Keyboard_iconNum8Key:
+ return ICON_NUM8_KEY;
+ case R.styleable.Keyboard_iconNum9Key:
+ return ICON_NUM9_KEY;
+ case R.styleable.Keyboard_iconNum0Key:
+ return ICON_NUM0_KEY;
+ case R.styleable.Keyboard_iconNumStarKey:
+ return ICON_NUM_STAR_KEY;
+ case R.styleable.Keyboard_iconNumPoundKey:
+ return ICON_NUM_POUND_KEY;
+ case R.styleable.Keyboard_iconNumAltKey:
+ return ICON_NUM_ALT_KEY;
+ case R.styleable.Keyboard_iconShiftedShiftKey:
+ return ICON_SHIFTED_SHIFT_KEY;
+ case R.styleable.Keyboard_iconPreviewSpaceKey:
+ return ICON_PREVIEW_SPACE_KEY;
+ case R.styleable.Keyboard_iconPreviewTabKey:
+ return ICON_PREVIEW_TAB_KEY;
+ case R.styleable.Keyboard_iconPreviewSettingsKey:
+ return ICON_PREVIEW_SETTINGS_KEY;
+ case R.styleable.Keyboard_iconPreviewShortcutKey:
+ return ICON_PREVIEW_SHORTCUT_KEY;
+ default:
+ return ICON_UNDEFINED;
+ }
+ }
+
+ public void loadIcons(TypedArray keyboardAttrs) {
+ final int count = keyboardAttrs.getIndexCount();
+ for (int i = 0; i < count; i++) {
+ final int attrIndex = keyboardAttrs.getIndex(i);
+ final int iconId = getIconId(attrIndex);
+ if (iconId != ICON_UNDEFINED) {
+ try {
+ final Drawable icon = keyboardAttrs.getDrawable(attrIndex);
+ Keyboard.setDefaultBounds(icon);
+ mIcons[iconId] = icon;
+ } catch (Resources.NotFoundException e) {
+ Log.w(TAG, "Drawable resource for icon #" + iconId + " not found");
+ }
+ }
+ }
+ }
+
+ public Drawable getIcon(int iconId) {
+ if (iconId == ICON_UNDEFINED)
+ return null;
+ if (iconId < 0 || iconId >= mIcons.length)
+ throw new IllegalArgumentException("icon id is out of range: " + iconId);
+ return mIcons[iconId];
+ }
+}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
index 20af12bc5..78546f879 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
@@ -14,7 +14,7 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
+package com.android.inputmethod.keyboard.internal;
import android.content.Context;
import android.content.res.Resources;
@@ -26,6 +26,8 @@ import android.util.Xml;
import android.view.InflateException;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.latin.R;
import org.xmlpull.v1.XmlPullParser;
@@ -88,14 +90,14 @@ import java.util.List;
* You can declare Key style and specify styles within Key tags.
* <pre>
* &gt;switch&lt;
- * &gt;case colorScheme="white"&lt;
- * &gt;key-style styleName="shift-key" parentStyle="modifier-key"
- * keyIcon="@drawable/sym_keyboard_shift"
+ * &gt;case mode="email"&lt;
+ * &gt;key-style styleName="f1-key" parentStyle="modifier-key"
+ * keyLabel=".com"
* /&lt;
* &gt;/case&lt;
- * &gt;case colorScheme="black"&lt;
- * &gt;key-style styleName="shift-key" parentStyle="modifier-key"
- * keyIcon="@drawable/sym_bkeyboard_shift"
+ * &gt;case mode="url"&lt;
+ * &gt;key-style styleName="f1-key" parentStyle="modifier-key"
+ * keyLabel="http://"
* /&lt;
* &gt;/case&lt;
* &gt;/switch&lt;
@@ -230,6 +232,8 @@ public class KeyboardParser {
keyboard.setMaxPopupKeyboardColumn(keyAttr.getInt(
R.styleable.Keyboard_Key_maxPopupKeyboardColumn, 5));
+
+ mKeyboard.mIconsSet.loadIcons(keyboardAttr);
} finally {
keyAttr.recycle();
keyboardAttr.recycle();
@@ -483,8 +487,6 @@ public class KeyboardParser {
R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled);
final boolean voiceKeyMatched = matchBoolean(a,
R.styleable.Keyboard_Case_hasVoiceKey, id.mHasVoiceKey);
- final boolean colorSchemeMatched = matchInteger(viewAttr,
- R.styleable.KeyboardView_colorScheme, id.mColorScheme);
// As noted at {@link KeyboardId} class, we are interested only in enum value masked by
// {@link android.view.inputmethod.EditorInfo#IME_MASK_ACTION} and
// {@link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION}. So matching
@@ -499,14 +501,11 @@ public class KeyboardParser {
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
final boolean selected = modeMatched && navigateActionMatched && passwordInputMatched
&& settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched
- && colorSchemeMatched && imeActionMatched && localeCodeMatched
- && languageCodeMatched && countryCodeMatched;
+ && imeActionMatched && localeCodeMatched && languageCodeMatched
+ && countryCodeMatched;
- if (DEBUG) Log.d(TAG, String.format("<%s%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", TAG_CASE,
textAttr(a.getString(R.styleable.Keyboard_Case_mode), "mode"),
- textAttr(KeyboardId.colorSchemeName(
- viewAttr.getInt(
- R.styleable.KeyboardView_colorScheme, -1)), "colorScheme"),
booleanAttr(a, R.styleable.Keyboard_Case_navigateAction, "navigateAction"),
booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardShiftState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
index e015b5158..0cde4e5b5 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardShiftState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardShiftState.java
@@ -14,10 +14,12 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
+package com.android.inputmethod.keyboard.internal;
import android.util.Log;
+import com.android.inputmethod.keyboard.KeyboardSwitcher;
+
public class KeyboardShiftState {
private static final String TAG = "KeyboardShiftState";
private static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
index 6e939123d..01faae61d 100644
--- a/java/src/com/android/inputmethod/keyboard/MiniKeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/MiniKeyboardBuilder.java
@@ -14,15 +14,18 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
-
-import com.android.inputmethod.latin.R;
+package com.android.inputmethod.keyboard.internal;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Rect;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.KeyboardView;
+import com.android.inputmethod.keyboard.MiniKeyboard;
+import com.android.inputmethod.latin.R;
+
import java.util.List;
public class MiniKeyboardBuilder {
diff --git a/java/src/com/android/inputmethod/keyboard/ModifierKeyState.java b/java/src/com/android/inputmethod/keyboard/internal/ModifierKeyState.java
index ebbc79a9e..dae73c4e4 100644
--- a/java/src/com/android/inputmethod/keyboard/ModifierKeyState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/ModifierKeyState.java
@@ -14,10 +14,12 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
+package com.android.inputmethod.keyboard.internal;
import android.util.Log;
+import com.android.inputmethod.keyboard.KeyboardSwitcher;
+
public class ModifierKeyState {
protected static final String TAG = "ModifierKeyState";
protected static final boolean DEBUG = KeyboardSwitcher.DEBUG_STATE;
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTrackerKeyState.java b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerKeyState.java
index eecbb26f3..ddadb1338 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTrackerKeyState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerKeyState.java
@@ -14,12 +14,15 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.keyboard.KeyDetector;
+import com.android.inputmethod.keyboard.PointerTracker;
/**
* This class keeps track of a key index and a position where {@link PointerTracker} is.
*/
-/* package */ class PointerTrackerKeyState {
+public class PointerTrackerKeyState {
private final KeyDetector mKeyDetector;
// The position and time at which first down event occurred.
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java
index 9e287c67d..f87cd869e 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTrackerQueue.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java
@@ -14,7 +14,9 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.keyboard.PointerTracker;
import java.util.LinkedList;
diff --git a/java/src/com/android/inputmethod/keyboard/PopupCharactersParser.java b/java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java
index ff78ee5c9..8276f5d78 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupCharactersParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java
@@ -14,13 +14,14 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
-
-import com.android.inputmethod.latin.R;
+package com.android.inputmethod.keyboard.internal;
import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.R;
/**
* String parser of popupCharacters attribute of Key.
@@ -28,16 +29,19 @@ import android.text.TextUtils;
* Each popup key text is one of the following:
* - A single letter (Letter)
* - Label optionally followed by keyOutputText or code (keyLabel|keyOutputText).
- * - Icon followed by keyOutputText or code (@drawable/icon|@integer/key_code)
+ * - Icon followed by keyOutputText or code (@icon/icon_number|@integer/key_code)
* Special character, comma ',' backslash '\', and bar '|' can be escaped by '\'
* character.
* Note that the character '@' and '\' are also parsed by XML parser and CSV parser as well.
+ * See {@link KeyboardIconsSet} about icon_number.
*/
public class PopupCharactersParser {
+ private static final String TAG = PopupCharactersParser.class.getSimpleName();
+
private static final char ESCAPE = '\\';
private static final String LABEL_END = "|";
private static final String PREFIX_AT = "@";
- private static final String PREFIX_ICON = PREFIX_AT + "drawable/";
+ private static final String PREFIX_ICON = PREFIX_AT + "icon/";
private static final String PREFIX_CODE = PREFIX_AT + "integer/";
private PopupCharactersParser() {
@@ -150,13 +154,18 @@ public class PopupCharactersParser {
return Keyboard.CODE_DUMMY;
}
- public static Drawable getIcon(Resources res, String popupSpec) {
+ public static int getIconId(String popupSpec) {
if (hasIcon(popupSpec)) {
int end = popupSpec.indexOf(LABEL_END, PREFIX_ICON.length() + 1);
- int resId = getResourceId(res, popupSpec.substring(PREFIX_AT.length(), end));
- return res.getDrawable(resId);
+ final String iconId = popupSpec.substring(PREFIX_ICON.length(), end);
+ try {
+ return Integer.valueOf(iconId);
+ } catch (NumberFormatException e) {
+ Log.w(TAG, "illegal icon id specified: " + iconId);
+ return KeyboardIconsSet.ICON_UNDEFINED;
+ }
}
- return null;
+ return KeyboardIconsSet.ICON_UNDEFINED;
}
private static int getResourceId(Resources res, String name) {
diff --git a/java/src/com/android/inputmethod/keyboard/Row.java b/java/src/com/android/inputmethod/keyboard/internal/Row.java
index 40d7e1472..06aadcc05 100644
--- a/java/src/com/android/inputmethod/keyboard/Row.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/Row.java
@@ -14,15 +14,16 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
-
-import com.android.inputmethod.latin.R;
+package com.android.inputmethod.keyboard.internal;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.Xml;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.R;
+
/**
* Container for keys in the keyboard. All keys in a row are at the same Y-coordinate.
* Some of the key size defaults can be overridden per row from what the {@link Keyboard}
diff --git a/java/src/com/android/inputmethod/keyboard/ShiftKeyState.java b/java/src/com/android/inputmethod/keyboard/internal/ShiftKeyState.java
index ba15624f0..6617b917f 100644
--- a/java/src/com/android/inputmethod/keyboard/ShiftKeyState.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/ShiftKeyState.java
@@ -14,7 +14,7 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
+package com.android.inputmethod.keyboard.internal;
import android.util.Log;
diff --git a/java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java b/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java
index dd271de64..df4b575f1 100644
--- a/java/src/com/android/inputmethod/keyboard/SlidingLocaleDrawable.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/SlidingLocaleDrawable.java
@@ -14,7 +14,7 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
+package com.android.inputmethod.keyboard.internal;
import android.content.Context;
import android.content.res.TypedArray;
@@ -28,6 +28,8 @@ import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.view.ViewConfiguration;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.LatinKeyboard;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher;
@@ -78,7 +80,7 @@ public class SlidingLocaleDrawable extends Drawable {
mThreshold = ViewConfiguration.get(context).getScaledTouchSlop();
}
- void setDiff(int diff) {
+ public void setDiff(int diff) {
if (diff == Integer.MAX_VALUE) {
mHitThreshold = false;
mCurrentLanguage = null;
diff --git a/java/src/com/android/inputmethod/keyboard/SwipeTracker.java b/java/src/com/android/inputmethod/keyboard/internal/SwipeTracker.java
index 975b13b50..8d192c2f0 100644
--- a/java/src/com/android/inputmethod/keyboard/SwipeTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/SwipeTracker.java
@@ -14,7 +14,7 @@
* the License.
*/
-package com.android.inputmethod.keyboard;
+package com.android.inputmethod.keyboard.internal;
import android.view.MotionEvent;
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index fa27ca5ad..09b356d65 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -44,6 +44,7 @@ import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
+import com.android.inputmethod.compat.FrameLayoutCompatUtils;
import com.android.inputmethod.compat.LinearLayoutCompatUtils;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
@@ -244,7 +245,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
public void setListener(Listener listener, View inputView) {
mListener = listener;
mKeyboardView = inputView.findViewById(R.id.keyboard_view);
- mCandidatesPane = (ViewGroup)inputView.findViewById(R.id.candidates_pane);
+ mCandidatesPane = FrameLayoutCompatUtils.getPlacer(
+ (ViewGroup)inputView.findViewById(R.id.candidates_pane));
mCandidatesPane.setOnClickListener(this);
mCandidatesPaneContainer = (ViewGroup)inputView.findViewById(
R.id.candidates_pane_container);
@@ -346,12 +348,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
if (x != 0) {
final View divider = mDividers.get(i - NUM_CANDIDATES_IN_STRIP);
- mCandidatesPane.addView(divider);
- placeCandidateAt(divider, x, y);
+ addCandidateAt(divider, x, y);
x += dividerWidth;
}
- mCandidatesPane.addView(tv);
- placeCandidateAt(tv, x, y);
+ addCandidateAt(tv, x, y);
x += width;
}
@@ -372,14 +372,13 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
}
- private void placeCandidateAt(View v, int x, int y) {
- ViewGroup.LayoutParams lp = v.getLayoutParams();
- if (lp instanceof ViewGroup.MarginLayoutParams) {
- ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams)lp;
- mlp.width = v.getMeasuredWidth();
- mlp.height = v.getMeasuredHeight();
- mlp.setMargins(x, y + (mCandidateStripHeight - mlp.height) / 2, 0, 0);
- }
+ 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) {