am 1cd7d96f: am ed5ce6c1: Merge "Remove extension keyboard" into gingerbread
Merge commit '1cd7d96fe42e63577d70e911c4b5dbfd8b50bba1' * commit '1cd7d96fe42e63577d70e911c4b5dbfd8b50bba1': Remove extension keyboardmain
commit
a66ccc3e8d
|
@ -1,61 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2008, 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:keyWidth="10%p"
|
||||
android:horizontalGap="0px"
|
||||
android:verticalGap="0px"
|
||||
android:keyHeight="@dimen/key_height"
|
||||
>
|
||||
|
||||
<Row android:rowEdgeFlags="top">
|
||||
<Key android:keyLabel="!" android:keyEdgeFlags="left"/>
|
||||
<Key android:keyLabel="\@"/>
|
||||
<Key android:keyLabel="\#"/>
|
||||
<Key android:keyLabel="&"/>
|
||||
<Key android:keyLabel="-"/>
|
||||
<Key android:keyLabel="\'"/>
|
||||
<Key android:keyLabel=":"/>
|
||||
<Key android:keyLabel="""/>
|
||||
<Key android:keyLabel="/"/>
|
||||
<Key android:keyLabel="\?" android:keyEdgeFlags="right"
|
||||
/>
|
||||
</Row>
|
||||
|
||||
<Row android:rowEdgeFlags="bottom">
|
||||
<Key android:codes="49" android:keyLabel="1" android:keyEdgeFlags="left"
|
||||
/>
|
||||
<Key android:codes="50" android:keyLabel="2"
|
||||
/>
|
||||
<Key android:codes="51" android:keyLabel="3"
|
||||
/>
|
||||
<Key android:codes="52" android:keyLabel="4"
|
||||
/>
|
||||
<Key android:codes="53" android:keyLabel="5"
|
||||
/>
|
||||
<Key android:codes="54" android:keyLabel="6"/>
|
||||
<Key android:codes="55" android:keyLabel="7"
|
||||
/>
|
||||
<Key android:codes="56" android:keyLabel="8"/>
|
||||
<Key android:codes="57" android:keyLabel="9"/>
|
||||
<Key android:codes="48" android:keyLabel="0"
|
||||
android:keyEdgeFlags="right"/>
|
||||
</Row>
|
||||
</Keyboard>
|
|
@ -261,14 +261,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
|| id.mXml == R.xml.kbd_symbols_black), mHasVoice);
|
||||
keyboard.setLanguageSwitcher(mLanguageSwitcher);
|
||||
keyboard.setBlackFlag(isBlackSym());
|
||||
if (id.mKeyboardMode == KEYBOARDMODE_NORMAL
|
||||
|| id.mKeyboardMode == KEYBOARDMODE_URL
|
||||
|| id.mKeyboardMode == KEYBOARDMODE_IM
|
||||
|| id.mKeyboardMode == KEYBOARDMODE_EMAIL
|
||||
|| id.mKeyboardMode == KEYBOARDMODE_WEB
|
||||
) {
|
||||
keyboard.setExtension(R.xml.kbd_extension);
|
||||
}
|
||||
|
||||
if (id.mEnableShiftLock) {
|
||||
keyboard.enableShiftLock();
|
||||
|
@ -439,7 +431,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
mLayoutId + "," + newLayout, e);
|
||||
}
|
||||
}
|
||||
mInputView.setExtentionLayoutResId(THEMES[newLayout]);
|
||||
mInputView.setOnKeyboardActionListener(mInputMethodService);
|
||||
mLayoutId = newLayout;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ public class LatinKeyboard extends Keyboard {
|
|||
private int mPrefLetterY;
|
||||
private int mPrefDistance;
|
||||
|
||||
private int mExtensionResId;
|
||||
// TODO: generalize for any keyboardId
|
||||
private boolean mIsBlackSym;
|
||||
|
||||
|
@ -278,14 +277,6 @@ public class LatinKeyboard extends Keyboard {
|
|||
return mIsAlphaKeyboard;
|
||||
}
|
||||
|
||||
public void setExtension(int resId) {
|
||||
mExtensionResId = resId;
|
||||
}
|
||||
|
||||
public int getExtension() {
|
||||
return mExtensionResId;
|
||||
}
|
||||
|
||||
public void setBlackFlag(boolean f) {
|
||||
mIsBlackSym = f;
|
||||
if (f) {
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
package com.android.inputmethod.latin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
|
@ -27,9 +25,9 @@ import android.os.Handler;
|
|||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LatinKeyboardView extends LatinKeyboardBaseView {
|
||||
|
||||
|
@ -41,21 +39,11 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
|
|||
|
||||
private Keyboard mPhoneKeyboard;
|
||||
|
||||
/** Whether the extension of this keyboard is visible */
|
||||
private boolean mExtensionVisible;
|
||||
/** The view that is shown as an extension of this keyboard view */
|
||||
private LatinKeyboardView mExtension;
|
||||
/** The popup window that contains the extension of this keyboard */
|
||||
private PopupWindow mExtensionPopup;
|
||||
/** Whether this view is an extension of another keyboard */
|
||||
private boolean mIsExtensionType;
|
||||
private boolean mFirstEvent;
|
||||
/** Whether we've started dropping move events because we found a big jump */
|
||||
private boolean mDroppingEvents;
|
||||
/**
|
||||
* Whether multi-touch disambiguation needs to be disabled for any reason. There are 2 reasons
|
||||
* for this to happen - (1) if a real multi-touch event has occured and (2) we've opened an
|
||||
* extension keyboard.
|
||||
* Whether multi-touch disambiguation needs to be disabled if a real multi-touch event has
|
||||
* occured
|
||||
*/
|
||||
private boolean mDisableDisambiguation;
|
||||
/** The distance threshold at which we start treating the touch session as a multi-touch */
|
||||
|
@ -63,8 +51,6 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
|
|||
/** The y coordinate of the last row */
|
||||
private int mLastRowY;
|
||||
|
||||
private int mExtensionLayoutResId = 0;
|
||||
|
||||
public LatinKeyboardView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
@ -77,10 +63,6 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
|
|||
mPhoneKeyboard = phoneKeyboard;
|
||||
}
|
||||
|
||||
public void setExtentionLayoutResId (int id) {
|
||||
mExtensionLayoutResId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyboard(Keyboard k) {
|
||||
super.setKeyboard(k);
|
||||
|
@ -214,11 +196,10 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
// If an extension keyboard is visible or this is an extension keyboard, don't look
|
||||
// for sudden jumps. Otherwise, if there was a sudden jump, return without processing the
|
||||
// actual motion event.
|
||||
if (!mExtensionVisible && !mIsExtensionType
|
||||
&& handleSuddenJump(me)) return true;
|
||||
// If there was a sudden jump, return without processing the actual motion event.
|
||||
if (handleSuddenJump(me))
|
||||
return true;
|
||||
|
||||
// Reset any bounding box controls in the keyboard
|
||||
if (me.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
keyboard.keyReleased();
|
||||
|
@ -236,154 +217,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
|
|||
}
|
||||
}
|
||||
|
||||
// If we don't have an extension keyboard, don't go any further.
|
||||
if (keyboard.getExtension() == 0) {
|
||||
return super.onTouchEvent(me);
|
||||
}
|
||||
// If the motion event is above the keyboard and it's not an UP event coming
|
||||
// even before the first MOVE event into the extension area
|
||||
if (me.getY() < 0 && (mExtensionVisible || me.getAction() != MotionEvent.ACTION_UP)) {
|
||||
if (mExtensionVisible) {
|
||||
int action = me.getAction();
|
||||
if (mFirstEvent) action = MotionEvent.ACTION_DOWN;
|
||||
mFirstEvent = false;
|
||||
MotionEvent translated = MotionEvent.obtain(me.getEventTime(), me.getEventTime(),
|
||||
action,
|
||||
me.getX(), me.getY() + mExtension.getHeight(), me.getMetaState());
|
||||
boolean result = mExtension.onTouchEvent(translated);
|
||||
translated.recycle();
|
||||
if (me.getAction() == MotionEvent.ACTION_UP
|
||||
|| me.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
closeExtension();
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
if (openExtension()) {
|
||||
MotionEvent cancel = MotionEvent.obtain(me.getDownTime(), me.getEventTime(),
|
||||
MotionEvent.ACTION_CANCEL, me.getX() - 100, me.getY() - 100, 0);
|
||||
super.onTouchEvent(cancel);
|
||||
cancel.recycle();
|
||||
if (mExtension.getHeight() > 0) {
|
||||
MotionEvent translated = MotionEvent.obtain(me.getEventTime(),
|
||||
me.getEventTime(),
|
||||
MotionEvent.ACTION_DOWN,
|
||||
me.getX(), me.getY() + mExtension.getHeight(),
|
||||
me.getMetaState());
|
||||
mExtension.onTouchEvent(translated);
|
||||
translated.recycle();
|
||||
} else {
|
||||
mFirstEvent = true;
|
||||
}
|
||||
// Stop processing multi-touch errors
|
||||
mDisableDisambiguation = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (mExtensionVisible) {
|
||||
closeExtension();
|
||||
// Send a down event into the main keyboard first
|
||||
MotionEvent down = MotionEvent.obtain(me.getEventTime(), me.getEventTime(),
|
||||
MotionEvent.ACTION_DOWN,
|
||||
me.getX(), me.getY(), me.getMetaState());
|
||||
super.onTouchEvent(down);
|
||||
down.recycle();
|
||||
// Send the actual event
|
||||
return super.onTouchEvent(me);
|
||||
} else {
|
||||
return super.onTouchEvent(me);
|
||||
}
|
||||
}
|
||||
|
||||
private void setExtensionType(boolean isExtensionType) {
|
||||
mIsExtensionType = isExtensionType;
|
||||
}
|
||||
|
||||
private boolean openExtension() {
|
||||
// If the current keyboard is not visible, don't show the popup
|
||||
if (!isShown()) {
|
||||
return false;
|
||||
}
|
||||
if (((LatinKeyboard) getKeyboard()).getExtension() == 0) return false;
|
||||
makePopupWindow();
|
||||
mExtensionVisible = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void makePopupWindow() {
|
||||
if (mExtensionPopup == null) {
|
||||
int[] windowLocation = new int[2];
|
||||
mExtensionPopup = new PopupWindow(getContext());
|
||||
mExtensionPopup.setBackgroundDrawable(null);
|
||||
LayoutInflater li = (LayoutInflater) getContext().getSystemService(
|
||||
Context.LAYOUT_INFLATER_SERVICE);
|
||||
mExtension = (LatinKeyboardView) li.inflate(mExtensionLayoutResId == 0 ?
|
||||
R.layout.input_trans : mExtensionLayoutResId, null);
|
||||
mExtension.setExtensionType(true);
|
||||
mExtension.setOnKeyboardActionListener(
|
||||
new ExtensionKeyboardListener(getOnKeyboardActionListener()));
|
||||
mExtension.setPopupParent(this);
|
||||
mExtension.setPopupOffset(0, -windowLocation[1]);
|
||||
Keyboard keyboard;
|
||||
mExtension.setKeyboard(keyboard = new LatinKeyboard(getContext(),
|
||||
((LatinKeyboard) getKeyboard()).getExtension()));
|
||||
mExtensionPopup.setContentView(mExtension);
|
||||
mExtensionPopup.setWidth(getWidth());
|
||||
mExtensionPopup.setHeight(keyboard.getHeight());
|
||||
mExtensionPopup.setAnimationStyle(-1);
|
||||
getLocationInWindow(windowLocation);
|
||||
// TODO: Fix the "- 30".
|
||||
mExtension.setPopupOffset(0, -windowLocation[1] - 30);
|
||||
mExtensionPopup.showAtLocation(this, 0, 0, -keyboard.getHeight()
|
||||
+ windowLocation[1]);
|
||||
} else {
|
||||
mExtension.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closing() {
|
||||
super.closing();
|
||||
if (mExtensionPopup != null && mExtensionPopup.isShowing()) {
|
||||
mExtensionPopup.dismiss();
|
||||
mExtensionPopup = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void closeExtension() {
|
||||
mExtension.closing();
|
||||
mExtension.setVisibility(INVISIBLE);
|
||||
mExtensionVisible = false;
|
||||
}
|
||||
|
||||
private static class ExtensionKeyboardListener implements OnKeyboardActionListener {
|
||||
private OnKeyboardActionListener mTarget;
|
||||
ExtensionKeyboardListener(OnKeyboardActionListener target) {
|
||||
mTarget = target;
|
||||
}
|
||||
public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
|
||||
mTarget.onKey(primaryCode, keyCodes, x, y);
|
||||
}
|
||||
public void onPress(int primaryCode) {
|
||||
mTarget.onPress(primaryCode);
|
||||
}
|
||||
public void onRelease(int primaryCode) {
|
||||
mTarget.onRelease(primaryCode);
|
||||
}
|
||||
public void onText(CharSequence text) {
|
||||
mTarget.onText(text);
|
||||
}
|
||||
public void swipeDown() {
|
||||
// Don't pass through
|
||||
}
|
||||
public void swipeLeft() {
|
||||
// Don't pass through
|
||||
}
|
||||
public void swipeRight() {
|
||||
// Don't pass through
|
||||
}
|
||||
public void swipeUp() {
|
||||
// Don't pass through
|
||||
}
|
||||
return super.onTouchEvent(me);
|
||||
}
|
||||
|
||||
/**************************** INSTRUMENTATION *******************************/
|
||||
|
|
Loading…
Reference in New Issue