Java Code Examples for android.text.InputType#TYPE_TEXT_FLAG_NO_SUGGESTIONS

The following examples show how to use android.text.InputType#TYPE_TEXT_FLAG_NO_SUGGESTIONS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputAttributes.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
private static String toFlagsString(final int flags) {
    final ArrayList<String> flagsArray = new ArrayList<>();
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS))
        flagsArray.add("TYPE_TEXT_FLAG_NO_SUGGESTIONS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_MULTI_LINE))
        flagsArray.add("TYPE_TEXT_FLAG_MULTI_LINE");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE))
        flagsArray.add("TYPE_TEXT_FLAG_IME_MULTI_LINE");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_WORDS))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_WORDS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_SENTENCES");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_CHARACTERS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT))
        flagsArray.add("TYPE_TEXT_FLAG_AUTO_CORRECT");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE))
        flagsArray.add("TYPE_TEXT_FLAG_AUTO_COMPLETE");
    return flagsArray.isEmpty() ? "" : Arrays.toString(flagsArray.toArray());
}
 
Example 2
Source File: InputAttributes.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
private static String toFlagsString(final int flags) {
    final ArrayList<String> flagsArray = new ArrayList<>();
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS))
        flagsArray.add("TYPE_TEXT_FLAG_NO_SUGGESTIONS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_MULTI_LINE))
        flagsArray.add("TYPE_TEXT_FLAG_MULTI_LINE");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE))
        flagsArray.add("TYPE_TEXT_FLAG_IME_MULTI_LINE");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_WORDS))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_WORDS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_SENTENCES");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_CHARACTERS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT))
        flagsArray.add("TYPE_TEXT_FLAG_AUTO_CORRECT");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE))
        flagsArray.add("TYPE_TEXT_FLAG_AUTO_COMPLETE");
    return flagsArray.isEmpty() ? "" : Arrays.toString(flagsArray.toArray());
}
 
Example 3
Source File: MaskedEditText.java    From star-dns-changer with MIT License 6 votes vote down vote up
@Override
public void setInputType(int type) {
    if (type == -1) {
        type = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD;
    }

    if (type == InputType.TYPE_CLASS_NUMBER ||
            type == InputType.TYPE_NUMBER_FLAG_SIGNED ||
            type == InputType.TYPE_NUMBER_FLAG_DECIMAL ||
            type == InputType.TYPE_CLASS_PHONE) {
        final String symbolExceptions = getSymbolExceptions();
        this.setKeyListener(DigitsKeyListener.getInstance("0123456789." + symbolExceptions));
    } else {
        super.setInputType(type);
    }
}
 
Example 4
Source File: InputAttributes.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
private static String toFlagsString(final int flags) {
    final ArrayList<String> flagsArray = new ArrayList<>();
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS))
        flagsArray.add("TYPE_TEXT_FLAG_NO_SUGGESTIONS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_MULTI_LINE))
        flagsArray.add("TYPE_TEXT_FLAG_MULTI_LINE");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE))
        flagsArray.add("TYPE_TEXT_FLAG_IME_MULTI_LINE");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_WORDS))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_WORDS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_SENTENCES");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS))
        flagsArray.add("TYPE_TEXT_FLAG_CAP_CHARACTERS");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT))
        flagsArray.add("TYPE_TEXT_FLAG_AUTO_CORRECT");
    if (0 != (flags & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE))
        flagsArray.add("TYPE_TEXT_FLAG_AUTO_COMPLETE");
    return flagsArray.isEmpty() ? "" : Arrays.toString(flagsArray.toArray());
}
 
Example 5
Source File: SearchView.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
/**
 * Updates the auto-complete text view.
 */
private void updateSearchAutoComplete() {
    // TODO mQueryTextView.setDropDownAnimationStyle(0); // no animation
    mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
    mQueryTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mQueryTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(),
                this, mSearchable, mOutsideDrawablesCache);
        mQueryTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL
                : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}
 
Example 6
Source File: SearchView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the auto-complete text view.
 */
private void updateSearchAutoComplete() {
    mSearchSrcTextView.setDropDownAnimationStyle(0); // no animation
    mSearchSrcTextView.setThreshold(mSearchable.getSuggestThreshold());
    mSearchSrcTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mSearchSrcTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(),
                this, mSearchable, mOutsideDrawablesCache);
        mSearchSrcTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL
                : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}
 
Example 7
Source File: SearchView.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the auto-complete text view.
 */
