aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-08-23 12:22:24 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-08-23 12:22:24 +0900
commit6dde878d515f7bf5268d16a8fe4921d8821c5ae7 (patch)
tree0a3a30aea74e8db0218d6ec13acf78c83a5b36d0 /java
parentb041412cd787ffb486512103ce17ef601fb7a075 (diff)
downloadlatinime-6dde878d515f7bf5268d16a8fe4921d8821c5ae7.tar.gz
latinime-6dde878d515f7bf5268d16a8fe4921d8821c5ae7.tar.xz
latinime-6dde878d515f7bf5268d16a8fe4921d8821c5ae7.zip
Move some methods from LatinKeyboardView up into LatinKeyboardBaseView
Bug: 5182291 Change-Id: I699ecef6fb8ea492d96fca1939f51faf0aac7fa6
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboard.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java83
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java82
3 files changed, 84 insertions, 83 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
index 1b6f57b92..3b3e1f87e 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
@@ -141,7 +141,7 @@ public class LatinKeyboard extends Keyboard {
}
}
- public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboardView view) {
+ public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboardBaseView view) {
mSpacebarTextFadeFactor = fadeFactor;
updateSpacebarForLocale(false);
if (view != null)
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
index e0c6bbbb2..4a7b2bd60 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.TypedArray;
+import android.graphics.Canvas;
import android.os.Message;
import android.os.SystemClock;
import android.util.AttributeSet;
@@ -34,11 +35,14 @@ import android.widget.PopupWindow;
import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
+import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
import com.android.inputmethod.keyboard.internal.MiniKeyboardBuilder;
+import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
+import com.android.inputmethod.latin.Utils;
import java.util.WeakHashMap;
@@ -266,6 +270,20 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
return mKeyTimerHandler;
}
+ @Override
+ public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
+ final Keyboard keyboard = getKeyboard();
+ if (keyboard instanceof LatinKeyboard) {
+ final LatinKeyboard latinKeyboard = (LatinKeyboard)keyboard;
+ if (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard()) {
+ // Phone and number keyboard never shows popup preview.
+ super.setKeyPreviewPopupEnabled(false, delay);
+ return;
+ }
+ }
+ super.setKeyPreviewPopupEnabled(previewEnabled, delay);
+ }
+
/**
* 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.
@@ -365,6 +383,15 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
return mPopupPanel != null;
}
+ public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) {
+ final Keyboard keyboard = getKeyboard();
+ // We should not set text fade factor to the keyboard which does not display the language on
+ // its spacebar.
+ if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
+ ((LatinKeyboard)keyboard).setSpacebarTextFadeFactor(fadeFactor, this);
+ }
+ }
+
/**
* Called when a key is long pressed. By default this will open mini keyboard associated
* with this key.
@@ -374,6 +401,42 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
* method on the base class if the subclass doesn't wish to handle the call.
*/
protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
+ final int primaryCode = parentKey.mCode;
+ final Keyboard keyboard = getKeyboard();
+ if (keyboard instanceof LatinKeyboard) {
+ final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard;
+ if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
+ tracker.onLongPressed();
+ // Long pressing on 0 in phone number keypad gives you a '+'.
+ return invokeOnKey(Keyboard.CODE_PLUS);
+ }
+ if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
+ tracker.onLongPressed();
+ return invokeOnKey(Keyboard.CODE_CAPSLOCK);
+ }
+ }
+ if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
+ // Both long pressing settings key and space key invoke IME switcher dialog.
+ if (getKeyboardActionListener().onCustomRequest(
+ LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
+ tracker.onLongPressed();
+ return true;
+ } else {
+ return openPopupPanel(parentKey, tracker);
+ }
+ } else {
+ return openPopupPanel(parentKey, tracker);
+ }
+ }
+
+ private boolean invokeOnKey(int primaryCode) {
+ getKeyboardActionListener().onCodeInput(primaryCode, null,
+ KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
+ KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
+ return true;
+ }
+
+ private boolean openPopupPanel(Key parentKey, PointerTracker tracker) {
PopupPanel popupPanel = mPopupPanelCache.get(parentKey);
if (popupPanel == null) {
popupPanel = onCreatePopupPanel(parentKey);
@@ -557,6 +620,26 @@ public class LatinKeyboardBaseView extends KeyboardView implements PointerTracke
}
@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) {
+ tryGC = Utils.GCUtils.getInstance().tryGCOrWait("LatinKeyboardView", e);
+ }
+ }
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ // Token is available from here.
+ VoiceProxy.getInstance().onAttachedToWindow();
+ }
+
+ @Override
public boolean dispatchTouchEvent(MotionEvent event) {
// Drop non-hover touch events when touch exploration is enabled.
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index dad37e728..42ce7c440 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -22,8 +22,6 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
-import com.android.inputmethod.deprecated.VoiceProxy;
-import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.Utils;
@@ -53,20 +51,6 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
}
@Override
- public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
- final Keyboard keyboard = getKeyboard();
- if (keyboard instanceof LatinKeyboard) {
- final LatinKeyboard latinKeyboard = (LatinKeyboard)keyboard;
- if (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard()) {
- // Phone and number keyboard never shows popup preview.
- super.setKeyPreviewPopupEnabled(false, delay);
- return;
- }
- }
- super.setKeyPreviewPopupEnabled(previewEnabled, delay);
- }
-
- @Override
public void setKeyboard(Keyboard newKeyboard) {
super.setKeyboard(newKeyboard);
// One-seventh of the keyboard width seems like a reasonable threshold
@@ -74,52 +58,6 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
mJumpThresholdSquare = jumpThreshold * jumpThreshold;
}
- public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) {
- final Keyboard keyboard = getKeyboard();
- // We should not set text fade factor to the keyboard which does not display the language on
- // its spacebar.
- if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
- ((LatinKeyboard)keyboard).setSpacebarTextFadeFactor(fadeFactor, this);
- }
- }
-
- @Override
- protected boolean onLongPress(Key key, PointerTracker tracker) {
- final int primaryCode = key.mCode;
- final Keyboard keyboard = getKeyboard();
- if (keyboard instanceof LatinKeyboard) {
- final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard;
- if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
- tracker.onLongPressed();
- // Long pressing on 0 in phone number keypad gives you a '+'.
- return invokeOnKey(Keyboard.CODE_PLUS);
- }
- if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
- tracker.onLongPressed();
- return invokeOnKey(Keyboard.CODE_CAPSLOCK);
- }
- }
- if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
- // Both long pressing settings key and space key invoke IME switcher dialog.
- if (getKeyboardActionListener().onCustomRequest(
- LatinIME.CODE_SHOW_INPUT_METHOD_PICKER)) {
- tracker.onLongPressed();
- return true;
- } else {
- return super.onLongPress(key, tracker);
- }
- } else {
- return super.onLongPress(key, tracker);
- }
- }
-
- private boolean invokeOnKey(int primaryCode) {
- getKeyboardActionListener().onCodeInput(primaryCode, null,
- KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
- KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
- return true;
- }
-
/**
* This function checks to see if we need to handle any sudden jumps in the pointer location
* that could be due to a multi-touch being treated as a move by the firmware or hardware.
@@ -211,24 +149,4 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
return super.onTouchEvent(me);
}
-
- @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) {
- tryGC = Utils.GCUtils.getInstance().tryGCOrWait("LatinKeyboardView", e);
- }
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- // Token is available from here.
- VoiceProxy.getInstance().onAttachedToWindow();
- }
}