Java Code Examples for android.text.InputType#TYPE_NULL

The following examples show how to use android.text.InputType#TYPE_NULL . 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: CreditEntryFieldBase.java    From CreditCardEntry with MIT License 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(@NonNull EditorInfo outAttrs) {
	outAttrs.actionLabel = null;
	outAttrs.inputType = InputType.TYPE_NULL;
	outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE;
	return new BackInputConnection(super.onCreateInputConnection(outAttrs));
}
 
Example 2
Source File: AbstractEditComponent.java    From weex-uikit with MIT License 5 votes vote down vote up
private int getInputType(String type) {
  int inputType;
  switch (type) {
    case Constants.Value.TEXT:
      inputType = InputType.TYPE_CLASS_TEXT;
      break;
    case Constants.Value.DATE:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.DATETIME:
      inputType = InputType.TYPE_CLASS_DATETIME;
      break;
    case Constants.Value.EMAIL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
      break;
    case Constants.Value.PASSWORD:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
      getHostView().setTransformationMethod(PasswordTransformationMethod.getInstance());
      break;
    case Constants.Value.TEL:
      inputType = InputType.TYPE_CLASS_PHONE;
      break;
    case Constants.Value.TIME:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.URL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      break;
    default:
      inputType = InputType.TYPE_CLASS_TEXT;
  }
  return inputType;
}
 
Example 3
Source File: SoftKeyboard.java    From AndroidKeyboard with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Helper to update the shift state of our keyboard based on the initial
 * editor state.
 */
private void updateShiftKeyState(EditorInfo attr) {
    if (attr != null
            && mInputView != null && mQwertyKeyboard == mInputView.getKeyboard()) {
        int caps = 0;
        EditorInfo ei = getCurrentInputEditorInfo();
        if (ei != null && ei.inputType != InputType.TYPE_NULL) {
            caps = getCurrentInputConnection().getCursorCapsMode(attr.inputType);
        }
        mInputView.setShifted(mCapsLock || caps != 0);

        // Change Shift key icon - 2
        updateShiftIcon();
    }
}
 
Example 4
Source File: AbstractEditComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private int getInputType(String type) {
  int inputType;
  switch (type) {
    case Constants.Value.TEXT:
      inputType = InputType.TYPE_CLASS_TEXT;
      break;
    case Constants.Value.DATE:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.DATETIME:
      inputType = InputType.TYPE_CLASS_DATETIME;
      break;
    case Constants.Value.EMAIL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
      break;
    case Constants.Value.PASSWORD:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
      getHostView().setTransformationMethod(PasswordTransformationMethod.getInstance());
      break;
    case Constants.Value.TEL:
      inputType = InputType.TYPE_CLASS_PHONE;
      break;
    case Constants.Value.TIME:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.URL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      break;
    case Constants.Value.NUMBER:
      inputType = InputType.TYPE_CLASS_NUMBER;
      break;
    default:
      inputType = InputType.TYPE_CLASS_TEXT;
  }
  return inputType;
}
 
Example 5
Source File: RSCBitmapSurfaceView.java    From Game with GNU General Public License v3.0 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo editorinfo) {
	BaseInputConnection bic = new BaseInputConnection(this, false);
	editorinfo.actionLabel = null;
	editorinfo.inputType = InputType.TYPE_NULL;
	editorinfo.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN;
	bic.finishComposingText();
	return bic;
}
 
Example 6
Source File: SingleEditSetting.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
private void initialize(Context aContext) {
    inflate(aContext, R.layout.setting_edit, this);

    mAudio = AudioEngine.fromContext(aContext);

    mDescriptionView = findViewById(R.id.setting_description);
    mDescriptionView.setText(mDescription);

    mText1 = findViewById(R.id.textValue1);
    mText1.setOnClickListener(mText1ClickListener);

    mEdit1 = findViewById(R.id.editValue1);
    mEdit1.setHighlightedTextColor(mHighlightedTextColor);
    mEdit1.setOnEditorActionListener(mInternalEditorActionListener);

    if (mMaxLength != 0) {
        mEdit1.setFilters(new InputFilter[]{
                new InputFilter.LengthFilter(mMaxLength)
        });
    }
    if (mInputType != InputType.TYPE_NULL) {
        mEdit1.setInputType(mInputType);
    }
    if (mWidth > 0) {
        mEdit1.setWidth((int)mWidth);
    }

    mButton = findViewById(R.id.settingButton);
    mButton.setOnClickListener(mInternalClickListener);
}
 
