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;
|
2012-04-25 05:17:49 +00:00
|
|
|
import android.content.res.Resources;
|
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;
|
2012-04-11 09:21:10 +00:00
|
|
|
import android.view.inputmethod.InputMethodSubtype;
|
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-04-18 08:39:57 +00:00
|
|
|
import com.android.inputmethod.latin.ImfUtils;
|
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-25 05:17:49 +00:00
|
|
|
import com.android.inputmethod.latin.StringUtils;
|
2012-04-03 03:50:28 +00:00
|
|
|
import com.android.inputmethod.latin.SubtypeLocale;
|
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
|
|
|
|
2012-04-25 05:17:49 +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;
|
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;
|
2012-04-26 05:40:47 +00:00
|
|
|
// The minimum x-scale to fit the language name on spacebar.
|
|
|
|
private static final float MINIMUM_XSCALE_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 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();
|
2012-05-08 03:39:54 +00:00
|
|
|
if (tracker == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final Key key = tracker.getKey();
|
|
|
|
final int delay;
|
|
|
|
switch (key.mCode) {
|
|
|
|
case Keyboard.CODE_SHIFT:
|
|
|
|
delay = mParams.mLongPressShiftKeyTimeout;
|
|
|
|
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;
|
2012-02-01 06:07:25 +00:00
|
|
|
}
|
2012-05-08 03:39:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (delay > 0) {
|
|
|
|
sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, tracker), delay);
|
2012-02-01 06:07:25 +00:00
|
|
|
}
|
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-04-12 07:25:53 +00:00
|
|
|
public static void cancelAndStartAnimators(final ObjectAnimator animatorToCancel,
|
|
|
|
final ObjectAnimator animatorToStart) {
|
|
|
|
float startFraction = 0.0f;
|
|
|
|
if (animatorToCancel.isStarted()) {
|
2012-03-15 12:05:17 +00:00
|
|
|
animatorToCancel.cancel();
|
2012-04-12 07:25:53 +00:00
|
|
|
startFraction = 1.0f - animatorToCancel.getAnimatedFraction();
|
2012-03-15 12:05:17 +00:00
|
|
|
}
|
2012-04-12 07:25:53 +00:00
|
|
|
final long startTime = (long)(animatorToStart.getDuration() * startFraction);
|
|
|
|
animatorToStart.start();
|
|
|
|
animatorToStart.setCurrentPlayTime(startTime);
|
2012-03-15 12:05:17 +00:00
|
|
|
}
|
|
|
|
|
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-04-12 06:33:48 +00:00
|
|
|
removeMessages(MSG_TYPING_STATE_EXPIRED);
|
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();
|
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;
|
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);
|
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);
|
|
|
|
|
|
|
|
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;
|
2012-04-18 03:54:33 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
|
|
ResearchLogger.latinKeyboardView_setKeyboard(keyboard);
|
|
|
|
}
|
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) {
|
2012-03-30 20:15:46 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
|
|
ResearchLogger.latinKeyboardView_onLongPress();
|
|
|
|
}
|
2011-08-23 03:22:24 +00:00
|
|
|
final int primaryCode = parentKey.mCode;
|
2012-03-05 02:39:07 +00:00
|
|
|
if (parentKey.hasEmbeddedMoreKey()) {
|
2012-04-09 08:48:32 +00:00
|
|
|
final int embeddedCode = parentKey.mMoreKeys[0].mCode;
|
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-03-30 20:15:46 +00:00
|
|
|
ResearchLogger.latinKeyboardView_processMotionEvent(me, action, eventTime, index, id,
|
|
|
|
x, y);
|
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-03-30 20:15:46 +00:00
|
|
|
ResearchLogger.latinKeyboardView_processMotionEvent(me, action, eventTime,
|
|
|
|
i, pointerId, px, py);
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
2012-05-08 03:39:54 +00:00
|
|
|
if (key.isLongPressEnabled() && ImfUtils.hasMultipleEnabledIMEsOrSubtypes(
|
|
|
|
getContext(), 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-04-18 08:39:57 +00:00
|
|
|
if (ImfUtils.hasMultipleEnabledIMEsOrSubtypes(
|
|
|
|
getContext(), 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
|
|
|
|
2012-04-26 05:40:47 +00:00
|
|
|
private boolean fitsTextIntoWidth(final int width, String text, Paint paint) {
|
|
|
|
paint.setTextScaleX(1.0f);
|
|
|
|
final float textWidth = getLabelWidth(text, paint);
|
|
|
|
if (textWidth < width) return true;
|
|
|
|
|
|
|
|
final float scaleX = width / textWidth;
|
|
|
|
if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) return false;
|
|
|
|
|
|
|
|
paint.setTextScaleX(scaleX);
|
|
|
|
return getLabelWidth(text, paint) < width;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Layout language name on spacebar.
|
|
|
|
private String layoutLanguageOnSpacebar(Paint paint, InputMethodSubtype subtype,
|
|
|
|
final int width) {
|
|
|
|
// Choose appropriate language name to fit into the width.
|
|
|
|
String text = getFullDisplayName(subtype, getResources());
|
|
|
|
if (fitsTextIntoWidth(width, text, paint)) {
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
text = getMiddleDisplayName(subtype);
|
|
|
|
if (fitsTextIntoWidth(width, text, paint)) {
|
|
|
|
return text;
|
2011-12-17 23:13:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-26 05:40:47 +00:00
|
|
|
text = getShortDisplayName(subtype);
|
|
|
|
if (fitsTextIntoWidth(width, text, paint)) {
|
|
|
|
return text;
|
2011-12-17 23:13:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-26 05:40:47 +00:00
|
|
|
return "";
|
2011-12-17 23:13:36 +00:00
|
|
|
}
|
|
|
|
|
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-04-11 09:21:10 +00:00
|
|
|
// If input language are explicitly selected.
|
2012-01-25 03:57:28 +00:00
|
|
|
if (mNeedsToDisplayLanguage) {
|
2012-04-26 05:40:47 +00:00
|
|
|
paint.setTextAlign(Align.CENTER);
|
|
|
|
paint.setTypeface(Typeface.DEFAULT);
|
|
|
|
paint.setTextSize(mSpacebarTextSize);
|
|
|
|
final InputMethodSubtype subtype = getKeyboard().mId.mSubtype;
|
|
|
|
final String language = layoutLanguageOnSpacebar(paint, subtype, width);
|
2011-12-17 23:13:36 +00:00
|
|
|
// Draw language text with shadow
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2012-04-25 05:17:49 +00:00
|
|
|
|
|
|
|
// InputMethodSubtype's display name for spacebar text in its locale.
|
|
|
|
// isAdditionalSubtype (T=true, F=false)
|
|
|
|
// locale layout | Short Middle Full
|
|
|
|
// ------ ------ - ---- --------- ----------------------
|
|
|
|
// en_US qwerty F En English English (US) exception
|
|
|
|
// en_GB qwerty F En English English (UK) exception
|
|
|
|
// fr azerty F Fr Français Français
|
|
|
|
// fr_CA qwerty F Fr Français Français (Canada)
|
|
|
|
// de qwertz F De Deutsch Deutsch
|
|
|
|
// zz qwerty F QWERTY QWERTY
|
|
|
|
// fr qwertz T Fr Français Français (QWERTZ)
|
|
|
|
// de qwerty T De Deutsch Deutsch (QWERTY)
|
|
|
|
// en_US azerty T En English English (US) (AZERTY)
|
|
|
|
// zz azerty T AZERTY AZERTY
|
|
|
|
|
|
|
|
// Get InputMethodSubtype's full display name in its locale.
|
|
|
|
static String getFullDisplayName(InputMethodSubtype subtype, Resources res) {
|
|
|
|
if (SubtypeLocale.isNoLanguage(subtype)) {
|
|
|
|
return SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SubtypeLocale.getSubtypeDisplayName(subtype, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get InputMethodSubtype's short display name in its locale.
|
|
|
|
static String getShortDisplayName(InputMethodSubtype subtype) {
|
|
|
|
if (SubtypeLocale.isNoLanguage(subtype)) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
|
|
|
|
return StringUtils.toTitleCase(locale.getLanguage(), locale);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get InputMethodSubtype's middle display name in its locale.
|
|
|
|
static String getMiddleDisplayName(InputMethodSubtype subtype) {
|
|
|
|
if (SubtypeLocale.isNoLanguage(subtype)) {
|
|
|
|
return SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype);
|
|
|
|
}
|
|
|
|
final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
|
|
|
|
return StringUtils.toTitleCase(locale.getDisplayLanguage(locale), locale);
|
|
|
|
}
|
2011-07-01 04:07:59 +00:00
|
|
|
}
|