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:net.fastfourier.something.widget.MarginDrawerLayout.java

public MarginDrawerLayout(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 a v a 2  s.co  m

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

From source file:com.mohamadamin.persianmaterialdatetimepicker.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;//from ww  w.  j a v  a  2 s  .  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 = res.getColor(R.color.mdtp_date_picker_text_normal_dark_theme);
        mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day_dark_theme);
        mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled_dark_theme);
        mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted_dark_theme);
    } else {
        mDayTextColor = res.getColor(R.color.mdtp_date_picker_text_normal);
        mMonthDayTextColor = res.getColor(R.color.mdtp_date_picker_month_day);
        mDisabledDayTextColor = res.getColor(R.color.mdtp_date_picker_text_disabled);
        mHighlightedDayTextColor = res.getColor(R.color.mdtp_date_picker_text_highlighted);
    }
    mSelectedDayTextColor = res.getColor(R.color.mdtp_white);
    mTodayNumberColor = res.getColor(R.color.mdtp_accent_color);
    mMonthTitleColor = res.getColor(R.color.mdtp_white);

    mStringBuilder = new StringBuilder(50);

    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.example.nitish.welcomapp.widgetpt.PeriodicTableView.java

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

    mSelectedPaint = new Paint();
    mSelectedPaint.setAntiAlias(true);//from  ww w .  ja v a2  s  .c o m
    mSelectedPaint.setStyle(Paint.Style.STROKE);
    mSelectedPaint.setStrokeJoin(Paint.Join.ROUND);
    mSelectedPaint.setColor(COLOR_SELECTED);

    mNumberPaint = new Paint();
    mNumberPaint.setAntiAlias(true);
    mNumberPaint.setColor(COLOR_BLOCK_FOREGROUND);

    mSymbolPaint = new Paint(mNumberPaint);
    mSymbolPaint.setTextAlign(Paint.Align.CENTER);

    mTitlePaint = new Paint(mSymbolPaint);
    mHeaderPaint = new Paint(mSymbolPaint);
    mSmallTextPaint = new Paint(mSymbolPaint);

    mNumberPaint.setSubpixelText(true);
    mSmallTextPaint.setSubpixelText(true);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PeriodicTableView, defStyle, 0);

    mTitle = a.getText(R.styleable.PeriodicTableView_title);
    setFgColor(a.getColor(R.styleable.PeriodicTableView_fgColor, COLOR_DEFAULT_FOREGROUND));
    setBgColor(a.getColor(R.styleable.PeriodicTableView_bgColor, COLOR_DEFAULT_BACKGROUND));

    a.recycle();

    mLegend = new PeriodicTableLegend(context);

    mScaleGestureDetector = new ScaleGestureDetector(context, getOnScaleGestureListener());
    mGestureDetector = new GestureDetector(context, getOnGestureListener());

    mZoomer = new Zoomer(context);
    mScroller = new Scroller(context);

    mEdgeEffectLeft = new EdgeEffectCompat(context);
    mEdgeEffectTop = new EdgeEffectCompat(context);
    mEdgeEffectRight = new EdgeEffectCompat(context);
    mEdgeEffectBottom = new EdgeEffectCompat(context);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        mAccessibilityDelegate = new AccessibilityDelegate(this);
        ViewCompat.setAccessibilityDelegate(this, mAccessibilityDelegate);
    }
}

From source file:com.borax12.materialdaterangepicker.single.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;//  w  ww.  j  a  v  a 2s . c  om
    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) {
        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.wdullaer.materialdatetimepicker.date.MonthView.java

public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;/* w  w  w .ja  v  a  2  s  . co m*/
    Resources res = context.getResources();

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

    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.layernet.thaidatetimepicker.date.MonthView.java

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) {
        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);

    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.googlecode.eyesfree.widget.RadialMenuView.java

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

    mRootMenu = menu;/* w  w w.  j a v  a2s.com*/
    mRootMenu.setLayoutListener(mLayoutListener);

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

    mHandler = new LongPressHandler(context);
    mHandler.setListener(mLongPressListener);

    final SurfaceHolder holder = getHolder();
    holder.setFormat(PixelFormat.TRANSLUCENT);
    holder.addCallback(mSurfaceCallback);

    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) {
        mTouchExplorer = new RadialMenuHelper(this);
        ViewCompat.setAccessibilityDelegate(this, mTouchExplorer);
    }

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

