private void installAccessibilityDelegate() {
      // The accessibility delegate enables customizing accessibility behavior
      // via composition as opposed as inheritance. The main benefit is that
      // one can write a backwards compatible application by setting the delegate
      // only if the API level is high enough i.e. the delegate is part of the APIs.
      // The easiest way to achieve that is by using the support library which
      // takes the burden of checking API version and knowing which API version
      // introduced the delegate off the developer.
      ViewCompat.setAccessibilityDelegate(
          this,
          new AccessibilityDelegateCompat() {
            @Override
            public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
              super.onPopulateAccessibilityEvent(host, event);
              // Note that View.onPopulateAccessibilityEvent was introduced in
              // ICS and we would like to tweak a bit the text that is reported to
              // accessibility services via the AccessibilityEvent.
              event
                  .getText()
                  .add(getContext().getString(R.string.accessibility_delegate_custom_text_added));
            }

            @Override
            public void onInitializeAccessibilityNodeInfo(
                View host, AccessibilityNodeInfoCompat info) {
              super.onInitializeAccessibilityNodeInfo(host, info);
              // Note that View.onInitializeAccessibilityNodeInfo was introduced in
              // ICS and we would like to tweak a bit the text that is reported to
              // accessibility services via the AccessibilityNodeInfo.
              info.setText(
                  getContext().getString(R.string.accessibility_delegate_custom_text_added));
            }
          });
    }
 /**
  * Called when the accessibility enabled state changes.
  *
  * @param enabled Whether accessibility is enabled.
  */
 public void onAccessibilityStatusChanged(boolean enabled) {
   // Instantiate and install the accessibility node provider on this view if necessary.
   // This overrides any hover event listeners or accessibility delegates
   // that may have been added elsewhere.
   if (enabled && (mNodeProvider == null)) {
     mAccessibilityView = new View(getContext());
     addView(mAccessibilityView);
     mNodeProvider = new CompositorAccessibilityProvider(mAccessibilityView);
     ViewCompat.setAccessibilityDelegate(mAccessibilityView, mNodeProvider);
   }
 }
Пример #3
0
 public SlidingPaneLayout(Context context, AttributeSet attributeSet, int n) {
     super(context, attributeSet, n);
     float f = context.getResources().getDisplayMetrics().density;
     this.mOverhangSize = (int)(32.0f * f + 0.5f);
     ViewConfiguration.get(context);
     this.setWillNotDraw(false);
     ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
     ViewCompat.setImportantForAccessibility(this, 1);
     this.mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
     this.mDragHelper.setMinVelocity(400.0f * f);
 }
Пример #4
0
  public ItemViewHolder(View view, DownloadActivity context) {
    this.context = context;
    dateFormat = android.text.format.DateFormat.getMediumDateFormat(context);
    progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
    rightButton = (Button) view.findViewById(R.id.rightButton);
    leftImageView = (ImageView) view.findViewById(R.id.icon);
    descrTextView = (TextView) view.findViewById(R.id.description);
    rightImageButton = (ImageView) view.findViewById(R.id.secondaryIcon);
    nameTextView = (TextView) view.findViewById(R.id.title);

    ViewCompat.setAccessibilityDelegate(view, context.getAccessibilityAssistant());
    ViewCompat.setAccessibilityDelegate(rightButton, context.getAccessibilityAssistant());
    ViewCompat.setAccessibilityDelegate(rightImageButton, context.getAccessibilityAssistant());

    TypedValue typedValue = new TypedValue();
    Resources.Theme theme = context.getTheme();
    theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
    textColorPrimary = typedValue.data;
    theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
    textColorSecondary = typedValue.data;
  }
Пример #5
0
  public MonthView(Context context, AttributeSet attr, DatePickerController controller) {
    super(context, attr);
    mController = controller;
    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 = 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 = mController.getAccentColor();
    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();
  }
 private void installAccessibilityDelegate() {
   ViewCompat.setAccessibilityDelegate(
       this,
       new AccessibilityDelegateCompat() {
         /**
          * Necessary for accessibility, to ensure we support "scrolling" forward and backward in
          * the circle.
          */
         @Override
         public void onInitializeAccessibilityNodeInfo(
             View host, AccessibilityNodeInfoCompat info) {
           super.onInitializeAccessibilityNodeInfo(host, info);
           info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
           info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
         }
       });
 }
Пример #7
0
 public NestedScrollView(Context var1, AttributeSet var2, int var3) {
   super(var1, var2, var3);
   this.mTempRect = new Rect();
   this.mIsLayoutDirty = true;
   this.mIsLaidOut = false;
   this.mChildToScrollTo = null;
   this.mIsBeingDragged = false;
   this.mSmoothScrollingEnabled = true;
   this.mActivePointerId = -1;
   this.mScrollOffset = new int[2];
   this.mScrollConsumed = new int[2];
   this.initScrollView();
   TypedArray var4 = var1.obtainStyledAttributes(var2, SCROLLVIEW_STYLEABLE, var3, 0);
   this.setFillViewport(var4.getBoolean(0, false));
   var4.recycle();
   this.mParentHelper = new NestedScrollingParentHelper(this);
   this.mChildHelper = new NestedScrollingChildHelper(this);
   this.setNestedScrollingEnabled(true);
   ViewCompat.setAccessibilityDelegate(this, ACCESSIBILITY_DELEGATE);
 }