diff options
| author | Tadashi G. Takaoka <takaoka@google.com> | 2012-02-08 16:12:11 +0900 |
|---|---|---|
| committer | Tadashi G. Takaoka <takaoka@google.com> | 2012-02-08 16:12:31 +0900 |
| commit | 2affaf91a04d63e0994102299816014a8bbe11e1 (patch) | |
| tree | ee9bbb3e0de8c31140f9d9e8ab3b614ed50938cf /java/src/com/android/inputmethod/keyboard/MiniKeyboardView.java | |
| parent | 71a14420d815824605ffc04b47b97386848d31b3 (diff) | |
Rename mini keyboard to more keys keyboard
Change-Id: Ie4c85e8ca5a1f41a420aae5c1cd9c1cb07e237e5
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/MiniKeyboardView.java')
| -rw-r--r-- | java/src/com/android/inputmethod/keyboard/MiniKeyboardView.java | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboardView.java deleted file mode 100644 index 72d5b6889..000000000 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboardView.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * 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; - -import android.content.Context; -import android.content.res.Resources; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.View; -import android.widget.PopupWindow; - -import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy; -import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; -import com.android.inputmethod.latin.R; - -/** - * A view that renders a virtual {@link MiniKeyboard}. It handles rendering of keys and detecting - * key presses and touch movements. - */ -public class MiniKeyboardView extends KeyboardView implements MoreKeysPanel { - private final int[] mCoordinates = new int[2]; - - private final KeyDetector mKeyDetector; - - private Controller mController; - private KeyboardActionListener mListener; - private int mOriginX; - private int mOriginY; - - private static final TimerProxy EMPTY_TIMER_PROXY = new TimerProxy.Adapter(); - - private final KeyboardActionListener mMiniKeyboardListener = - new KeyboardActionListener.Adapter() { - @Override - public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) { - mListener.onCodeInput(primaryCode, keyCodes, x, y); - } - - @Override - public void onTextInput(CharSequence text) { - mListener.onTextInput(text); - } - - @Override - public void onCancelInput() { - mListener.onCancelInput(); - } - - @Override - public void onPressKey(int primaryCode) { - mListener.onPressKey(primaryCode); - } - - @Override - public void onReleaseKey(int primaryCode, boolean withSliding) { - mListener.onReleaseKey(primaryCode, withSliding); - } - }; - - public MiniKeyboardView(Context context, AttributeSet attrs) { - this(context, attrs, R.attr.miniKeyboardViewStyle); - } - - public MiniKeyboardView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - - final Resources res = context.getResources(); - mKeyDetector = new MoreKeysDetector( - res.getDimension(R.dimen.mini_keyboard_slide_allowance)); - setKeyPreviewPopupEnabled(false, 0); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final Keyboard keyboard = getKeyboard(); - if (keyboard != null) { - final int width = keyboard.mOccupiedWidth + getPaddingLeft() + getPaddingRight(); - final int height = keyboard.mOccupiedHeight + getPaddingTop() + getPaddingBottom(); - setMeasuredDimension(width, height); - } else { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - } - - @Override - public void setKeyboard(Keyboard keyboard) { - super.setKeyboard(keyboard); - mKeyDetector.setKeyboard(keyboard, -getPaddingLeft(), - -getPaddingTop() + mVerticalCorrection); - } - - @Override - public KeyDetector getKeyDetector() { - return mKeyDetector; - } - - @Override - public KeyboardActionListener getKeyboardActionListener() { - return mMiniKeyboardListener; - } - - @Override - public DrawingProxy getDrawingProxy() { - return this; - } - - @Override - public TimerProxy getTimerProxy() { - return EMPTY_TIMER_PROXY; - } - - @Override - public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) { - // Mini keyboard needs no pop-up key preview displayed, so we pass always false with a - // delay of 0. The delay does not matter actually since the popup is not shown anyway. - super.setKeyPreviewPopupEnabled(false, 0); - } - - @Override - public void showMoreKeysPanel(View parentView, Controller controller, int pointX, int pointY, - PopupWindow window, KeyboardActionListener listener) { - mController = controller; - mListener = listener; - final View container = (View)getParent(); - final MiniKeyboard miniKeyboard = (MiniKeyboard)getKeyboard(); - - parentView.getLocationInWindow(mCoordinates); - final int miniKeyboardLeft = pointX - miniKeyboard.getDefaultCoordX() - + parentView.getPaddingLeft(); - final int x = wrapUp(Math.max(0, Math.min(miniKeyboardLeft, - parentView.getWidth() - miniKeyboard.mOccupiedWidth)) - - container.getPaddingLeft() + mCoordinates[0], - container.getMeasuredWidth(), 0, parentView.getWidth()); - final int y = pointY - - (container.getMeasuredHeight() - container.getPaddingBottom()) - + parentView.getPaddingTop() + mCoordinates[1]; - - window.setContentView(container); - window.setWidth(container.getMeasuredWidth()); - window.setHeight(container.getMeasuredHeight()); - window.showAtLocation(parentView, Gravity.NO_GRAVITY, x, y); - - mOriginX = x + container.getPaddingLeft() - mCoordinates[0]; - mOriginY = y + container.getPaddingTop() - mCoordinates[1]; - } - - private static int wrapUp(int x, int width, int left, int right) { - if (x < left) - return left; - if (x + width > right) - return right - width; - return x; - } - - private boolean mIsDismissing; - - @Override - public boolean dismissMoreKeysPanel() { - if (mIsDismissing) return false; - mIsDismissing = true; - final boolean dismissed = mController.dismissMoreKeysPanel(); - mIsDismissing = false; - return dismissed; - } - - @Override - public int translateX(int x) { - return x - mOriginX; - } - - @Override - public int translateY(int y) { - return y - mOriginY; - } -} |
