Example usage for android.support.v4.view ViewCompat setAccessibilityDelegate

List of usage examples for android.support.v4.view ViewCompat setAccessibilityDelegate

Introduction

In this page you can find the example usage for android.support.v4.view ViewCompat setAccessibilityDelegate.

Prototype

public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) 

Source Link

Document

Sets a delegate for implementing accessibility support via compositon as opposed to inheritance.

Usage

From source file:com.matthewlogan.reversedrawerlayout.library.ReverseDrawerLayout.java

public ReverseDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final float density = getResources().getDisplayMetrics().density;

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ReverseDrawerLayout, 0, 0);
    try {// ww  w  .jav a 2 s.  c  o m
        mDrawerOverhang = (int) a.getDimension(R.styleable.ReverseDrawerLayout_drawerOverhang,
                (int) (DRAWER_OVERHANG * density + 0.5f));
    } finally {
        a.recycle();
    }

    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
}

From source file:com.mojtaba.materialdatetimepicker.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;//from  w w w.  j  a  v a 2s .c  o  m
    Resources res = context.getResources();

    mDayLabelCalendar = new PersianCalendar();
    mPersianCalendar = new PersianCalendar();

    mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif);

    boolean darkTheme = mController != null && mController.isThemeDark();
    if (darkTheme) {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal_dark_theme);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme);
        mDisabledDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_disabled_dark_theme);
        mHighlightedDayTextColor = ContextCompat.getColor(context,
                R.color.mdtp_date_picker_text_highlighted_dark_theme);
    } else {
        mDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_normal);
        mMonthDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day);
        mDisabledDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled);
        mHighlightedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_highlighted);
    }
    mSelectedDayTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mTodayNumberColor = mController.getAccentColor();
    mMonthTitleColor = ContextCompat.getColor(context, R.color.mdtp_white);

    mStringBuilder = new StringBuilder(50);
    mFormatter = new Formatter(mStringBuilder, Locale.getDefault());

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height)
            - getMonthHeaderSize()) / MAX_NUM_ROWS;

    // Set up accessibility components.
    mTouchHelper = getMonthViewTouchHelper();
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);
    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    mLockAccessibilityDelegate = true;

    // Sets up any standard paints that will be used
    initView();
}

From source file:com.grottworkshop.gwsmaterialdaterangepicker.date.MonthView.java

@SuppressWarnings("deprecation")
public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;// w  ww.ja v a2  s .  c  o m
    Resources res = context.getResources();

    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();

    mDayOfWeekTypeface = res.getString(R.string.mdtp_day_of_week_label_typeface);
    mMonthTitleTypeface = res.getString(R.string.mdtp_sans_serif);

    boolean darkTheme = mController != null && mController.isThemeDark();
    if (darkTheme) {
        //TODO: getColor(int) depreciated
        mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal_dark_theme);
        //TODO: getColor(int) depreciated
        mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day_dark_theme);
        //TODO: getColor(int) depreciated
        mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled_dark_theme);
        //TODO: getColor(int) depreciated
        mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted_dark_theme);
    } else {
        //TODO: getColor(int) depreciated
        mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal);
        //TODO: getColor(int) depreciated
        mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day);
        //TODO: getColor(int) depreciated
        mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled);
        //TODO: getColor(int) depreciated
        mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted);
    }
    //TODO: getColor(int) depreciated
    mSelectedDayTextColor = res.getColor(R.color.mdtp_white);
    //TODO: getColor(int) depreciated
    mTodayNumberColor = res.getColor(R.color.mdtp_accent_color);
    //TODO: getColor(int) depreciated
    mMonthTitleColor = res.getColor(R.color.mdtp_white);

    mStringBuilder = new StringBuilder(50);
    mFormatter = new Formatter(mStringBuilder, Locale.getDefault());

    MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_size);
    MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_month_day_label_text_size);
    MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.mdtp_month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.mdtp_day_number_select_circle_radius);

    mRowHeight = (res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height)
            - getMonthHeaderSize()) / MAX_NUM_ROWS;

    // Set up accessibility components.
    mTouchHelper = getMonthViewTouchHelper();
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);
    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    mLockAccessibilityDelegate = true;

    // Sets up any standard paints that will be used
    initView();
}

From source file:com.android.screenspeak.contextmenu.RadialMenuView.java

