2011-07-01 04:07:59 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2012-03-14 03:33:03 +00:00
|
|
|
import android.animation.AnimatorInflater;
|
2012-03-16 05:05:20 +00:00
|
|
|
import android.animation.ObjectAnimator;
|
2011-07-01 04:07:59 +00:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.pm.PackageManager;
|
2011-12-17 23:13:36 +00:00
|
|
|
import android.content.res.TypedArray;
|
2011-08-23 03:22:24 +00:00
|
|
|
import android.graphics.Canvas;
|
2011-12-17 18:06:20 +00:00
|
|
|
import android.graphics.Paint;
|
2011-12-17 23:13:36 +00:00
|
|
|
import android.graphics.Paint.Align;
|
2012-01-25 03:57:28 +00:00
|
|
|
import android.graphics.Typeface;
|
2011-12-17 23:13:36 +00:00
|
|
|
import android.graphics.drawable.Drawable;
|
2011-07-01 04:07:59 +00:00
|
|
|
import android.os.Message;
|
2011-12-15 14:26:18 +00:00
|
|
|
import android.text.TextUtils;
|
2011-07-01 04:07:59 +00:00
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewConfiguration;
|
2011-08-31 04:00:32 +00:00
|
|
|
import android.view.ViewGroup;
|
2011-07-01 04:07:59 +00:00
|
|
|
import android.widget.PopupWindow;
|
|
|
|
|
|
|
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
|
|
|
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
2011-07-11 02:31:02 +00:00
|
|
|
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
|
2011-07-09 01:35:58 +00:00
|
|
|
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
2012-03-05 02:39:07 +00:00
|
|
|
import com.android.inputmethod.keyboard.internal.KeySpecParser;
|
2011-08-23 03:22:24 +00:00
|
|
|
import com.android.inputmethod.latin.LatinIME;
|
2011-12-15 14:26:18 +00:00
|
|
|
import com.android.inputmethod.latin.LatinImeLogger;
|
2011-07-01 04:07:59 +00:00
|
|
|
import com.android.inputmethod.latin.R;
|
2012-03-22 02:13:33 +00:00
|
|
|
import com.android.inputmethod.latin.ResearchLogger;
|
2011-07-01 04:07:59 +00:00
|
|
|
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
|
2012-04-03 03:50:28 +00:00
|
|
|
import com.android.inputmethod.latin.SubtypeLocale;
|
2012-03-08 08:07:02 +00:00
|
|
|
import com.android.inputmethod.latin.SubtypeUtils;
|
2011-08-23 03:22:24 +00:00
|
|
|
import com.android.inputmethod.latin.Utils;
|
2011-12-15 14:26:18 +00:00
|
|
|
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
|
2012-03-26 13:10:21 +00:00
|
|
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2011-12-17 23:13:36 +00:00
|
|
|
import java.util.Locale;
|
2011-07-01 04:07:59 +00:00
|
|
|
import java.util.WeakHashMap;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A view that is responsible for detecting key presses and touch movements.
|
|
|
|
*
|
|
|
|
* @attr ref R.styleable#KeyboardView_keyHysteresisDistance
|
|
|
|
* @attr ref R.styleable#KeyboardView_verticalCorrection
|
|
|
|
* @attr ref R.styleable#KeyboardView_popupLayout
|
|
|
|
*/
|
2011-08-23 08:57:02 +00:00
|
|
|
public class LatinKeyboardView extends KeyboardView implements PointerTracker.KeyEventHandler,
|
2011-08-23 06:57:51 +00:00
|
|
|
SuddenJumpingTouchEventHandler.ProcessMotionEvent {
|
2011-08-23 08:57:02 +00:00
|
|
|
private static final String TAG = LatinKeyboardView.class.getSimpleName();
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2012-03-22 02:13:33 +00:00
|
|
|
// TODO: Kill process when the usability study mode was changed.
|
|
|
|
private static final boolean ENABLE_USABILITY_STUDY_LOG = LatinImeLogger.sUsabilityStudy;
|
|
|
|
|
2012-01-25 03:57:28 +00:00
|
|
|
/** Listener for {@link KeyboardActionListener}. */
|
|
|
|
private KeyboardActionListener mKeyboardActionListener;
|
|
|
|
|
|
|
|
/* Space key and its icons */
|
2011-12-17 23:13:36 +00:00
|
|
|
private Key mSpaceKey;
|
|
|
|
private Drawable mSpaceIcon;
|
2012-01-25 03:57:28 +00:00
|
|
|
// Stuff to draw language name on spacebar.
|
2012-03-16 05:05:20 +00:00
|
|
|
private final int mLanguageOnSpacebarFinalAlpha;
|
|
|
|
private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
|
2012-03-13 07:47:45 +00:00
|
|
|
private static final int ALPHA_OPAQUE = 255;
|
2012-01-25 03:57:28 +00:00
|
|
|
private boolean mNeedsToDisplayLanguage;
|
|
|
|
private Locale mSpacebarLocale;
|
2012-03-16 05:05:20 +00:00
|
|
|
private int mLanguageOnSpacebarAnimAlpha = ALPHA_OPAQUE;
|
2011-12-17 23:13:36 +00:00
|
|
|
private final float mSpacebarTextRatio;
|
|
|
|
private float mSpacebarTextSize;
|
|
|
|
private final int mSpacebarTextColor;
|
|
|
|
private final int mSpacebarTextShadowColor;
|
|
|
|
// If the full language name needs to be smaller than this value to be drawn on space key,
|
|
|
|
// its short language name will be used instead.
|
|
|
|
private static final float MINIMUM_SCALE_OF_LANGUAGE_NAME = 0.8f;
|
2012-01-25 03:57:28 +00:00
|
|
|
// Stuff to draw auto correction LED on spacebar.
|
|
|
|
private boolean mAutoCorrectionSpacebarLedOn;
|
|
|
|
private final boolean mAutoCorrectionSpacebarLedEnabled;
|
|
|
|
private final Drawable mAutoCorrectionSpacebarLedIcon;
|
|
|
|
private static final int SPACE_LED_LENGTH_PERCENT = 80;
|
2011-12-15 14:26:18 +00:00
|
|
|
|
2012-03-14 05:46:22 +00:00
|
|
|
// Stuff to draw altCodeWhileTyping keys.
|
2012-03-16 05:05:20 +00:00
|
|
|
private ObjectAnimator mAltCodeKeyWhileTypingFadeoutAnimator;
|
|
|
|
private ObjectAnimator mAltCodeKeyWhileTypingFadeinAnimator;
|
2012-03-15 12:05:17 +00:00
|
|
|
private int mAltCodeKeyWhileTypingAnimAlpha = ALPHA_OPAQUE;
|
2012-03-14 05:46:22 +00:00
|
|
|
|
2012-02-08 07:12:11 +00:00
|
|
|
// More keys keyboard
|
2011-08-31 06:26:32 +00:00
|
|
|
private PopupWindow mMoreKeysWindow;
|
|
|
|
private MoreKeysPanel mMoreKeysPanel;
|
|
|
|
private int mMoreKeysPanelPointerTrackerId;
|
|
|
|
private final WeakHashMap<Key, MoreKeysPanel> mMoreKeysPanelCache =
|
|
|
|
new WeakHashMap<Key, MoreKeysPanel>();
|
2012-02-08 07:12:11 +00:00
|
|
|
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2012-01-25 11:14:39 +00:00
|
|
|
private final PointerTrackerParams mPointerTrackerParams;
|
2012-01-25 03:57:28 +00:00
|
|
|
private final boolean mIsSpacebarTriggeringPopupByLongPress;
|
|
|
|
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2012-01-25 03:57:28 +00:00
|
|
|
protected KeyDetector mKeyDetector;
|
2012-01-16 08:18:40 +00:00
|
|
|
private boolean mHasDistinctMultitouch;
|
2011-07-01 04:07:59 +00:00
|
|
|
private int mOldPointerCount = 1;
|
2011-11-29 07:56:27 +00:00
|
|
|
private Key mOldKey;
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2012-01-25 11:14:39 +00:00
|
|
|
private final KeyTimerHandler mKeyTimerHandler;
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2011-08-23 08:57:02 +00:00
|
|
|
private static class KeyTimerHandler extends StaticInnerHandlerWrapper<LatinKeyboardView>
|
2011-07-09 01:35:58 +00:00
|
|
|
implements TimerProxy {
|
2011-07-04 11:58:58 +00:00
|
|
|
private static final int MSG_REPEAT_KEY = 1;
|
|
|
|
private static final int MSG_LONGPRESS_KEY = 2;
|
2012-01-31 06:54:48 +00:00
|
|
|
private static final int MSG_DOUBLE_TAP = 3;
|
2012-03-14 05:46:22 +00:00
|
|
|
private static final int MSG_TYPING_STATE_EXPIRED = 4;
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2012-02-01 06:07:25 +00:00
|
|
|
private final KeyTimerParams mParams;
|
2011-07-01 04:07:59 +00:00
|
|
|
private boolean mInKeyRepeat;
|
|
|
|
|
2012-02-01 06:07:25 +00:00
|
|
|
public KeyTimerHandler(LatinKeyboardView outerInstance, KeyTimerParams params) {
|
2011-07-01 04:07:59 +00:00
|
|
|
super(outerInstance);
|
2012-02-01 06:07:25 +00:00
|
|
|
mParams = params;
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleMessage(Message msg) {
|
2011-08-23 08:57:02 +00:00
|
|
|
final LatinKeyboardView keyboardView = getOuterInstance();
|
2011-07-01 04:07:59 +00:00
|
|
|
final PointerTracker tracker = (PointerTracker) msg.obj;
|
|
|
|
switch (msg.what) {
|
|
|
|
case MSG_REPEAT_KEY:
|
2011-11-29 07:56:27 +00:00
|
|
|
tracker.onRepeatKey(tracker.getKey());
|
2012-02-03 01:01:59 +00:00
|
|
|
startKeyRepeatTimer(tracker, mParams.mKeyRepeatInterval);
|
2011-07-01 04:07:59 +00:00
|
|
|
break;
|
|
|
|
case MSG_LONGPRESS_KEY:
|
2012-02-01 06:07:25 +00:00
|
|
|
if (tracker != null) {
|
2012-02-08 07:12:11 +00:00
|
|
|
keyboardView.openMoreKeysKeyboardIfRequired(tracker.getKey(), tracker);
|
2012-02-01 06:07:25 +00:00
|
|
|
} else {
|
|
|
|
KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1);
|
|
|
|
}
|
2011-07-01 04:07:59 +00:00
|
|
|
break;
|
2012-03-14 05:46:22 +00:00
|
|
|
case MSG_TYPING_STATE_EXPIRED:
|
2012-03-15 12:05:17 +00:00
|
|
|
cancelAndStartAnimators(keyboardView.mAltCodeKeyWhileTypingFadeoutAnimator,
|
|
|
|
keyboardView.mAltCodeKeyWhileTypingFadeinAnimator);
|
2012-03-14 05:46:22 +00:00
|
|
|
break;
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 01:01:59 +00:00
|
|
|
private void startKeyRepeatTimer(PointerTracker tracker, long delay) {
|
|
|
|
sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, tracker), delay);
|
|
|
|
}
|
|
|
|
|
2011-07-09 01:35:58 +00:00
|
|
|
@Override
|
2012-02-01 06:07:25 +00:00
|
|
|
public void startKeyRepeatTimer(PointerTracker tracker) {
|
2011-07-01 04:07:59 +00:00
|
|
|
mInKeyRepeat = true;
|
2012-02-03 01:01:59 +00:00
|
|
|
startKeyRepeatTimer(tracker, mParams.mKeyRepeatStartTimeout);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void cancelKeyRepeatTimer() {
|
|
|
|
mInKeyRepeat = false;
|
|
|
|
removeMessages(MSG_REPEAT_KEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isInKeyRepeat() {
|
|
|
|
return mInKeyRepeat;
|
|
|
|
}
|
|
|
|
|
2011-07-09 01:35:58 +00:00
|
|
|
@Override
|
2012-02-01 06:07:25 +00:00
|
|
|
public void startLongPressTimer(int code) {
|
2011-07-17 21:37:30 +00:00
|
|
|
cancelLongPressTimer();
|
2012-02-01 06:07:25 +00:00
|
|
|
final int delay;
|
|
|
|
switch (code) {
|
|
|
|
case Keyboard.CODE_SHIFT:
|
2012-02-01 12:15:34 +00:00
|
|
|
delay = mParams.mLongPressShiftKeyTimeout;
|
2012-02-01 06:07:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
delay = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (delay > 0) {
|
|
|
|
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, code, 0), delay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startLongPressTimer(PointerTracker tracker) {
|
|
|
|
cancelLongPressTimer();
|
|
|
|
if (tracker != null) {
|
|
|
|
final Key key = tracker.getKey();
|
|
|
|
final int delay;
|
|
|
|
switch (key.mCode) {
|
|
|
|
case Keyboard.CODE_SHIFT:
|
|
|
|
delay = mParams.mLongPressShiftKeyTimeout;
|
|
|
|
break;
|
|
|
|
case Keyboard.CODE_SPACE:
|
|
|
|
delay = mParams.mLongPressSpaceKeyTimeout;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) {
|
|
|
|
// We use longer timeout for sliding finger input started from the symbols
|
|
|
|
// mode key.
|
|
|
|
delay = mParams.mLongPressKeyTimeout * 3;
|
|
|
|
} else {
|
|
|
|
delay = mParams.mLongPressKeyTimeout;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (delay > 0) {
|
|
|
|
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, tracker), delay);
|
|
|
|
}
|
|
|
|
}
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-07-09 01:35:58 +00:00
|
|
|
@Override
|
2011-07-17 21:37:30 +00:00
|
|
|
public void cancelLongPressTimer() {
|
2011-07-01 04:07:59 +00:00
|
|
|
removeMessages(MSG_LONGPRESS_KEY);
|
|
|
|
}
|
|
|
|
|
2012-03-16 05:05:20 +00:00
|
|
|
public static void cancelAndStartAnimators(ObjectAnimator animatorToCancel,
|
|
|
|
ObjectAnimator animatorToStart) {
|
2012-03-15 12:05:17 +00:00
|
|
|
if (animatorToCancel != null && animatorToCancel.isStarted()) {
|
|
|
|
animatorToCancel.cancel();
|
|
|
|
}
|
|
|
|
// TODO: Start the animation with an initial value that is the same as the final value
|
|
|
|
// of the above animation when it gets cancelled.
|
|
|
|
if (animatorToStart != null && !animatorToStart.isStarted()) {
|
|
|
|
animatorToStart.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void cancelTypingStateTimer() {
|
|
|
|
removeMessages(MSG_TYPING_STATE_EXPIRED);
|
|
|
|
}
|
|
|
|
|
2011-11-22 00:41:01 +00:00
|
|
|
@Override
|
2012-03-14 05:46:22 +00:00
|
|
|
public void startTypingStateTimer() {
|
|
|
|
final boolean isTyping = isTypingState();
|
2012-03-15 12:05:17 +00:00
|
|
|
cancelTypingStateTimer();
|
2012-03-14 05:46:22 +00:00
|
|
|
sendMessageDelayed(
|
|
|
|
obtainMessage(MSG_TYPING_STATE_EXPIRED), mParams.mIgnoreAltCodeKeyTimeout);
|
|
|
|
if (isTyping) {
|
|
|
|
return;
|
|
|
|
}
|
2012-03-15 12:05:17 +00:00
|
|
|
final LatinKeyboardView keyboardView = getOuterInstance();
|
|
|
|
cancelAndStartAnimators(keyboardView.mAltCodeKeyWhileTypingFadeinAnimator,
|
|
|
|
keyboardView.mAltCodeKeyWhileTypingFadeoutAnimator);
|
2011-11-22 00:41:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-03-14 05:46:22 +00:00
|
|
|
public boolean isTypingState() {
|
|
|
|
return hasMessages(MSG_TYPING_STATE_EXPIRED);
|
2011-11-22 00:41:01 +00:00
|
|
|
}
|
|
|
|
|
2011-07-09 01:35:58 +00:00
|
|
|
@Override
|
2012-01-31 06:54:48 +00:00
|
|
|
public void startDoubleTapTimer() {
|
|
|
|
sendMessageDelayed(obtainMessage(MSG_DOUBLE_TAP),
|
2011-07-01 04:07:59 +00:00
|
|
|
ViewConfiguration.getDoubleTapTimeout());
|
|
|
|
}
|
|
|
|
|
2012-02-16 19:45:35 +00:00
|
|
|
@Override
|
|
|
|
public void cancelDoubleTapTimer() {
|
|
|
|
removeMessages(MSG_DOUBLE_TAP);
|
|
|
|
}
|
|
|
|
|
2012-01-31 06:54:48 +00:00
|
|
|
@Override
|
|
|
|
public boolean isInDoubleTapTimeout() {
|
|
|
|
return hasMessages(MSG_DOUBLE_TAP);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
2011-07-08 06:14:51 +00:00
|
|
|
|
|
|
|
@Override
|
2012-01-31 06:54:48 +00:00
|
|
|
public void cancelKeyTimers() {
|
|
|
|
cancelKeyRepeatTimer();
|
|
|
|
cancelLongPressTimer();
|
2011-07-08 06:14:51 +00:00
|
|
|
}
|
|
|
|
|
2012-01-31 06:54:48 +00:00
|
|
|
public void cancelAllMessages() {
|
|
|
|
cancelKeyTimers();
|
2012-03-15 12:05:17 +00:00
|
|
|
cancelTypingStateTimer();
|
2011-07-08 06:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-25 11:14:39 +00:00
|
|
|
public static class PointerTrackerParams {
|
|
|
|
public final boolean mSlidingKeyInputEnabled;
|
|
|
|
public final int mTouchNoiseThresholdTime;
|
|
|
|
public final float mTouchNoiseThresholdDistance;
|
|
|
|
|
|
|
|
public static final PointerTrackerParams DEFAULT = new PointerTrackerParams();
|
|
|
|
|
|
|
|
private PointerTrackerParams() {
|
|
|
|
mSlidingKeyInputEnabled = false;
|
|
|
|
mTouchNoiseThresholdTime =0;
|
|
|
|
mTouchNoiseThresholdDistance = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PointerTrackerParams(TypedArray latinKeyboardViewAttr) {
|
|
|
|
mSlidingKeyInputEnabled = latinKeyboardViewAttr.getBoolean(
|
|
|
|
R.styleable.LatinKeyboardView_slidingKeyInputEnable, false);
|
2012-02-01 06:07:25 +00:00
|
|
|
mTouchNoiseThresholdTime = latinKeyboardViewAttr.getInt(
|
|
|
|
R.styleable.LatinKeyboardView_touchNoiseThresholdTime, 0);
|
|
|
|
mTouchNoiseThresholdDistance = latinKeyboardViewAttr.getDimension(
|
|
|
|
R.styleable.LatinKeyboardView_touchNoiseThresholdDistance, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static class KeyTimerParams {
|
|
|
|
public final int mKeyRepeatStartTimeout;
|
|
|
|
public final int mKeyRepeatInterval;
|
|
|
|
public final int mLongPressKeyTimeout;
|
|
|
|
public final int mLongPressShiftKeyTimeout;
|
|
|
|
public final int mLongPressSpaceKeyTimeout;
|
2012-03-14 05:46:22 +00:00
|
|
|
public final int mIgnoreAltCodeKeyTimeout;
|
2012-02-01 06:07:25 +00:00
|
|
|
|
|
|
|
public KeyTimerParams(TypedArray latinKeyboardViewAttr) {
|
2012-01-25 11:14:39 +00:00
|
|
|
mKeyRepeatStartTimeout = latinKeyboardViewAttr.getInt(
|
|
|
|
R.styleable.LatinKeyboardView_keyRepeatStartTimeout, 0);
|
2012-02-01 06:07:25 +00:00
|
|
|
mKeyRepeatInterval = latinKeyboardViewAttr.getInt(
|
|
|
|
R.styleable.LatinKeyboardView_keyRepeatInterval, 0);
|
2012-01-25 11:14:39 +00:00
|
|
|
mLongPressKeyTimeout = latinKeyboardViewAttr.getInt(
|
|
|
|
R.styleable.LatinKeyboardView_longPressKeyTimeout, 0);
|
|
|
|
mLongPressShiftKeyTimeout = latinKeyboardViewAttr.getInt(
|
|
|
|
R.styleable.LatinKeyboardView_longPressShiftKeyTimeout, 0);
|
|
|
|
mLongPressSpaceKeyTimeout = latinKeyboardViewAttr.getInt(
|
|
|
|
R.styleable.LatinKeyboardView_longPressSpaceKeyTimeout, 0);
|
2012-03-14 05:46:22 +00:00
|
|
|
mIgnoreAltCodeKeyTimeout = latinKeyboardViewAttr.getInt(
|
|
|
|
R.styleable.LatinKeyboardView_ignoreAltCodeKeyTimeout, 0);
|
2012-01-25 11:14:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-23 08:57:02 +00:00
|
|
|
public LatinKeyboardView(Context context, AttributeSet attrs) {
|
2011-12-17 19:55:17 +00:00
|
|
|
this(context, attrs, R.attr.latinKeyboardViewStyle);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-08-23 08:57:02 +00:00
|
|
|
public LatinKeyboardView(Context context, AttributeSet attrs, int defStyle) {
|
2011-07-01 04:07:59 +00:00
|
|
|
super(context, attrs, defStyle);
|
|
|
|
|
2011-08-23 06:57:51 +00:00
|
|
|
mTouchScreenRegulator = new SuddenJumpingTouchEventHandler(getContext(), this);
|
|
|
|
|
2011-07-01 04:07:59 +00:00
|
|
|
mHasDistinctMultitouch = context.getPackageManager()
|
|
|
|
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT);
|
2011-07-06 23:11:30 +00:00
|
|
|
|
2012-02-01 06:07:25 +00:00
|
|
|
PointerTracker.init(mHasDistinctMultitouch);
|
2011-12-17 18:06:20 +00:00
|
|
|
|
2011-12-17 23:13:36 +00:00
|
|
|
final TypedArray a = context.obtainStyledAttributes(
|
|
|
|
attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView);
|
|
|
|
mAutoCorrectionSpacebarLedEnabled = a.getBoolean(
|
|
|
|
R.styleable.LatinKeyboardView_autoCorrectionSpacebarLedEnabled, false);
|
|
|
|
mAutoCorrectionSpacebarLedIcon = a.getDrawable(
|
|
|
|
R.styleable.LatinKeyboardView_autoCorrectionSpacebarLedIcon);
|
|
|
|
mSpacebarTextRatio = a.getFraction(R.styleable.LatinKeyboardView_spacebarTextRatio,
|
|
|
|
1000, 1000, 1) / 1000.0f;
|
|
|
|
mSpacebarTextColor = a.getColor(R.styleable.LatinKeyboardView_spacebarTextColor, 0);
|
|
|
|
mSpacebarTextShadowColor = a.getColor(
|
|
|
|
R.styleable.LatinKeyboardView_spacebarTextShadowColor, 0);
|
2012-03-16 05:05:20 +00:00
|
|
|
mLanguageOnSpacebarFinalAlpha = a.getInt(
|
|
|
|
R.styleable.LatinKeyboardView_languageOnSpacebarFinalAlpha, ALPHA_OPAQUE);
|
2012-03-14 03:33:03 +00:00
|
|
|
final int languageOnSpacebarFadeoutAnimatorResId = a.getResourceId(
|
|
|
|
R.styleable.LatinKeyboardView_languageOnSpacebarFadeoutAnimator, 0);
|
2012-03-14 05:46:22 +00:00
|
|
|
final int altCodeKeyWhileTypingFadeoutAnimatorResId = a.getResourceId(
|
|
|
|
R.styleable.LatinKeyboardView_altCodeKeyWhileTypingFadeoutAnimator, 0);
|
|
|
|
final int altCodeKeyWhileTypingFadeinAnimatorResId = a.getResourceId(
|
|
|
|
R.styleable.LatinKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
2012-01-25 11:14:39 +00:00
|
|
|
|
2012-02-01 06:07:25 +00:00
|
|
|
final KeyTimerParams keyTimerParams = new KeyTimerParams(a);
|
2012-01-25 11:14:39 +00:00
|
|
|
mPointerTrackerParams = new PointerTrackerParams(a);
|
2012-02-01 06:07:25 +00:00
|
|
|
mIsSpacebarTriggeringPopupByLongPress = (keyTimerParams.mLongPressSpaceKeyTimeout > 0);
|
2012-01-25 11:14:39 +00:00
|
|
|
|
|
|
|
final float keyHysteresisDistance = a.getDimension(
|
|
|
|
R.styleable.LatinKeyboardView_keyHysteresisDistance, 0);
|
|
|
|
mKeyDetector = new KeyDetector(keyHysteresisDistance);
|
2012-02-01 06:07:25 +00:00
|
|
|
mKeyTimerHandler = new KeyTimerHandler(this, keyTimerParams);
|
2012-02-08 07:12:11 +00:00
|
|
|
mConfigShowMoreKeysKeyboardAtTouchedPoint = a.getBoolean(
|
|
|
|
R.styleable.LatinKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
|
2011-12-17 23:13:36 +00:00
|
|
|
a.recycle();
|
2012-01-25 11:14:39 +00:00
|
|
|
|
|
|
|
PointerTracker.setParameters(mPointerTrackerParams);
|
2012-03-13 03:44:03 +00:00
|
|
|
|
2012-03-16 05:05:20 +00:00
|
|
|
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(
|
|
|
|
languageOnSpacebarFadeoutAnimatorResId, this);
|
|
|
|
mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator(
|
|
|
|
altCodeKeyWhileTypingFadeoutAnimatorResId, this);
|
|
|
|
mAltCodeKeyWhileTypingFadeinAnimator = loadObjectAnimator(
|
|
|
|
altCodeKeyWhileTypingFadeinAnimatorResId, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
private ObjectAnimator loadObjectAnimator(int resId, Object target) {
|
|
|
|
if (resId == 0) return null;
|
|
|
|
final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
|
|
|
|
getContext(), resId);
|
2012-03-14 03:33:03 +00:00
|
|
|
if (animator != null) {
|
2012-03-16 05:05:20 +00:00
|
|
|
animator.setTarget(target);
|
2012-03-14 05:46:22 +00:00
|
|
|
}
|
2012-03-16 05:05:20 +00:00
|
|
|
return animator;
|
|
|
|
}
|
2012-03-14 05:46:22 +00:00
|
|
|
|
2012-03-16 05:05:20 +00:00
|
|
|
// Getter/setter methods for {@link ObjectAnimator}.
|
|
|
|
public int getLanguageOnSpacebarAnimAlpha() {
|
|
|
|
return mLanguageOnSpacebarAnimAlpha;
|
2012-03-14 03:33:03 +00:00
|
|
|
}
|
|
|
|
|
2012-03-16 05:05:20 +00:00
|
|
|
public void setLanguageOnSpacebarAnimAlpha(int alpha) {
|
|
|
|
mLanguageOnSpacebarAnimAlpha = alpha;
|
|
|
|
invalidateKey(mSpaceKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getAltCodeKeyWhileTypingAnimAlpha() {
|
|
|
|
return mAltCodeKeyWhileTypingAnimAlpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAltCodeKeyWhileTypingAnimAlpha(int alpha) {
|
|
|
|
mAltCodeKeyWhileTypingAnimAlpha = alpha;
|
|
|
|
updateAltCodeKeyWhileTyping();
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-07-08 05:31:29 +00:00
|
|
|
public void setKeyboardActionListener(KeyboardActionListener listener) {
|
2011-07-01 04:07:59 +00:00
|
|
|
mKeyboardActionListener = listener;
|
2011-07-11 22:24:01 +00:00
|
|
|
PointerTracker.setKeyboardActionListener(listener);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the {@link KeyboardActionListener} object.
|
|
|
|
* @return the listener attached to this keyboard
|
|
|
|
*/
|
2011-07-09 04:26:29 +00:00
|
|
|
@Override
|
|
|
|
public KeyboardActionListener getKeyboardActionListener() {
|
2011-07-01 04:07:59 +00:00
|
|
|
return mKeyboardActionListener;
|
|
|
|
}
|
|
|
|
|
2011-07-09 04:26:29 +00:00
|
|
|
@Override
|
|
|
|
public KeyDetector getKeyDetector() {
|
|
|
|
return mKeyDetector;
|
|
|
|
}
|
|
|
|
|
2011-07-11 02:31:02 +00:00
|
|
|
@Override
|
|
|
|
public DrawingProxy getDrawingProxy() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2011-07-09 04:26:29 +00:00
|
|
|
@Override
|
|
|
|
public TimerProxy getTimerProxy() {
|
|
|
|
return mKeyTimerHandler;
|
|
|
|
}
|
|
|
|
|
2011-07-01 04:07:59 +00:00
|
|
|
/**
|
|
|
|
* Attaches a keyboard to this view. The keyboard can be switched at any time and the
|
|
|
|
* view will re-layout itself to accommodate the keyboard.
|
|
|
|
* @see Keyboard
|
|
|
|
* @see #getKeyboard()
|
|
|
|
* @param keyboard the keyboard to display in this view
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void setKeyboard(Keyboard keyboard) {
|
|
|
|
// Remove any pending messages, except dismissing preview
|
2011-07-04 11:58:58 +00:00
|
|
|
mKeyTimerHandler.cancelKeyTimers();
|
2011-07-01 04:07:59 +00:00
|
|
|
super.setKeyboard(keyboard);
|
2011-07-08 05:31:29 +00:00
|
|
|
mKeyDetector.setKeyboard(
|
|
|
|
keyboard, -getPaddingLeft(), -getPaddingTop() + mVerticalCorrection);
|
2011-07-11 22:24:01 +00:00
|
|
|
PointerTracker.setKeyDetector(mKeyDetector);
|
2011-08-23 06:57:51 +00:00
|
|
|
mTouchScreenRegulator.setKeyboard(keyboard);
|
2011-08-31 06:26:32 +00:00
|
|
|
mMoreKeysPanelCache.clear();
|
2011-12-17 23:13:36 +00:00
|
|
|
|
|
|
|
mSpaceKey = keyboard.getKey(Keyboard.CODE_SPACE);
|
2012-02-27 12:35:35 +00:00
|
|
|
mSpaceIcon = (mSpaceKey != null) ? mSpaceKey.getIcon(keyboard.mIconsSet) : null;
|
2011-12-17 23:13:36 +00:00
|
|
|
final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
|
|
|
|
mSpacebarTextSize = keyHeight * mSpacebarTextRatio;
|
|
|
|
mSpacebarLocale = keyboard.mId.mLocale;
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the device has distinct multi-touch panel.
|
|
|
|
* @return true if the device has distinct multi-touch panel.
|
|
|
|
*/
|
|
|
|
public boolean hasDistinctMultitouch() {
|
|
|
|
return mHasDistinctMultitouch;
|
|
|
|
}
|
|
|
|
|
2012-01-16 08:18:40 +00:00
|
|
|
public void setDistinctMultitouch(boolean hasDistinctMultitouch) {
|
|
|
|
mHasDistinctMultitouch = hasDistinctMultitouch;
|
|
|
|
}
|
|
|
|
|
2011-07-01 04:07:59 +00:00
|
|
|
/**
|
|
|
|
* When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key
|
|
|
|
* codes for adjacent keys. When disabled, only the primary key code will be
|
|
|
|
* reported.
|
|
|
|
* @param enabled whether or not the proximity correction is enabled
|
|
|
|
*/
|
|
|
|
public void setProximityCorrectionEnabled(boolean enabled) {
|
|
|
|
mKeyDetector.setProximityCorrectionEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if proximity correction is enabled.
|
|
|
|
*/
|
|
|
|
public boolean isProximityCorrectionEnabled() {
|
|
|
|
return mKeyDetector.isProximityCorrectionEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void cancelAllMessages() {
|
2011-07-04 11:58:58 +00:00
|
|
|
mKeyTimerHandler.cancelAllMessages();
|
2011-07-01 04:07:59 +00:00
|
|
|
super.cancelAllMessages();
|
|
|
|
}
|
|
|
|
|
2012-02-08 07:12:11 +00:00
|
|
|
private boolean openMoreKeysKeyboardIfRequired(Key parentKey, PointerTracker tracker) {
|
2011-07-01 04:07:59 +00:00
|
|
|
// Check if we have a popup layout specified first.
|
2011-08-31 06:26:32 +00:00
|
|
|
if (mMoreKeysLayout == 0) {
|
2011-07-01 04:07:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-07-11 01:09:15 +00:00
|
|
|
// Check if we are already displaying popup panel.
|
2011-08-31 06:26:32 +00:00
|
|
|
if (mMoreKeysPanel != null)
|
2011-07-11 01:09:15 +00:00
|
|
|
return false;
|
2011-07-01 04:07:59 +00:00
|
|
|
if (parentKey == null)
|
|
|
|
return false;
|
2011-07-11 01:09:15 +00:00
|
|
|
return onLongPress(parentKey, tracker);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-08-31 06:26:32 +00:00
|
|
|
// This default implementation returns a more keys panel.
|
|
|
|
protected MoreKeysPanel onCreateMoreKeysPanel(Key parentKey) {
|
|
|
|
if (parentKey.mMoreKeys == null)
|
2011-07-01 04:07:59 +00:00
|
|
|
return null;
|
|
|
|
|
2011-08-31 06:26:32 +00:00
|
|
|
final View container = LayoutInflater.from(getContext()).inflate(mMoreKeysLayout, null);
|
2011-07-01 04:07:59 +00:00
|
|
|
if (container == null)
|
|
|
|
throw new NullPointerException();
|
|
|
|
|
2012-02-08 07:12:11 +00:00
|
|
|
final MoreKeysKeyboardView moreKeysKeyboardView =
|
|
|
|
(MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view);
|
2011-07-01 04:07:59 +00:00
|
|
|
final Keyboard parentKeyboard = getKeyboard();
|
2012-02-08 07:12:11 +00:00
|
|
|
final Keyboard moreKeysKeyboard = new MoreKeysKeyboard.Builder(
|
2011-08-31 06:26:32 +00:00
|
|
|
this, parentKeyboard.mMoreKeysTemplate, parentKey, parentKeyboard).build();
|
2012-02-08 07:12:11 +00:00
|
|
|
moreKeysKeyboardView.setKeyboard(moreKeysKeyboard);
|
2011-08-31 04:00:32 +00:00
|
|
|
container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2012-02-08 07:12:11 +00:00
|
|
|
return moreKeysKeyboardView;
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-02-08 07:12:11 +00:00
|
|
|
* Called when a key is long pressed. By default this will open more keys keyboard associated
|
2011-07-01 04:07:59 +00:00
|
|
|
* with this key.
|
|
|
|
* @param parentKey the key that was long pressed
|
|
|
|
* @param tracker the pointer tracker which pressed the parent key
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
|
2011-08-23 03:22:24 +00:00
|
|
|
final int primaryCode = parentKey.mCode;
|
2012-03-05 02:39:07 +00:00
|
|
|
if (parentKey.hasEmbeddedMoreKey()) {
|
|
|
|
final int embeddedCode = KeySpecParser.getCode(getResources(), parentKey.mMoreKeys[0]);
|
2011-12-17 23:36:16 +00:00
|
|
|
tracker.onLongPressed();
|
2012-03-05 02:39:07 +00:00
|
|
|
invokeCodeInput(embeddedCode);
|
2011-12-17 23:36:16 +00:00
|
|
|
invokeReleaseKey(primaryCode);
|
2012-02-01 06:07:25 +00:00
|
|
|
KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode);
|
2011-12-17 23:36:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-02-18 01:46:01 +00:00
|
|
|
if (primaryCode == Keyboard.CODE_SPACE || primaryCode == Keyboard.CODE_LANGUAGE_SWITCH) {
|
2011-12-17 23:36:16 +00:00
|
|
|
// Long pressing the space key invokes IME switcher dialog.
|
|
|
|
if (invokeCustomRequest(LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
|
2011-08-23 03:22:24 +00:00
|
|
|
tracker.onLongPressed();
|
2011-11-17 00:00:02 +00:00
|
|
|
invokeReleaseKey(primaryCode);
|
|
|
|
return true;
|
2011-08-23 03:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-14 06:20:52 +00:00
|
|
|
return openMoreKeysPanel(parentKey, tracker);
|
2011-08-23 03:22:24 +00:00
|
|
|
}
|
|
|
|
|
2011-11-17 00:00:02 +00:00
|
|
|
private boolean invokeCustomRequest(int code) {
|
2012-01-17 08:08:26 +00:00
|
|
|
return mKeyboardActionListener.onCustomRequest(code);
|
2011-11-17 00:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void invokeCodeInput(int primaryCode) {
|
2012-03-06 05:56:46 +00:00
|
|
|
mKeyboardActionListener.onCodeInput(primaryCode,
|
2011-08-23 03:22:24 +00:00
|
|
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
|
|
|
|
KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
|
2011-11-17 00:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void invokeReleaseKey(int primaryCode) {
|
2012-01-17 08:08:26 +00:00
|
|
|
mKeyboardActionListener.onReleaseKey(primaryCode, false);
|
2011-08-23 03:22:24 +00:00
|
|
|
}
|
|
|
|
|
2011-08-31 06:26:32 +00:00
|
|
|
private boolean openMoreKeysPanel(Key parentKey, PointerTracker tracker) {
|
|
|
|
MoreKeysPanel moreKeysPanel = mMoreKeysPanelCache.get(parentKey);
|
|
|
|
if (moreKeysPanel == null) {
|
|
|
|
moreKeysPanel = onCreateMoreKeysPanel(parentKey);
|
|
|
|
if (moreKeysPanel == null)
|
2011-07-01 04:07:59 +00:00
|
|
|
return false;
|
2011-08-31 06:26:32 +00:00
|
|
|
mMoreKeysPanelCache.put(parentKey, moreKeysPanel);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
2011-08-31 06:26:32 +00:00
|
|
|
if (mMoreKeysWindow == null) {
|
|
|
|
mMoreKeysWindow = new PopupWindow(getContext());
|
|
|
|
mMoreKeysWindow.setBackgroundDrawable(null);
|
2012-02-08 07:12:11 +00:00
|
|
|
mMoreKeysWindow.setAnimationStyle(R.style.MoreKeysKeyboardAnimation);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
2011-08-31 06:26:32 +00:00
|
|
|
mMoreKeysPanel = moreKeysPanel;
|
|
|
|
mMoreKeysPanelPointerTrackerId = tracker.mPointerId;
|
2011-07-11 01:09:15 +00:00
|
|
|
|
2011-08-29 08:02:52 +00:00
|
|
|
final Keyboard keyboard = getKeyboard();
|
2012-02-08 07:12:11 +00:00
|
|
|
final int pointX = (mConfigShowMoreKeysKeyboardAtTouchedPoint) ? tracker.getLastX()
|
2011-08-29 08:02:52 +00:00
|
|
|
: parentKey.mX + parentKey.mWidth / 2;
|
|
|
|
final int pointY = parentKey.mY - keyboard.mVerticalGap;
|
2011-08-31 06:26:32 +00:00
|
|
|
moreKeysPanel.showMoreKeysPanel(
|
2012-01-17 08:08:26 +00:00
|
|
|
this, this, pointX, pointY, mMoreKeysWindow, mKeyboardActionListener);
|
2011-08-31 06:26:32 +00:00
|
|
|
final int translatedX = moreKeysPanel.translateX(tracker.getLastX());
|
|
|
|
final int translatedY = moreKeysPanel.translateY(tracker.getLastY());
|
2011-10-26 11:54:35 +00:00
|
|
|
tracker.onShowMoreKeysPanel(translatedX, translatedY, moreKeysPanel);
|
2011-09-01 08:50:51 +00:00
|
|
|
dimEntireKeyboard(true);
|
2011-07-01 04:07:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isInSlidingKeyInput() {
|
2011-08-31 06:26:32 +00:00
|
|
|
if (mMoreKeysPanel != null) {
|
2011-07-11 01:09:15 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
2011-07-11 22:24:01 +00:00
|
|
|
return PointerTracker.isAnyInSlidingKeyInput();
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPointerCount() {
|
|
|
|
return mOldPointerCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent me) {
|
2011-08-29 09:36:26 +00:00
|
|
|
if (getKeyboard() == null) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-23 06:57:51 +00:00
|
|
|
return mTouchScreenRegulator.onTouchEvent(me);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean processMotionEvent(MotionEvent me) {
|
2011-07-04 11:58:58 +00:00
|
|
|
final boolean nonDistinctMultitouch = !mHasDistinctMultitouch;
|
2011-07-01 04:07:59 +00:00
|
|
|
final int action = me.getActionMasked();
|
|
|
|
final int pointerCount = me.getPointerCount();
|
|
|
|
final int oldPointerCount = mOldPointerCount;
|
|
|
|
mOldPointerCount = pointerCount;
|
|
|
|
|
|
|
|
// TODO: cleanup this code into a multi-touch to single-touch event converter class?
|
|
|
|
// If the device does not have distinct multi-touch support panel, ignore all multi-touch
|
|
|
|
// events except a transition from/to single-touch.
|
2011-07-04 11:58:58 +00:00
|
|
|
if (nonDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
|
2011-07-01 04:07:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
final long eventTime = me.getEventTime();
|
|
|
|
final int index = me.getActionIndex();
|
|
|
|
final int id = me.getPointerId(index);
|
2011-07-11 01:09:15 +00:00
|
|
|
final int x, y;
|
2011-08-31 06:26:32 +00:00
|
|
|
if (mMoreKeysPanel != null && id == mMoreKeysPanelPointerTrackerId) {
|
|
|
|
x = mMoreKeysPanel.translateX((int)me.getX(index));
|
|
|
|
y = mMoreKeysPanel.translateY((int)me.getY(index));
|
2011-07-11 01:09:15 +00:00
|
|
|
} else {
|
|
|
|
x = (int)me.getX(index);
|
|
|
|
y = (int)me.getY(index);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
2012-03-22 02:13:33 +00:00
|
|
|
if (ENABLE_USABILITY_STUDY_LOG) {
|
|
|
|
final String eventTag;
|
|
|
|
switch (action) {
|
|
|
|
case MotionEvent.ACTION_UP:
|
|
|
|
eventTag = "[Up]";
|
|
|
|
break;
|
|
|
|
case MotionEvent.ACTION_DOWN:
|
|
|
|
eventTag = "[Down]";
|
|
|
|
break;
|
|
|
|
case MotionEvent.ACTION_POINTER_UP:
|
|
|
|
eventTag = "[PointerUp]";
|
|
|
|
break;
|
|
|
|
case MotionEvent.ACTION_POINTER_DOWN:
|
|
|
|
eventTag = "[PointerDown]";
|
|
|
|
break;
|
|
|
|
case MotionEvent.ACTION_MOVE: // Skip this as being logged below
|
|
|
|
eventTag = "";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
eventTag = "[Action" + action + "]";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!TextUtils.isEmpty(eventTag)) {
|
|
|
|
final float size = me.getSize(index);
|
|
|
|
final float pressure = me.getPressure(index);
|
|
|
|
UsabilityStudyLogUtils.getInstance().write(
|
|
|
|
eventTag + eventTime + "," + id + "," + x + "," + y + ","
|
|
|
|
+ size + "," + pressure);
|
|
|
|
}
|
|
|
|
}
|
2012-03-26 13:10:21 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
2012-04-07 01:26:34 +00:00
|
|
|
if (ResearchLogger.sIsLogging) {
|
|
|
|
// TODO: remove redundant calculations of size and pressure by
|
|
|
|
// removing UsabilityStudyLog code once the ResearchLogger is mature enough
|
|
|
|
final float size = me.getSize(index);
|
|
|
|
final float pressure = me.getPressure(index);
|
|
|
|
if (action != MotionEvent.ACTION_MOVE) {
|
|
|
|
// Skip ACTION_MOVE events as they are logged below
|
|
|
|
ResearchLogger.getInstance().logMotionEvent(action, eventTime, id, x, y,
|
|
|
|
size, pressure);
|
|
|
|
}
|
|
|
|
}
|
2011-12-15 14:26:18 +00:00
|
|
|
}
|
2011-07-01 04:07:59 +00:00
|
|
|
|
2011-07-04 11:58:58 +00:00
|
|
|
if (mKeyTimerHandler.isInKeyRepeat()) {
|
2012-01-25 02:08:30 +00:00
|
|
|
final PointerTracker tracker = PointerTracker.getPointerTracker(id, this);
|
2011-07-01 04:07:59 +00:00
|
|
|
// Key repeating timer will be canceled if 2 or more keys are in action, and current
|
|
|
|
// event (UP or DOWN) is non-modifier key.
|
|
|
|
if (pointerCount > 1 && !tracker.isModifier()) {
|
2011-07-04 11:58:58 +00:00
|
|
|
mKeyTimerHandler.cancelKeyRepeatTimer();
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
// Up event will pass through.
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: cleanup this code into a multi-touch to single-touch event converter class?
|
|
|
|
// Translate mutli-touch event to single-touch events on the device that has no distinct
|
|
|
|
// multi-touch panel.
|
2011-07-04 11:58:58 +00:00
|
|
|
if (nonDistinctMultitouch) {
|
2011-07-01 04:07:59 +00:00
|
|
|
// Use only main (id=0) pointer tracker.
|
2012-01-25 02:08:30 +00:00
|
|
|
final PointerTracker tracker = PointerTracker.getPointerTracker(0, this);
|
2011-07-01 04:07:59 +00:00
|
|
|
if (pointerCount == 1 && oldPointerCount == 2) {
|
|
|
|
// Multi-touch to single touch transition.
|
|
|
|
// Send a down event for the latest pointer if the key is different from the
|
|
|
|
// previous key.
|
2011-11-29 07:56:27 +00:00
|
|
|
final Key newKey = tracker.getKeyOn(x, y);
|
|
|
|
if (mOldKey != newKey) {
|
2011-07-09 04:26:29 +00:00
|
|
|
tracker.onDownEvent(x, y, eventTime, this);
|
2011-07-01 04:07:59 +00:00
|
|
|
if (action == MotionEvent.ACTION_UP)
|
2011-07-06 23:11:30 +00:00
|
|
|
tracker.onUpEvent(x, y, eventTime);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
} else if (pointerCount == 2 && oldPointerCount == 1) {
|
|
|
|
// Single-touch to multi-touch transition.
|
|
|
|
// Send an up event for the last pointer.
|
|
|
|
final int lastX = tracker.getLastX();
|
|
|
|
final int lastY = tracker.getLastY();
|
2011-11-29 07:56:27 +00:00
|
|
|
mOldKey = tracker.getKeyOn(lastX, lastY);
|
2011-07-06 23:11:30 +00:00
|
|
|
tracker.onUpEvent(lastX, lastY, eventTime);
|
2011-07-01 04:07:59 +00:00
|
|
|
} else if (pointerCount == 1 && oldPointerCount == 1) {
|
2011-09-06 06:25:58 +00:00
|
|
|
tracker.processMotionEvent(action, x, y, eventTime, this);
|
2011-07-01 04:07:59 +00:00
|
|
|
} else {
|
|
|
|
Log.w(TAG, "Unknown touch panel behavior: pointer count is " + pointerCount
|
|
|
|
+ " (old " + oldPointerCount + ")");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == MotionEvent.ACTION_MOVE) {
|
|
|
|
for (int i = 0; i < pointerCount; i++) {
|
2012-03-22 02:13:33 +00:00
|
|
|
final int pointerId = me.getPointerId(i);
|
2012-01-25 02:08:30 +00:00
|
|
|
final PointerTracker tracker = PointerTracker.getPointerTracker(
|
2012-03-22 02:13:33 +00:00
|
|
|
pointerId, this);
|
2011-07-11 01:09:15 +00:00
|
|
|
final int px, py;
|
2011-08-31 06:26:32 +00:00
|
|
|
if (mMoreKeysPanel != null
|
|
|
|
&& tracker.mPointerId == mMoreKeysPanelPointerTrackerId) {
|
|
|
|
px = mMoreKeysPanel.translateX((int)me.getX(i));
|
|
|
|
py = mMoreKeysPanel.translateY((int)me.getY(i));
|
2011-07-11 01:09:15 +00:00
|
|
|
} else {
|
|
|
|
px = (int)me.getX(i);
|
|
|
|
py = (int)me.getY(i);
|
|
|
|
}
|
|
|
|
tracker.onMoveEvent(px, py, eventTime);
|
2012-03-22 02:13:33 +00:00
|
|
|
if (ENABLE_USABILITY_STUDY_LOG) {
|
|
|
|
final float pointerSize = me.getSize(i);
|
|
|
|
final float pointerPressure = me.getPressure(i);
|
|
|
|
UsabilityStudyLogUtils.getInstance().write("[Move]" + eventTime + ","
|
|
|
|
+ pointerId + "," + px + "," + py + ","
|
|
|
|
+ pointerSize + "," + pointerPressure);
|
|
|
|
}
|
2012-03-26 13:10:21 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
2012-04-07 01:26:34 +00:00
|
|
|
if (ResearchLogger.sIsLogging) {
|
|
|
|
// TODO: earlier comment about redundant calculations applies here too
|
|
|
|
final float pointerSize = me.getSize(i);
|
|
|
|
final float pointerPressure = me.getPressure(i);
|
|
|
|
ResearchLogger.getInstance().logMotionEvent(action, eventTime, pointerId,
|
|
|
|
px, py, pointerSize, pointerPressure);
|
|
|
|
}
|
2011-12-15 14:26:18 +00:00
|
|
|
}
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-01-25 02:08:30 +00:00
|
|
|
final PointerTracker tracker = PointerTracker.getPointerTracker(id, this);
|
|
|
|
tracker.processMotionEvent(action, x, y, eventTime, this);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void closing() {
|
|
|
|
super.closing();
|
2011-08-31 06:26:32 +00:00
|
|
|
dismissMoreKeysPanel();
|
|
|
|
mMoreKeysPanelCache.clear();
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-07-23 08:16:56 +00:00
|
|
|
@Override
|
2011-08-31 06:26:32 +00:00
|
|
|
public boolean dismissMoreKeysPanel() {
|
|
|
|
if (mMoreKeysWindow != null && mMoreKeysWindow.isShowing()) {
|
|
|
|
mMoreKeysWindow.dismiss();
|
|
|
|
mMoreKeysPanel = null;
|
|
|
|
mMoreKeysPanelPointerTrackerId = -1;
|
2011-09-01 08:50:51 +00:00
|
|
|
dimEntireKeyboard(false);
|
2011-07-01 04:07:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean handleBack() {
|
2011-08-31 06:26:32 +00:00
|
|
|
return dismissMoreKeysPanel();
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-08-23 03:22:24 +00:00
|
|
|
@Override
|
|
|
|
public void draw(Canvas c) {
|
|
|
|
Utils.GCUtils.getInstance().reset();
|
|
|
|
boolean tryGC = true;
|
|
|
|
for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
|
|
|
|
try {
|
|
|
|
super.draw(c);
|
|
|
|
tryGC = false;
|
|
|
|
} catch (OutOfMemoryError e) {
|
2012-03-13 05:15:39 +00:00
|
|
|
tryGC = Utils.GCUtils.getInstance().tryGCOrWait(TAG, e);
|
2011-08-23 03:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-26 21:06:26 +00:00
|
|
|
/**
|
2012-04-02 14:13:09 +00:00
|
|
|
* Receives hover events from the input framework.
|
2011-07-26 21:06:26 +00:00
|
|
|
*
|
|
|
|
* @param event The motion event to be dispatched.
|
|
|
|
* @return {@code true} if the event was handled by the view, {@code false}
|
|
|
|
* otherwise
|
|
|
|
*/
|
2012-04-02 14:13:09 +00:00
|
|
|
@Override
|
2011-07-26 21:06:26 +00:00
|
|
|
public boolean dispatchHoverEvent(MotionEvent event) {
|
2011-07-01 04:07:59 +00:00
|
|
|
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
2012-01-25 02:08:30 +00:00
|
|
|
final PointerTracker tracker = PointerTracker.getPointerTracker(0, this);
|
2011-07-26 21:06:26 +00:00
|
|
|
return AccessibleKeyboardViewProxy.getInstance().dispatchHoverEvent(event, tracker);
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-07-26 21:06:26 +00:00
|
|
|
// Reflection doesn't support calling superclass methods.
|
2011-07-01 04:07:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-12-17 18:06:20 +00:00
|
|
|
|
2011-12-17 19:55:17 +00:00
|
|
|
public void updateShortcutKey(boolean available) {
|
2011-12-17 23:00:07 +00:00
|
|
|
final Keyboard keyboard = getKeyboard();
|
|
|
|
if (keyboard == null) return;
|
|
|
|
final Key shortcutKey = keyboard.getKey(Keyboard.CODE_SHORTCUT);
|
|
|
|
if (shortcutKey == null) return;
|
|
|
|
shortcutKey.setEnabled(available);
|
|
|
|
invalidateKey(shortcutKey);
|
2011-12-17 19:55:17 +00:00
|
|
|
}
|
|
|
|
|
2012-03-14 05:46:22 +00:00
|
|
|
private void updateAltCodeKeyWhileTyping() {
|
|
|
|
final Keyboard keyboard = getKeyboard();
|
|
|
|
if (keyboard == null) return;
|
|
|
|
for (final Key key : keyboard.mAltCodeKeysWhileTyping) {
|
|
|
|
invalidateKey(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-13 05:15:39 +00:00
|
|
|
public void startDisplayLanguageOnSpacebar(boolean subtypeChanged,
|
2012-03-13 03:44:03 +00:00
|
|
|
boolean needsToDisplayLanguage) {
|
2012-03-16 05:05:20 +00:00
|
|
|
final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
|
2011-12-17 23:13:36 +00:00
|
|
|
mNeedsToDisplayLanguage = needsToDisplayLanguage;
|
2012-03-14 03:33:03 +00:00
|
|
|
if (animator == null) {
|
2012-03-13 07:47:45 +00:00
|
|
|
mNeedsToDisplayLanguage = false;
|
2012-03-13 03:44:03 +00:00
|
|
|
} else {
|
2012-03-13 05:15:39 +00:00
|
|
|
if (subtypeChanged && needsToDisplayLanguage) {
|
2012-03-16 05:05:20 +00:00
|
|
|
setLanguageOnSpacebarAnimAlpha(ALPHA_OPAQUE);
|
|
|
|
if (animator.isStarted()) {
|
|
|
|
animator.cancel();
|
|
|
|
}
|
2012-03-14 03:33:03 +00:00
|
|
|
animator.start();
|
2012-03-13 05:15:39 +00:00
|
|
|
} else {
|
2012-03-16 05:05:20 +00:00
|
|
|
if (!animator.isStarted()) {
|
|
|
|
mLanguageOnSpacebarAnimAlpha = mLanguageOnSpacebarFinalAlpha;
|
|
|
|
}
|
2012-03-13 05:15:39 +00:00
|
|
|
}
|
2012-03-13 03:44:03 +00:00
|
|
|
}
|
2011-12-17 23:13:36 +00:00
|
|
|
invalidateKey(mSpaceKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateAutoCorrectionState(boolean isAutoCorrection) {
|
|
|
|
if (!mAutoCorrectionSpacebarLedEnabled) return;
|
|
|
|
mAutoCorrectionSpacebarLedOn = isAutoCorrection;
|
|
|
|
invalidateKey(mSpaceKey);
|
2011-12-17 18:06:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-01-25 02:12:48 +00:00
|
|
|
protected void onDrawKeyTopVisuals(Key key, Canvas canvas, Paint paint, KeyDrawParams params) {
|
2012-03-14 10:49:13 +00:00
|
|
|
if (key.altCodeWhileTyping() && key.isEnabled()) {
|
2012-03-14 05:46:22 +00:00
|
|
|
params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
|
|
|
|
}
|
2011-12-17 23:13:36 +00:00
|
|
|
if (key.mCode == Keyboard.CODE_SPACE) {
|
2012-01-25 03:57:28 +00:00
|
|
|
drawSpacebar(key, canvas, paint);
|
|
|
|
|
2011-12-17 23:13:36 +00:00
|
|
|
// Whether space key needs to show the "..." popup hint for special purposes
|
|
|
|
if (mIsSpacebarTriggeringPopupByLongPress
|
2012-03-08 08:07:02 +00:00
|
|
|
&& SubtypeUtils.hasMultipleEnabledIMEsOrSubtypes(
|
|
|
|
true /* include aux subtypes */)) {
|
2012-01-25 03:57:28 +00:00
|
|
|
drawKeyPopupHint(key, canvas, paint, params);
|
2011-12-17 23:13:36 +00:00
|
|
|
}
|
2012-02-18 01:46:01 +00:00
|
|
|
} else if (key.mCode == Keyboard.CODE_LANGUAGE_SWITCH) {
|
|
|
|
super.onDrawKeyTopVisuals(key, canvas, paint, params);
|
2012-03-08 08:07:02 +00:00
|
|
|
if (SubtypeUtils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) {
|
2012-02-18 01:46:01 +00:00
|
|
|
drawKeyPopupHint(key, canvas, paint, params);
|
|
|
|
}
|
2012-02-27 12:35:35 +00:00
|
|
|
} else {
|
|
|
|
super.onDrawKeyTopVisuals(key, canvas, paint, params);
|
2011-12-17 18:06:20 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-17 23:13:36 +00:00
|
|
|
|
|
|
|
// Compute width of text with specified text size using paint.
|
2012-01-25 03:57:28 +00:00
|
|
|
private int getTextWidth(Paint paint, String text, float textSize) {
|
2011-12-17 23:13:36 +00:00
|
|
|
paint.setTextSize(textSize);
|
2012-01-25 03:57:28 +00:00
|
|
|
return (int)getLabelWidth(text, paint);
|
2011-12-17 23:13:36 +00:00
|
|
|
}
|
|
|
|
|
2012-01-10 09:13:34 +00:00
|
|
|
// Layout locale language name on spacebar.
|
2012-01-25 03:57:28 +00:00
|
|
|
private String layoutLanguageOnSpacebar(Paint paint, Locale locale, int width,
|
2011-12-17 23:13:36 +00:00
|
|
|
float origTextSize) {
|
2012-01-25 03:57:28 +00:00
|
|
|
paint.setTextAlign(Align.CENTER);
|
|
|
|
paint.setTypeface(Typeface.DEFAULT);
|
2011-12-17 23:13:36 +00:00
|
|
|
// Estimate appropriate language name text size to fit in maxTextWidth.
|
2012-04-03 03:50:28 +00:00
|
|
|
String language = SubtypeLocale.getFullDisplayName(locale);
|
2012-01-25 03:57:28 +00:00
|
|
|
int textWidth = getTextWidth(paint, language, origTextSize);
|
2011-12-17 23:13:36 +00:00
|
|
|
// Assuming text width and text size are proportional to each other.
|
|
|
|
float textSize = origTextSize * Math.min(width / textWidth, 1.0f);
|
|
|
|
// allow variable text size
|
2012-01-25 03:57:28 +00:00
|
|
|
textWidth = getTextWidth(paint, language, textSize);
|
2011-12-17 23:13:36 +00:00
|
|
|
// If text size goes too small or text does not fit, use middle or short name
|
|
|
|
final boolean useMiddleName = (textSize / origTextSize < MINIMUM_SCALE_OF_LANGUAGE_NAME)
|
|
|
|
|| (textWidth > width);
|
|
|
|
|
|
|
|
final boolean useShortName;
|
|
|
|
if (useMiddleName) {
|
2012-04-03 03:50:28 +00:00
|
|
|
language = SubtypeLocale.getMiddleDisplayName(locale);
|
2012-01-25 03:57:28 +00:00
|
|
|
textWidth = getTextWidth(paint, language, origTextSize);
|
2011-12-17 23:13:36 +00:00
|
|
|
textSize = origTextSize * Math.min(width / textWidth, 1.0f);
|
|
|
|
useShortName = (textSize / origTextSize < MINIMUM_SCALE_OF_LANGUAGE_NAME)
|
|
|
|
|| (textWidth > width);
|
|
|
|
} else {
|
|
|
|
useShortName = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (useShortName) {
|
2012-04-03 03:50:28 +00:00
|
|
|
language = SubtypeLocale.getShortDisplayName(locale);
|
2012-01-25 03:57:28 +00:00
|
|
|
textWidth = getTextWidth(paint, language, origTextSize);
|
2011-12-17 23:13:36 +00:00
|
|
|
textSize = origTextSize * Math.min(width / textWidth, 1.0f);
|
|
|
|
}
|
|
|
|
paint.setTextSize(textSize);
|
|
|
|
|
|
|
|
return language;
|
|
|
|
}
|
|
|
|
|
2012-01-25 03:57:28 +00:00
|
|
|
private void drawSpacebar(Key key, Canvas canvas, Paint paint) {
|
|
|
|
final int width = key.mWidth;
|
2012-02-27 12:35:35 +00:00
|
|
|
final int height = key.mHeight;
|
2011-12-17 23:13:36 +00:00
|
|
|
|
2012-03-13 07:47:45 +00:00
|
|
|
// If input subtypes are explicitly selected.
|
2012-01-25 03:57:28 +00:00
|
|
|
if (mNeedsToDisplayLanguage) {
|
|
|
|
final String language = layoutLanguageOnSpacebar(paint, mSpacebarLocale, width,
|
|
|
|
mSpacebarTextSize);
|
2011-12-17 23:13:36 +00:00
|
|
|
// Draw language text with shadow
|
|
|
|
// In case there is no space icon, we will place the language text at the center of
|
|
|
|
// spacebar.
|
|
|
|
final float descent = paint.descent();
|
|
|
|
final float textHeight = -paint.ascent() + descent;
|
2012-02-27 12:35:35 +00:00
|
|
|
final float baseline = height / 2 + textHeight / 2;
|
2012-03-13 07:47:45 +00:00
|
|
|
paint.setColor(mSpacebarTextShadowColor);
|
2012-03-16 05:05:20 +00:00
|
|
|
paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
|
2011-12-17 23:13:36 +00:00
|
|
|
canvas.drawText(language, width / 2, baseline - descent - 1, paint);
|
2012-03-13 07:47:45 +00:00
|
|
|
paint.setColor(mSpacebarTextColor);
|
2012-03-16 05:05:20 +00:00
|
|
|
paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
|
2011-12-17 23:13:36 +00:00
|
|
|
canvas.drawText(language, width / 2, baseline - descent, paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the spacebar icon at the bottom
|
2012-01-25 03:57:28 +00:00
|
|
|
if (mAutoCorrectionSpacebarLedOn) {
|
2011-12-17 23:13:36 +00:00
|
|
|
final int iconWidth = width * SPACE_LED_LENGTH_PERCENT / 100;
|
|
|
|
final int iconHeight = mAutoCorrectionSpacebarLedIcon.getIntrinsicHeight();
|
|
|
|
int x = (width - iconWidth) / 2;
|
|
|
|
int y = height - iconHeight;
|
2012-01-25 03:57:28 +00:00
|
|
|
drawIcon(canvas, mAutoCorrectionSpacebarLedIcon, x, y, iconWidth, iconHeight);
|
2011-12-17 23:13:36 +00:00
|
|
|
} else if (mSpaceIcon != null) {
|
|
|
|
final int iconWidth = mSpaceIcon.getIntrinsicWidth();
|
|
|
|
final int iconHeight = mSpaceIcon.getIntrinsicHeight();
|
|
|
|
int x = (width - iconWidth) / 2;
|
|
|
|
int y = height - iconHeight;
|
2012-01-25 03:57:28 +00:00
|
|
|
drawIcon(canvas, mSpaceIcon, x, y, iconWidth, iconHeight);
|
2011-12-17 23:13:36 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|