From source file:com.rexmtorres.android.patternlock.PatternLockView.java

@SuppressWarnings("deprecation")
public PatternLockView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mContext = getContext();/* ww w. jav  a2s.  co  m*/

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PatternLockView,
            R.attr.patternLockViewStyle, 0);
    final String aspect = a.getString(R.styleable.PatternLockView_aspect);
    if ("square".equals(aspect)) {
        mAspect = ASPECT_SQUARE;
    } else if ("lock_width".equals(aspect)) {
        mAspect = ASPECT_LOCK_WIDTH;
    } else if ("lock_height".equals(aspect)) {
        mAspect = ASPECT_LOCK_HEIGHT;
    } else {
        mAspect = ASPECT_SQUARE;
    }
    setClickable(true);
    mPathPaint.setAntiAlias(true);
    mPathPaint.setDither(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        mRegularColor = context.getColor(R.color.lock_pattern_view_regular_color);
        mErrorColor = context.getColor(R.color.lock_pattern_view_error_color);
        mSuccessColor = context.getColor(R.color.lock_pattern_view_success_color);
    } else {
        Resources resources = context.getResources();

        mRegularColor = resources.getColor(R.color.lock_pattern_view_regular_color);
        mErrorColor = resources.getColor(R.color.lock_pattern_view_error_color);
        mSuccessColor = resources.getColor(R.color.lock_pattern_view_success_color);
    }

    mRegularColor = a.getColor(R.styleable.PatternLockView_regularColor, mRegularColor);
    mErrorColor = a.getColor(R.styleable.PatternLockView_errorColor, mErrorColor);
    mSuccessColor = a.getColor(R.styleable.PatternLockView_successColor, mSuccessColor);

    int pathColor = a.getColor(R.styleable.PatternLockView_pathColor, mRegularColor);

    // [START rexmtorres 20160401] If set, replaces the pattern dots with the specified bitmap.
    Drawable oDotDrawable = a.getDrawable(R.styleable.PatternLockView_dotBitmap);

    if (oDotDrawable != null) {
        if (oDotDrawable instanceof BitmapDrawable) {
            m_oDotBitmap = ((BitmapDrawable) oDotDrawable).getBitmap();
            m_oBigDotBitmap = Bitmap.createScaledBitmap(m_oDotBitmap, (int) (m_oDotBitmap.getWidth() * 1.25),
                    (int) (m_oDotBitmap.getHeight() * 1.25), false);
        }
    }
    // [END rexmtorres 20160401]

    a.recycle();

    mPathPaint.setColor(pathColor);
    mPathPaint.setStyle(Paint.Style.STROKE);
    mPathPaint.setStrokeJoin(Paint.Join.ROUND);
    mPathPaint.setStrokeCap(Paint.Cap.ROUND);
    mPathWidth = getResources().getDimensionPixelSize(R.dimen.lock_pattern_dot_line_width);
    mPathPaint.setStrokeWidth(mPathWidth);
    mDotSize = getResources().getDimensionPixelSize(R.dimen.lock_pattern_dot_size);
    mDotSizeActivated = getResources().getDimensionPixelSize(R.dimen.lock_pattern_dot_size_activated);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mCellStates = new CellState[3][3];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            mCellStates[i][j] = new CellState();
            mCellStates[i][j].radius = mDotSize / 2;
            mCellStates[i][j].row = i;
            mCellStates[i][j].col = j;
            mCellStates[i][j].bitmapDot = m_oDotBitmap;
        }
    }

    mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
    mLinearOutSlowInInterpolator = new LinearOutSlowInInterpolator();
    mExploreByTouchHelper = new PatternExploreByTouchHelper(this);
    ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper);
    mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
}

From source file:com.aidy.bottomdrawerlayout.DrawerLayout.java

public DrawerLayout(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);//from  w ww .  j  a v a 2 s . c o  m

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

From source file:com.klinker.android.launcher.addons.view.LauncherDrawerLayout.java

public LauncherDrawerLayout(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);/*from   www  . j a  v a 2 s .c o m*/

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