private void updateSearchAutoComplete() {
    // TODO mQueryTextView.setDropDownAnimationStyle(0); // no animation
    mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
    mQueryTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mQueryTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(),
                this, mSearchable, mOutsideDrawablesCache);
        mQueryTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL
                : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}
 
Example 8
Source File: SearchView.java    From zen4android with MIT License 5 votes vote down vote up
/**
 * Updates the auto-complete text view.
 */
private void updateSearchAutoComplete() {
    // TODO mQueryTextView.setDropDownAnimationStyle(0); // no animation
    mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
    mQueryTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mQueryTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(),
                this, mSearchable, mOutsideDrawablesCache);
        mQueryTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL
                : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}
 
Example 9
Source File: InPlaceEditView.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
private int makeNonPredictive(int codenameOneInputType, int inputType) {
    if (isNonPredictive(codenameOneInputType)) {
        inputType = inputType | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        if (!hasConstraint(codenameOneInputType, TextArea.PASSWORD)) {
            inputType = inputType | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
        }
    }
    return inputType;
}
 
Example 10
Source File: SearchView.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Updates the auto-complete text view.
 */
private void updateSearchAutoComplete() {
    // TODO mQueryTextView.setDropDownAnimationStyle(0); // no animation
    mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
    mQueryTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mQueryTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(),
                this, mSearchable, mOutsideDrawablesCache);
        mQueryTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL
                : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}
 
Example 11
Source File: InputAttributes.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 4 votes vote down vote up
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode,
        final String packageNameForPrivateImeOptions) {
    mEditorInfo = editorInfo;
    mPackageNameForPrivateImeOptions = packageNameForPrivateImeOptions;
    mTargetApplicationPackageName = null != editorInfo ? editorInfo.packageName : null;
    final int inputType = null != editorInfo ? editorInfo.inputType : 0;
    final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
    mInputType = inputType;
    mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
            || InputTypeUtils.isVisiblePasswordInputType(inputType);
    if (inputClass != InputType.TYPE_CLASS_TEXT) {
        // If we are not looking at a TYPE_CLASS_TEXT field, the following strange
        // cases may arise, so we do a couple sanity checks for them. If it's a
        // TYPE_CLASS_TEXT field, these special cases cannot happen, by construction
        // of the flags.
        if (null == editorInfo) {
            Log.w(TAG, "No editor info for this field. Bug?");
        } else if (InputType.TYPE_NULL == inputType) {
            // TODO: We should honor TYPE_NULL specification.
            Log.i(TAG, "InputType.TYPE_NULL is specified");
        } else if (inputClass == 0) {
            // TODO: is this check still necessary?
            Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
                    + " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
        }
        mShouldShowSuggestions = false;
        mInputTypeNoAutoCorrect = false;
        mApplicationSpecifiedCompletionOn = false;
        mShouldInsertSpacesAutomatically = false;
        mShouldShowVoiceInputKey = false;
        mDisableGestureFloatingPreviewText = false;
        mIsGeneralTextInput = false;
        return;
    }
    // inputClass == InputType.TYPE_CLASS_TEXT
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    final boolean flagNoSuggestions =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    final boolean flagMultiLine =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    final boolean flagAutoCorrect =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    final boolean flagAutoComplete =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);

    // TODO: Have a helper method in InputTypeUtils
    // Make sure that passwords are not displayed in {@link SuggestionStripView}.
    final boolean shouldSuppressSuggestions = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || InputType.TYPE_TEXT_VARIATION_FILTER == variation
            || flagNoSuggestions
            || flagAutoComplete;
    mShouldShowSuggestions = !shouldSuppressSuggestions;

    mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);

    final boolean noMicrophone = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || hasNoMicrophoneKeyOption();
    mShouldShowVoiceInputKey = !noMicrophone;

    mDisableGestureFloatingPreviewText = InputAttributes.inPrivateImeOptions(
            mPackageNameForPrivateImeOptions, NO_FLOATING_GESTURE_PREVIEW, editorInfo);

    // If it's a browser edit field and auto correct is not ON explicitly, then
    // disable auto correction, but keep suggestions on.
    // If NO_SUGGESTIONS is set, don't do prediction.
    // If it's not multiline and the autoCorrect flag is not set, then don't correct
    mInputTypeNoAutoCorrect =
            (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT && !flagAutoCorrect)
            || flagNoSuggestions
            || (!flagAutoCorrect && !flagMultiLine);

    mApplicationSpecifiedCompletionOn = flagAutoComplete && isFullscreenMode;

    // If we come here, inputClass is always TYPE_CLASS_TEXT
    mIsGeneralTextInput = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS != variation
            && InputType.TYPE_TEXT_VARIATION_PASSWORD != variation
            && InputType.TYPE_TEXT_VARIATION_PHONETIC != variation
            && InputType.TYPE_TEXT_VARIATION_URI != variation
            && InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD != variation
            && InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != variation
            && InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD != variation;
}
 
