am 6fb586a5: Fix missing prediction words on contextual strip

* commit '6fb586a527e7ffe5da187c8b345cdf897b8481c7':
  Fix missing prediction words on contextual strip
main
Tadashi G. Takaoka 2014-10-06 15:23:07 +00:00 committed by Android Git Automerger
commit c6e4acb1d2
9 changed files with 34 additions and 24 deletions

View File

@ -23,7 +23,7 @@
<string name="prefs_debug_mode">Debug Mode</string>
<string name="prefs_force_non_distinct_multitouch">Force non-distinct multitouch</string>
<string name="prefs_force_physical_keyboard_special_key">Force physical keyboard special key</string>
<string name="prefs_show_ui_to_accept_typed_word">Show UI to accept typed word</string>
<string name="prefs_should_show_lxx_suggestion_ui">Show LXX suggestion UI</string>
<!-- Option to enable sliding key input indicator. The user can see a rubber band-like effect during sliding key input. [CHAR LIMIT=30]-->
<string name="sliding_key_input_preview">Show slide indicator</string>
<!-- Option summary to enable sliding key input indicator. The user can see a rubber band-like effect during sliding key input. [CHAR LIMIT=66]-->

View File

@ -36,8 +36,8 @@
android:defaultValue="false"
android:persistent="true" />
<CheckBoxPreference
android:key="pref_show_ui_to_accept_typed_word"
android:title="@string/prefs_show_ui_to_accept_typed_word"
android:key="pref_should_show_lxx_suggestion_ui"
android:title="@string/prefs_should_show_lxx_suggestion_ui"
android:defaultValue="true"
android:persistent="true" />
<CheckBoxPreference

View File

@ -112,6 +112,19 @@ public class SuggestedWords {
return mSuggestedWordInfoList.size();
}
/**
* Get suggested word to show as suggestions to UI.
*
* @param shouldShowLxxSuggestionUi true if showing suggestion UI introduced in LXX and later.
* @return the count of suggested word to show as suggestions to UI.
*/
public int getWordCountToShow(final boolean shouldShowLxxSuggestionUi) {
if (isPrediction() || !shouldShowLxxSuggestionUi) {
return size();
}
return size() - /* typed word */ 1;
}
/**
* Get suggested word at <code>index</code>.
* @param index The index of the suggested word.

View File

@ -53,7 +53,6 @@ import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.WordComposer;
import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.define.ProductionFlags;
import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
@ -169,7 +168,7 @@ public final class InputLogic {
mInputLogicHandler.reset();
}
if (settingsValues.mShouldShowUiToAcceptTypedWord) {
if (settingsValues.mShouldShowLxxSuggestionUi) {
mConnection.requestCursorUpdates(true /* enableMonitor */,
true /* requestImmediateCallback */);
}
@ -2352,7 +2351,7 @@ public final class InputLogic {
// We cannot help in this case because we are heavily relying on this new API.
return false;
}
if (!settingsValues.mShouldShowUiToAcceptTypedWord) {
if (!settingsValues.mShouldShowLxxSuggestionUi) {
return false;
}
if (TextUtils.isEmpty(lastComposedWord.mTypedWord)) {

View File

@ -21,8 +21,8 @@ public final class DebugSettings {
public static final String PREF_FORCE_NON_DISTINCT_MULTITOUCH = "force_non_distinct_multitouch";
public static final String PREF_FORCE_PHYSICAL_KEYBOARD_SPECIAL_KEY =
"force_physical_keyboard_special_key";
public static final String PREF_SHOW_UI_TO_ACCEPT_TYPED_WORD =
"pref_show_ui_to_accept_typed_word";
public static final String PREF_SHOULD_SHOW_LXX_SUGGESTION_UI =
"pref_should_show_lxx_suggestion_ui";
public static final String PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS =
"pref_has_custom_key_preview_animation_params";
public static final String PREF_KEY_PREVIEW_SHOW_UP_START_X_SCALE =

View File

@ -56,8 +56,8 @@ public final class DebugSettingsFragment extends SubScreenFragment
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs_screen_debug);
if (!Settings.HAS_UI_TO_ACCEPT_TYPED_WORD) {
removePreference(DebugSettings.PREF_SHOW_UI_TO_ACCEPT_TYPED_WORD);
if (!Settings.SHOULD_SHOW_LXX_SUGGESTION_UI) {
removePreference(DebugSettings.PREF_SHOULD_SHOW_LXX_SUGGESTION_UI);
}
mReadExternalDictionaryPref = findPreference(PREF_READ_EXTERNAL_DICTIONARY);

View File

@ -77,7 +77,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
BuildCompatUtils.EFFECTIVE_SDK_INT <= Build.VERSION_CODES.KITKAT;
public static final boolean ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS =
BuildCompatUtils.EFFECTIVE_SDK_INT <= Build.VERSION_CODES.KITKAT;
public static final boolean HAS_UI_TO_ACCEPT_TYPED_WORD =
public static final boolean SHOULD_SHOW_LXX_SUGGESTION_UI =
BuildCompatUtils.EFFECTIVE_SDK_INT >= BuildCompatUtils.VERSION_CODES_LXX;
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
"pref_show_language_switch_key";

View File

@ -80,7 +80,7 @@ public class SettingsValues {
public final boolean mPhraseGestureEnabled;
public final int mKeyLongpressTimeout;
public final boolean mEnableMetricsLogging;
public final boolean mShouldShowUiToAcceptTypedWord;
public final boolean mShouldShowLxxSuggestionUi;
// Use split layout for keyboard.
public final boolean mIsSplitKeyboardEnabled;
public final int mScreenMetrics;
@ -163,8 +163,8 @@ public class SettingsValues {
mIsSplitKeyboardEnabled = prefs.getBoolean(Settings.PREF_ENABLE_SPLIT_KEYBOARD, false);
mScreenMetrics = res.getInteger(R.integer.config_screen_metrics);
mShouldShowUiToAcceptTypedWord = Settings.HAS_UI_TO_ACCEPT_TYPED_WORD
&& prefs.getBoolean(DebugSettings.PREF_SHOW_UI_TO_ACCEPT_TYPED_WORD, true);
mShouldShowLxxSuggestionUi = Settings.SHOULD_SHOW_LXX_SUGGESTION_UI
&& prefs.getBoolean(DebugSettings.PREF_SHOULD_SHOW_LXX_SUGGESTION_UI, true);
// Compute other readable settings
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);

View File

@ -240,9 +240,9 @@ final class SuggestionStripLayoutHelper {
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
final boolean shouldOmitTypedWord = shouldOmitTypedWord(suggestedWords.mInputStyle,
settingsValues.mGestureFloatingPreviewTextEnabled,
settingsValues.mShouldShowUiToAcceptTypedWord);
settingsValues.mShouldShowLxxSuggestionUi);
return getPositionInSuggestionStrip(indexInSuggestedWords, suggestedWords.mWillAutoCorrect,
settingsValues.mShouldShowUiToAcceptTypedWord && shouldOmitTypedWord,
settingsValues.mShouldShowLxxSuggestionUi && shouldOmitTypedWord,
mCenterPositionInStrip, mTypedWordPositionWhenAutocorrect);
}
@ -367,21 +367,19 @@ final class SuggestionStripLayoutHelper {
(PunctuationSuggestions)suggestedWords, stripView);
}
final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance().getCurrent()
.mShouldShowUiToAcceptTypedWord;
final int suggestionsCount = suggestedWords.size()
- (shouldShowUiToAcceptTypedWord ? /* typed word */ 1 : 0);
final int wordCountToShow = suggestedWords.getWordCountToShow(
Settings.getInstance().getCurrent().mShouldShowLxxSuggestionUi);
final int startIndexOfMoreSuggestions = setupWordViewsAndReturnStartIndexOfMoreSuggestions(
suggestedWords, mSuggestionsCountInStrip);
final TextView centerWordView = mWordViews.get(mCenterPositionInStrip);
final int stripWidth = stripView.getWidth();
final int centerWidth = getSuggestionWidth(mCenterPositionInStrip, stripWidth);
if (suggestionsCount == 1 || getTextScaleX(centerWordView.getText(), centerWidth,
if (wordCountToShow == 1 || getTextScaleX(centerWordView.getText(), centerWidth,
centerWordView.getPaint()) < MIN_TEXT_XSCALE) {
// Layout only the most relevant suggested word at the center of the suggestion strip
// by consolidating all slots in the strip.
final int countInStrip = 1;
mMoreSuggestionsAvailable = (suggestionsCount > countInStrip);
mMoreSuggestionsAvailable = (wordCountToShow > countInStrip);
layoutWord(mCenterPositionInStrip, stripWidth - mPadding);
stripView.addView(centerWordView);
setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
@ -393,7 +391,7 @@ final class SuggestionStripLayoutHelper {
}
final int countInStrip = mSuggestionsCountInStrip;
mMoreSuggestionsAvailable = (suggestionsCount > countInStrip);
mMoreSuggestionsAvailable = (wordCountToShow > countInStrip);
int x = 0;
for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) {
if (positionInStrip != 0) {
@ -557,7 +555,7 @@ final class SuggestionStripLayoutHelper {
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) {
final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance().getCurrent()
.mShouldShowUiToAcceptTypedWord;
.mShouldShowLxxSuggestionUi;
final int stripWidth = addToDictionaryStrip.getWidth();
final int width = shouldShowUiToAcceptTypedWord ? stripWidth
: stripWidth - mDividerWidth - mPadding * 2;