aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyPreviewChoreographer.java13
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java2
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTestsBase.java (renamed from tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserBase.java)6
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java2
5 files changed, 18 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 71e3eeeaf..f3cfae203 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -484,11 +484,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
return;
}
- final TextView previewTextView = mKeyPreviewChoreographer.getKeyPreviewTextView(
- key, getContext());
locatePreviewPlacerView();
- mDrawingPreviewPlacerView.addView(
- previewTextView, ViewLayoutUtils.newLayoutParam(mDrawingPreviewPlacerView, 0, 0));
+ final TextView previewTextView = mKeyPreviewChoreographer.getKeyPreviewTextView(
+ key, mDrawingPreviewPlacerView);
getLocationInWindow(mOriginCoords);
mKeyPreviewChoreographer.placeKeyPreview(key, previewTextView, keyboard.mIconsSet,
mKeyDrawParams, getWidth(), mOriginCoords);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyPreviewChoreographer.java b/java/src/com/android/inputmethod/keyboard/internal/KeyPreviewChoreographer.java
index c1922b7c4..df869b2bc 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyPreviewChoreographer.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyPreviewChoreographer.java
@@ -58,7 +58,7 @@ public final class KeyPreviewChoreographer {
mParams = params;
}
- public TextView getKeyPreviewTextView(final Key key, final Context context) {
+ public TextView getKeyPreviewTextView(final Key key, final ViewGroup placerView) {
TextView previewTextView = mShowingKeyPreviewTextViews.remove(key);
if (previewTextView != null) {
return previewTextView;
@@ -67,10 +67,15 @@ public final class KeyPreviewChoreographer {
if (previewTextView != null) {
return previewTextView;
}
+ final Context context = placerView.getContext();
if (mParams.mLayoutId != 0) {
- return (TextView)LayoutInflater.from(context).inflate(mParams.mLayoutId, null);
+ previewTextView = (TextView)LayoutInflater.from(context)
+ .inflate(mParams.mLayoutId, null);
+ } else {
+ previewTextView = new TextView(context);
}
- return new TextView(context);
+ placerView.addView(previewTextView, ViewLayoutUtils.newLayoutParam(placerView, 0, 0));
+ return previewTextView;
}
public boolean isShowingKeyPreview(final Key key) {
@@ -244,7 +249,7 @@ public final class KeyPreviewChoreographer {
zoomOutAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animation) {
- dismissKeyPreview(key, true /* withAnimation */);
+ dismissKeyPreview(key, false /* withAnimation */);
}
});
return zoomOutAnimation;
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java
index e29181c71..9b6c46200 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java
@@ -21,7 +21,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import com.android.inputmethod.latin.Constants;
@SmallTest
-public final class KeySpecParserTests extends KeySpecParserBase {
+public final class KeySpecParserTests extends KeySpecParserTestsBase {
@Override
protected void assertParser(final String message, final String keySpec,
final String expectedLabel, final String expectedOutputText, final int expectedIcon,
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserBase.java b/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTestsBase.java
index aecef23e8..04b7008ef 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTestsBase.java
@@ -30,7 +30,7 @@ import com.android.inputmethod.latin.utils.RunInLocale;
import java.util.Locale;
-abstract class KeySpecParserBase extends AndroidTestCase {
+abstract class KeySpecParserTestsBase extends AndroidTestCase {
private final static Locale TEST_LOCALE = Locale.ENGLISH;
protected final KeyboardCodesSet mCodesSet = new KeyboardCodesSet();
protected final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
@@ -251,8 +251,12 @@ abstract class KeySpecParserBase extends AndroidTestCase {
}
public void testFormatError() {
+ assertParserError("Null spec", null, null,
+ null, ICON_UNDEFINED, CODE_UNSPECIFIED);
assertParserError("Empty spec", "", null,
null, ICON_UNDEFINED, CODE_UNSPECIFIED);
+ assertParserError("Single bar", "|",
+ "|", null, ICON_UNDEFINED, '|');
assertParserError("Empty label with outputText", "|a",
null, "a", ICON_UNDEFINED, CODE_UNSPECIFIED);
assertParserError("Empty label with code", "|" + CODE_SETTINGS,
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java
index 213e2d483..e49c62461 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java
@@ -24,7 +24,7 @@ import java.util.Arrays;
import java.util.Locale;
@SmallTest
-public final class MoreKeySpecTests extends KeySpecParserBase {
+public final class MoreKeySpecTests extends KeySpecParserTestsBase {
@Override
protected void assertParser(final String message, final String moreKeySpec,
final String expectedLabel, final String expectedOutputText, final int expectedIconId,