Example 12
Source File: TextFieldImpl.java    From J2ME-Loader with Apache License 2.0 4 votes vote down vote up
void setConstraints(int constraints) {
	this.constraints = constraints;

	if (textview != null) {
		int inputtype;

		switch (constraints & TextField.CONSTRAINT_MASK) {
			default:
			case TextField.ANY:
				inputtype = InputType.TYPE_CLASS_TEXT;
				break;

			case TextField.EMAILADDR:
				inputtype = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
				break;

			case TextField.NUMERIC:
				inputtype = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
				break;

			case TextField.PHONENUMBER:
				inputtype = InputType.TYPE_CLASS_PHONE;
				break;

			case TextField.URL:
				inputtype = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
				break;

			case TextField.DECIMAL:
				inputtype = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL;
				break;
		}

		if ((constraints & TextField.PASSWORD) != 0 ||
				(constraints & TextField.SENSITIVE) != 0) {
			inputtype = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
		}

		if ((constraints & TextField.UNEDITABLE) != 0) {
			inputtype = InputType.TYPE_NULL;
		}

		if ((constraints & TextField.NON_PREDICTIVE) != 0) {
			inputtype |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
		}

		if ((constraints & TextField.INITIAL_CAPS_WORD) != 0) {
			inputtype |= InputType.TYPE_TEXT_FLAG_CAP_WORDS;
		}

		if ((constraints & TextField.INITIAL_CAPS_SENTENCE) != 0) {
			inputtype |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
		}

		textview.setInputType(inputtype);
		if ((constraints & TextField.CONSTRAINT_MASK) == TextField.ANY) {
			textview.setSingleLine(false);
		}
	}
}
 
Example 13
Source File: InputAttributes.java    From simple-keyboard with Apache License 2.0 4 votes vote down vote up
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode) {
    mTargetApplicationPackageName = null != editorInfo ? editorInfo.packageName : null;
    final int inputType = null != editorInfo ? editorInfo.inputType : 0;
    final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
    mInputType = inputType;
    mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
            || InputTypeUtils.isVisiblePasswordInputType(inputType);
    if (inputClass != InputType.TYPE_CLASS_TEXT) {
        // If we are not looking at a TYPE_CLASS_TEXT field, the following strange
        // cases may arise, so we do a couple sanity checks for them. If it's a
        // TYPE_CLASS_TEXT field, these special cases cannot happen, by construction
        // of the flags.
        if (null == editorInfo) {
            Log.w(TAG, "No editor info for this field. Bug?");
        } else if (InputType.TYPE_NULL == inputType) {
            // TODO: We should honor TYPE_NULL specification.
            Log.i(TAG, "InputType.TYPE_NULL is specified");
        } else if (inputClass == 0) {
            // TODO: is this check still necessary?
            Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
                    + " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
        }
        mShouldShowSuggestions = false;
        mInputTypeNoAutoCorrect = false;
        mApplicationSpecifiedCompletionOn = false;
        mShouldInsertSpacesAutomatically = false;
        return;
    }
    // inputClass == InputType.TYPE_CLASS_TEXT
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    final boolean flagNoSuggestions =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    final boolean flagMultiLine =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    final boolean flagAutoCorrect =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    final boolean flagAutoComplete =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);

    // TODO: Have a helper method in InputTypeUtils
    // Make sure that passwords are not displayed in {@link SuggestionStripView}.
    final boolean shouldSuppressSuggestions = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || InputType.TYPE_TEXT_VARIATION_FILTER == variation
            || flagNoSuggestions
            || flagAutoComplete;
    mShouldShowSuggestions = !shouldSuppressSuggestions;

    mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);

    // If it's a browser edit field and auto correct is not ON explicitly, then
    // disable auto correction, but keep suggestions on.
    // If NO_SUGGESTIONS is set, don't do prediction.
    // If it's not multiline and the autoCorrect flag is not set, then don't correct
    mInputTypeNoAutoCorrect =
            (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT && !flagAutoCorrect)
            || flagNoSuggestions
            || (!flagAutoCorrect && !flagMultiLine);

    mApplicationSpecifiedCompletionOn = flagAutoComplete && isFullscreenMode;
}
 
