diff options
Diffstat (limited to 'java')
9 files changed, 65 insertions, 78 deletions
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml index 57466396b..cb0a9a2e1 100644 --- a/java/AndroidManifest.xml +++ b/java/AndroidManifest.xml @@ -21,7 +21,7 @@ <meta-data android:name="android.view.im" android:resource="@xml/method" /> </service> - <activity android:name="SettingsActivity" android:label="@string/english_ime_settings"> + <activity android:name="Settings" android:label="@string/english_ime_settings"> <intent-filter> <action android:name="android.intent.action.MAIN"/> </intent-filter> diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 43e72ce5f..7aaf57b47 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -28,7 +28,7 @@ <!-- If IME doesn't have an applicable subtype, the first subtype will be used as a default subtype.--> <input-method xmlns:android="http://schemas.android.com/apk/res/android" - android:settingsActivity="com.android.inputmethod.latin.SettingsActivity" + android:settingsActivity="com.android.inputmethod.latin.Settings" android:isDefault="@bool/im_is_default"> <subtype android:icon="@drawable/ic_subtype_keyboard" android:label="@string/subtype_mode_en_US_keyboard" diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index b18cbd3ef..de1e3963d 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -200,7 +200,7 @@ public class AccessibleKeyboardViewProxy { } private void fireKeyPressEvent(PointerTracker tracker, int x, int y, long eventTime) { - tracker.onDownEvent(x, y, eventTime); + tracker.onDownEvent(x, y, eventTime, mView); tracker.onUpEvent(x, y, eventTime + DELAY_KEY_PRESS); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index e31aa8478..56e4dc871 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -38,6 +38,7 @@ import android.view.ViewGroup; import android.widget.TextView; import com.android.inputmethod.compat.FrameLayoutCompatUtils; +import com.android.inputmethod.keyboard.PointerTracker.TimerProxy; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; @@ -72,7 +73,7 @@ import java.util.HashMap; * @attr ref R.styleable#KeyboardView_shadowColor * @attr ref R.styleable#KeyboardView_shadowRadius */ -public class KeyboardView extends View implements PointerTracker.DrawingProxy { +public abstract class KeyboardView extends View implements PointerTracker.DrawingProxy { private static final boolean DEBUG_KEYBOARD_GRID = false; // Miscellaneous constants @@ -917,4 +918,23 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { super.onDetachedFromWindow(); closing(); } + + /** + * Get KeyDetector object that is used for the Keyboard of this KeyboardView. + * @return the KeyDetector object that is used for the Keyboard + */ + public abstract KeyDetector getKeyDetector(); + + /** + * Get KeyboardActionListener object that is used to register key code and so on. + * @return the KeyboardActionListner for this KeyboardView + */ + public abstract KeyboardActionListener getKeyboardActionListener(); + + /** + * Get TimerProxy object that handles key repeat and long press timer event for the Keyboard + * of this KeyboardView. + * @return the TimerProxy object that handles key repeat and long press timer event. + */ + public abstract TimerProxy getTimerProxy(); } diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java index 06cd319de..318e454d3 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardBaseView.java @@ -267,11 +267,22 @@ public class LatinKeyboardBaseView extends KeyboardView { * Returns the {@link KeyboardActionListener} object. * @return the listener attached to this keyboard */ - protected KeyboardActionListener getKeyboardActionListener() { + @Override + public KeyboardActionListener getKeyboardActionListener() { return mKeyboardActionListener; } @Override + public KeyDetector getKeyDetector() { + return mKeyDetector; + } + + @Override + public TimerProxy getTimerProxy() { + return mKeyTimerHandler; + } + + @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { // TODO: Should notify InputMethodService instead? KeyboardSwitcher.getInstance().onSizeChanged(); @@ -545,7 +556,7 @@ public class LatinKeyboardBaseView extends KeyboardView { // previous key. final int newKeyIndex = tracker.getKeyIndexOn(x, y); if (mOldKeyIndex != newKeyIndex) { - tracker.onDownEvent(x, y, eventTime); + tracker.onDownEvent(x, y, eventTime, this); if (action == MotionEvent.ACTION_UP) tracker.onUpEvent(x, y, eventTime); } @@ -557,7 +568,7 @@ public class LatinKeyboardBaseView extends KeyboardView { mOldKeyIndex = tracker.getKeyIndexOn(lastX, lastY); tracker.onUpEvent(lastX, lastY, eventTime); } else if (pointerCount == 1 && oldPointerCount == 1) { - tracker.onTouchEvent(action, x, y, eventTime); + processMotionEvent(tracker, action, x, y, eventTime, this); } else { Log.w(TAG, "Unknown touch panel behavior: pointer count is " + pointerCount + " (old " + oldPointerCount + ")"); @@ -571,25 +582,29 @@ public class LatinKeyboardBaseView extends KeyboardView { tracker.onMoveEvent((int)me.getX(i), (int)me.getY(i), eventTime); } } else { - final PointerTracker tracker = getPointerTracker(id); - switch (action) { - case MotionEvent.ACTION_DOWN: - case MotionEvent.ACTION_POINTER_DOWN: - tracker.onDownEvent(x, y, eventTime); - break; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_POINTER_UP: - tracker.onUpEvent(x, y, eventTime); - break; - case MotionEvent.ACTION_CANCEL: - tracker.onCancelEvent(x, y, eventTime); - break; - } + processMotionEvent(getPointerTracker(id), action, x, y, eventTime, this); } return true; } + private static void processMotionEvent(PointerTracker tracker, int action, int x, int y, + long eventTime, KeyboardView keyboardView) { + switch (action) { + case MotionEvent.ACTION_DOWN: + case MotionEvent.ACTION_POINTER_DOWN: + tracker.onDownEvent(x, y, eventTime, keyboardView); + break; + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_POINTER_UP: + tracker.onUpEvent(x, y, eventTime); + break; + case MotionEvent.ACTION_CANCEL: + tracker.onCancelEvent(x, y, eventTime); + break; + } + } + @Override public void closing() { super.closing(); diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index c960c7613..95574258e 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -20,7 +20,6 @@ import android.content.Context; import android.content.res.Resources; import android.os.SystemClock; import android.util.Log; -import android.view.MotionEvent; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.latin.LatinImeLogger; @@ -59,8 +58,8 @@ public class PointerTracker { private final int mLongPressKeyTimeout; private final int mLongPressShiftKeyTimeout; - private final DrawingProxy mDrawingProxy; - private final TimerProxy mTimerProxy; + private DrawingProxy mDrawingProxy; + private TimerProxy mTimerProxy; private final PointerTrackerQueue mPointerTrackerQueue; private KeyDetector mKeyDetector; private KeyboardActionListener mListener = EMPTY_LISTENER; @@ -330,29 +329,13 @@ public class PointerTracker { return onMoveKeyInternal(x, y); } - public void onTouchEvent(int action, int x, int y, long eventTime) { - switch (action) { - case MotionEvent.ACTION_MOVE: - onMoveEvent(x, y, eventTime); - break; - case MotionEvent.ACTION_DOWN: - case MotionEvent.ACTION_POINTER_DOWN: - onDownEvent(x, y, eventTime); - break; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_POINTER_UP: - onUpEvent(x, y, eventTime); - break; - case MotionEvent.ACTION_CANCEL: - onCancelEvent(x, y, eventTime); - break; - } - } - - public void onDownEvent(int x, int y, long eventTime) { + public void onDownEvent(int x, int y, long eventTime, KeyboardView keyboardView) { if (DEBUG_EVENT) printTouchEvent("onDownEvent:", x, y, eventTime); + mDrawingProxy = keyboardView; + setKeyboardActionListener(keyboardView.getKeyboardActionListener()); + setKeyDetectorInner(keyboardView.getKeyDetector()); // Naive up-to-down noise filter. final long deltaT = eventTime - mUpTime; if (deltaT < mTouchNoiseThresholdMillis) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 30eb83c58..c41ff0ee6 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -2029,7 +2029,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } protected void launchSettings() { - launchSettings(SettingsActivity.class); + launchSettings(Settings.class); } public void launchDebugSettings() { diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 9b8199723..33e9bc35f 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -21,7 +21,7 @@ import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodServiceCompatWrapper; import com.android.inputmethod.deprecated.VoiceProxy; import com.android.inputmethod.compat.VibratorCompatWrapper; -import com.android.inputmethodcommon.InputMethodSettingsFragment; +import com.android.inputmethodcommon.InputMethodSettingsActivity; import android.app.Activity; import android.app.AlertDialog; @@ -38,7 +38,6 @@ import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; -import android.preference.PreferenceActivity; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; import android.speech.SpeechRecognizer; @@ -50,7 +49,7 @@ import android.widget.TextView; import java.util.Arrays; import java.util.Locale; -public class Settings extends InputMethodSettingsFragment +public class Settings extends InputMethodSettingsActivity implements SharedPreferences.OnSharedPreferenceChangeListener, DialogInterface.OnDismissListener, OnPreferenceClickListener { private static final String TAG = "Settings"; diff --git a/java/src/com/android/inputmethod/latin/SettingsActivity.java b/java/src/com/android/inputmethod/latin/SettingsActivity.java deleted file mode 100644 index 7a6c2efd0..000000000 --- a/java/src/com/android/inputmethod/latin/SettingsActivity.java +++ /dev/null @@ -1,30 +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.latin; - -import android.content.Intent; -import android.preference.PreferenceActivity; - -public class SettingsActivity extends PreferenceActivity { - @Override - public Intent getIntent() { - final Intent modIntent = new Intent(super.getIntent()); - modIntent.putExtra(EXTRA_SHOW_FRAGMENT, Settings.class.getName()); - modIntent.putExtra(EXTRA_NO_HEADERS, true); - return modIntent; - } -} |