am 6fb586a5: Fix missing prediction words on contextual strip
* commit '6fb586a527e7ffe5da187c8b345cdf897b8481c7': Fix missing prediction words on contextual stripmain
commit
c6e4acb1d2
|
@ -23,7 +23,7 @@
|
||||||
<string name="prefs_debug_mode">Debug Mode</string>
|
<string name="prefs_debug_mode">Debug Mode</string>
|
||||||
<string name="prefs_force_non_distinct_multitouch">Force non-distinct multitouch</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_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]-->
|
<!-- 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>
|
<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]-->
|
<!-- Option summary to enable sliding key input indicator. The user can see a rubber band-like effect during sliding key input. [CHAR LIMIT=66]-->
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:persistent="true" />
|
android:persistent="true" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="pref_show_ui_to_accept_typed_word"
|
android:key="pref_should_show_lxx_suggestion_ui"
|
||||||
android:title="@string/prefs_show_ui_to_accept_typed_word"
|
android:title="@string/prefs_should_show_lxx_suggestion_ui"
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:persistent="true" />
|
android:persistent="true" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
|
|
@ -112,6 +112,19 @@ public class SuggestedWords {
|
||||||
return mSuggestedWordInfoList.size();
|
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>.
|
* Get suggested word at <code>index</code>.
|
||||||
* @param index The index of the suggested word.
|
* @param index The index of the suggested word.
|
||||||
|
|
|
@ -53,7 +53,6 @@ import com.android.inputmethod.latin.SuggestedWords;
|
||||||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||||
import com.android.inputmethod.latin.WordComposer;
|
import com.android.inputmethod.latin.WordComposer;
|
||||||
import com.android.inputmethod.latin.define.DebugFlags;
|
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.SettingsValues;
|
||||||
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
|
||||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||||
|
@ -169,7 +168,7 @@ public final class InputLogic {
|
||||||
mInputLogicHandler.reset();
|
mInputLogicHandler.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settingsValues.mShouldShowUiToAcceptTypedWord) {
|
if (settingsValues.mShouldShowLxxSuggestionUi) {
|
||||||
mConnection.requestCursorUpdates(true /* enableMonitor */,
|
mConnection.requestCursorUpdates(true /* enableMonitor */,
|
||||||
true /* requestImmediateCallback */);
|
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.
|
// We cannot help in this case because we are heavily relying on this new API.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!settingsValues.mShouldShowUiToAcceptTypedWord) {
|
if (!settingsValues.mShouldShowLxxSuggestionUi) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(lastComposedWord.mTypedWord)) {
|
if (TextUtils.isEmpty(lastComposedWord.mTypedWord)) {
|
||||||
|
|
|
@ -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_NON_DISTINCT_MULTITOUCH = "force_non_distinct_multitouch";
|
||||||
public static final String PREF_FORCE_PHYSICAL_KEYBOARD_SPECIAL_KEY =
|
public static final String PREF_FORCE_PHYSICAL_KEYBOARD_SPECIAL_KEY =
|
||||||
"force_physical_keyboard_special_key";
|
"force_physical_keyboard_special_key";
|
||||||
public static final String PREF_SHOW_UI_TO_ACCEPT_TYPED_WORD =
|
public static final String PREF_SHOULD_SHOW_LXX_SUGGESTION_UI =
|
||||||
"pref_show_ui_to_accept_typed_word";
|
"pref_should_show_lxx_suggestion_ui";
|
||||||
public static final String PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS =
|
public static final String PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS =
|
||||||
"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 =
|
public static final String PREF_KEY_PREVIEW_SHOW_UP_START_X_SCALE =
|
||||||
|
|
|
@ -56,8 +56,8 @@ public final class DebugSettingsFragment extends SubScreenFragment
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
addPreferencesFromResource(R.xml.prefs_screen_debug);
|
addPreferencesFromResource(R.xml.prefs_screen_debug);
|
||||||
|
|
||||||
if (!Settings.HAS_UI_TO_ACCEPT_TYPED_WORD) {
|
if (!Settings.SHOULD_SHOW_LXX_SUGGESTION_UI) {
|
||||||
removePreference(DebugSettings.PREF_SHOW_UI_TO_ACCEPT_TYPED_WORD);
|
removePreference(DebugSettings.PREF_SHOULD_SHOW_LXX_SUGGESTION_UI);
|
||||||
}
|
}
|
||||||
|
|
||||||
mReadExternalDictionaryPref = findPreference(PREF_READ_EXTERNAL_DICTIONARY);
|
mReadExternalDictionaryPref = findPreference(PREF_READ_EXTERNAL_DICTIONARY);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
BuildCompatUtils.EFFECTIVE_SDK_INT <= Build.VERSION_CODES.KITKAT;
|
BuildCompatUtils.EFFECTIVE_SDK_INT <= Build.VERSION_CODES.KITKAT;
|
||||||
public static final boolean ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS =
|
public static final boolean ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS =
|
||||||
BuildCompatUtils.EFFECTIVE_SDK_INT <= Build.VERSION_CODES.KITKAT;
|
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;
|
BuildCompatUtils.EFFECTIVE_SDK_INT >= BuildCompatUtils.VERSION_CODES_LXX;
|
||||||
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
|
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
|
||||||
"pref_show_language_switch_key";
|
"pref_show_language_switch_key";
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class SettingsValues {
|
||||||
public final boolean mPhraseGestureEnabled;
|
public final boolean mPhraseGestureEnabled;
|
||||||
public final int mKeyLongpressTimeout;
|
public final int mKeyLongpressTimeout;
|
||||||
public final boolean mEnableMetricsLogging;
|
public final boolean mEnableMetricsLogging;
|
||||||
public final boolean mShouldShowUiToAcceptTypedWord;
|
public final boolean mShouldShowLxxSuggestionUi;
|
||||||
// Use split layout for keyboard.
|
// Use split layout for keyboard.
|
||||||
public final boolean mIsSplitKeyboardEnabled;
|
public final boolean mIsSplitKeyboardEnabled;
|
||||||
public final int mScreenMetrics;
|
public final int mScreenMetrics;
|
||||||
|
@ -163,8 +163,8 @@ public class SettingsValues {
|
||||||
mIsSplitKeyboardEnabled = prefs.getBoolean(Settings.PREF_ENABLE_SPLIT_KEYBOARD, false);
|
mIsSplitKeyboardEnabled = prefs.getBoolean(Settings.PREF_ENABLE_SPLIT_KEYBOARD, false);
|
||||||
mScreenMetrics = res.getInteger(R.integer.config_screen_metrics);
|
mScreenMetrics = res.getInteger(R.integer.config_screen_metrics);
|
||||||
|
|
||||||
mShouldShowUiToAcceptTypedWord = Settings.HAS_UI_TO_ACCEPT_TYPED_WORD
|
mShouldShowLxxSuggestionUi = Settings.SHOULD_SHOW_LXX_SUGGESTION_UI
|
||||||
&& prefs.getBoolean(DebugSettings.PREF_SHOW_UI_TO_ACCEPT_TYPED_WORD, true);
|
&& prefs.getBoolean(DebugSettings.PREF_SHOULD_SHOW_LXX_SUGGESTION_UI, true);
|
||||||
// Compute other readable settings
|
// Compute other readable settings
|
||||||
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
|
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
|
||||||
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);
|
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);
|
||||||
|
|
|
@ -240,9 +240,9 @@ final class SuggestionStripLayoutHelper {
|
||||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
||||||
final boolean shouldOmitTypedWord = shouldOmitTypedWord(suggestedWords.mInputStyle,
|
final boolean shouldOmitTypedWord = shouldOmitTypedWord(suggestedWords.mInputStyle,
|
||||||
settingsValues.mGestureFloatingPreviewTextEnabled,
|
settingsValues.mGestureFloatingPreviewTextEnabled,
|
||||||
settingsValues.mShouldShowUiToAcceptTypedWord);
|
settingsValues.mShouldShowLxxSuggestionUi);
|
||||||
return getPositionInSuggestionStrip(indexInSuggestedWords, suggestedWords.mWillAutoCorrect,
|
return getPositionInSuggestionStrip(indexInSuggestedWords, suggestedWords.mWillAutoCorrect,
|
||||||
settingsValues.mShouldShowUiToAcceptTypedWord && shouldOmitTypedWord,
|
settingsValues.mShouldShowLxxSuggestionUi && shouldOmitTypedWord,
|
||||||
mCenterPositionInStrip, mTypedWordPositionWhenAutocorrect);
|
mCenterPositionInStrip, mTypedWordPositionWhenAutocorrect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,21 +367,19 @@ final class SuggestionStripLayoutHelper {
|
||||||
(PunctuationSuggestions)suggestedWords, stripView);
|
(PunctuationSuggestions)suggestedWords, stripView);
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance().getCurrent()
|
final int wordCountToShow = suggestedWords.getWordCountToShow(
|
||||||
.mShouldShowUiToAcceptTypedWord;
|
Settings.getInstance().getCurrent().mShouldShowLxxSuggestionUi);
|
||||||
final int suggestionsCount = suggestedWords.size()
|
|
||||||
- (shouldShowUiToAcceptTypedWord ? /* typed word */ 1 : 0);
|
|
||||||
final int startIndexOfMoreSuggestions = setupWordViewsAndReturnStartIndexOfMoreSuggestions(
|
final int startIndexOfMoreSuggestions = setupWordViewsAndReturnStartIndexOfMoreSuggestions(
|
||||||
suggestedWords, mSuggestionsCountInStrip);
|
suggestedWords, mSuggestionsCountInStrip);
|
||||||
final TextView centerWordView = mWordViews.get(mCenterPositionInStrip);
|
final TextView centerWordView = mWordViews.get(mCenterPositionInStrip);
|
||||||
final int stripWidth = stripView.getWidth();
|
final int stripWidth = stripView.getWidth();
|
||||||
final int centerWidth = getSuggestionWidth(mCenterPositionInStrip, stripWidth);
|
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) {
|
centerWordView.getPaint()) < MIN_TEXT_XSCALE) {
|
||||||
// Layout only the most relevant suggested word at the center of the suggestion strip
|
// Layout only the most relevant suggested word at the center of the suggestion strip
|
||||||
// by consolidating all slots in the strip.
|
// by consolidating all slots in the strip.
|
||||||
final int countInStrip = 1;
|
final int countInStrip = 1;
|
||||||
mMoreSuggestionsAvailable = (suggestionsCount > countInStrip);
|
mMoreSuggestionsAvailable = (wordCountToShow > countInStrip);
|
||||||
layoutWord(mCenterPositionInStrip, stripWidth - mPadding);
|
layoutWord(mCenterPositionInStrip, stripWidth - mPadding);
|
||||||
stripView.addView(centerWordView);
|
stripView.addView(centerWordView);
|
||||||
setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
|
setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
|
@ -393,7 +391,7 @@ final class SuggestionStripLayoutHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
final int countInStrip = mSuggestionsCountInStrip;
|
final int countInStrip = mSuggestionsCountInStrip;
|
||||||
mMoreSuggestionsAvailable = (suggestionsCount > countInStrip);
|
mMoreSuggestionsAvailable = (wordCountToShow > countInStrip);
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) {
|
for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) {
|
||||||
if (positionInStrip != 0) {
|
if (positionInStrip != 0) {
|
||||||
|
@ -557,7 +555,7 @@ final class SuggestionStripLayoutHelper {
|
||||||
|
|
||||||
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) {
|
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) {
|
||||||
final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance().getCurrent()
|
final boolean shouldShowUiToAcceptTypedWord = Settings.getInstance().getCurrent()
|
||||||
.mShouldShowUiToAcceptTypedWord;
|
.mShouldShowLxxSuggestionUi;
|
||||||
final int stripWidth = addToDictionaryStrip.getWidth();
|
final int stripWidth = addToDictionaryStrip.getWidth();
|
||||||
final int width = shouldShowUiToAcceptTypedWord ? stripWidth
|
final int width = shouldShowUiToAcceptTypedWord ? stripWidth
|
||||||
: stripWidth - mDividerWidth - mPadding * 2;
|
: stripWidth - mDividerWidth - mPadding * 2;
|
||||||
|
|
Loading…
Reference in New Issue