Example 14
Source File: InPlaceEditView.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
private int getAndroidInputType(int codenameOneInputType, boolean multiline) {
    int type = mInputTypeMap.get(codenameOneInputType, -1);
    if (type == -1) {
        
        if (!multiline && hasConstraint(codenameOneInputType, TextArea.NUMERIC)) {
            type = InputType.TYPE_CLASS_NUMBER;
        } else if (!multiline && hasConstraint(codenameOneInputType, TextArea.DECIMAL)) {
            type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED;
        } else if (!multiline && hasConstraint(codenameOneInputType, TextArea.EMAILADDR)) {
            type = makeNonPredictive(codenameOneInputType, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
            
        } else if (hasConstraint(codenameOneInputType, TextArea.INITIAL_CAPS_SENTENCE)) {
            type = makeNonPredictive(codenameOneInputType, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
            
        } else if (hasConstraint(codenameOneInputType, TextArea.INITIAL_CAPS_WORD)) {
            type = makeNonPredictive(codenameOneInputType, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

        } else if (!multiline && hasConstraint(codenameOneInputType, TextArea.PASSWORD)) {
            type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
        } else if (!multiline && hasConstraint(codenameOneInputType, TextArea.PHONENUMBER)) {
            type = makeNonPredictive(codenameOneInputType, InputType.TYPE_CLASS_PHONE);
        } else if (!multiline && hasConstraint(codenameOneInputType, TextArea.URL)) {
            type = makeNonPredictive(codenameOneInputType, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
        } else {
            type = makeNonPredictive(codenameOneInputType, InputType.TYPE_CLASS_TEXT);
        }
    }

    // If we're editing standard text, disable auto complete.
    // The name of the flag is a little misleading. From the docs:
    // the text editor is performing auto-completion of the text being entered
    // based on its own semantics, which it will present to the user as they type.
    // This generally means that the input method should not be showing candidates itself,
    // but can expect for the editor to supply its own completions/candidates from
    // InputMethodSession.displayCompletions().
    if ((type & InputType.TYPE_CLASS_TEXT) != 0 && (type & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) == 0) {
        type |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
    }
    if (multiline) {
        type |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
    }
    return type;
}
 
Example 15
Source File: InputAttributes.java    From Indic-Keyboard with Apache License 2.0 4 votes vote down vote up
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode,
        final String packageNameForPrivateImeOptions) {
    mEditorInfo = editorInfo;
    mPackageNameForPrivateImeOptions = packageNameForPrivateImeOptions;
    mTargetApplicationPackageName = null != editorInfo ? editorInfo.packageName : null;
    final int inputType = null != editorInfo ? editorInfo.inputType : 0;
    final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
    mInputType = inputType;
    mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
            || InputTypeUtils.isVisiblePasswordInputType(inputType);
    if (inputClass != InputType.TYPE_CLASS_TEXT) {
        // If we are not looking at a TYPE_CLASS_TEXT field, the following strange
        // cases may arise, so we do a couple sanity checks for them. If it's a
        // TYPE_CLASS_TEXT field, these special cases cannot happen, by construction
        // of the flags.
        if (null == editorInfo) {
            Log.w(TAG, "No editor info for this field. Bug?");
        } else if (InputType.TYPE_NULL == inputType) {
            // TODO: We should honor TYPE_NULL specification.
            Log.i(TAG, "InputType.TYPE_NULL is specified");
        } else if (inputClass == 0) {
            // TODO: is this check still necessary?
            Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
                    + " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
        }
        mShouldShowSuggestions = false;
        mInputTypeNoAutoCorrect = false;
        mApplicationSpecifiedCompletionOn = false;
        mShouldInsertSpacesAutomatically = false;
        mShouldShowVoiceInputKey = false;
        mDisableGestureFloatingPreviewText = false;
        mIsGeneralTextInput = false;
        mNoLearning = false;
        return;
    }
    // inputClass == InputType.TYPE_CLASS_TEXT
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    final boolean flagNoSuggestions =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    final boolean flagMultiLine =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    final boolean flagAutoCorrect =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    final boolean flagAutoComplete =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);

    // TODO: Have a helper method in InputTypeUtils
    // Make sure that passwords are not displayed in {@link SuggestionStripView}.
    final boolean shouldSuppressSuggestions = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || InputType.TYPE_TEXT_VARIATION_FILTER == variation
            || flagNoSuggestions
            || flagAutoComplete;
    mShouldShowSuggestions = !shouldSuppressSuggestions;

    mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);

    final boolean noMicrophone = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || hasNoMicrophoneKeyOption();
    mShouldShowVoiceInputKey = !noMicrophone;

    mDisableGestureFloatingPreviewText = InputAttributes.inPrivateImeOptions(
            mPackageNameForPrivateImeOptions, NO_FLOATING_GESTURE_PREVIEW, editorInfo);

    // If it's a browser edit field and auto correct is not ON explicitly, then
    // disable auto correction, but keep suggestions on.
    // If NO_SUGGESTIONS is set, don't do prediction.
    // If it's not multiline and the autoCorrect flag is not set, then don't correct
    mInputTypeNoAutoCorrect =
            (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT && !flagAutoCorrect)
            || flagNoSuggestions
            || (!flagAutoCorrect && !flagMultiLine);

    mApplicationSpecifiedCompletionOn = flagAutoComplete && isFullscreenMode;

    // If we come here, inputClass is always TYPE_CLASS_TEXT
    mIsGeneralTextInput = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS != variation
            && InputType.TYPE_TEXT_VARIATION_PASSWORD != variation
            && InputType.TYPE_TEXT_VARIATION_PHONETIC != variation
            && InputType.TYPE_TEXT_VARIATION_URI != variation
            && InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD != variation
            && InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != variation
            && InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD != variation;

    mNoLearning = (editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING) != 0;
}
 
Example 16
Source File: HexKeyListener.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public int getInputType() {
	return InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
}
 
Example 17
Source File: InputAttributes.java    From LokiBoard-Android-Keylogger with Apache License 2.0 4 votes vote down vote up
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode) {
    mTargetApplicationPackageName = null != editorInfo ? editorInfo.packageName : null;
    final int inputType = null != editorInfo ? editorInfo.inputType : 0;
    final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
    mInputType = inputType;
    mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
            || InputTypeUtils.isVisiblePasswordInputType(inputType);
    if (inputClass != InputType.TYPE_CLASS_TEXT) {
        // If we are not looking at a TYPE_CLASS_TEXT field, the following strange
        // cases may arise, so we do a couple sanity checks for them. If it's a
        // TYPE_CLASS_TEXT field, these special cases cannot happen, by construction
        // of the flags.
        if (null == editorInfo) {
            Log.w(TAG, "No editor info for this field. Bug?");
        } else if (InputType.TYPE_NULL == inputType) {
            // TODO: We should honor TYPE_NULL specification.
            Log.i(TAG, "InputType.TYPE_NULL is specified");
        } else if (inputClass == 0) {
            // TODO: is this check still necessary?
            Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
                    + " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
        }
        mShouldShowSuggestions = false;
        mInputTypeNoAutoCorrect = false;
        mApplicationSpecifiedCompletionOn = false;
        mShouldInsertSpacesAutomatically = false;
        return;
    }
    // inputClass == InputType.TYPE_CLASS_TEXT
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    final boolean flagNoSuggestions =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    final boolean flagMultiLine =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    final boolean flagAutoCorrect =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    final boolean flagAutoComplete =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);

    // TODO: Have a helper method in InputTypeUtils
    // Make sure that passwords are not displayed in {@link SuggestionStripView}.
    final boolean shouldSuppressSuggestions = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || InputType.TYPE_TEXT_VARIATION_FILTER == variation
            || flagNoSuggestions
            || flagAutoComplete;
    mShouldShowSuggestions = !shouldSuppressSuggestions;

    mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);

    // If it's a browser edit field and auto correct is not ON explicitly, then
    // disable auto correction, but keep suggestions on.
    // If NO_SUGGESTIONS is set, don't do prediction.
    // If it's not multiline and the autoCorrect flag is not set, then don't correct
    mInputTypeNoAutoCorrect =
            (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT && !flagAutoCorrect)
            || flagNoSuggestions
            || (!flagAutoCorrect && !flagMultiLine);

    mApplicationSpecifiedCompletionOn = flagAutoComplete && isFullscreenMode;
}
 
