Search in sources :

Example 16 with SettingsValues

use of com.android.inputmethod.latin.settings.SettingsValues in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class LatinIME method setSuggestedWords.

private void setSuggestedWords(final SuggestedWords suggestedWords) {
    final SettingsValues currentSettingsValues = mSettings.getCurrent();
    mInputLogic.setSuggestedWords(suggestedWords);
    // TODO: Modify this when we support suggestions with hard keyboard
    if (!hasSuggestionStripView()) {
        return;
    }
    if (!onEvaluateInputViewShown()) {
        return;
    }
    final boolean shouldShowImportantNotice = ImportantNoticeUtils.shouldShowImportantNotice(this, currentSettingsValues);
    final boolean shouldShowSuggestionCandidates = currentSettingsValues.mInputAttributes.mShouldShowSuggestions && currentSettingsValues.isSuggestionsEnabledPerUserSettings();
    final boolean shouldShowSuggestionsStripUnlessPassword = shouldShowImportantNotice || currentSettingsValues.mShowsVoiceInputKey || shouldShowSuggestionCandidates || currentSettingsValues.isApplicationSpecifiedCompletionsOn();
    final boolean shouldShowSuggestionsStrip = shouldShowSuggestionsStripUnlessPassword && !currentSettingsValues.mInputAttributes.mIsPasswordField;
    mSuggestionStripView.updateVisibility(shouldShowSuggestionsStrip, isFullscreenMode());
    if (!shouldShowSuggestionsStrip) {
        return;
    }
    final boolean isEmptyApplicationSpecifiedCompletions = currentSettingsValues.isApplicationSpecifiedCompletionsOn() && suggestedWords.isEmpty();
    final boolean noSuggestionsFromDictionaries = suggestedWords.isEmpty() || suggestedWords.isPunctuationSuggestions() || isEmptyApplicationSpecifiedCompletions;
    final boolean isBeginningOfSentencePrediction = (suggestedWords.mInputStyle == SuggestedWords.INPUT_STYLE_BEGINNING_OF_SENTENCE_PREDICTION);
    final boolean noSuggestionsToOverrideImportantNotice = noSuggestionsFromDictionaries || isBeginningOfSentencePrediction;
    if (shouldShowImportantNotice && noSuggestionsToOverrideImportantNotice) {
        if (mSuggestionStripView.maybeShowImportantNoticeTitle()) {
            return;
        }
    }
    if (currentSettingsValues.isSuggestionsEnabledPerUserSettings() || currentSettingsValues.isApplicationSpecifiedCompletionsOn() || // We should clear the contextual strip if there is no suggestion from dictionaries.
    noSuggestionsFromDictionaries) {
        mSuggestionStripView.setSuggestions(suggestedWords, mRichImm.getCurrentSubtype().isRtlSubtype());
    }
}
Also used : SettingsValues(com.android.inputmethod.latin.settings.SettingsValues)

Example 17 with SettingsValues

use of com.android.inputmethod.latin.settings.SettingsValues in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class SuggestionStripLayoutHelper method getPositionInSuggestionStrip.

/**
 * Convert an index of {@link SuggestedWords} to position in the suggestion strip.
 * @param indexInSuggestedWords the index of {@link SuggestedWords}.
 * @param suggestedWords the suggested words list
 * @return Non-negative integer of the position in the suggestion strip.
 *         Negative integer if the word of the index shouldn't be shown on the suggestion strip.
 */
private int getPositionInSuggestionStrip(final int indexInSuggestedWords, final SuggestedWords suggestedWords) {
    final SettingsValues settingsValues = Settings.getInstance().getCurrent();
    final boolean shouldOmitTypedWord = shouldOmitTypedWord(suggestedWords.mInputStyle, settingsValues.mGestureFloatingPreviewTextEnabled, settingsValues.mShouldShowLxxSuggestionUi);
    return getPositionInSuggestionStrip(indexInSuggestedWords, suggestedWords.mWillAutoCorrect, settingsValues.mShouldShowLxxSuggestionUi && shouldOmitTypedWord, mCenterPositionInStrip, mTypedWordPositionWhenAutocorrect);
}
Also used : SettingsValues(com.android.inputmethod.latin.settings.SettingsValues)

Example 18 with SettingsValues

use of com.android.inputmethod.latin.settings.SettingsValues in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class SuggestionStripView method updateVisibility.

public void updateVisibility(final boolean shouldBeVisible, final boolean isFullscreenMode) {
    final int visibility = shouldBeVisible ? VISIBLE : (isFullscreenMode ? GONE : INVISIBLE);
    setVisibility(visibility);
    final SettingsValues currentSettingsValues = Settings.getInstance().getCurrent();
    mVoiceKey.setVisibility(currentSettingsValues.mShowsVoiceInputKey ? VISIBLE : INVISIBLE);
}
Also used : SettingsValues(com.android.inputmethod.latin.settings.SettingsValues)

Example 19 with SettingsValues

use of com.android.inputmethod.latin.settings.SettingsValues in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class SuggestionStripView method maybeShowImportantNoticeTitle.

// This method checks if we should show the important notice (checks on permanent storage if
// it has been shown once already or not, and if in the setup wizard). If applicable, it shows
// the notice. In all cases, it returns true if it was shown, false otherwise.
public boolean maybeShowImportantNoticeTitle() {
    final SettingsValues currentSettingsValues = Settings.getInstance().getCurrent();
    if (!ImportantNoticeUtils.shouldShowImportantNotice(getContext(), currentSettingsValues)) {
        return false;
    }
    if (getWidth() <= 0) {
        return false;
    }
    final String importantNoticeTitle = ImportantNoticeUtils.getSuggestContactsNoticeTitle(getContext());
    if (TextUtils.isEmpty(importantNoticeTitle)) {
        return false;
    }
    if (isShowingMoreSuggestionPanel()) {
        dismissMoreSuggestionsPanel();
    }
    mLayoutHelper.layoutImportantNotice(mImportantNoticeStrip, importantNoticeTitle);
    mStripVisibilityGroup.showImportantNoticeStrip();
    mImportantNoticeStrip.setOnClickListener(this);
    return true;
}
Also used : SettingsValues(com.android.inputmethod.latin.settings.SettingsValues)

Aggregations

SettingsValues (com.android.inputmethod.latin.settings.SettingsValues)19 EditorInfo (android.view.inputmethod.EditorInfo)3 UsedForTesting (com.android.inputmethod.annotations.UsedForTesting)2 MainKeyboardView (com.android.inputmethod.keyboard.MainKeyboardView)2 SpannableString (android.text.SpannableString)1 PrintWriterPrinter (android.util.PrintWriterPrinter)1 Printer (android.util.Printer)1 View (android.view.View)1 AccessibilityUtils (com.android.inputmethod.accessibility.AccessibilityUtils)1 Keyboard (com.android.inputmethod.keyboard.Keyboard)1 KeyboardSwitcher (com.android.inputmethod.keyboard.KeyboardSwitcher)1 SuggestionStripView (com.android.inputmethod.latin.suggestions.SuggestionStripView)1 Locale (java.util.Locale)1