diff options
author | 2011-01-18 15:49:17 +0000 | |
---|---|---|
committer | 2011-01-18 15:49:17 +0000 | |
commit | bbd651a00898dabf6b2ae0e715d99953ea81063f (patch) | |
tree | f586647143ff2df64dfb44e57533599f86e66d0a /java/src/com/android/inputmethod/voice/VoiceIMEConnector.java | |
parent | da9eb5946c0b0a9050f63c5caf13cc50011c0caf (diff) | |
download | latinime-bbd651a00898dabf6b2ae0e715d99953ea81063f.tar.gz latinime-bbd651a00898dabf6b2ae0e715d99953ea81063f.tar.xz latinime-bbd651a00898dabf6b2ae0e715d99953ea81063f.zip |
Change the UI of Voice IME to be more like Voice Search.
There has been a bit of refactoring in RecognitionView in particular to fix the portrait layout.
The main issues found were:
- the size of the keyboard is specified in inches, and
(cm)(inches + inches) != ((cm) inches) + ((cm) inches))
- the height of keyboard background is high as the landscape keyboard, but it higher than
the portrait keyboard. This is not an issue on LatinKeyboard, as it overwrite the
onMeasure method. However, if I use the same image background in RelativeLayout
the Relative layout height is set to the height of the background, thus higher than the keyboard
- the change configuration was not propageted correctly
Change-Id: Id5dca425826997c573ccae7a085d5ddc9719733b
Diffstat (limited to 'java/src/com/android/inputmethod/voice/VoiceIMEConnector.java')
-rw-r--r-- | java/src/com/android/inputmethod/voice/VoiceIMEConnector.java | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java b/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java index 9a6c3a83a..a02dbcb55 100644 --- a/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java +++ b/java/src/com/android/inputmethod/voice/VoiceIMEConnector.java @@ -30,6 +30,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.net.Uri; import android.os.IBinder; import android.preference.PreferenceManager; @@ -78,6 +79,9 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { // dialog is already showing a voice search button. private static final String IME_OPTION_NO_MICROPHONE = "nm"; + @SuppressWarnings("unused") + private static final String TAG = "VoiceIMEConnector"; + private boolean mAfterVoiceInput; private boolean mHasUsedVoiceInput; private boolean mHasUsedVoiceInputUnsupportedLocale; @@ -164,8 +168,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { } } - private void showVoiceWarningDialog(final boolean swipe, IBinder token, - final boolean configurationChanging) { + private void showVoiceWarningDialog(final boolean swipe, IBinder token) { if (mVoiceWarningDialog != null && mVoiceWarningDialog.isShowing()) { return; } @@ -176,7 +179,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { @Override public void onClick(DialogInterface dialog, int whichButton) { mVoiceInput.logKeyboardWarningDialogOk(); - reallyStartListening(swipe, configurationChanging); + reallyStartListening(swipe); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @@ -519,22 +522,38 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { onCancelVoice(); } - public void switchToRecognitionStatusView(final boolean configurationChanging) { - final boolean configChanged = configurationChanging; + public void switchToRecognitionStatusView(final Configuration configuration) { mHandler.post(new Runnable() { @Override public void run() { mService.setCandidatesViewShown(false); mRecognizing = true; + mVoiceInput.newView(); View v = mVoiceInput.getView(); + ViewParent p = v.getParent(); if (p != null && p instanceof ViewGroup) { - ((ViewGroup)p).removeView(v); + ((ViewGroup) p).removeView(v); + } + + View keyboardView = KeyboardSwitcher.getInstance().getInputView(); + + // The full height of the keyboard is difficult to calculate + // as the dimension is expressed in "mm" and not in "pixel" + // As we add mm, we don't know how the rounding is going to work + // thus we may end up with few pixels extra (or less). + if (keyboardView != null) { + int h = keyboardView.getHeight(); + if (h > 0) { + View popupLayout = v.findViewById(R.id.popup_layout); + popupLayout.getLayoutParams().height = h; + } } mService.setInputView(v); mService.updateInputViewShown(); - if (configChanged) { - mVoiceInput.onConfigurationChanged(); + + if (configuration != null) { + mVoiceInput.onConfigurationChanged(configuration); } }}); } @@ -544,7 +563,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { mImm.switchToLastInputMethod(token); } - private void reallyStartListening(boolean swipe, final boolean configurationChanging) { + private void reallyStartListening(boolean swipe) { if (!VOICE_INSTALLED) { return; } @@ -573,22 +592,21 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { FieldContext context = makeFieldContext(); mVoiceInput.startListening(context, swipe); - switchToRecognitionStatusView(configurationChanging); + switchToRecognitionStatusView(null); } - public void startListening(final boolean swipe, IBinder token, - final boolean configurationChanging) { + public void startListening(final boolean swipe, IBinder token) { + // TODO: remove swipe which is no longer used. if (VOICE_INSTALLED) { if (needsToShowWarningDialog()) { // Calls reallyStartListening if user clicks OK, does nothing if user clicks Cancel. - showVoiceWarningDialog(swipe, token, configurationChanging); + showVoiceWarningDialog(swipe, token); } else { - reallyStartListening(swipe, configurationChanging); + reallyStartListening(swipe); } } } - private boolean fieldCanDoVoice(FieldContext fieldContext) { return !mPasswordText && mVoiceInput != null @@ -632,7 +650,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { // Close keyboard view if it is been shown. if (KeyboardSwitcher.getInstance().isInputViewShown()) KeyboardSwitcher.getInstance().getInputView().purgeKeyboardAndClosing(); - startListening(false, token, false); + startListening(false, token); } // If we have no token, onAttachedToWindow will take care of showing dialog and start // listening. @@ -644,9 +662,9 @@ public class VoiceIMEConnector implements VoiceInput.UiListener { mSubtypeSwitcher.setVoiceInput(mVoiceInput); } - public void onConfigurationChanged(boolean configurationChanging) { + public void onConfigurationChanged(Configuration configuration) { if (mRecognizing) { - switchToRecognitionStatusView(configurationChanging); + switchToRecognitionStatusView(configuration); } } |