am f008a11c: Merge "Cache MoreKeysKeyboard instead of container view of it"
* commit 'f008a11ccef84916197b0031a8ed3353c87c10f1': Cache MoreKeysKeyboard instead of container view of itmain
commit
ad7e0f9fe4
|
@ -169,11 +169,11 @@ public class KeyboardView extends View {
|
||||||
public void setKeyboard(final Keyboard keyboard) {
|
public void setKeyboard(final Keyboard keyboard) {
|
||||||
mKeyboard = keyboard;
|
mKeyboard = keyboard;
|
||||||
LatinImeLogger.onSetKeyboard(keyboard);
|
LatinImeLogger.onSetKeyboard(keyboard);
|
||||||
requestLayout();
|
|
||||||
invalidateAllKeys();
|
|
||||||
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
||||||
mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes);
|
mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes);
|
||||||
mKeyDrawParams.updateParams(keyHeight, keyboard.mKeyVisualAttributes);
|
mKeyDrawParams.updateParams(keyHeight, keyboard.mKeyVisualAttributes);
|
||||||
|
invalidateAllKeys();
|
||||||
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -638,7 +638,6 @@ public class KeyboardView extends View {
|
||||||
public void closing() {
|
public void closing() {
|
||||||
mInvalidateAllKeys = true;
|
mInvalidateAllKeys = true;
|
||||||
mKeyboard = null;
|
mKeyboard = null;
|
||||||
requestLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -174,9 +174,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
// More keys keyboard
|
// More keys keyboard
|
||||||
private final Paint mBackgroundDimAlphaPaint = new Paint();
|
private final Paint mBackgroundDimAlphaPaint = new Paint();
|
||||||
private boolean mNeedsToDimEntireKeyboard;
|
private boolean mNeedsToDimEntireKeyboard;
|
||||||
private final WeakHashMap<Key, MoreKeysPanel> mMoreKeysPanelCache =
|
private final View mMoreKeysKeyboardContainer;
|
||||||
new WeakHashMap<Key, MoreKeysPanel>();
|
private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache =
|
||||||
private final int mMoreKeysLayout;
|
CollectionUtils.newWeakHashMap();
|
||||||
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
|
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
|
||||||
// More keys panel (used by both more keys keyboard and more suggestions view)
|
// More keys panel (used by both more keys keyboard and more suggestions view)
|
||||||
// TODO: Consider extending to support multiple more keys panels
|
// TODO: Consider extending to support multiple more keys panels
|
||||||
|
@ -245,7 +245,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
break;
|
break;
|
||||||
case MSG_LONGPRESS_KEY:
|
case MSG_LONGPRESS_KEY:
|
||||||
if (tracker != null) {
|
if (tracker != null) {
|
||||||
keyboardView.openMoreKeysKeyboardIfRequired(tracker.getKey(), tracker);
|
keyboardView.onLongPress(tracker);
|
||||||
} else {
|
} else {
|
||||||
KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
|
KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
if (mKeyPreviewLayoutId == 0) {
|
if (mKeyPreviewLayoutId == 0) {
|
||||||
mShowKeyPreviewPopup = false;
|
mShowKeyPreviewPopup = false;
|
||||||
}
|
}
|
||||||
mMoreKeysLayout = mainKeyboardViewAttr.getResourceId(
|
final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId(
|
||||||
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
|
R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0);
|
||||||
mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
|
mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean(
|
||||||
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
|
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
|
||||||
|
@ -566,6 +566,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
mPreviewPlacerView.addPreview(mSlidingKeyInputPreview);
|
mPreviewPlacerView.addPreview(mSlidingKeyInputPreview);
|
||||||
mainKeyboardViewAttr.recycle();
|
mainKeyboardViewAttr.recycle();
|
||||||
|
|
||||||
|
mMoreKeysKeyboardContainer = LayoutInflater.from(getContext())
|
||||||
|
.inflate(moreKeysKeyboardLayoutId, null);
|
||||||
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(
|
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(
|
||||||
languageOnSpacebarFadeoutAnimatorResId, this);
|
languageOnSpacebarFadeoutAnimatorResId, this);
|
||||||
mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator(
|
mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator(
|
||||||
|
@ -653,7 +655,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection);
|
keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection);
|
||||||
PointerTracker.setKeyDetector(mKeyDetector);
|
PointerTracker.setKeyDetector(mKeyDetector);
|
||||||
mTouchScreenRegulator.setKeyboardGeometry(keyboard.mOccupiedWidth);
|
mTouchScreenRegulator.setKeyboardGeometry(keyboard.mOccupiedWidth);
|
||||||
mMoreKeysPanelCache.clear();
|
mMoreKeysKeyboardCache.clear();
|
||||||
|
|
||||||
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
|
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);
|
||||||
mSpaceIcon = (mSpaceKey != null)
|
mSpaceIcon = (mSpaceKey != null)
|
||||||
|
@ -942,123 +944,105 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean openMoreKeysKeyboardIfRequired(final Key parentKey,
|
private MoreKeysPanel onCreateMoreKeysPanel(final Key key, final Context context) {
|
||||||
final PointerTracker tracker) {
|
if (key.mMoreKeys == null) {
|
||||||
// Check if we have a popup layout specified first.
|
|
||||||
if (mMoreKeysLayout == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we are already displaying popup panel.
|
|
||||||
if (mMoreKeysPanel != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (parentKey == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return onLongPress(parentKey, tracker);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MoreKeysPanel onCreateMoreKeysPanel(final Key parentKey) {
|
|
||||||
if (parentKey.mMoreKeys == null) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Keyboard moreKeysKeyboard = mMoreKeysKeyboardCache.get(key);
|
||||||
final View container = LayoutInflater.from(getContext()).inflate(mMoreKeysLayout, null);
|
if (moreKeysKeyboard == null) {
|
||||||
if (container == null) {
|
moreKeysKeyboard = new MoreKeysKeyboard.Builder(
|
||||||
throw new NullPointerException();
|
context, key, this, mKeyPreviewDrawParams).build();
|
||||||
|
mMoreKeysKeyboardCache.put(key, moreKeysKeyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final View container = mMoreKeysKeyboardContainer;
|
||||||
final MoreKeysKeyboardView moreKeysKeyboardView =
|
final MoreKeysKeyboardView moreKeysKeyboardView =
|
||||||
(MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view);
|
(MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view);
|
||||||
final Keyboard moreKeysKeyboard = new MoreKeysKeyboard.Builder(
|
|
||||||
container, parentKey, this, mKeyPreviewDrawParams)
|
|
||||||
.build();
|
|
||||||
moreKeysKeyboardView.setKeyboard(moreKeysKeyboard);
|
moreKeysKeyboardView.setKeyboard(moreKeysKeyboard);
|
||||||
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
|
||||||
return moreKeysKeyboardView;
|
return moreKeysKeyboardView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a key is long pressed.
|
* Called when a key is long pressed.
|
||||||
* @param parentKey the key that was long pressed
|
|
||||||
* @param tracker the pointer tracker which pressed the parent key
|
* @param tracker the pointer tracker which pressed the parent key
|
||||||
* @return true if the long press is handled, false otherwise. Subclasses should call the
|
* @return true if the long press is handled, false otherwise. Subclasses should call the
|
||||||
* method on the base class if the subclass doesn't wish to handle the call.
|
* method on the base class if the subclass doesn't wish to handle the call.
|
||||||
*/
|
*/
|
||||||
private boolean onLongPress(final Key parentKey, final PointerTracker tracker) {
|
private boolean onLongPress(final PointerTracker tracker) {
|
||||||
|
if (isShowingMoreKeysPanel()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Key key = tracker.getKey();
|
||||||
|
if (key == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
ResearchLogger.mainKeyboardView_onLongPress();
|
ResearchLogger.mainKeyboardView_onLongPress();
|
||||||
}
|
}
|
||||||
final int primaryCode = parentKey.mCode;
|
final int code = key.mCode;
|
||||||
if (parentKey.hasEmbeddedMoreKey()) {
|
if (key.hasEmbeddedMoreKey()) {
|
||||||
final int embeddedCode = parentKey.mMoreKeys[0].mCode;
|
final int embeddedCode = key.mMoreKeys[0].mCode;
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
invokeCodeInput(embeddedCode);
|
invokeCodeInput(embeddedCode);
|
||||||
invokeReleaseKey(primaryCode);
|
invokeReleaseKey(code);
|
||||||
KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode);
|
KeyboardSwitcher.getInstance().hapticAndAudioFeedback(code);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (primaryCode == Constants.CODE_SPACE || primaryCode == Constants.CODE_LANGUAGE_SWITCH) {
|
if (code == Constants.CODE_SPACE || code == Constants.CODE_LANGUAGE_SWITCH) {
|
||||||
// Long pressing the space key invokes IME switcher dialog.
|
// Long pressing the space key invokes IME switcher dialog.
|
||||||
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
|
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
invokeReleaseKey(primaryCode);
|
invokeReleaseKey(code);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return openMoreKeysPanel(parentKey, tracker);
|
return openMoreKeysPanel(key, tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean invokeCustomRequest(final int code) {
|
private boolean invokeCustomRequest(final int requestCode) {
|
||||||
return mKeyboardActionListener.onCustomRequest(code);
|
return mKeyboardActionListener.onCustomRequest(requestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeCodeInput(final int primaryCode) {
|
private void invokeCodeInput(final int code) {
|
||||||
mKeyboardActionListener.onCodeInput(
|
mKeyboardActionListener.onCodeInput(
|
||||||
primaryCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
code, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeReleaseKey(final int primaryCode) {
|
private void invokeReleaseKey(final int code) {
|
||||||
mKeyboardActionListener.onReleaseKey(primaryCode, false);
|
mKeyboardActionListener.onReleaseKey(code, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean openMoreKeysPanel(final Key parentKey, final PointerTracker tracker) {
|
private boolean openMoreKeysPanel(final Key key, final PointerTracker tracker) {
|
||||||
MoreKeysPanel moreKeysPanel = mMoreKeysPanelCache.get(parentKey);
|
final MoreKeysPanel moreKeysPanel = onCreateMoreKeysPanel(key, getContext());
|
||||||
if (moreKeysPanel == null) {
|
if (moreKeysPanel == null) {
|
||||||
moreKeysPanel = onCreateMoreKeysPanel(parentKey);
|
return false;
|
||||||
if (moreKeysPanel == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
mMoreKeysPanelCache.put(parentKey, moreKeysPanel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final int[] lastCoords = CoordinateUtils.newInstance();
|
final int[] lastCoords = CoordinateUtils.newInstance();
|
||||||
tracker.getLastCoordinates(lastCoords);
|
tracker.getLastCoordinates(lastCoords);
|
||||||
final boolean keyPreviewEnabled = isKeyPreviewPopupEnabled() && !parentKey.noKeyPreview();
|
final boolean keyPreviewEnabled = isKeyPreviewPopupEnabled() && !key.noKeyPreview();
|
||||||
// The more keys keyboard is usually horizontally aligned with the center of the parent key.
|
// The more keys keyboard is usually horizontally aligned with the center of the parent key.
|
||||||
// If showMoreKeysKeyboardAtTouchedPoint is true and the key preview is disabled, the more
|
// If showMoreKeysKeyboardAtTouchedPoint is true and the key preview is disabled, the more
|
||||||
// keys keyboard is placed at the touch point of the parent key.
|
// keys keyboard is placed at the touch point of the parent key.
|
||||||
final int pointX = (mConfigShowMoreKeysKeyboardAtTouchedPoint && !keyPreviewEnabled)
|
final int pointX = (mConfigShowMoreKeysKeyboardAtTouchedPoint && !keyPreviewEnabled)
|
||||||
? CoordinateUtils.x(lastCoords)
|
? CoordinateUtils.x(lastCoords)
|
||||||
: parentKey.mX + parentKey.mWidth / 2;
|
: key.mX + key.mWidth / 2;
|
||||||
// The more keys keyboard is usually vertically aligned with the top edge of the parent key
|
// The more keys keyboard is usually vertically aligned with the top edge of the parent key
|
||||||
// (plus vertical gap). If the key preview is enabled, the more keys keyboard is vertically
|
// (plus vertical gap). If the key preview is enabled, the more keys keyboard is vertically
|
||||||
// aligned with the bottom edge of the visible part of the key preview.
|
// aligned with the bottom edge of the visible part of the key preview.
|
||||||
// {@code mPreviewVisibleOffset} has been set appropriately in
|
// {@code mPreviewVisibleOffset} has been set appropriately in
|
||||||
// {@link KeyboardView#showKeyPreview(PointerTracker)}.
|
// {@link KeyboardView#showKeyPreview(PointerTracker)}.
|
||||||
final int pointY = parentKey.mY + mKeyPreviewDrawParams.mPreviewVisibleOffset;
|
final int pointY = key.mY + mKeyPreviewDrawParams.mPreviewVisibleOffset;
|
||||||
moreKeysPanel.showMoreKeysPanel(this, this, pointX, pointY, mKeyboardActionListener);
|
moreKeysPanel.showMoreKeysPanel(this, this, pointX, pointY, mKeyboardActionListener);
|
||||||
final int translatedX = moreKeysPanel.translateX(CoordinateUtils.x(lastCoords));
|
final int translatedX = moreKeysPanel.translateX(CoordinateUtils.x(lastCoords));
|
||||||
final int translatedY = moreKeysPanel.translateY(CoordinateUtils.y(lastCoords));
|
final int translatedY = moreKeysPanel.translateY(CoordinateUtils.y(lastCoords));
|
||||||
tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel);
|
tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel);
|
||||||
dimEntireKeyboard(true /* dimmed */);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInSlidingKeyInput() {
|
public boolean isInSlidingKeyInput() {
|
||||||
if (mMoreKeysPanel != null) {
|
if (isShowingMoreKeysPanel()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return PointerTracker.isAnyInSlidingKeyInput();
|
return PointerTracker.isAnyInSlidingKeyInput();
|
||||||
|
@ -1069,19 +1053,17 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
if (isShowingMoreKeysPanel()) {
|
if (isShowingMoreKeysPanel()) {
|
||||||
onDismissMoreKeysPanel();
|
onDismissMoreKeysPanel();
|
||||||
}
|
}
|
||||||
|
mPreviewPlacerView.addView(panel.getContainerView());
|
||||||
mMoreKeysPanel = panel;
|
mMoreKeysPanel = panel;
|
||||||
mPreviewPlacerView.addView(mMoreKeysPanel.getContainerView());
|
dimEntireKeyboard(true /* dimmed */);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingMoreKeysPanel() {
|
public boolean isShowingMoreKeysPanel() {
|
||||||
return (mMoreKeysPanel != null);
|
return mMoreKeysPanel != null && mMoreKeysPanel.isShowingInParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancelMoreKeysPanel() {
|
public void onCancelMoreKeysPanel() {
|
||||||
if (isShowingMoreKeysPanel()) {
|
|
||||||
mMoreKeysPanel.dismissMoreKeysPanel();
|
|
||||||
}
|
|
||||||
PointerTracker.dismissAllMoreKeysPanels();
|
PointerTracker.dismissAllMoreKeysPanels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1254,9 +1236,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
public void closing() {
|
public void closing() {
|
||||||
dismissAllKeyPreviews();
|
dismissAllKeyPreviews();
|
||||||
cancelAllMessages();
|
cancelAllMessages();
|
||||||
|
onDismissMoreKeysPanel();
|
||||||
|
mMoreKeysKeyboardCache.clear();
|
||||||
super.closing();
|
super.closing();
|
||||||
onCancelMoreKeysPanel();
|
|
||||||
mMoreKeysPanelCache.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1331,7 +1313,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
invalidateKey(mSpaceKey);
|
invalidateKey(mSpaceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dimEntireKeyboard(final boolean dimmed) {
|
private void dimEntireKeyboard(final boolean dimmed) {
|
||||||
final boolean needsRedrawing = mNeedsToDimEntireKeyboard != dimmed;
|
final boolean needsRedrawing = mNeedsToDimEntireKeyboard != dimmed;
|
||||||
mNeedsToDimEntireKeyboard = dimmed;
|
mNeedsToDimEntireKeyboard = dimmed;
|
||||||
if (needsRedrawing) {
|
if (needsRedrawing) {
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.android.inputmethod.annotations.UsedForTesting;
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
|
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
|
||||||
|
@ -260,15 +260,15 @@ public final class MoreKeysKeyboard extends Keyboard {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The builder of MoreKeysKeyboard.
|
* The builder of MoreKeysKeyboard.
|
||||||
* @param containerView the container of {@link MoreKeysKeyboardView}.
|
* @param context the context of {@link MoreKeysKeyboardView}.
|
||||||
* @param parentKey the {@link Key} that invokes more keys keyboard.
|
* @param parentKey the {@link Key} that invokes more keys keyboard.
|
||||||
* @param parentKeyboardView the {@link KeyboardView} that contains the parentKey.
|
* @param parentKeyboardView the {@link KeyboardView} that contains the parentKey.
|
||||||
* @param keyPreviewDrawParams the parameter to place key preview.
|
* @param keyPreviewDrawParams the parameter to place key preview.
|
||||||
*/
|
*/
|
||||||
public Builder(final View containerView, final Key parentKey,
|
public Builder(final Context context, final Key parentKey,
|
||||||
final MainKeyboardView parentKeyboardView,
|
final MainKeyboardView parentKeyboardView,
|
||||||
final KeyPreviewDrawParams keyPreviewDrawParams) {
|
final KeyPreviewDrawParams keyPreviewDrawParams) {
|
||||||
super(containerView.getContext(), new MoreKeysKeyboardParams());
|
super(context, new MoreKeysKeyboardParams());
|
||||||
final Keyboard parentKeyboard = parentKeyboardView.getKeyboard();
|
final Keyboard parentKeyboard = parentKeyboardView.getKeyboard();
|
||||||
load(parentKeyboard.mMoreKeysTemplate, parentKeyboard.mId);
|
load(parentKeyboard.mMoreKeysTemplate, parentKeyboard.mId);
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dismissMoreKeysPanel() {
|
public boolean dismissMoreKeysPanel() {
|
||||||
|
super.closing();
|
||||||
if (mController == null) return false;
|
if (mController == null) return false;
|
||||||
return mController.onDismissMoreKeysPanel();
|
return mController.onDismissMoreKeysPanel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
@ -39,6 +40,10 @@ public final class CollectionUtils {
|
||||||
return new HashMap<K,V>();
|
return new HashMap<K,V>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <K, V> WeakHashMap<K, V> newWeakHashMap() {
|
||||||
|
return new WeakHashMap<K, V>();
|
||||||
|
}
|
||||||
|
|
||||||
public static <K,V> TreeMap<K,V> newTreeMap() {
|
public static <K,V> TreeMap<K,V> newTreeMap() {
|
||||||
return new TreeMap<K,V>();
|
return new TreeMap<K,V>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package com.android.inputmethod.latin.suggestions;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
|
||||||
import com.android.inputmethod.keyboard.MoreKeysKeyboardView;
|
import com.android.inputmethod.keyboard.MoreKeysKeyboardView;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ import com.android.inputmethod.latin.R;
|
||||||
* key presses and touch movements.
|
* key presses and touch movements.
|
||||||
*/
|
*/
|
||||||
public final class MoreSuggestionsView extends MoreKeysKeyboardView {
|
public final class MoreSuggestionsView extends MoreKeysKeyboardView {
|
||||||
|
|
||||||
public MoreSuggestionsView(final Context context, final AttributeSet attrs) {
|
public MoreSuggestionsView(final Context context, final AttributeSet attrs) {
|
||||||
this(context, attrs, R.attr.moreSuggestionsViewStyle);
|
this(context, attrs, R.attr.moreSuggestionsViewStyle);
|
||||||
}
|
}
|
||||||
|
@ -44,32 +42,15 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
|
||||||
return pane.mOccupiedWidth / 2;
|
return pane.mOccupiedWidth / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
|
||||||
final Keyboard keyboard = getKeyboard();
|
|
||||||
if (keyboard != null) {
|
|
||||||
final int width = keyboard.mOccupiedWidth + getPaddingLeft() + getPaddingRight();
|
|
||||||
final int height = keyboard.mOccupiedHeight + getPaddingTop() + getPaddingBottom();
|
|
||||||
setMeasuredDimension(width, height);
|
|
||||||
} else {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateKeyboardGeometry(final int keyHeight) {
|
public void updateKeyboardGeometry(final int keyHeight) {
|
||||||
mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes);
|
mKeyDrawParams.updateParams(keyHeight, mKeyVisualAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCodeInput(final int primaryCode, final int x, final int y) {
|
public void onCodeInput(final int code, final int x, final int y) {
|
||||||
final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE;
|
final int index = code - MoreSuggestions.SUGGESTION_CODE_BASE;
|
||||||
if (index >= 0 && index < SuggestionStripView.MAX_SUGGESTIONS) {
|
if (index >= 0 && index < SuggestionStripView.MAX_SUGGESTIONS) {
|
||||||
mListener.onCustomRequest(index);
|
mListener.onCustomRequest(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isShowingInParent() {
|
|
||||||
return (getContainerView().getParent() != null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -676,12 +676,11 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
new MoreKeysPanel.Controller() {
|
new MoreKeysPanel.Controller() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onDismissMoreKeysPanel() {
|
public boolean onDismissMoreKeysPanel() {
|
||||||
mMainKeyboardView.dimEntireKeyboard(false /* dimmed */);
|
|
||||||
return mMainKeyboardView.onDismissMoreKeysPanel();
|
return mMainKeyboardView.onDismissMoreKeysPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onShowMoreKeysPanel(MoreKeysPanel panel) {
|
public void onShowMoreKeysPanel(final MoreKeysPanel panel) {
|
||||||
mMainKeyboardView.onShowMoreKeysPanel(panel);
|
mMainKeyboardView.onShowMoreKeysPanel(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,7 +727,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
|
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
|
||||||
mOriginX = mLastX;
|
mOriginX = mLastX;
|
||||||
mOriginY = mLastY;
|
mOriginY = mLastY;
|
||||||
mMainKeyboardView.dimEntireKeyboard(true /* dimmed */);
|
|
||||||
for (int i = 0; i < params.mSuggestionsCountInStrip; i++) {
|
for (int i = 0; i < params.mSuggestionsCountInStrip; i++) {
|
||||||
mWords.get(i).setPressed(false);
|
mWords.get(i).setPressed(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue