Move CandidateView into input view

Bug: 4175031
Change-Id: I95f379b9943d1dcab1dc5527b6e5ac5abd58e280
main
Tadashi G. Takaoka 2011-05-23 18:30:21 +09:00
parent 8c08a49895
commit c150acc7c8
13 changed files with 171 additions and 134 deletions

View File

@ -20,6 +20,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/candidates_container"
android:orientation="horizontal" android:orientation="horizontal"
android:gravity="bottom" android:gravity="bottom"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -20,6 +20,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/candidates_container"
android:orientation="horizontal" android:orientation="horizontal"
android:gravity="bottom" android:gravity="bottom"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -18,15 +18,21 @@
*/ */
--> -->
<com.android.inputmethod.keyboard.LatinKeyboardView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<include
layout="@layout/candidates" />
<com.android.inputmethod.keyboard.LatinKeyboardView
android:id="@+id/latin_keyboard_view" android:id="@+id/latin_keyboard_view"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="0dip" android:padding="0dip"
android:background="@drawable/keyboard_background" android:background="@drawable/keyboard_background"
latin:keyBackground="@drawable/btn_keyboard_key" />
latin:keyBackground="@drawable/btn_keyboard_key" </LinearLayout>
/>

View File

@ -18,15 +18,21 @@
*/ */
--> -->
<com.android.inputmethod.keyboard.LatinKeyboardView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<include
layout="@layout/candidates" />
<com.android.inputmethod.keyboard.LatinKeyboardView
android:id="@+id/latin_keyboard_view" android:id="@+id/latin_keyboard_view"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="0dip" android:padding="0dip"
android:background="@android:color/black" android:background="@android:color/black"
latin:keyBackground="@drawable/btn_keyboard_key3" />
latin:keyBackground="@drawable/btn_keyboard_key3" </LinearLayout>
/>

View File

@ -18,16 +18,22 @@
*/ */
--> -->
<com.android.inputmethod.keyboard.LatinKeyboardView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<include
layout="@layout/candidates" />
<com.android.inputmethod.keyboard.LatinKeyboardView
android:id="@+id/latin_keyboard_view" android:id="@+id/latin_keyboard_view"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="0dip" android:padding="0dip"
android:background="@drawable/keyboard_dark_background" android:background="@drawable/keyboard_dark_background"
latin:keyBackground="@drawable/btn_keyboard_key_gingerbread" latin:keyBackground="@drawable/btn_keyboard_key_gingerbread"
latin:keyLetterStyle="bold" latin:keyLetterStyle="bold" />
/> </LinearLayout>

View File

@ -18,16 +18,22 @@
*/ */
--> -->
<com.android.inputmethod.keyboard.LatinKeyboardView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<include
layout="@layout/candidates" />
<com.android.inputmethod.keyboard.LatinKeyboardView
android:id="@+id/latin_keyboard_view" android:id="@+id/latin_keyboard_view"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="0dip" android:padding="0dip"
android:background="@drawable/keyboard_background_holo" android:background="@drawable/keyboard_background_holo"
latin:keyBackground="@drawable/btn_keyboard_key_honeycomb" latin:keyBackground="@drawable/btn_keyboard_key_honeycomb"
latin:keyPreviewLayout="@layout/key_preview_honeycomb" latin:keyPreviewLayout="@layout/key_preview_honeycomb"
latin:keyPreviewHeight="@dimen/key_preview_height_holo" latin:keyPreviewHeight="@dimen/key_preview_height_holo"
@ -36,5 +42,5 @@
latin:keyTextColorDisabled="#FF63666D" latin:keyTextColorDisabled="#FF63666D"
latin:keyLetterStyle="bold" latin:keyLetterStyle="bold"
latin:shadowColor="#00000000" latin:shadowColor="#00000000"
latin:shadowRadius="0.0" latin:shadowRadius="0.0" />
/> </LinearLayout>

View File

@ -18,21 +18,27 @@
*/ */
--> -->
<com.android.inputmethod.keyboard.LatinKeyboardView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<include
layout="@layout/candidates" />
<com.android.inputmethod.keyboard.LatinKeyboardView
android:id="@+id/latin_keyboard_view" android:id="@+id/latin_keyboard_view"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="0dip" android:padding="0dip"
android:background="@drawable/keyboard_background" android:background="@drawable/keyboard_background"
latin:keyBackground="@drawable/btn_keyboard_key_stone" latin:keyBackground="@drawable/btn_keyboard_key_stone"
latin:keyTextColor="@color/latinkeyboard_key_color_black" latin:keyTextColor="@color/latinkeyboard_key_color_black"
latin:keyTextColorDisabled="#FF808080" latin:keyTextColorDisabled="#FF808080"
latin:shadowColor="@color/latinkeyboard_key_color_white" latin:shadowColor="@color/latinkeyboard_key_color_white"
latin:keyLetterStyle="bold" latin:keyLetterStyle="bold"
latin:colorScheme="black" latin:colorScheme="black"
latin:popupLayout="@layout/keyboard_popup_stone" latin:popupLayout="@layout/keyboard_popup_stone" />
/> </LinearLayout>

View File

@ -18,20 +18,26 @@
*/ */
--> -->
<com.android.inputmethod.keyboard.LatinKeyboardView <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<include
layout="@layout/candidates" />
<com.android.inputmethod.keyboard.LatinKeyboardView
android:id="@+id/latin_keyboard_view" android:id="@+id/latin_keyboard_view"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="0dip" android:padding="0dip"
android:background="@drawable/keyboard_background" android:background="@drawable/keyboard_background"
latin:keyBackground="@drawable/btn_keyboard_key_stone" latin:keyBackground="@drawable/btn_keyboard_key_stone"
latin:keyTextColor="@color/latinkeyboard_key_color_black" latin:keyTextColor="@color/latinkeyboard_key_color_black"
latin:keyTextColorDisabled="#FF808080" latin:keyTextColorDisabled="#FF808080"
latin:shadowColor="@color/latinkeyboard_key_color_white" latin:shadowColor="@color/latinkeyboard_key_color_white"
latin:colorScheme="black" latin:colorScheme="black"
latin:popupLayout="@layout/keyboard_popup_stone" latin:popupLayout="@layout/keyboard_popup_stone" />
/> </LinearLayout>

View File

@ -536,7 +536,7 @@ public class VoiceProxy implements VoiceInput.UiListener {
((ViewGroup) p).removeView(v); ((ViewGroup) p).removeView(v);
} }
View keyboardView = KeyboardSwitcher.getInstance().getInputView(); View keyboardView = KeyboardSwitcher.getInstance().getKeyboardView();
// The full height of the keyboard is difficult to calculate // The full height of the keyboard is difficult to calculate
// as the dimension is expressed in "mm" and not in "pixel" // as the dimension is expressed in "mm" and not in "pixel"
@ -691,7 +691,7 @@ public class VoiceProxy implements VoiceInput.UiListener {
if (mSubtypeSwitcher.isVoiceMode() && windowToken != null) { if (mSubtypeSwitcher.isVoiceMode() && windowToken != null) {
// Close keyboard view if it is been shown. // Close keyboard view if it is been shown.
if (KeyboardSwitcher.getInstance().isInputViewShown()) if (KeyboardSwitcher.getInstance().isInputViewShown())
KeyboardSwitcher.getInstance().getInputView().purgeKeyboardAndClosing(); KeyboardSwitcher.getInstance().getKeyboardView().purgeKeyboardAndClosing();
startListening(false, windowToken); startListening(false, windowToken);
} }
// If we have no token, onAttachedToWindow will take care of showing dialog and start // If we have no token, onAttachedToWindow will take care of showing dialog and start

View File

@ -57,6 +57,6 @@ public class RecorrectionSuggestionEntries {
private static SuggestedWords.Builder getTypedSuggestions( private static SuggestedWords.Builder getTypedSuggestions(
Suggest suggest, KeyboardSwitcher keyboardSwitcher, WordComposer word) { Suggest suggest, KeyboardSwitcher keyboardSwitcher, WordComposer word) {
return suggest.getSuggestedWordBuilder(keyboardSwitcher.getInputView(), word, null); return suggest.getSuggestedWordBuilder(keyboardSwitcher.getKeyboardView(), word, null);
} }
} }

View File

@ -16,6 +16,15 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.util.Log;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.latin.LatinIME; import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
@ -24,13 +33,6 @@ import com.android.inputmethod.latin.Settings;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.util.Log;
import android.view.InflateException;
import android.view.inputmethod.EditorInfo;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
@ -54,7 +56,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private SubtypeSwitcher mSubtypeSwitcher; private SubtypeSwitcher mSubtypeSwitcher;
private SharedPreferences mPrefs; private SharedPreferences mPrefs;
private LatinKeyboardView mInputView; private View mInputView;
private LatinKeyboardView mKeyboardView;
private LatinIME mInputMethodService; private LatinIME mInputMethodService;
// TODO: Combine these key state objects with auto mode switch state. // TODO: Combine these key state objects with auto mode switch state.
@ -143,7 +146,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private void loadKeyboardInternal(EditorInfo attribute, boolean voiceButtonEnabled, private void loadKeyboardInternal(EditorInfo attribute, boolean voiceButtonEnabled,
boolean voiceButtonOnPrimary, boolean isSymbols) { boolean voiceButtonOnPrimary, boolean isSymbols) {
if (mInputView == null) return; if (mKeyboardView == null) return;
mAttribute = attribute; mAttribute = attribute;
mVoiceKeyEnabled = voiceButtonEnabled; mVoiceKeyEnabled = voiceButtonEnabled;
@ -178,11 +181,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
private void setKeyboard(final Keyboard newKeyboard) { private void setKeyboard(final Keyboard newKeyboard) {
final Keyboard oldKeyboard = mInputView.getKeyboard(); final Keyboard oldKeyboard = mKeyboardView.getKeyboard();
mInputView.setKeyboard(newKeyboard); mKeyboardView.setKeyboard(newKeyboard);
mCurrentId = newKeyboard.mId; mCurrentId = newKeyboard.mId;
final Resources res = mInputMethodService.getResources(); final Resources res = mInputMethodService.getResources();
mInputView.setKeyPreviewPopupEnabled( mKeyboardView.setKeyPreviewPopupEnabled(
Settings.Values.isKeyPreviewPopupEnabled(mPrefs, res), Settings.Values.isKeyPreviewPopupEnabled(mPrefs, res),
Settings.Values.getKeyPreviewPopupDismissDelay(mPrefs, res)); Settings.Values.getKeyPreviewPopupDismissDelay(mPrefs, res));
final boolean localeChanged = (oldKeyboard == null) final boolean localeChanged = (oldKeyboard == null)
@ -291,18 +294,18 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
public boolean isInputViewShown() { public boolean isInputViewShown() {
return mInputView != null && mInputView.isShown(); return mKeyboardView != null && mKeyboardView.isShown();
} }
public boolean isKeyboardAvailable() { public boolean isKeyboardAvailable() {
if (mInputView != null) if (mKeyboardView != null)
return mInputView.getKeyboard() != null; return mKeyboardView.getKeyboard() != null;
return false; return false;
} }
public LatinKeyboard getLatinKeyboard() { public LatinKeyboard getLatinKeyboard() {
if (mInputView != null) { if (mKeyboardView != null) {
final Keyboard keyboard = mInputView.getKeyboard(); final Keyboard keyboard = mKeyboardView.getKeyboard();
if (keyboard instanceof LatinKeyboard) if (keyboard instanceof LatinKeyboard)
return (LatinKeyboard)keyboard; return (LatinKeyboard)keyboard;
} }
@ -355,7 +358,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
latinKeyboard.setShiftLocked(false); latinKeyboard.setShiftLocked(false);
} }
if (latinKeyboard.setShifted(shifted)) { if (latinKeyboard.setShifted(shifted)) {
mInputView.invalidateAllKeys(); mKeyboardView.invalidateAllKeys();
} }
} }
} }
@ -363,7 +366,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
private void setShiftLocked(boolean shiftLocked) { private void setShiftLocked(boolean shiftLocked) {
LatinKeyboard latinKeyboard = getLatinKeyboard(); LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard != null && latinKeyboard.setShiftLocked(shiftLocked)) { if (latinKeyboard != null && latinKeyboard.setShiftLocked(shiftLocked)) {
mInputView.invalidateAllKeys(); mKeyboardView.invalidateAllKeys();
} }
} }
@ -405,7 +408,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
LatinKeyboard latinKeyboard = getLatinKeyboard(); LatinKeyboard latinKeyboard = getLatinKeyboard();
if (latinKeyboard != null) { if (latinKeyboard != null) {
latinKeyboard.setAutomaticTemporaryUpperCase(); latinKeyboard.setAutomaticTemporaryUpperCase();
mInputView.invalidateAllKeys(); mKeyboardView.invalidateAllKeys();
} }
} }
@ -500,7 +503,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
// To be able to turn off caps lock by "double tap" on shift key, we should ignore // To be able to turn off caps lock by "double tap" on shift key, we should ignore
// the second tap of the "double tap" from now for a while because we just have // the second tap of the "double tap" from now for a while because we just have
// already turned off caps lock above. // already turned off caps lock above.
mInputView.startIgnoringDoubleTap(); mKeyboardView.startIgnoringDoubleTap();
} else if (isShiftedOrShiftLocked() && shiftKeyState.isPressingOnShifted() } else if (isShiftedOrShiftLocked() && shiftKeyState.isPressingOnShifted()
&& !withSliding) { && !withSliding) {
// Shift has been pressed without chording while shifted state. // Shift has been pressed without chording while shifted state.
@ -589,11 +592,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
public boolean isVibrateAndSoundFeedbackRequired() { public boolean isVibrateAndSoundFeedbackRequired() {
return mInputView == null || !mInputView.isInSlidingKeyInput(); return mKeyboardView == null || !mKeyboardView.isInSlidingKeyInput();
} }
private int getPointerCount() { private int getPointerCount() {
return mInputView == null ? 0 : mInputView.getPointerCount(); return mKeyboardView == null ? 0 : mKeyboardView.getPointerCount();
} }
private void toggleKeyboardMode() { private void toggleKeyboardMode() {
@ -606,7 +609,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
public boolean hasDistinctMultitouch() { public boolean hasDistinctMultitouch() {
return mInputView != null && mInputView.hasDistinctMultitouch(); return mKeyboardView != null && mKeyboardView.hasDistinctMultitouch();
} }
private static boolean isSpaceCharacter(int c) { private static boolean isSpaceCharacter(int c) {
@ -703,20 +706,20 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
} }
public LatinKeyboardView getInputView() { public LatinKeyboardView getKeyboardView() {
return mInputView; return mKeyboardView;
} }
public LatinKeyboardView onCreateInputView() { public View onCreateInputView() {
createInputViewInternal(mLayoutId, true); createInputViewInternal(mLayoutId, true);
return mInputView; return mInputView;
} }
private void createInputViewInternal(int newLayout, boolean forceReset) { private void createInputViewInternal(int newLayout, boolean forceReset) {
int layoutId = newLayout; int layoutId = newLayout;
if (mLayoutId != layoutId || mInputView == null || forceReset) { if (mLayoutId != layoutId || mKeyboardView == null || forceReset) {
if (mInputView != null) { if (mKeyboardView != null) {
mInputView.closing(); mKeyboardView.closing();
} }
if (KEYBOARD_THEMES.length <= layoutId) { if (KEYBOARD_THEMES.length <= layoutId) {
layoutId = Integer.valueOf(sConfigDefaultKeyboardThemeId); layoutId = Integer.valueOf(sConfigDefaultKeyboardThemeId);
@ -726,8 +729,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
boolean tryGC = true; boolean tryGC = true;
for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
try { try {
mInputView = (LatinKeyboardView) mInputMethodService.getLayoutInflater( mInputView = LayoutInflater.from(mInputMethodService).inflate(
).inflate(KEYBOARD_THEMES[layoutId], null); KEYBOARD_THEMES[layoutId], null);
tryGC = false; tryGC = false;
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
Log.w(TAG, "load keyboard failed: " + e); Log.w(TAG, "load keyboard failed: " + e);
@ -739,7 +742,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mLayoutId + "," + layoutId, e); mLayoutId + "," + layoutId, e);
} }
} }
mInputView.setOnKeyboardActionListener(mInputMethodService); mKeyboardView = (LatinKeyboardView)mInputView.findViewById(R.id.latin_keyboard_view);
mKeyboardView.setOnKeyboardActionListener(mInputMethodService);
mLayoutId = layoutId; mLayoutId = layoutId;
} }
} }
@ -748,8 +752,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mInputMethodService.mHandler.post(new Runnable() { mInputMethodService.mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (mInputView != null) { if (mKeyboardView != null) {
mInputMethodService.setInputView(mInputView); mInputMethodService.setInputView(mKeyboardView);
} }
mInputMethodService.updateInputViewShown(); mInputMethodService.updateInputViewShown();
} }
@ -772,13 +776,13 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
private int getColorScheme() { private int getColorScheme() {
return (mInputView != null) return (mKeyboardView != null)
? mInputView.getColorScheme() : KeyboardView.COLOR_SCHEME_WHITE; ? mKeyboardView.getColorScheme() : KeyboardView.COLOR_SCHEME_WHITE;
} }
public void onAutoCorrectionStateChanged(boolean isAutoCorrection) { public void onAutoCorrectionStateChanged(boolean isAutoCorrection) {
if (isAutoCorrection != mIsAutoCorrectionActive) { if (isAutoCorrection != mIsAutoCorrectionActive) {
LatinKeyboardView keyboardView = getInputView(); LatinKeyboardView keyboardView = getKeyboardView();
mIsAutoCorrectionActive = isAutoCorrection; mIsAutoCorrectionActive = isAutoCorrection;
keyboardView.invalidateKey(((LatinKeyboard) keyboardView.getKeyboard()) keyboardView.invalidateKey(((LatinKeyboard) keyboardView.getKeyboard())
.onAutoCorrectionStateChanged(isAutoCorrection)); .onAutoCorrectionStateChanged(isAutoCorrection));

View File

@ -16,22 +16,6 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import com.android.inputmethod.compat.CompatUtils;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputConnectionCompatUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.deprecated.LanguageSwitcherProxy;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.deprecated.recorrection.Recorrection;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.LatinKeyboard;
import com.android.inputmethod.keyboard.LatinKeyboardView;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@ -59,7 +43,6 @@ import android.util.PrintWriterPrinter;
import android.util.Printer; import android.util.Printer;
import android.view.HapticFeedbackConstants; import android.view.HapticFeedbackConstants;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent; import android.view.ViewParent;
@ -69,7 +52,22 @@ import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import android.widget.LinearLayout;
import com.android.inputmethod.compat.CompatUtils;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputConnectionCompatUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.deprecated.LanguageSwitcherProxy;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.deprecated.recorrection.Recorrection;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.LatinKeyboard;
import com.android.inputmethod.keyboard.LatinKeyboardView;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -217,7 +215,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
final KeyboardSwitcher switcher = mKeyboardSwitcher; final KeyboardSwitcher switcher = mKeyboardSwitcher;
final LatinKeyboardView inputView = switcher.getInputView(); final LatinKeyboardView inputView = switcher.getKeyboardView();
switch (msg.what) { switch (msg.what) {
case MSG_UPDATE_SUGGESTIONS: case MSG_UPDATE_SUGGESTIONS:
updateSuggestions(); updateSuggestions();
@ -307,7 +305,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void startDisplayLanguageOnSpacebar(boolean localeChanged) { public void startDisplayLanguageOnSpacebar(boolean localeChanged) {
removeMessages(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR); removeMessages(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR);
removeMessages(MSG_DISMISS_LANGUAGE_ON_SPACEBAR); removeMessages(MSG_DISMISS_LANGUAGE_ON_SPACEBAR);
final LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); final LatinKeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) { if (inputView != null) {
final LatinKeyboard keyboard = mKeyboardSwitcher.getLatinKeyboard(); final LatinKeyboard keyboard = mKeyboardSwitcher.getLatinKeyboard();
// The language is always displayed when the delay is negative. // The language is always displayed when the delay is negative.
@ -483,25 +481,23 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override @Override
public View onCreateInputView() { public View onCreateInputView() {
return mKeyboardSwitcher.onCreateInputView(); final View inputView = mKeyboardSwitcher.onCreateInputView();
mCandidateViewContainer = inputView.findViewById(R.id.candidates_container);
mCandidateView = (CandidateView) inputView.findViewById(R.id.candidates);
mCandidateStripHeight = (int)mResources.getDimension(R.dimen.candidate_strip_height);
return inputView;
} }
@Override @Override
public View onCreateCandidatesView() { public void setCandidatesView(View view) {
LayoutInflater inflater = getLayoutInflater(); // To ensure that CandidatesView will never be set.
LinearLayout container = (LinearLayout)inflater.inflate(R.layout.candidates, null); return;
mCandidateViewContainer = container;
mCandidateStripHeight = (int)mResources.getDimension(R.dimen.candidate_strip_height);
mCandidateView = (CandidateView) container.findViewById(R.id.candidates);
mCandidateView.setService(this);
setCandidatesViewShown(true);
return container;
} }
@Override @Override
public void onStartInputView(EditorInfo attribute, boolean restarting) { public void onStartInputView(EditorInfo attribute, boolean restarting) {
final KeyboardSwitcher switcher = mKeyboardSwitcher; final KeyboardSwitcher switcher = mKeyboardSwitcher;
LatinKeyboardView inputView = switcher.getInputView(); LatinKeyboardView inputView = switcher.getKeyboardView();
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "onStartInputView: " + inputView); Log.d(TAG, "onStartInputView: " + inputView);
@ -550,7 +546,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
switcher.updateShiftState(); switcher.updateShiftState();
} }
setCandidatesViewShownInternal(isCandidateStripVisible(), false /* needsInputViewShown */ ); setSuggestionStripShownInternal(isCandidateStripVisible(), /* needsInputViewShown */ false);
// Delay updating suggestions because keyboard input view may not be shown at this point. // Delay updating suggestions because keyboard input view may not be shown at this point.
mHandler.postUpdateSuggestions(); mHandler.postUpdateSuggestions();
@ -626,7 +622,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override @Override
public void onWindowHidden() { public void onWindowHidden() {
super.onWindowHidden(); super.onWindowHidden();
KeyboardView inputView = mKeyboardSwitcher.getInputView(); KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) inputView.closing(); if (inputView != null) inputView.closing();
} }
@ -639,7 +635,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging); mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging);
KeyboardView inputView = mKeyboardSwitcher.getInputView(); KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) inputView.closing(); if (inputView != null) inputView.closing();
if (mAutoDictionary != null) mAutoDictionary.flushPendingWrites(); if (mAutoDictionary != null) mAutoDictionary.flushPendingWrites();
if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites(); if (mUserBigramDictionary != null) mUserBigramDictionary.flushPendingWrites();
@ -648,7 +644,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override @Override
public void onFinishInputView(boolean finishingInput) { public void onFinishInputView(boolean finishingInput) {
super.onFinishInputView(finishingInput); super.onFinishInputView(finishingInput);
KeyboardView inputView = mKeyboardSwitcher.getInputView(); KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) inputView.setForeground(false); if (inputView != null) inputView.setForeground(false);
// Remove pending messages related to update suggestions // Remove pending messages related to update suggestions
mHandler.cancelUpdateSuggestions(); mHandler.cancelUpdateSuggestions();
@ -804,11 +800,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// When in fullscreen mode, show completions generated by the application // When in fullscreen mode, show completions generated by the application
setSuggestions(builder.build()); setSuggestions(builder.build());
mBestWord = null; mBestWord = null;
setCandidatesViewShown(true); setSuggestionStripShown(true);
} }
} }
private void setCandidatesViewShownInternal(boolean shown, boolean needsInputViewShown) { private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) {
// TODO: Modify this if we support candidates with hard keyboard // TODO: Modify this if we support candidates with hard keyboard
if (onEvaluateInputViewShown()) { if (onEvaluateInputViewShown()) {
final boolean shouldShowCandidates = shown final boolean shouldShowCandidates = shown
@ -816,26 +812,25 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (isExtractViewShown()) { if (isExtractViewShown()) {
// No need to have extra space to show the key preview. // No need to have extra space to show the key preview.
mCandidateViewContainer.setMinimumHeight(0); mCandidateViewContainer.setMinimumHeight(0);
super.setCandidatesViewShown(shouldShowCandidates); mCandidateViewContainer.setVisibility(
shouldShowCandidates ? View.VISIBLE : View.GONE);
} else { } else {
// We must control the visibility of the suggestion strip in order to avoid clipped // We must control the visibility of the suggestion strip in order to avoid clipped
// key previews, even when we don't show the suggestion strip. // key previews, even when we don't show the suggestion strip.
mCandidateViewContainer.setVisibility( mCandidateViewContainer.setVisibility(
shouldShowCandidates ? View.VISIBLE : View.INVISIBLE); shouldShowCandidates ? View.VISIBLE : View.INVISIBLE);
super.setCandidatesViewShown(true);
} }
} }
} }
@Override private void setSuggestionStripShown(boolean shown) {
public void setCandidatesViewShown(boolean shown) { setSuggestionStripShownInternal(shown, /* needsInputViewShown */true);
setCandidatesViewShownInternal(shown, true /* needsInputViewShown */ );
} }
@Override @Override
public void onComputeInsets(InputMethodService.Insets outInsets) { public void onComputeInsets(InputMethodService.Insets outInsets) {
super.onComputeInsets(outInsets); super.onComputeInsets(outInsets);
final KeyboardView inputView = mKeyboardSwitcher.getInputView(); final KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView == null) if (inputView == null)
return; return;
final int containerHeight = mCandidateViewContainer.getHeight(); final int containerHeight = mCandidateViewContainer.getHeight();
@ -877,8 +872,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) { switch (keyCode) {
case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_BACK:
if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getInputView() != null) { if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getKeyboardView() != null) {
if (mKeyboardSwitcher.getInputView().handleBack()) { if (mKeyboardSwitcher.getKeyboardView().handleBack()) {
return true; return true;
} }
} }
@ -1365,7 +1360,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
commitTyped(getCurrentInputConnection()); commitTyped(getCurrentInputConnection());
mVoiceProxy.handleClose(); mVoiceProxy.handleClose();
requestHideSelf(0); requestHideSelf(0);
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); LatinKeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) if (inputView != null)
inputView.closing(); inputView.closing();
} }
@ -1401,7 +1396,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "Switch to keyboard view."); Log.d(TAG, "Switch to keyboard view.");
} }
View v = mKeyboardSwitcher.getInputView(); View v = mKeyboardSwitcher.getKeyboardView();
if (v != null) { if (v != null) {
// Confirms that the keyboard view doesn't have parent view. // Confirms that the keyboard view doesn't have parent view.
ViewParent p = v.getParent(); ViewParent p = v.getParent();
@ -1410,7 +1405,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
setInputView(v); setInputView(v);
} }
setCandidatesViewShown(isCandidateStripVisible()); setSuggestionStripShown(isCandidateStripVisible());
updateInputViewShown(); updateInputViewShown();
mHandler.postUpdateSuggestions(); mHandler.postUpdateSuggestions();
} }
@ -1452,7 +1447,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
CharSequence prevWord = EditingUtils.getPreviousWord(getCurrentInputConnection(), CharSequence prevWord = EditingUtils.getPreviousWord(getCurrentInputConnection(),
mSettingsValues.mWordSeparators); mSettingsValues.mWordSeparators);
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder( SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
mKeyboardSwitcher.getInputView(), word, prevWord); mKeyboardSwitcher.getKeyboardView(), word, prevWord);
boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection(); boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection();
final CharSequence typedWord = word.getTypedWord(); final CharSequence typedWord = word.getTypedWord();
@ -1501,7 +1496,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} else { } else {
mBestWord = null; mBestWord = null;
} }
setCandidatesViewShown(isCandidateStripVisible()); setSuggestionStripShown(isCandidateStripVisible());
} }
private boolean pickDefaultSuggestion(int separatorCode) { private boolean pickDefaultSuggestion(int separatorCode) {
@ -1664,7 +1659,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(), final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
mSettingsValues.mWordSeparators); mSettingsValues.mWordSeparators);
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder( SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
mKeyboardSwitcher.getInputView(), sEmptyWordComposer, prevWord); mKeyboardSwitcher.getKeyboardView(), sEmptyWordComposer, prevWord);
if (builder.size() > 0) { if (builder.size() > 0) {
// Explicitly supply an empty typed word (the no-second-arg version of // Explicitly supply an empty typed word (the no-second-arg version of
@ -1677,7 +1672,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void setPunctuationSuggestions() { public void setPunctuationSuggestions() {
setSuggestions(mSettingsValues.mSuggestPuncList); setSuggestions(mSettingsValues.mSuggestPuncList);
setCandidatesViewShown(isCandidateStripVisible()); setSuggestionStripShown(isCandidateStripVisible());
} }
private void addToAutoAndUserBigramDictionaries(CharSequence suggestion, int frequencyDelta) { private void addToAutoAndUserBigramDictionaries(CharSequence suggestion, int frequencyDelta) {
@ -1886,7 +1881,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// if mAudioManager is null, we don't have the ringer state yet // if mAudioManager is null, we don't have the ringer state yet
// mAudioManager will be set by updateRingerMode // mAudioManager will be set by updateRingerMode
if (mAudioManager == null) { if (mAudioManager == null) {
if (mKeyboardSwitcher.getInputView() != null) { if (mKeyboardSwitcher.getKeyboardView() != null) {
updateRingerMode(); updateRingerMode();
} }
} }
@ -1913,7 +1908,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (!mSettingsValues.mVibrateOn) { if (!mSettingsValues.mVibrateOn) {
return; return;
} }
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); LatinKeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) { if (inputView != null) {
inputView.performHapticFeedback( inputView.performHapticFeedback(
HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.KEYBOARD_TAP,
@ -2037,7 +2032,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private void showOptionsMenuInternal(CharSequence title, CharSequence[] items, private void showOptionsMenuInternal(CharSequence title, CharSequence[] items,
DialogInterface.OnClickListener listener) { DialogInterface.OnClickListener listener) {
final IBinder windowToken = mKeyboardSwitcher.getInputView().getWindowToken(); final IBinder windowToken = mKeyboardSwitcher.getKeyboardView().getWindowToken();
if (windowToken == null) return; if (windowToken == null) return;
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true); builder.setCancelable(true);

View File

@ -413,7 +413,7 @@ public class SubtypeSwitcher {
final KeyboardSwitcher switcher = KeyboardSwitcher.getInstance(); final KeyboardSwitcher switcher = KeyboardSwitcher.getInstance();
final LatinKeyboard keyboard = switcher.getLatinKeyboard(); final LatinKeyboard keyboard = switcher.getLatinKeyboard();
if (keyboard != null) { if (keyboard != null) {
keyboard.updateShortcutKey(isShortcutImeReady(), switcher.getInputView()); keyboard.updateShortcutKey(isShortcutImeReady(), switcher.getKeyboardView());
} }
} }
@ -503,7 +503,7 @@ public class SubtypeSwitcher {
private void triggerVoiceIME() { private void triggerVoiceIME() {
if (!mService.isInputViewShown()) return; if (!mService.isInputViewShown()) return;
VoiceProxy.getInstance().startListening(false, VoiceProxy.getInstance().startListening(false,
KeyboardSwitcher.getInstance().getInputView().getWindowToken()); KeyboardSwitcher.getInstance().getKeyboardView().getWindowToken());
} }
////////////////////////////////////// //////////////////////////////////////