Example usage for android.view View IMPORTANT_FOR_ACCESSIBILITY_NO

List of usage examples for android.view View IMPORTANT_FOR_ACCESSIBILITY_NO

Introduction

In this page you can find the example usage for android.view View IMPORTANT_FOR_ACCESSIBILITY_NO.

Prototype

int IMPORTANT_FOR_ACCESSIBILITY_NO

To view the source code for android.view View IMPORTANT_FOR_ACCESSIBILITY_NO.

Click Source Link

Document

The view is not important for accessibility.

Usage

From source file:Main.java

public static void setAccessibilityIgnore(View view) {
    view.setClickable(false);//from   ww  w  .j a va  2 s. co  m
    view.setFocusable(false);
    view.setContentDescription("");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    }
}

From source file:com.android.launcher2.HideFromAccessibilityHelper.java

private void setImportantForAccessibilityToNoHelper(View v) {
    mPreviousValues.put(v, ViewCompat.getImportantForAccessibility(v));
    ViewCompat.setImportantForAccessibility(v, View.IMPORTANT_FOR_ACCESSIBILITY_NO);

    // Call method on children recursively
    if (v instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) v;/*w w w  . ja v a 2  s .  c om*/
        vg.setOnHierarchyChangeListener(this);
        for (int i = 0; i < vg.getChildCount(); i++) {
            View child = vg.getChildAt(i);

            if (includeView(child)) {
                setImportantForAccessibilityToNoHelper(child);
            }
        }
    }
}

From source file:com.google.android.apps.common.testing.accessibility.framework.ViewAccessibilityUtils.java

/**
 * @see View#isImportantForAccessibility()
 *///from w  w  w.j a va 2s.c o m
public static boolean isImportantForAccessibility(View view) {
    if (view == null) {
        return false;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return view.isImportantForAccessibility();
    } else {
        // On earlier APIs, we must piece together accessibility importance from the available
        // properties. We return false incorrectly for some cases where unretrievable listeners
        // prevent us from determining importance.

        // If the developer marked the view as explicitly not important, it isn't.
        int mode = view.getImportantForAccessibility();
        if ((mode == View.IMPORTANT_FOR_ACCESSIBILITY_NO)
                || (mode == View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS)) {
            return false;
        }

        // No parent view can be hiding us. (APIs 19 to 21)
        ViewParent parent = view.getParent();
        while (parent instanceof View) {
            if (((View) parent)
                    .getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) {
                return false;
            }
            parent = parent.getParent();
        }

        // Interrogate the view's other properties to determine importance.
        return (mode == View.IMPORTANT_FOR_ACCESSIBILITY_YES) || isActionableForAccessibility(view)
                || hasListenersForAccessibility(view) || (view.getAccessibilityNodeProvider() != null)
                || (ViewCompat.getAccessibilityLiveRegion(view) != ViewCompat.ACCESSIBILITY_LIVE_REGION_NONE);
    }
}

From source file:com.sysdata.widget.accordion.CollapsedViewHolder.java

protected CollapsedViewHolder(View itemView) {
    super(itemView);

    // Expand handler
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override// w  ww .ja v  a2 s .co m
        public void onClick(View v) {
            getItemHolder().expand();
            notifyItemClicked(ItemAdapter.OnItemClickedListener.ACTION_ID_COLLAPSED_VIEW);
        }
    });

    if (arrow != null) {
        arrow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getItemHolder().expand();
                notifyItemClicked(ItemAdapter.OnItemClickedListener.ACTION_ID_COLLAPSED_VIEW);
            }
        });

        // Override arrow drawable if running Lollipop
        if (SystemUtils.isLMR1OrLater()) {
            arrow.setImageDrawable(
                    ContextCompat.getDrawable(itemView.getContext(), R.drawable.ic_caret_down_animation));
        }
    }

    itemView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}

From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java

protected ExpandedViewHolder(View itemView) {
    super(itemView);

    final Context context = itemView.getContext();
    itemView.setBackground(new LayerDrawable(
            new Drawable[] { ContextCompat.getDrawable(context, R.drawable.alarm_background_expanded),
                    ThemeUtils.resolveDrawable(context, R.attr.selectableItemBackground) }));

    // Collapse handler
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override/*  w w  w .j a va2s  .  co  m*/
        public void onClick(View v) {
            getItemHolder().collapse();
            notifyItemClicked(ItemAdapter.OnItemClickedListener.ACTION_ID_EXPANDED_VIEW);
        }
    });

    if (arrow != null) {
        arrow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getItemHolder().collapse();
                notifyItemClicked(ItemAdapter.OnItemClickedListener.ACTION_ID_EXPANDED_VIEW);
            }
        });

        // Override arrow drawable if running Lollipop
        if (SystemUtils.isLMR1OrLater()) {
            arrow.setImageDrawable(
                    ContextCompat.getDrawable(itemView.getContext(), R.drawable.ic_caret_up_animation));
        }
    }

    itemView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}

