diff options
author | 2012-12-19 02:12:39 -0800 | |
---|---|---|
committer | 2012-12-19 02:12:39 -0800 | |
commit | 1f5708e8fd63460455b0a646110a84892b37755d (patch) | |
tree | 4494582cb612456eaaa76811edbfd23602c8b7f6 /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | cc17479453db1bd6416f558bd4c3e3027a5e8225 (diff) | |
parent | cff28c5d5db3e0c3e97149519a3f705150aeb224 (diff) | |
download | latinime-1f5708e8fd63460455b0a646110a84892b37755d.tar.gz latinime-1f5708e8fd63460455b0a646110a84892b37755d.tar.xz latinime-1f5708e8fd63460455b0a646110a84892b37755d.zip |
am cff28c5d: Add skeleton classes for hardware event flow (B1)
* commit 'cff28c5d5db3e0c3e97149519a3f705150aeb224':
Add skeleton classes for hardware event flow (B1)
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 19076d2e7..f0705a890 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -64,6 +64,7 @@ import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.compat.InputMethodServiceCompatUtils; import com.android.inputmethod.compat.SuggestionSpanUtils; +import com.android.inputmethod.event.EventInterpreter; import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; @@ -142,6 +143,9 @@ public final class LatinIME extends InputMethodService implements KeyboardAction @UsedForTesting final KeyboardSwitcher mKeyboardSwitcher; private final SubtypeSwitcher mSubtypeSwitcher; private final SubtypeState mSubtypeState = new SubtypeState(); + // At start, create a default event interpreter that does nothing by passing it no decoder spec. + // The event interpreter should never be null. + private EventInterpreter mEventInterpreter = new EventInterpreter(); private boolean mIsMainDictionaryAvailable; private UserBinaryDictionary mUserDictionary; @@ -2376,6 +2380,27 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } } + // Hooks for hardware keyboard + @Override + public boolean onKeyDown(final int keyCode, final KeyEvent event) { + // onHardwareKeyEvent, like onKeyDown returns true if it handled the event, false if + // it doesn't know what to do with it and leave it to the application. For example, + // hardware key events for adjusting the screen's brightness are passed as is. + if (mEventInterpreter.onHardwareKeyEvent(event)) return true; + return super.onKeyDown(keyCode, event); + } + + @Override + public boolean onKeyUp(final int keyCode, final KeyEvent event) { + if (mEventInterpreter.onHardwareKeyEvent(event)) return true; + return super.onKeyUp(keyCode, event); + } + + // onKeyDown and onKeyUp are the main events we are interested in. There are two more events + // related to handling of hardware key events that we may want to implement in the future: + // boolean onKeyLongPress(final int keyCode, final KeyEvent event); + // boolean onKeyMultiple(final int keyCode, final int count, final KeyEvent event); + // receive ringer mode change and network state change. private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override |