Example 18
Source File: KeyboardKeyListener.java    From BluetoothHidEmu with Apache License 2.0 4 votes vote down vote up
@Override
public int getInputType() {
    return InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
}
 
Example 19
Source File: InputAttributes.java    From openboard with GNU General Public License v3.0 4 votes vote down vote up
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode,
        final String packageNameForPrivateImeOptions) {
    mEditorInfo = editorInfo;
    mPackageNameForPrivateImeOptions = packageNameForPrivateImeOptions;
    mTargetApplicationPackageName = null != editorInfo ? editorInfo.packageName : null;
    final int inputType = null != editorInfo ? editorInfo.inputType : 0;
    final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
    mInputType = inputType;
    mIsPasswordField = InputTypeUtils.isPasswordInputType(inputType)
            || InputTypeUtils.isVisiblePasswordInputType(inputType);
    if (inputClass != InputType.TYPE_CLASS_TEXT) {
        // If we are not looking at a TYPE_CLASS_TEXT field, the following strange
        // cases may arise, so we do a couple sanity checks for them. If it's a
        // TYPE_CLASS_TEXT field, these special cases cannot happen, by construction
        // of the flags.
        if (null == editorInfo) {
            Log.w(TAG, "No editor info for this field. Bug?");
        } else if (InputType.TYPE_NULL == inputType) {
            // TODO: We should honor TYPE_NULL specification.
            Log.i(TAG, "InputType.TYPE_NULL is specified");
        } else if (inputClass == 0) {
            // TODO: is this check still necessary?
            Log.w(TAG, String.format("Unexpected input class: inputType=0x%08x"
                    + " imeOptions=0x%08x", inputType, editorInfo.imeOptions));
        }
        mShouldShowSuggestions = false;
        mInputTypeNoAutoCorrect = false;
        mApplicationSpecifiedCompletionOn = false;
        mShouldInsertSpacesAutomatically = false;
        mShouldShowVoiceInputKey = false;
        mDisableGestureFloatingPreviewText = false;
        mIsGeneralTextInput = false;
        mNoLearning = false;
        return;
    }
    // inputClass == InputType.TYPE_CLASS_TEXT
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    final boolean flagNoSuggestions =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    final boolean flagMultiLine =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    final boolean flagAutoCorrect =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
    final boolean flagAutoComplete =
            0 != (inputType & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);

    // TODO: Have a helper method in InputTypeUtils
    // Make sure that passwords are not displayed in {@link SuggestionStripView}.
    final boolean shouldSuppressSuggestions = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || InputType.TYPE_TEXT_VARIATION_FILTER == variation
            //|| flagNoSuggestions
            || flagAutoComplete;
    mShouldShowSuggestions = !shouldSuppressSuggestions;

    mShouldInsertSpacesAutomatically = InputTypeUtils.isAutoSpaceFriendlyType(inputType);

    final boolean noMicrophone = mIsPasswordField
            || InputTypeUtils.isEmailVariation(variation)
            || InputType.TYPE_TEXT_VARIATION_URI == variation
            || hasNoMicrophoneKeyOption();
    mShouldShowVoiceInputKey = !noMicrophone;

    mDisableGestureFloatingPreviewText = InputAttributes.inPrivateImeOptions(
            mPackageNameForPrivateImeOptions, NO_FLOATING_GESTURE_PREVIEW, editorInfo);

    // If it's a browser edit field and auto correct is not ON explicitly, then
    // disable auto correction, but keep suggestions on.
    // If NO_SUGGESTIONS is set, don't do prediction.
    // If it's not multiline and the autoCorrect flag is not set, then don't correct
    mInputTypeNoAutoCorrect =
            (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT && !flagAutoCorrect)
            || flagNoSuggestions
            || (!flagAutoCorrect && !flagMultiLine);

    mApplicationSpecifiedCompletionOn = flagAutoComplete && isFullscreenMode;

    // If we come here, inputClass is always TYPE_CLASS_TEXT
    mIsGeneralTextInput = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS != variation
            && InputType.TYPE_TEXT_VARIATION_PASSWORD != variation
            && InputType.TYPE_TEXT_VARIATION_PHONETIC != variation
            && InputType.TYPE_TEXT_VARIATION_URI != variation
            && InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD != variation
            && InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != variation
            && InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD != variation;

    mNoLearning = (editorInfo.imeOptions & EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING) != 0;
}