public RadialMenuView(Context context, RadialMenu menu, boolean useNodeProvider) {
    super(context);

    mRootMenu = menu;//from   w w w  . jav  a  2s.c  o  m
    mRootMenu.setLayoutListener(new RadialMenu.MenuLayoutListener() {
        @Override
        public void onLayoutChanged() {
            invalidate();
        }
    });

    mPaint = new Paint();
    mPaint.setAntiAlias(true);

    mHandler = new LongPressHandler(context);
    mHandler.setListener(new LongPressHandler.LongPressListener() {
        @Override
        public void onLongPress() {
            onItemLongPressed(mFocusedItem);
        }
    });

    final SurfaceHolder holder = getHolder();
    holder.setFormat(PixelFormat.TRANSLUCENT);
    holder.addCallback(new SurfaceHolder.Callback() {
        @Override
        public void surfaceCreated(SurfaceHolder holder) {
            mHolder = holder;
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
            mHolder = null;
        }

        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
            invalidate();
        }
    });

    final Resources res = context.getResources();
    final ViewConfiguration config = ViewConfiguration.get(context);

    mSingleTapRadiusSq = config.getScaledTouchSlop();

    // Dimensions.
    mInnerRadius = res.getDimensionPixelSize(R.dimen.inner_radius);
    mOuterRadius = res.getDimensionPixelSize(R.dimen.outer_radius);
    mCornerRadius = res.getDimensionPixelSize(R.dimen.corner_radius);
    mExtremeRadius = res.getDimensionPixelSize(R.dimen.extreme_radius);
    mSpacing = res.getDimensionPixelOffset(R.dimen.spacing);
    mTextSize = res.getDimensionPixelSize(R.dimen.text_size);
    mTextShadowRadius = res.getDimensionPixelSize(R.dimen.text_shadow_radius);
    mShadowRadius = res.getDimensionPixelSize(R.dimen.shadow_radius);

    // Colors.
    mOuterFillColor = res.getColor(R.color.outer_fill);
    mTextFillColor = res.getColor(R.color.text_fill);
    mCornerFillColor = res.getColor(R.color.corner_fill);
    mCornerTextFillColor = res.getColor(R.color.corner_text_fill);
    mDotFillColor = res.getColor(R.color.dot_fill);
    mDotStrokeColor = res.getColor(R.color.dot_stroke);
    mSelectionColor = res.getColor(R.color.selection_fill);
    mSelectionTextFillColor = res.getColor(R.color.selection_text_fill);
    mSelectionShadowColor = res.getColor(R.color.selection_shadow);
    mCenterFillColor = res.getColor(R.color.center_fill);
    mCenterTextFillColor = res.getColor(R.color.center_text_fill);
    mTextShadowColor = res.getColor(R.color.text_shadow);

    // Gradient colors.
    final int gradientInnerColor = res.getColor(R.color.gradient_inner);
    final int gradientOuterColor = res.getColor(R.color.gradient_outer);
    final int[] colors = new int[] { gradientInnerColor, gradientOuterColor };
    mGradientBackground = new GradientDrawable(Orientation.TOP_BOTTOM, colors);
    mGradientBackground.setGradientType(GradientDrawable.RADIAL_GRADIENT);
    mGradientBackground.setGradientRadius(mExtremeRadius * 2.0f);

    final int subMenuOverlayColor = res.getColor(R.color.submenu_overlay);

    // Lighting filters generated from colors.
    mSubMenuFilter = new PorterDuffColorFilter(subMenuOverlayColor, PorterDuff.Mode.SCREEN);

    mInnerRadiusSq = (mInnerRadius * mInnerRadius);
    mExtremeRadiusSq = (mExtremeRadius * mExtremeRadius);

    mUseNodeProvider = useNodeProvider;

    if (mUseNodeProvider) {
        // Lazily-constructed node provider helper.
        ViewCompat.setAccessibilityDelegate(this, new RadialMenuHelper(this));
    }

    // Corner shapes only need to be invalidated and cached once.
    initializeCachedShapes();
}

From source file:org.buffer.android.buffertextinputlayout.BufferTextInputLayout.java

public BufferTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    ThemeUtils.checkAppCompatTheme(context);
    setOrientation(VERTICAL);//from  ww w  .j a  v a2  s . co  m
    setWillNotDraw(false);
    setAddStatesFromChildren(true);
    inputFrame = new FrameLayout(context);
    inputFrame.setAddStatesFromChildren(true);
    addView(inputFrame);
    collapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
    collapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator());
    collapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START);
    isHintExpanded = collapsingTextHelper.getExpansionFraction() == 1f;
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
            R.styleable.BufferTextInputLayout, defStyleAttr, R.style.BufferTextInputLayout);
    isHintEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_hintEnabled, true);
    setHint(a.getText(R.styleable.BufferTextInputLayout_android_hint));
    hintAnimationEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_hintAnimationEnabled, true);
    if (a.hasValue(R.styleable.BufferTextInputLayout_android_textColorHint)) {
        defaultTextColor = focusedTextColor = a
                .getColorStateList(R.styleable.BufferTextInputLayout_android_textColorHint);
    }
    final int hintAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_hintTextAppearance, -1);
    if (hintAppearance != -1) {
        setHintTextAppearance(a.getResourceId(R.styleable.BufferTextInputLayout_hintTextAppearance, 0));
    }
    errorTextAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_errorTextAppearance, 0);
    final boolean errorEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_errorEnabled, false);
    final boolean counterEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_counterEnabled, false);
    setCounterMaxLength(a.getInt(R.styleable.BufferTextInputLayout_counterMaxLength, INVALID_MAX_LENGTH));
    counterTextAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_counterTextAppearance, 0);
    counterOverflowTextAppearance = a
            .getResourceId(R.styleable.BufferTextInputLayout_counterOverflowTextAppearance, 0);
    counterVisible = counterEnabled;

    counterMode = CounterMode.fromId(a.getInt(R.styleable.BufferTextInputLayout_counterMode, 2));

    charactersRemainingUntilCounterDisplay = a.getInt(R.styleable.BufferTextInputLayout_displayFromCount,
            getCounterMaxLength());

    a.recycle();
    setErrorEnabled(errorEnabled);
    setCounterEnabled(counterEnabled);
    setCounterVisible(counterVisible && (charactersRemainingUntilCounterDisplay == getCounterMaxLength()));
    applyPasswordToggleTint();
    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        // Make sure we're important for accessibility if we haven't been explicitly not
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
    ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate());
}

From source file:com.dk.view.FolderDrawerLayout.java

public FolderDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);/* w  w  w.j av a2  s .  c om*/

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
}

From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java

public VerticalDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mTopCallback = new ViewDragCallback(Gravity.TOP);
    mBottomCallback = new ViewDragCallback(Gravity.BOTTOM);

    mTopDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mTopCallback);
    mTopDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP);
    mTopDragger.setMinVelocity(minVel);/*from ww w  .  j av  a 2  s .c  o m*/
    mTopCallback.setDragger(mTopDragger);

    mBottomDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mBottomCallback);
    mBottomDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM);
    mBottomDragger.setMinVelocity(minVel);
    mBottomCallback.setDragger(mBottomDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);

    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
}

From source file:com.example.zhaozhu.practisecustomview.customviewgroup.HSlidingPaneLayout.java

public HSlidingPaneLayout(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);

    final float density = context.getResources().getDisplayMetrics().density;
    //TODO -32?0//  w w w.  j a v  a 2 s.c o m
    this.mOverhangSize = -32;

    this.setWillNotDraw(false);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    this.mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    this.mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    this.mDragHelper.setMinVelocity(HSlidingPaneLayout.MIN_FLING_VELOCITY * density);
}

From source file:com.hyena.framework.app.widget.HSlidingPaneLayout.java

public HSlidingPaneLayout(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);

    final float density = context.getResources().getDisplayMetrics().density;
    this.mOverhangSize = -32;

    this.setWillNotDraw(false);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    this.mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    this.mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    this.mDragHelper.setMinVelocity(HSlidingPaneLayout.MIN_FLING_VELOCITY * density);
}

From source file:cn.emagsoftware.ui.BugFixedSlidingPaneLayout.java

public BugFixedSlidingPaneLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final float density = context.getResources().getDisplayMetrics().density;
    mOverhangSize = (int) (DEFAULT_OVERHANG_SIZE * density + 0.5f);

    final ViewConfiguration viewConfig = ViewConfiguration.get(context);

    setWillNotDraw(false);//from   w  w w.  j  a  v  a  2 s  . c o m

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mDragHelper.setMinVelocity(MIN_FLING_VELOCITY * density);
}