aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-04-18 17:00:58 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-04-18 17:00:58 +0900
commit3f2653ba60c2509bdf72c44c2ae051d2cadc5dbb (patch)
tree39900835587f3ce2f7d29957309fa8600a3fd9b7 /java/src
parenta0efebf304c3924f93e49cf9e7c85e9a9d1627b2 (diff)
downloadlatinime-3f2653ba60c2509bdf72c44c2ae051d2cadc5dbb.tar.gz
latinime-3f2653ba60c2509bdf72c44c2ae051d2cadc5dbb.tar.xz
latinime-3f2653ba60c2509bdf72c44c2ae051d2cadc5dbb.zip
Refactor key preview related code in KeyboardView
Change-Id: Ib8f08cb4f5e03d0c32c32a0ea0363ce3d72fc050
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java36
1 files changed, 25 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 3550dcbb0..3cef002d7 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -118,6 +118,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
private int mPopupPreviewDisplayedY;
private final int mDelayBeforePreview;
private final int mDelayAfterPreview;
+ private ViewGroup mPreviewPlacer;
// Popup mini keyboard
private PopupWindow mMiniKeyboardPopup;
@@ -898,22 +899,35 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
}
}
- // TODO: Introduce minimum duration for displaying key previews
- // TODO: Display up to two key previews when the user presses two keys at the same time
- private void showKey(final int keyIndex, PointerTracker tracker) {
- // If the preview popup has no parent view yet, add it to the screen FrameLayout.
- if (mPreviewText.getParent() == null) {
- final FrameLayout screenContent = (FrameLayout) getRootView()
- .findViewById(android.R.id.content);
- if (android.os.Build.VERSION.SDK_INT >= /* HONEYCOMB */ 11) {
- screenContent.addView(mPreviewText, new FrameLayout.LayoutParams(0, 0));
+ 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.
- final LinearLayout placer = new LinearLayout(getContext());
+ placer = new LinearLayout(getContext());
screenContent.addView(placer);
- placer.addView(mPreviewText, new LinearLayout.LayoutParams(0, 0));
}
+ mPreviewPlacer = placer;
+ }
+ if (placer instanceof FrameLayout) {
+ placer.addView(keyPreview, new FrameLayout.LayoutParams(0, 0));
+ } else {
+ placer.addView(keyPreview, new LinearLayout.LayoutParams(0, 0));
+ }
+ }
+
+ // TODO: Introduce minimum duration for displaying key previews
+ // TODO: Display up to two key previews when the user presses two keys at the same time
+ private void showKey(final int keyIndex, PointerTracker tracker) {
+ // If the preview popup has no parent view yet, add it to the ViewGroup which can place
+ // key preview absolutely in SoftInputWindow.
+ if (mPreviewText.getParent() == null) {
+ addKeyPreview(mPreviewText);
}
final Key key = tracker.getKey(keyIndex);