diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-22 00:13:40 -0800 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-22 00:13:40 -0800 |
| commit | 5a4d0fa291a7269007701282f32cfda55ce39008 (patch) | |
| tree | 6bd8ab843ae67aca3883ca25554f88116424f479 /samples/SoftKeyboard | |
| parent | 7b53e3937797ee1eea71c6291bdcd58cb9dedf7a (diff) | |
| download | android_development-5a4d0fa291a7269007701282f32cfda55ce39008.tar.gz android_development-5a4d0fa291a7269007701282f32cfda55ce39008.tar.bz2 android_development-5a4d0fa291a7269007701282f32cfda55ce39008.zip | |
auto import from //branches/cupcake/...@127436
Diffstat (limited to 'samples/SoftKeyboard')
| -rw-r--r-- | samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java b/samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java index 36d4233ff..d26b1730d 100644 --- a/samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java +++ b/samples/SoftKeyboard/src/com/example/android/softkeyboard/SoftKeyboard.java @@ -68,6 +68,8 @@ public class SoftKeyboard extends InputMethodService private Keyboard mSymbolsShiftedKeyboard; private Keyboard mQwertyKeyboard; + private Keyboard mCurKeyboard; + private String mWordSeparators; /** @@ -132,8 +134,8 @@ public class SoftKeyboard extends InputMethodService * bound to the client, and are now receiving all of the detailed information * about the target of our edits. */ - @Override public void onStartInputView(EditorInfo attribute, boolean restarting) { - super.onStartInputView(attribute, restarting); + @Override public void onStartInput(EditorInfo attribute, boolean restarting) { + super.onStartInput(attribute, restarting); // Reset our state. We want to do this even if restarting, because // the underlying state of the text editor could have changed in any way. @@ -148,7 +150,6 @@ public class SoftKeyboard extends InputMethodService mPredictionOn = false; mCompletionOn = false; mCompletions = null; - Keyboard keyboard; // We are now going to initialize our state based on the type of // text being edited. @@ -157,13 +158,13 @@ public class SoftKeyboard extends InputMethodService case EditorInfo.TYPE_CLASS_DATETIME: // Numbers and dates default to the symbols keyboard, with // no extra features. - keyboard = mSymbolsKeyboard; + mCurKeyboard = mSymbolsKeyboard; break; case EditorInfo.TYPE_CLASS_PHONE: // Phones will also default to the symbols keyboard, though // often you will want to have a dedicated phone keyboard. - keyboard = mSymbolsKeyboard; + mCurKeyboard = mSymbolsKeyboard; break; case EditorInfo.TYPE_CLASS_TEXT: @@ -171,7 +172,7 @@ public class SoftKeyboard extends InputMethodService // normal alphabetic keyboard, and assume that we should // be doing predictive text (showing candidates as the // user types). - keyboard = mQwertyKeyboard; + mCurKeyboard = mQwertyKeyboard; mPredictionOn = true; // We now look for a few special variations of text that will @@ -209,13 +210,7 @@ public class SoftKeyboard extends InputMethodService default: // For all unknown input types, default to the alphabetic // keyboard with no special features. - keyboard = mQwertyKeyboard; - } - - // Apply the selected keyboard to the input view. - if (mInputView != null) { - mInputView.setKeyboard(keyboard); - mInputView.closing(); + mCurKeyboard = mQwertyKeyboard; } } @@ -236,11 +231,19 @@ public class SoftKeyboard extends InputMethodService // its window. setCandidatesViewShown(false); + mCurKeyboard = mQwertyKeyboard; if (mInputView != null) { mInputView.closing(); } } + @Override public void onStartInputView(EditorInfo attribute, boolean restarting) { + super.onStartInputView(attribute, restarting); + // Apply the selected keyboard to the input view. + mInputView.setKeyboard(mCurKeyboard); + mInputView.closing(); + } + /** * Deal with the editor reporting movement of its cursor. */ @@ -350,6 +353,10 @@ public class SoftKeyboard extends InputMethodService } break; + case KeyEvent.KEYCODE_ENTER: + // Let the underlying text editor always handle these. + return false; + default: // For all other keys, if we want to do transformations on // text being entered with a hard keyboard, we need to process @@ -500,13 +507,13 @@ public class SoftKeyboard extends InputMethodService public void setSuggestions(List<String> suggestions, boolean completions, boolean typedWordValid) { + if (suggestions != null && suggestions.size() > 0) { + setCandidatesViewShown(true); + } else if (isFullscreenMode()) { + setCandidatesViewShown(true); + } if (mCandidateView != null) { mCandidateView.setSuggestions(suggestions, completions, typedWordValid); - if (suggestions != null && suggestions.size() > 0) { - setCandidatesViewShown(true); - } else if (isFullscreenMode()) { - setCandidatesViewShown(true); - } } } |