From source file:org.chromium.chrome.browser.infobar.AppBannerInfoBarAndroid.java

@Override
public void createContent(InfoBarLayout layout) {
    super.createContent(layout);

    mButton = layout.getPrimaryButton();
    mIconView = layout.getIcon();//from   ww  w. j a va2s  .c  o m
    layout.setIsUsingBigIcon();
    layout.setMessage(mAppTitle);

    mMessageLayout = layout.getMessageLayout();
    mTitleView = layout.getMessageTextView();

    Context context = getContext();
    if (mAppData != null) {
        // Native app.
        layout.getPrimaryButton().setButtonColor(
                ApiCompatibilityUtils.getColor(context.getResources(), R.color.app_banner_install_button_bg));
        mMessageLayout.addRatingBar(mAppData.rating());
        mMessageLayout.setContentDescription(context
                .getString(R.string.app_banner_view_native_app_accessibility, mAppTitle, mAppData.rating()));
        updateButton();
    } else {
        // Web app.
        mMessageLayout.addDescription(mAppUrl);
        mMessageLayout.setContentDescription(
                context.getString(R.string.app_banner_view_web_app_accessibility, mAppTitle, mAppUrl));
    }

    // Hide uninteresting views from accessibility.
    if (mIconView != null) {
        ViewCompat.setImportantForAccessibility(mIconView, View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    }

    // Clicking on the controls brings up the app's details.  The OnClickListener has to be
    // added to both the TextView and its parent because the TextView has special handling for
    // links within the text.
    mMessageLayout.setOnClickListener(this);
    mTitleView.setOnClickListener(this);
    if (mIconView != null)
        mIconView.setOnClickListener(this);
}

From source file:com.androidinspain.deskclock.alarms.dataadapter.ExpandedAlarmViewHolder.java

private ExpandedAlarmViewHolder(View itemView, boolean hasVibrator) {
    super(itemView);

    mHasVibrator = hasVibrator;/* w  w  w . j  a  v  a  2s.c  o  m*/

    delete = (TextView) itemView.findViewById(R.id.delete);
    repeat = (CheckBox) itemView.findViewById(R.id.repeat_onoff);
    vibrate = (CheckBox) itemView.findViewById(R.id.vibrate_onoff);
    ringtone = (TextView) itemView.findViewById(R.id.choose_ringtone);
    editLabel = (TextView) itemView.findViewById(R.id.edit_label);
    repeatDays = (LinearLayout) itemView.findViewById(R.id.repeat_days);
    hairLine = itemView.findViewById(R.id.hairline);

    final Context context = itemView.getContext();
    itemView.setBackground(new LayerDrawable(
            new Drawable[] { ContextCompat.getDrawable(context, R.drawable.alarm_background_expanded),
                    ThemeUtils.resolveDrawable(context, R.attr.selectableItemBackground) }));

    // Build button for each day.
    final LayoutInflater inflater = LayoutInflater.from(context);
    final List<Integer> weekdays = DataModel.getDataModel().getWeekdayOrder().getCalendarDays();
    for (int i = 0; i < 7; i++) {
        final View dayButtonFrame = inflater.inflate(R.layout.day_button, repeatDays, false /* attachToRoot */);
        final CompoundButton dayButton = (CompoundButton) dayButtonFrame.findViewById(R.id.day_button_box);
        final int weekday = weekdays.get(i);
        dayButton.setText(UiDataModel.getUiDataModel().getShortWeekday(weekday));
        dayButton.setContentDescription(UiDataModel.getUiDataModel().getLongWeekday(weekday));
        repeatDays.addView(dayButtonFrame);
        dayButtons[i] = dayButton;
    }

    // Cannot set in xml since we need compat functionality for API < 21
    final Drawable labelIcon = Utils.getVectorDrawable(context, R.drawable.ic_label);
    editLabel.setCompoundDrawablesRelativeWithIntrinsicBounds(labelIcon, null, null, null);
    final Drawable deleteIcon = Utils.getVectorDrawable(context, R.drawable.ic_delete_small);
    delete.setCompoundDrawablesRelativeWithIntrinsicBounds(deleteIcon, null, null, null);

    // Collapse handler
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Events.sendAlarmEvent(R.string.action_collapse_implied, R.string.label_deskclock);
            getItemHolder().collapse();
        }
    });
    arrow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Events.sendAlarmEvent(R.string.action_collapse, R.string.label_deskclock);
            getItemHolder().collapse();
        }
    });
    // Edit time handler
    clock.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getAlarmTimeClickHandler().onClockClicked(getItemHolder().item);
        }
    });
    // Edit label handler
    editLabel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getAlarmTimeClickHandler().onEditLabelClicked(getItemHolder().item);
        }
    });
    // Vibrator checkbox handler
    vibrate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getAlarmTimeClickHandler().setAlarmVibrationEnabled(getItemHolder().item,
                    ((CheckBox) v).isChecked());
        }
    });
    // Ringtone editor handler
    ringtone.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getAlarmTimeClickHandler().onRingtoneClicked(context, getItemHolder().item);
        }
    });
    // Delete alarm handler
    delete.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getAlarmTimeClickHandler().onDeleteClicked(getItemHolder());
            v.announceForAccessibility(context.getString(R.string.alarm_deleted));
        }
    });
    // Repeat checkbox handler
    repeat.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final boolean checked = ((CheckBox) view).isChecked();
            getAlarmTimeClickHandler().setAlarmRepeatEnabled(getItemHolder().item, checked);
            getItemHolder().notifyItemChanged(ANIMATE_REPEAT_DAYS);
        }
    });
    // Day buttons handler
    for (int i = 0; i < dayButtons.length; i++) {
        final int buttonIndex = i;
        dayButtons[i].setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final boolean isChecked = ((CompoundButton) view).isChecked();
                getAlarmTimeClickHandler().setDayOfWeekEnabled(getItemHolder().item, isChecked, buttonIndex);
            }
        });
    }

    itemView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}

