Java Code Examples for android.support.v4.view.ViewCompat#setAccessibilityLiveRegion()

The following examples show how to use android.support.v4.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: Floaty.java    From Floaty with Apache License 2.0 5 votes vote down vote up
private Floaty(ViewGroup parent, View content) {
    if (parent == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null parent");
    }
    if (content == null) {
        throw new IllegalArgumentException("Transient bottom bar must have non-null content");
    }

    targetParent = parent;
    context = parent.getContext();
    view = (FloatyContentLayout) content;

    stage = Stage.of(targetParent);

    ViewCompat.setAccessibilityLiveRegion(stage, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(stage, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    stage.setFitsSystemWindows(true);
    ViewCompat.setOnApplyWindowInsetsListener(stage,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
                @Override
                public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                    // Copy over the bottom inset as padding so that we're displayed
                    // above the navigation bar
                    v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(),
                            insets.getSystemWindowInsetBottom());
                    return insets;
                }
            });

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

    scene = new Scene(stage, view);
}
 
Example 2
Source File: SweetSnackbar.java    From SweetTips with Apache License 2.0 5 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);

    // Now inflate our content. We need to do this manually rather than using an <include>
    // in the layout since older versions of the Android do not inflate includes with
    // the correct Context.
    LayoutInflater.from(context).inflate(com.jet.sweettips.R.layout.sweet_layout_snackbar_include, this);

    ViewCompat.setAccessibilityLiveRegion(this,
            ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(this,
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    ViewCompat.setFitsSystemWindows(this, true);
    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            // Copy over the bottom inset as padding so that we're displayed above the
            // navigation bar
            v.setPadding(v.getPaddingLeft(), v.getPaddingTop(),
                    v.getPaddingRight(), insets.getSystemWindowInsetBottom());
            return insets;
        }
    });
}
 
Example 3
Source File: ToolbarProgressBar.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a toolbar progress bar.
 *
 * @param context the application environment.
 * @param attrs the xml attributes that should be used to initialize this view.
 */
public ToolbarProgressBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    setAlpha(0.0f);

    // This tells accessibility services that progress bar changes are important enough to
    // announce to the user even when not focused.
    ViewCompat.setAccessibilityLiveRegion(this, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
}
 
Example 4
Source File: ToolbarProgressBar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a toolbar progress bar.
 *
 * @param context the application environment.
 * @param attrs the xml attributes that should be used to initialize this view.
 */
public ToolbarProgressBar(Context context, AttributeSet attrs) {
    super(context, attrs);
    setAlpha(0.0f);

    // This tells accessibility services that progress bar changes are important enough to
    // announce to the user even when not focused.
    ViewCompat.setAccessibilityLiveRegion(this, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
}
 
Example 5
Source File: SweetSnackbar.java    From SweetTips with Apache License 2.0 5 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);

    // Now inflate our content. We need to do this manually rather than using an <include>
    // in the layout since older versions of the Android do not inflate includes with
    // the correct Context.
    LayoutInflater.from(context).inflate(com.jet.sweettips.R.layout.sweet_layout_snackbar_include, this);

    ViewCompat.setAccessibilityLiveRegion(this,
            ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
    ViewCompat.setImportantForAccessibility(this,
            ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    // Make sure that we fit system windows and have a listener to apply any insets
    ViewCompat.setFitsSystemWindows(this, true);
    ViewCompat.setOnApplyWindowInsetsListener(this,
            new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            // Copy over the bottom inset as padding so that we're displayed above the
            // navigation bar
            v.setPadding(v.getPaddingLeft(), v.getPaddingTop(),
                    v.getPaddingRight(), insets.getSystemWindowInsetBottom());
            return insets;
        }
    });
}
 
Example 6
Source File: ToolbarProgressBar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a toolbar progress bar.
 *
 * @param context The application environment.
 * @param height The height of the progress bar in px.
 * @param topMargin The top margin of the progress bar.
 * @param useStatusBarColorAsBackground Whether or not to use the status bar color as the
 *                                      background of the toolbar.
 */
public ToolbarProgressBar(
        Context context, int height, int topMargin, boolean useStatusBarColorAsBackground) {
    super(context, height);
    setAlpha(0.0f);
    mMarginTop = topMargin;
    mUseStatusBarColorAsBackground = useStatusBarColorAsBackground;

    // This tells accessibility services that progress bar changes are important enough to
    // announce to the user even when not focused.
    ViewCompat.setAccessibilityLiveRegion(this, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE);
}