Rename SuggestionsView to SuggestionStripView

main
Tadashi G. Takaoka 2012-07-23 15:28:28 +09:00
parent c8e45ddb03
commit 4702671ea4
16 changed files with 99 additions and 93 deletions

View File

@ -43,13 +43,13 @@
android:layout_width="@dimen/suggestions_strip_padding" android:layout_width="@dimen/suggestions_strip_padding"
android:layout_height="@dimen/suggestions_strip_height" android:layout_height="@dimen/suggestions_strip_height"
style="?attr/suggestionsStripBackgroundStyle" /> style="?attr/suggestionsStripBackgroundStyle" />
<com.android.inputmethod.latin.suggestions.SuggestionsView <com.android.inputmethod.latin.suggestions.SuggestionStripView
android:id="@+id/suggestions_view" android:id="@+id/suggestion_strip_view"
android:layout_weight="1.0" android:layout_weight="1.0"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="@dimen/suggestions_strip_height" android:layout_height="@dimen/suggestions_strip_height"
android:gravity="center_vertical" android:gravity="center_vertical"
style="?attr/suggestionsViewStyle" /> style="?attr/suggestionStripViewStyle" />
<View <View
android:layout_width="@dimen/suggestions_strip_padding" android:layout_width="@dimen/suggestions_strip_padding"
android:layout_height="@dimen/suggestions_strip_height" android:layout_height="@dimen/suggestions_strip_height"

View File

@ -29,7 +29,7 @@
<attr name="moreKeysKeyboardPanelStyle" format="reference" /> <attr name="moreKeysKeyboardPanelStyle" format="reference" />
<!-- Suggestions strip style --> <!-- Suggestions strip style -->
<attr name="suggestionsStripBackgroundStyle" format="reference" /> <attr name="suggestionsStripBackgroundStyle" format="reference" />
<attr name="suggestionsViewStyle" format="reference" /> <attr name="suggestionStripViewStyle" format="reference" />
<attr name="moreSuggestionsViewStyle" format="reference" /> <attr name="moreSuggestionsViewStyle" format="reference" />
<attr name="suggestionBackgroundStyle" format="reference" /> <attr name="suggestionBackgroundStyle" format="reference" />
<attr name="suggestionPreviewBackgroundStyle" format="reference" /> <attr name="suggestionPreviewBackgroundStyle" format="reference" />
@ -155,9 +155,9 @@
<attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" /> <attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" />
</declare-styleable> </declare-styleable>
<declare-styleable name="SuggestionsView"> <declare-styleable name="SuggestionStripView">
<attr name="suggestionStripOption" format="integer"> <attr name="suggestionStripOption" format="integer">
<!-- This should be aligned with SuggestionsViewParams.AUTO_CORRECT_* and etc. --> <!-- This should be aligned with SuggestionStripViewParams.AUTO_CORRECT_* and etc. -->
<flag name="autoCorrectBold" value="0x01" /> <flag name="autoCorrectBold" value="0x01" />
<flag name="autoCorrectUnderline" value="0x02" /> <flag name="autoCorrectUnderline" value="0x02" />
<flag name="validTypedWordBold" value="0x04" /> <flag name="validTypedWordBold" value="0x04" />

View File

@ -114,7 +114,7 @@
<item name="android:background">@drawable/keyboard_suggest_strip</item> <item name="android:background">@drawable/keyboard_suggest_strip</item>
</style> </style>
<style <style
name="SuggestionsViewStyle" name="SuggestionStripViewStyle"
parent="SuggestionsStripBackgroundStyle" parent="SuggestionsStripBackgroundStyle"
> >
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>
@ -348,7 +348,7 @@
<item name="android:background">@drawable/keyboard_suggest_strip_holo</item> <item name="android:background">@drawable/keyboard_suggest_strip_holo</item>
</style> </style>
<style <style
name="SuggestionsViewStyle.IceCreamSandwich" name="SuggestionStripViewStyle.IceCreamSandwich"
parent="SuggestionsStripBackgroundStyle.IceCreamSandwich" parent="SuggestionsStripBackgroundStyle.IceCreamSandwich"
> >
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>

View File

@ -23,7 +23,7 @@
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item> <item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>

View File

@ -23,7 +23,7 @@
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item> <item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>

View File

@ -23,7 +23,7 @@
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Gingerbread</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Gingerbread</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item> <item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>

View File

@ -23,7 +23,7 @@
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.IceCreamSandwich</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.IceCreamSandwich</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle.IceCreamSandwich</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle.IceCreamSandwich</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle.IceCreamSandwich</item> <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle.IceCreamSandwich</item>
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle.IceCreamSandwich</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle.IceCreamSandwich</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle.IceCreamSandwich</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle.IceCreamSandwich</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item>
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle.IceCreamSandwich</item> <item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle.IceCreamSandwich</item>

View File

@ -23,7 +23,7 @@
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item> <item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>

View File

@ -23,7 +23,7 @@
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionsViewStyle">@style/SuggestionsViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>
<item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item> <item name="suggestionPreviewBackgroundStyle">@style/SuggestionPreviewBackgroundStyle</item>

View File

@ -63,7 +63,7 @@ public class InputAttributes {
final boolean flagAutoComplete = final boolean flagAutoComplete =
0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE); 0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
// Make sure that passwords are not displayed in {@link SuggestionsView}. // Make sure that passwords are not displayed in {@link SuggestionStripView}.
if (InputTypeUtils.isPasswordInputType(inputType) if (InputTypeUtils.isPasswordInputType(inputType)
|| InputTypeUtils.isVisiblePasswordInputType(inputType) || InputTypeUtils.isVisiblePasswordInputType(inputType)
|| InputTypeUtils.isEmailVariation(variation) || InputTypeUtils.isEmailVariation(variation)

View File

@ -24,7 +24,7 @@ import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
public class InputView extends LinearLayout { public class InputView extends LinearLayout {
private View mSuggestionsContainer; private View mSuggestionStripContainer;
private View mKeyboardView; private View mKeyboardView;
private int mKeyboardTopPadding; private int mKeyboardTopPadding;
@ -43,13 +43,13 @@ public class InputView extends LinearLayout {
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
mSuggestionsContainer = findViewById(R.id.suggestions_container); mSuggestionStripContainer = findViewById(R.id.suggestions_container);
mKeyboardView = findViewById(R.id.keyboard_view); mKeyboardView = findViewById(R.id.keyboard_view);
} }
@Override @Override
public boolean dispatchTouchEvent(MotionEvent me) { public boolean dispatchTouchEvent(MotionEvent me) {
if (mSuggestionsContainer.getVisibility() == VISIBLE if (mSuggestionStripContainer.getVisibility() == VISIBLE
&& mKeyboardView.getVisibility() == VISIBLE && mKeyboardView.getVisibility() == VISIBLE
&& forwardTouchEvent(me)) { && forwardTouchEvent(me)) {
return true; return true;
@ -57,7 +57,8 @@ public class InputView extends LinearLayout {
return super.dispatchTouchEvent(me); return super.dispatchTouchEvent(me);
} }
// The touch events that hit the top padding of keyboard should be forwarded to SuggestionsView. // The touch events that hit the top padding of keyboard should be forwarded to
// {@link SuggestionStripView}.
private boolean forwardTouchEvent(MotionEvent me) { private boolean forwardTouchEvent(MotionEvent me) {
final Rect rect = mInputViewRect; final Rect rect = mInputViewRect;
this.getGlobalVisibleRect(rect); this.getGlobalVisibleRect(rect);
@ -96,7 +97,7 @@ public class InputView extends LinearLayout {
} }
final Rect receivingRect = mEventReceivingRect; final Rect receivingRect = mEventReceivingRect;
mSuggestionsContainer.getGlobalVisibleRect(receivingRect); mSuggestionStripContainer.getGlobalVisibleRect(receivingRect);
final int translatedX = x - receivingRect.left; final int translatedX = x - receivingRect.left;
final int translatedY; final int translatedY;
if (y < forwardingLimitY) { if (y < forwardingLimitY) {
@ -106,7 +107,7 @@ public class InputView extends LinearLayout {
translatedY = y - receivingRect.top; translatedY = y - receivingRect.top;
} }
me.setLocation(translatedX, translatedY); me.setLocation(translatedX, translatedY);
mSuggestionsContainer.dispatchTouchEvent(me); mSuggestionStripContainer.dispatchTouchEvent(me);
return true; return true;
} }
} }

View File

@ -70,7 +70,7 @@ import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.MainKeyboardView; import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.latin.LocaleUtils.RunInLocale; import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.suggestions.SuggestionsView; import com.android.inputmethod.latin.suggestions.SuggestionStripView;
import com.android.inputmethod.research.ResearchLogger; import com.android.inputmethod.research.ResearchLogger;
import java.io.FileDescriptor; import java.io.FileDescriptor;
@ -82,7 +82,7 @@ import java.util.Locale;
* Input method implementation for Qwerty'ish keyboard. * Input method implementation for Qwerty'ish keyboard.
*/ */
public class LatinIME extends InputMethodService implements KeyboardActionListener, public class LatinIME extends InputMethodService implements KeyboardActionListener,
SuggestionsView.Listener, TargetApplicationGetter.OnTargetApplicationKnownListener { SuggestionStripView.Listener, TargetApplicationGetter.OnTargetApplicationKnownListener {
private static final String TAG = LatinIME.class.getSimpleName(); private static final String TAG = LatinIME.class.getSimpleName();
private static final boolean TRACE = false; private static final boolean TRACE = false;
private static boolean DEBUG; private static boolean DEBUG;
@ -126,7 +126,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private View mExtractArea; private View mExtractArea;
private View mKeyPreviewBackingView; private View mKeyPreviewBackingView;
private View mSuggestionsContainer; private View mSuggestionsContainer;
private SuggestionsView mSuggestionsView; private SuggestionStripView mSuggestionStripView;
/* package for tests */ Suggest mSuggest; /* package for tests */ Suggest mSuggest;
private CompletionInfo[] mApplicationSpecifiedCompletions; private CompletionInfo[] mApplicationSpecifiedCompletions;
private ApplicationInfo mTargetApplicationInfo; private ApplicationInfo mTargetApplicationInfo;
@ -549,9 +549,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
.findViewById(android.R.id.extractArea); .findViewById(android.R.id.extractArea);
mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing); mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing);
mSuggestionsContainer = view.findViewById(R.id.suggestions_container); mSuggestionsContainer = view.findViewById(R.id.suggestions_container);
mSuggestionsView = (SuggestionsView) view.findViewById(R.id.suggestions_view); mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view);
if (mSuggestionsView != null) if (mSuggestionStripView != null)
mSuggestionsView.setListener(this, view); mSuggestionStripView.setListener(this, view);
if (LatinImeLogger.sVISUALDEBUG) { if (LatinImeLogger.sVISUALDEBUG) {
mKeyPreviewBackingView.setBackgroundColor(0x10FF0000); mKeyPreviewBackingView.setBackgroundColor(0x10FF0000);
} }
@ -674,8 +674,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
switcher.loadKeyboard(editorInfo, mCurrentSettings); switcher.loadKeyboard(editorInfo, mCurrentSettings);
if (mSuggestionsView != null) if (mSuggestionStripView != null)
mSuggestionsView.clear(); mSuggestionStripView.clear();
setSuggestionStripShownInternal( setSuggestionStripShownInternal(
isSuggestionsStripVisible(), /* needsInputViewShown */ false); isSuggestionsStripVisible(), /* needsInputViewShown */ false);
@ -927,7 +927,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
- keyboardHeight; - keyboardHeight;
final LayoutParams params = mKeyPreviewBackingView.getLayoutParams(); final LayoutParams params = mKeyPreviewBackingView.getLayoutParams();
params.height = mSuggestionsView.setMoreSuggestionsHeight(remainingHeight); params.height = mSuggestionStripView.setMoreSuggestionsHeight(remainingHeight);
mKeyPreviewBackingView.setLayoutParams(params); mKeyPreviewBackingView.setLayoutParams(params);
return params.height; return params.height;
} }
@ -1091,7 +1091,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|| codePoint == Keyboard.CODE_CLOSING_ANGLE_BRACKET; || codePoint == Keyboard.CODE_CLOSING_ANGLE_BRACKET;
} }
// Callback for the SuggestionsView, to call when the "add to dictionary" hint is pressed. // Callback for the {@link SuggestionStripView}, to call when the "add to dictionary" hint is
// pressed.
@Override @Override
public boolean addWordToUserDictionary(String word) { public boolean addWordToUserDictionary(String word) {
mUserDictionary.addWordToUserDictionary(word, 128); mUserDictionary.addWordToUserDictionary(word, 128);
@ -1564,7 +1565,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mSpaceState = SPACE_STATE_WEAK; mSpaceState = SPACE_STATE_WEAK;
} }
// In case the "add to dictionary" hint was still displayed. // In case the "add to dictionary" hint was still displayed.
if (null != mSuggestionsView) mSuggestionsView.dismissAddToDictionaryHint(); if (null != mSuggestionStripView) mSuggestionStripView.dismissAddToDictionaryHint();
} }
mHandler.postUpdateSuggestionStrip(); mHandler.postUpdateSuggestionStrip();
Utils.Stats.onNonSeparator((char)primaryCode, x, y); Utils.Stats.onNonSeparator((char)primaryCode, x, y);
@ -1651,14 +1652,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO: make this private // TODO: make this private
// Outside LatinIME, only used by the test suite. // Outside LatinIME, only used by the test suite.
/* package for tests */ boolean isShowingPunctuationList() { /* package for tests */ boolean isShowingPunctuationList() {
if (mSuggestionsView == null) return false; if (mSuggestionStripView == null) return false;
return mCurrentSettings.mSuggestPuncList == mSuggestionsView.getSuggestions(); return mCurrentSettings.mSuggestPuncList == mSuggestionStripView.getSuggestions();
} }
private boolean isSuggestionsStripVisible() { private boolean isSuggestionsStripVisible() {
if (mSuggestionsView == null) if (mSuggestionStripView == null)
return false; return false;
if (mSuggestionsView.isShowingAddToDictionaryHint()) if (mSuggestionStripView.isShowingAddToDictionaryHint())
return true; return true;
if (!mCurrentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation)) if (!mCurrentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation))
return false; return false;
@ -1673,8 +1674,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
private void setSuggestions(final SuggestedWords words, final boolean isAutoCorrection) { private void setSuggestions(final SuggestedWords words, final boolean isAutoCorrection) {
if (mSuggestionsView != null) { if (mSuggestionStripView != null) {
mSuggestionsView.setSuggestions(words); mSuggestionStripView.setSuggestions(words);
mKeyboardSwitcher.onAutoCorrectionStateChanged(isAutoCorrection); mKeyboardSwitcher.onAutoCorrectionStateChanged(isAutoCorrection);
} }
} }
@ -1737,10 +1738,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// revert to suggestions - although it is unclear how we can come here if it's displayed. // revert to suggestions - although it is unclear how we can come here if it's displayed.
if (suggestedWords.size() > 1 || typedWord.length() <= 1 if (suggestedWords.size() > 1 || typedWord.length() <= 1
|| !suggestedWords.mTypedWordValid || !suggestedWords.mTypedWordValid
|| mSuggestionsView.isShowingAddToDictionaryHint()) { || mSuggestionStripView.isShowingAddToDictionaryHint()) {
return suggestedWords; return suggestedWords;
} else { } else {
SuggestedWords previousSuggestions = mSuggestionsView.getSuggestions(); SuggestedWords previousSuggestions = mSuggestionStripView.getSuggestions();
if (previousSuggestions == mCurrentSettings.mSuggestPuncList) { if (previousSuggestions == mCurrentSettings.mSuggestPuncList) {
previousSuggestions = SuggestedWords.EMPTY; previousSuggestions = SuggestedWords.EMPTY;
} }
@ -1811,11 +1812,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
} }
// Called from SuggestionsView through the SuggestionsView.Listener interface // Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
// interface
@Override @Override
public void pickSuggestionManually(final int index, final CharSequence suggestion, public void pickSuggestionManually(final int index, final CharSequence suggestion,
final int x, final int y) { final int x, final int y) {
final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions(); final SuggestedWords suggestedWords = mSuggestionStripView.getSuggestions();
// If this is a punctuation picked from the suggestion strip, pass it to onCodeInput // If this is a punctuation picked from the suggestion strip, pass it to onCodeInput
if (suggestion.length() == 1 && isShowingPunctuationList()) { if (suggestion.length() == 1 && isShowingPunctuationList()) {
// Word separators are suggested before the user inputs something. // Word separators are suggested before the user inputs something.
@ -1847,8 +1849,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (mCurrentSettings.isApplicationSpecifiedCompletionsOn() if (mCurrentSettings.isApplicationSpecifiedCompletionsOn()
&& mApplicationSpecifiedCompletions != null && mApplicationSpecifiedCompletions != null
&& index >= 0 && index < mApplicationSpecifiedCompletions.length) { && index >= 0 && index < mApplicationSpecifiedCompletions.length) {
if (mSuggestionsView != null) { if (mSuggestionStripView != null) {
mSuggestionsView.clear(); mSuggestionStripView.clear();
} }
mKeyboardSwitcher.updateShiftState(); mKeyboardSwitcher.updateShiftState();
resetComposingState(true /* alsoResetLastComposedWord */); resetComposingState(true /* alsoResetLastComposedWord */);
@ -1897,7 +1899,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
Utils.Stats.onSeparator((char)Keyboard.CODE_SPACE, WordComposer.NOT_A_COORDINATE, Utils.Stats.onSeparator((char)Keyboard.CODE_SPACE, WordComposer.NOT_A_COORDINATE,
WordComposer.NOT_A_COORDINATE); WordComposer.NOT_A_COORDINATE);
if (showingAddToDictionaryHint && mIsUserDictionaryAvailable) { if (showingAddToDictionaryHint && mIsUserDictionaryAvailable) {
mSuggestionsView.showAddToDictionaryHint(suggestion, mCurrentSettings.mHintToSaveText); mSuggestionStripView.showAddToDictionaryHint(
suggestion, mCurrentSettings.mHintToSaveText);
} else { } else {
// If we're not showing the "Touch again to save", then update the suggestion strip. // If we're not showing the "Touch again to save", then update the suggestion strip.
mHandler.postUpdateSuggestionStrip(); mHandler.postUpdateSuggestionStrip();
@ -1909,7 +1912,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
*/ */
private void commitChosenWord(final CharSequence chosenWord, final int commitType, private void commitChosenWord(final CharSequence chosenWord, final int commitType,
final int separatorCode) { final int separatorCode) {
final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions(); final SuggestedWords suggestedWords = mSuggestionStripView.getSuggestions();
mConnection.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan( mConnection.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan(
this, chosenWord, suggestedWords, mIsMainDictionaryAvailable), 1); this, chosenWord, suggestedWords, mIsMainDictionaryAvailable), 1);
if (ProductionFlag.IS_EXPERIMENTAL) { if (ProductionFlag.IS_EXPERIMENTAL) {

View File

@ -42,10 +42,10 @@ public class MoreSuggestions extends Keyboard {
private int mToPos; private int mToPos;
public static class MoreSuggestionsParam extends Keyboard.Params { public static class MoreSuggestionsParam extends Keyboard.Params {
private final int[] mWidths = new int[SuggestionsView.MAX_SUGGESTIONS]; private final int[] mWidths = new int[SuggestionStripView.MAX_SUGGESTIONS];
private final int[] mRowNumbers = new int[SuggestionsView.MAX_SUGGESTIONS]; private final int[] mRowNumbers = new int[SuggestionStripView.MAX_SUGGESTIONS];
private final int[] mColumnOrders = new int[SuggestionsView.MAX_SUGGESTIONS]; private final int[] mColumnOrders = new int[SuggestionStripView.MAX_SUGGESTIONS];
private final int[] mNumColumnsInRow = new int[SuggestionsView.MAX_SUGGESTIONS]; private final int[] mNumColumnsInRow = new int[SuggestionStripView.MAX_SUGGESTIONS];
private static final int MAX_COLUMNS_IN_ROW = 3; private static final int MAX_COLUMNS_IN_ROW = 3;
private int mNumRows; private int mNumRows;
public Drawable mDivider; public Drawable mDivider;
@ -63,7 +63,7 @@ public class MoreSuggestions extends Keyboard {
int row = 0; int row = 0;
int pos = fromPos, rowStartPos = fromPos; int pos = fromPos, rowStartPos = fromPos;
final int size = Math.min(suggestions.size(), SuggestionsView.MAX_SUGGESTIONS); final int size = Math.min(suggestions.size(), SuggestionStripView.MAX_SUGGESTIONS);
while (pos < size) { while (pos < size) {
final String word = suggestions.getWord(pos).toString(); final String word = suggestions.getWord(pos).toString();
// TODO: Should take care of text x-scaling. // TODO: Should take care of text x-scaling.

View File

@ -68,7 +68,7 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
@Override @Override
public void onCodeInput(int primaryCode, int x, int y) { public void onCodeInput(int primaryCode, int x, int y) {
final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE; final int index = primaryCode - MoreSuggestions.SUGGESTION_CODE_BASE;
if (index >= 0 && index < SuggestionsView.MAX_SUGGESTIONS) { if (index >= 0 && index < SuggestionStripView.MAX_SUGGESTIONS) {
mListener.onCustomRequest(index); mListener.onCustomRequest(index);
} }
} }

View File

@ -68,7 +68,7 @@ import com.android.inputmethod.research.ResearchLogger;
import java.util.ArrayList; import java.util.ArrayList;
public class SuggestionsView extends RelativeLayout implements OnClickListener, public class SuggestionStripView extends RelativeLayout implements OnClickListener,
OnLongClickListener { OnLongClickListener {
public interface Listener { public interface Listener {
public boolean addWordToUserDictionary(String word); public boolean addWordToUserDictionary(String word);
@ -98,24 +98,24 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private Listener mListener; private Listener mListener;
private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY; private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;
private final SuggestionsViewParams mParams; private final SuggestionStripViewParams mParams;
private static final float MIN_TEXT_XSCALE = 0.70f; private static final float MIN_TEXT_XSCALE = 0.70f;
private final UiHandler mHandler = new UiHandler(this); private final UiHandler mHandler = new UiHandler(this);
private static class UiHandler extends StaticInnerHandlerWrapper<SuggestionsView> { private static class UiHandler extends StaticInnerHandlerWrapper<SuggestionStripView> {
private static final int MSG_HIDE_PREVIEW = 0; private static final int MSG_HIDE_PREVIEW = 0;
public UiHandler(SuggestionsView outerInstance) { public UiHandler(SuggestionStripView outerInstance) {
super(outerInstance); super(outerInstance);
} }
@Override @Override
public void dispatchMessage(Message msg) { public void dispatchMessage(Message msg) {
final SuggestionsView suggestionsView = getOuterInstance(); final SuggestionStripView suggestionStripView = getOuterInstance();
switch (msg.what) { switch (msg.what) {
case MSG_HIDE_PREVIEW: case MSG_HIDE_PREVIEW:
suggestionsView.hidePreview(); suggestionStripView.hidePreview();
break; break;
} }
} }
@ -129,7 +129,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
} }
} }
private static class SuggestionsViewParams { private static class SuggestionStripViewParams {
private static final int DEFAULT_SUGGESTIONS_COUNT_IN_STRIP = 3; private static final int DEFAULT_SUGGESTIONS_COUNT_IN_STRIP = 3;
private static final int DEFAULT_CENTER_SUGGESTION_PERCENTILE = 40; private static final int DEFAULT_CENTER_SUGGESTION_PERCENTILE = 40;
private static final int DEFAULT_MAX_MORE_SUGGESTIONS_ROW = 2; private static final int DEFAULT_MAX_MORE_SUGGESTIONS_ROW = 2;
@ -175,7 +175,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private final TextView mLeftwardsArrowView; private final TextView mLeftwardsArrowView;
private final TextView mHintToSaveView; private final TextView mHintToSaveView;
public SuggestionsViewParams(Context context, AttributeSet attrs, int defStyle, public SuggestionStripViewParams(Context context, AttributeSet attrs, int defStyle,
ArrayList<TextView> words, ArrayList<View> dividers, ArrayList<TextView> infos) { ArrayList<TextView> words, ArrayList<View> dividers, ArrayList<TextView> infos) {
mWords = words; mWords = words;
mDividers = dividers; mDividers = dividers;
@ -191,38 +191,39 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
final Resources res = word.getResources(); final Resources res = word.getResources();
mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.suggestions_strip_height); mSuggestionsStripHeight = res.getDimensionPixelSize(R.dimen.suggestions_strip_height);
final TypedArray a = context.obtainStyledAttributes( final TypedArray a = context.obtainStyledAttributes(attrs,
attrs, R.styleable.SuggestionsView, defStyle, R.style.SuggestionsViewStyle); R.styleable.SuggestionStripView, defStyle, R.style.SuggestionStripViewStyle);
mSuggestionStripOption = a.getInt(R.styleable.SuggestionsView_suggestionStripOption, 0); mSuggestionStripOption = a.getInt(
R.styleable.SuggestionStripView_suggestionStripOption, 0);
final float alphaValidTypedWord = getPercent(a, final float alphaValidTypedWord = getPercent(a,
R.styleable.SuggestionsView_alphaValidTypedWord, 100); R.styleable.SuggestionStripView_alphaValidTypedWord, 100);
final float alphaTypedWord = getPercent(a, final float alphaTypedWord = getPercent(a,
R.styleable.SuggestionsView_alphaTypedWord, 100); R.styleable.SuggestionStripView_alphaTypedWord, 100);
final float alphaAutoCorrect = getPercent(a, final float alphaAutoCorrect = getPercent(a,
R.styleable.SuggestionsView_alphaAutoCorrect, 100); R.styleable.SuggestionStripView_alphaAutoCorrect, 100);
final float alphaSuggested = getPercent(a, final float alphaSuggested = getPercent(a,
R.styleable.SuggestionsView_alphaSuggested, 100); R.styleable.SuggestionStripView_alphaSuggested, 100);
mAlphaObsoleted = getPercent(a, R.styleable.SuggestionsView_alphaSuggested, 100); mAlphaObsoleted = getPercent(a,
mColorValidTypedWord = applyAlpha( R.styleable.SuggestionStripView_alphaSuggested, 100);
a.getColor(R.styleable.SuggestionsView_colorValidTypedWord, 0), mColorValidTypedWord = applyAlpha(a.getColor(
alphaValidTypedWord); R.styleable.SuggestionStripView_colorValidTypedWord, 0), alphaValidTypedWord);
mColorTypedWord = applyAlpha( mColorTypedWord = applyAlpha(a.getColor(
a.getColor(R.styleable.SuggestionsView_colorTypedWord, 0), alphaTypedWord); R.styleable.SuggestionStripView_colorTypedWord, 0), alphaTypedWord);
mColorAutoCorrect = applyAlpha( mColorAutoCorrect = applyAlpha(a.getColor(
a.getColor(R.styleable.SuggestionsView_colorAutoCorrect, 0), alphaAutoCorrect); R.styleable.SuggestionStripView_colorAutoCorrect, 0), alphaAutoCorrect);
mColorSuggested = applyAlpha( mColorSuggested = applyAlpha(a.getColor(
a.getColor(R.styleable.SuggestionsView_colorSuggested, 0), alphaSuggested); R.styleable.SuggestionStripView_colorSuggested, 0), alphaSuggested);
mSuggestionsCountInStrip = a.getInt( mSuggestionsCountInStrip = a.getInt(
R.styleable.SuggestionsView_suggestionsCountInStrip, R.styleable.SuggestionStripView_suggestionsCountInStrip,
DEFAULT_SUGGESTIONS_COUNT_IN_STRIP); DEFAULT_SUGGESTIONS_COUNT_IN_STRIP);
mCenterSuggestionWeight = getPercent(a, mCenterSuggestionWeight = getPercent(a,
R.styleable.SuggestionsView_centerSuggestionPercentile, R.styleable.SuggestionStripView_centerSuggestionPercentile,
DEFAULT_CENTER_SUGGESTION_PERCENTILE); DEFAULT_CENTER_SUGGESTION_PERCENTILE);
mMaxMoreSuggestionsRow = a.getInt( mMaxMoreSuggestionsRow = a.getInt(
R.styleable.SuggestionsView_maxMoreSuggestionsRow, R.styleable.SuggestionStripView_maxMoreSuggestionsRow,
DEFAULT_MAX_MORE_SUGGESTIONS_ROW); DEFAULT_MAX_MORE_SUGGESTIONS_ROW);
mMinMoreSuggestionsWidth = getRatio(a, mMinMoreSuggestionsWidth = getRatio(a,
R.styleable.SuggestionsView_minMoreSuggestionsWidth); R.styleable.SuggestionStripView_minMoreSuggestionsWidth);
a.recycle(); a.recycle();
mMoreSuggestionsHint = getMoreSuggestionsHint(res, mMoreSuggestionsHint = getMoreSuggestionsHint(res,
@ -596,15 +597,15 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
} }
/** /**
* Construct a {@link SuggestionsView} for showing suggestions to be picked by the user. * Construct a {@link SuggestionStripView} for showing suggestions to be picked by the user.
* @param context * @param context
* @param attrs * @param attrs
*/ */
public SuggestionsView(Context context, AttributeSet attrs) { public SuggestionStripView(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.suggestionsViewStyle); this(context, attrs, R.attr.suggestionStripViewStyle);
} }
public SuggestionsView(Context context, AttributeSet attrs, int defStyle) { public SuggestionStripView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); super(context, attrs, defStyle);
final LayoutInflater inflater = LayoutInflater.from(context); final LayoutInflater inflater = LayoutInflater.from(context);
@ -631,7 +632,8 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mInfos.add((TextView)inflater.inflate(R.layout.suggestion_info, null)); mInfos.add((TextView)inflater.inflate(R.layout.suggestion_info, null));
} }
mParams = new SuggestionsViewParams(context, attrs, defStyle, mWords, mDividers, mInfos); mParams = new SuggestionStripViewParams(
context, attrs, defStyle, mWords, mDividers, mInfos);
mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null);
mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer
@ -677,7 +679,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mSuggestedWords = suggestedWords; mSuggestedWords = suggestedWords;
mParams.layout(mSuggestedWords, mSuggestionsStrip, this, getWidth()); mParams.layout(mSuggestedWords, mSuggestionsStrip, this, getWidth());
if (ProductionFlag.IS_EXPERIMENTAL) { if (ProductionFlag.IS_EXPERIMENTAL) {
ResearchLogger.suggestionsView_setSuggestions(mSuggestedWords); ResearchLogger.suggestionStripView_setSuggestions(mSuggestedWords);
} }
} }
@ -759,7 +761,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
} }
private boolean showMoreSuggestions() { private boolean showMoreSuggestions() {
final SuggestionsViewParams params = mParams; final SuggestionStripViewParams params = mParams;
if (params.mMoreSuggestionsAvailable) { if (params.mMoreSuggestionsAvailable) {
final int stripWidth = getWidth(); final int stripWidth = getWidth();
final View container = mMoreSuggestionsContainer; final View container = mMoreSuggestionsContainer;

View File

@ -1258,16 +1258,16 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
} }
} }
private static final String[] EVENTKEYS_SUGGESTIONSVIEW_SETSUGGESTIONS = { private static final String[] EVENTKEYS_SUGGESTIONSTRIPVIEW_SETSUGGESTIONS = {
"SuggestionsViewSetSuggestions", "suggestedWords" "SuggestionStripViewSetSuggestions", "suggestedWords"
}; };
public static void suggestionsView_setSuggestions(final SuggestedWords suggestedWords) { public static void suggestionStripView_setSuggestions(final SuggestedWords suggestedWords) {
if (suggestedWords != null) { if (suggestedWords != null) {
final Object[] values = { final Object[] values = {
suggestedWords suggestedWords
}; };
getInstance().enqueuePotentiallyPrivateEvent(EVENTKEYS_SUGGESTIONSVIEW_SETSUGGESTIONS, getInstance().enqueuePotentiallyPrivateEvent(
values); EVENTKEYS_SUGGESTIONSTRIPVIEW_SETSUGGESTIONS, values);
} }
} }