Java Code Examples for androidx.core.view.ViewCompat#setAccessibilityLiveRegion()

The following examples show how to use androidx.core.view.ViewCompat#setAccessibilityLiveRegion() . 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: TextInputLayout.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void setPlaceholderTextEnabled(boolean placeholderEnabled) {
  // If the enabled state is the same as before, do nothing.
  if (this.placeholderEnabled == placeholderEnabled) {
    return;
  }

  // Otherwise, adjust enabled state.
  if (placeholderEnabled) {
    placeholderTextView = new AppCompatTextView(getContext());
    placeholderTextView.setId(R.id.textinput_placeholder);

    ViewCompat.setAccessibilityLiveRegion(
        placeholderTextView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);

    setPlaceholderTextAppearance(placeholderTextAppearance);
    setPlaceholderTextColor(placeholderTextColor);
    addPlaceholderTextView();
  } else {
    removePlaceholderTextView();
    placeholderTextView = null;
  }
  this.placeholderEnabled = placeholderEnabled;
}
 
Example 2
Source File: TSnackbar.java    From TSnackBar with Apache License 2.0 6 votes vote down vote up
public SnackbarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnackbarLayout);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_android_maxWidth, -1);
    mMaxInlineActionWidth = a.getDimensionPixelSize(
            R.styleable.SnackbarLayout_maxActionInlineWidth, -1);
    if (a.hasValue(R.styleable.SnackbarLayout_elevation)) {
        ViewCompat.setElevation(this, a.getDimensionPixelSize(
                R.styleable.SnackbarLayout_elevation, 0));
    }
    a.recycle();

    setClickable(true);


    LayoutInflater.from(context)
            .inflate(R.layout.tsnackbar_layout_include, this);

    ViewCompat.setAccessibilityLiveRegion(this,
            ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
}
 
Example 3
Source File: IndicatorViewController.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
void setErrorEnabled(boolean enabled) {
  // If the enabled state is the same as before, do nothing.
  if (errorEnabled == enabled) {
    return;
  }

  // Otherwise, adjust enabled state.
  cancelCaptionAnimator();

  if (enabled) {
    errorView = new AppCompatTextView(context);
    errorView.setId(R.id.textinput_error);
    if (VERSION.SDK_INT >= 17) {
      errorView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
    }
    if (typeface != null) {
      errorView.setTypeface(typeface);
    }
    setErrorTextAppearance(errorTextAppearance);
    setErrorViewTextColor(errorViewTextColor);
    setErrorContentDescription(errorViewContentDescription);
    errorView.setVisibility(View.INVISIBLE);
    ViewCompat.setAccessibilityLiveRegion(errorView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    addIndicator(errorView, ERROR_INDEX);
  } else {
    hideError();
    removeIndicator(errorView, ERROR_INDEX);
    errorView = null;
    textInputView.updateEditTextBackground();
    textInputView.updateTextInputBoxState();
  }
  errorEnabled = enabled;
}
 
Example 4
Source File: IndicatorViewController.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
void setHelperTextEnabled(boolean enabled) {
  // If the enabled state is the same as before, do nothing.
  if (helperTextEnabled == enabled) {
    return;
  }

  // Otherwise, adjust enabled state.
  cancelCaptionAnimator();

  if (enabled) {
    helperTextView = new AppCompatTextView(context);
    helperTextView.setId(R.id.textinput_helper_text);
    if (VERSION.SDK_INT >= 17) {
      helperTextView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
    }
    if (typeface != null) {
      helperTextView.setTypeface(typeface);
    }
    helperTextView.setVisibility(View.INVISIBLE);
    ViewCompat.setAccessibilityLiveRegion(
        helperTextView, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    setHelperTextAppearance(helperTextTextAppearance);
    setHelperTextViewTextColor(helperTextViewTextColor);
    addIndicator(helperTextView, HELPER_INDEX);
  } else {
    hideHelperText();
    removeIndicator(helperTextView, HELPER_INDEX);
    helperTextView = null;
    textInputView.updateEditTextBackground();
    textInputView.updateTextInputBoxState();
  }
  helperTextEnabled = enabled;
}