aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-04-14 17:43:25 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-04-14 17:43:25 +0900
commit37cfacbae657c2a6329c5c4d8dae13b1c2fe45b7 (patch)
treec8cba6f876bca0253bc0ec2f2df3d264dcfaee25 /java/src
parent0851abf9990cac21dad5eaa70eefe33142c0e949 (diff)
downloadlatinime-37cfacbae657c2a6329c5c4d8dae13b1c2fe45b7.tar.gz
latinime-37cfacbae657c2a6329c5c4d8dae13b1c2fe45b7.tar.xz
latinime-37cfacbae657c2a6329c5c4d8dae13b1c2fe45b7.zip
Make showing key preview compatible with pre-Honeycomb
Bug: 4179964 Change-Id: Ide0a9c75983b45f8e829f0d64f41557d42fc11e7
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 71863803b..dee191352 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -47,6 +47,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
+import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
@@ -908,10 +909,18 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
if (mPreviewText.getParent() == null) {
final FrameLayout screenContent = (FrameLayout) getRootView()
.findViewById(android.R.id.content);
- screenContent.addView(mPreviewText, new FrameLayout.LayoutParams(0, 0));
+ if (android.os.Build.VERSION.SDK_INT >= /* HONEYCOMB */ 11) {
+ screenContent.addView(mPreviewText, new FrameLayout.LayoutParams(0, 0));
+ } else {
+ // Insert LinearLayout to be able to setMargin because pre-Honeycomb FrameLayout
+ // could not handle setMargin properly.
+ final LinearLayout placer = new LinearLayout(getContext());
+ screenContent.addView(placer);
+ placer.addView(mPreviewText, new LinearLayout.LayoutParams(0, 0));
+ }
}
- Key key = tracker.getKey(keyIndex);
+ final Key key = tracker.getKey(keyIndex);
// If keyIndex is invalid or IME is already closed, we must not show key preview.
// Trying to show preview PopupWindow while root window is closed causes
// WindowManager.BadTokenException.
@@ -943,10 +952,8 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
+ mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
final int popupHeight = mPreviewHeight;
final ViewGroup.LayoutParams lp = mPreviewText.getLayoutParams();
- if (lp != null) {
- lp.width = popupWidth;
- lp.height = popupHeight;
- }
+ lp.width = popupWidth;
+ lp.height = popupHeight;
int popupPreviewX = keyDrawX - (popupWidth - keyDrawWidth) / 2;
int popupPreviewY = key.mY - popupHeight + mPreviewOffset;