Example 7
Source File: InputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Called when the fullscreen-mode extracting editor info has changed,
 * to determine whether the extracting (extract text and candidates) portion
 * of the UI should be shown.  The standard implementation hides or shows
 * the extract area depending on whether it makes sense for the
 * current editor.  In particular, a {@link InputType#TYPE_NULL}
 * input type or {@link EditorInfo#IME_FLAG_NO_EXTRACT_UI} flag will
 * turn off the extract area since there is no text to be shown.
 */
public void onUpdateExtractingVisibility(EditorInfo ei) {
    if (ei.inputType == InputType.TYPE_NULL ||
            (ei.imeOptions&EditorInfo.IME_FLAG_NO_EXTRACT_UI) != 0) {
        // No reason to show extract UI!
        setExtractViewShown(false);
        return;
    }
    
    setExtractViewShown(true);
}
 
Example 8
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 9
Source File: InputAttributes.java    From LokiBoard-Android-Keylogger with Apache License 2.0 4 votes vote down vote up
public boolean isTypeNull() {
    return InputType.TYPE_NULL == mInputType;
}
 
Example 10
Source File: InputAttributes.java    From Indic-Keyboard with Apache License 2.0 4 votes vote down vote up
public boolean isTypeNull() {
    return InputType.TYPE_NULL == mInputType;
}
 
Example 11
Source File: InputAttributes.java    From openboard with GNU General Public License v3.0 4 votes vote down vote up
public boolean isTypeNull() {
    return InputType.TYPE_NULL == mInputType;
}
 
Example 12
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;
}
 
Example 13
Source File: RuleViewModel.java    From Jockey with Apache License 2.0 4 votes vote down vote up
@Bindable
public int getValueTextVisibility() {
    return (mEnumeratedRule.getInputType() != InputType.TYPE_NULL) ? View.VISIBLE : View.GONE;
}
 
Example 14
Source File: InputAttributes.java    From simple-keyboard with Apache License 2.0 4 votes vote down vote up
public boolean isTypeNull() {
    return InputType.TYPE_NULL == mInputType;
}
 
Example 15
Source File: TextKeyListener.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public int getInputType() {
    return InputType.TYPE_NULL;
}
 
Example 16
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 17
Source File: InputAttributes.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 4 votes vote down vote up
public boolean isTypeNull() {
    return InputType.TYPE_NULL == mInputType;
}
 
Example 18
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 19
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 20
Source File: MaterialAutoCompleteTextView.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
public MaterialAutoCompleteTextView(
    @NonNull Context context, @Nullable AttributeSet attributeSet, int defStyleAttr) {
  super(wrap(context, attributeSet, defStyleAttr, 0), attributeSet, defStyleAttr);
  // Ensure we are using the correctly themed context rather than the context that was passed in.
  context = getContext();

  TypedArray attributes =
      ThemeEnforcement.obtainStyledAttributes(
          context,
          attributeSet,
          R.styleable.MaterialAutoCompleteTextView,
          defStyleAttr,
          R.style.Widget_AppCompat_AutoCompleteTextView);

  // Due to a framework bug, setting android:inputType="none" on xml has no effect. Therefore,
  // we check it here in case the autoCompleteTextView should be non-editable.
  if (attributes.hasValue(R.styleable.MaterialAutoCompleteTextView_android_inputType)) {
    int inputType =
        attributes.getInt(
            R.styleable.MaterialAutoCompleteTextView_android_inputType, InputType.TYPE_NULL);
    if (inputType == InputType.TYPE_NULL) {
      setKeyListener(null);
    }
  }

  accessibilityManager =
      (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

  modalListPopup = new ListPopupWindow(context);
  modalListPopup.setModal(true);
  modalListPopup.setAnchorView(this);
  modalListPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
  modalListPopup.setAdapter(getAdapter());
  modalListPopup.setOnItemClickListener(
      new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View selectedView, int position, long id) {
          Object selectedItem =
              position < 0 ? modalListPopup.getSelectedItem() : getAdapter().getItem(position);

          updateText(selectedItem);

          OnItemClickListener userOnitemClickListener = getOnItemClickListener();
          if (userOnitemClickListener != null) {
            if (selectedView == null || position < 0) {
              selectedView = modalListPopup.getSelectedView();
              position = modalListPopup.getSelectedItemPosition();
              id = modalListPopup.getSelectedItemId();
            }
            userOnitemClickListener.onItemClick(
                modalListPopup.getListView(), selectedView, position, id);
          }

          modalListPopup.dismiss();
        }
      });

  attributes.recycle();
}