From source file:org.onebusaway.android.util.UIUtils.java

/**
 * Formats a view so it is ignored for accessible access
 *///w w  w . jav a2 s .c  o m
public static void setAccessibilityIgnore(View view) {
    view.setClickable(false);
    view.setFocusable(false);
    view.setContentDescription("");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    }
}

From source file:com.android.dialer.DialtactsActivity.java

/**
 * Initiates animations and other visual updates to hide the dialpad. The fragment is hidden in
 * a callback after the hide animation ends.
 * @see #commitDialpadFragmentHide//w ww.  j a va  2s  .co m
 */
public void hideDialpadFragment(boolean animate, boolean clearDialpad) {
    if (mDialpadFragment == null || mDialpadFragment.getView() == null) {
        return;
    }
    if (clearDialpad) {
        // Temporarily disable accessibility when we clear the dialpad, since it should be
        // invisible and should not announce anything.
        mDialpadFragment.getDigitsWidget().setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        mDialpadFragment.clearDialpad();
        mDialpadFragment.getDigitsWidget().setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
    }
    if (!mIsDialpadShown) {
        return;
    }
    mIsDialpadShown = false;
    mDialpadFragment.setAnimate(animate);
    mListsFragment.setUserVisibleHint(true);
    mListsFragment.sendScreenViewForCurrentPosition();

    updateSearchFragmentPosition();

    mFloatingActionButtonController.align(getFabAlignment(), animate);
    if (animate) {
        mDialpadFragment.getView().startAnimation(mSlideOut);
    } else {
        commitDialpadFragmentHide();
    }

    mActionBarController.onDialpadDown();

    if (isInSearchUi()) {
        if (TextUtils.isEmpty(mSearchQuery)) {
            exitSearchUi();
        }
    }
    //reset the title to normal.
    setTitle(R.string.launcherActivityLabel);
}

From source file:org.mozilla.gecko.BrowserApp.java

@Override
public void onTabsLayoutChange(int width, int height) {
    int animationLength = TABS_ANIMATION_DURATION;

    if (mMainLayoutAnimator != null) {
        animationLength = Math.max(1, animationLength - (int) mMainLayoutAnimator.getRemainingTime());
        mMainLayoutAnimator.stop(false);
    }//from w  w  w  . j  a  v a2s.co  m

    if (areTabsShown()) {
        mTabsPanel.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        // Hide the web content from accessibility tools even though it's visible
        // so that you can't examine it as long as the tabs are being shown.
        if (Versions.feature16Plus) {
            mLayerView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        }
    } else {
        if (Versions.feature16Plus) {
            mLayerView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
        }
    }

    mMainLayoutAnimator = new PropertyAnimator(animationLength, sTabsInterpolator);
    mMainLayoutAnimator.addPropertyAnimationListener(this);
    mMainLayoutAnimator.attach(mMainLayout, PropertyAnimator.Property.SCROLL_Y, -height);

    mTabsPanel.prepareTabsAnimation(mMainLayoutAnimator);
    mBrowserToolbar.triggerTabsPanelTransition(mMainLayoutAnimator, areTabsShown());

    // If the tabs panel is animating onto the screen, pin the dynamic
    // toolbar.
    if (mDynamicToolbar.isEnabled()) {
        if (width > 0 && height > 0) {
            mDynamicToolbar.setPinned(true, PinReason.RELAYOUT);
            mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
        } else {
            mDynamicToolbar.setPinned(false, PinReason.RELAYOUT);
        }
    }

    mMainLayoutAnimator.start();
}