ViewCompat.java revision 8a0c51a3d438802df28612e02fdf0cc8fab06ddb
1bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/*
2bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Copyright (C) 2011 The Android Open Source Project
3bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell *
4bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Licensed under the Apache License, Version 2.0 (the "License");
5bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * you may not use this file except in compliance with the License.
6bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * You may obtain a copy of the License at
7bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell *
8bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell *      http://www.apache.org/licenses/LICENSE-2.0
9bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell *
10bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Unless required by applicable law or agreed to in writing, software
11bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * distributed under the License is distributed on an "AS IS" BASIS,
12bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * See the License for the specific language governing permissions and
14bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * limitations under the License.
15bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */
16bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
17bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpackage android.support.v4.view;
18bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
198a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powellimport android.graphics.Paint;
200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganovimport android.graphics.Rect;
210d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanvimport android.os.Bundle;
229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
2325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeProviderCompat;
24bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellimport android.view.View;
259648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.accessibility.AccessibilityEvent;
26bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
27bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/**
280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link View} introduced after API
290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * level 4 in a backwards compatible fashion.
30bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */
31bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpublic class ViewCompat {
32560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
33560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Always allow a user to over-scroll this view, provided it is a
34560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * view that can scroll.
35560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
36560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_ALWAYS = 0;
37560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
38560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
39560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Allow a user to over-scroll this view only if the content is large
40560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * enough to meaningfully scroll, provided it is a view that can scroll.
41560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
42560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_IF_CONTENT_SCROLLS = 1;
43560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
44560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
45560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Never allow a user to over-scroll this view.
46560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
47560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_NEVER = 2;
48560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
49ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    private static final long FAKE_FRAME_TIME = 10;
50ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
5125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
5225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Automatically determine whether a view is important for accessibility.
5325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
5425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = 0x00000000;
5525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
5625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
5725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * The view is important for accessibility.
5825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
5925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 0x00000001;
6025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
6125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
6225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * The view is not important for accessibility.
6325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
6425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002;
6525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
668a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
678a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * Indicates that the view does not have a layer.
688a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
698a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_NONE = 0;
708a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
718a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
728a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Indicates that the view has a software layer. A software layer is backed
738a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * by a bitmap and causes the view to be rendered using Android's software
748a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rendering pipeline, even if hardware acceleration is enabled.</p>
758a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
768a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Software layers have various usages:</p>
778a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>When the application is not using hardware acceleration, a software layer
788a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * is useful to apply a specific color filter and/or blending mode and/or
798a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * translucency to a view and all its children.</p>
808a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>When the application is using hardware acceleration, a software layer
818a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * is useful to render drawing primitives not supported by the hardware
828a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * accelerated pipeline. It can also be used to cache a complex view tree
838a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * into a texture and reduce the complexity of drawing operations. For instance,
848a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * when animating a complex view tree with a translation, a software layer can
858a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * be used to render the view tree only once.</p>
868a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Software layers should be avoided when the affected view tree updates
878a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * often. Every update will require to re-render the software layer, which can
888a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * potentially be slow (particularly when hardware acceleration is turned on
898a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * since the layer will have to be uploaded into a hardware texture after every
908a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * update.)</p>
918a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
928a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_SOFTWARE = 1;
938a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
948a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
958a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Indicates that the view has a hardware layer. A hardware layer is backed
968a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * by a hardware specific texture (generally Frame Buffer Objects or FBO on
978a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * OpenGL hardware) and causes the view to be rendered using Android's hardware
988a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rendering pipeline, but only if hardware acceleration is turned on for the
998a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * view hierarchy. When hardware acceleration is turned off, hardware layers
1008a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * behave exactly as {@link #LAYER_TYPE_SOFTWARE software layers}.</p>
1018a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
1028a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer is useful to apply a specific color filter and/or
1038a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * blending mode and/or translucency to a view and all its children.</p>
1048a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer can be used to cache a complex view tree into a
1058a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * texture and reduce the complexity of drawing operations. For instance,
1068a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * when animating a complex view tree with a translation, a hardware layer can
1078a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * be used to render the view tree only once.</p>
1088a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer can also be used to increase the rendering quality when
1098a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rotation transformations are applied on a view. It can also be used to
1108a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * prevent potential clipping issues when applying 3D transforms on a view.</p>
1118a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
1128a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_HARDWARE = 2;
1138a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
114bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    interface ViewCompatImpl {
115bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction);
116bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction);
117560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v);
118560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode);
1199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event);
1209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event);
1219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info);
1229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate);
123c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view);
124c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState);
125ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view);
126ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom);
127ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action);
128ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis);
12925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view);
13025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode);
1310d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments);
13225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view);
1338a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        public void setLayerType(View view, int layerType, Paint paint);
134bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
135bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
136bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static class BaseViewCompatImpl implements ViewCompatImpl {
137bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
138bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
139bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
140bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
141bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
142bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
143560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
144560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return OVER_SCROLL_NEVER;
145560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
146560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
147560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            // Do nothing; API doesn't exist
148560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
1499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
1509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
1539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
1569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov         // Do nothing; API doesn't exist
1579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
1599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
161c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
162c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // A view can't have transient state if transient state wasn't supported.
163c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return false;
164c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
165c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
166c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // Do nothing; API doesn't exist
167c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
168ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
169ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime());
170ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
171ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
172ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime(), left, top, right, bottom);
173ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
174ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
175ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime());
176ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
177ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
178ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime() + delayMillis);
179ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
180ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
181ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return FAKE_FRAME_TIME;
182ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
18325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
18425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return 0;
18525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
18625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
18725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
18825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
1890d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
1900d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return false;
1910d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
19225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
19325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
19425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
1958a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        public void setLayerType(View view, int layerType, Paint paint) {
1968a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
197bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
198bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
199560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    static class GBViewCompatImpl extends BaseViewCompatImpl {
2009648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
201560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
202560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return ViewCompatGingerbread.getOverScrollMode(v);
203560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
2049648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
205560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
206560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            ViewCompatGingerbread.setOverScrollMode(v, mode);
207560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
208560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
209560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
210ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class HCViewCompatImpl extends GBViewCompatImpl {
211ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
212ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return ViewCompatHC.getFrameTime();
213ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
2148a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        @Override public void setLayerType(View view, int layerType, Paint paint) {
2158a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell            ViewCompatHC.setLayerType(view, layerType, paint);
2168a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
217ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
218ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
219ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class ICSViewCompatImpl extends HCViewCompatImpl {
2209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
221bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
222bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollHorizontally(v, direction);
223bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
2249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
225bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
226bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollVertically(v, direction);
227bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
2289648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2299648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
2309648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onPopulateAccessibilityEvent(v, event);
2319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2339648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
2349648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityEvent(v, event);
2359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2379648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
238956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityNodeInfo(v, info.getInfo());
2399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
2429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.setAccessibilityDelegate(v, delegate.getBridge());
2439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
244bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
245bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
246c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    static class JBViewCompatImpl extends ICSViewCompatImpl {
247c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
248c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
249c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return ViewCompatJB.hasTransientState(view);
250c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
251c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
252c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
253c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            ViewCompatJB.setHasTransientState(view, hasTransientState);
254c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
255ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
256ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
257ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view);
258ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
259ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
260ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
261ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view, left, top, right, bottom);
262ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
263ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
264ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
265ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimation(view, action);
266ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
267ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
268ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
269ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimationDelayed(view, action, delayMillis);
270ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
27125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
27225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
27325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return ViewCompatJB.getImportantForAccessibility(view);
27425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
27525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
27625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
27725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            ViewCompatJB.setImportantForAccessibility(view, mode);
27825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
27925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
2800d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
2810d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return ViewCompatJB.performAccessibilityAction(view, action, arguments);
2820d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
2830d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        @Override
28425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
28525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            Object compat = ViewCompatJB.getAccessibilityNodeProvider(view);
28625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            if (compat != null) {
28725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov                return new AccessibilityNodeProviderCompat(compat);
28825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            }
28925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
29025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
291c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
292c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
293bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static final ViewCompatImpl IMPL;
294bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static {
295560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        final int version = android.os.Build.VERSION.SDK_INT;
296c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        if (version >= 16 || android.os.Build.VERSION.CODENAME.equals("JellyBean")) {
297c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            IMPL = new JBViewCompatImpl();
298c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        } else if (version >= 14) {
299bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new ICSViewCompatImpl();
300ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        } else if (version >= 11) {
301ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            IMPL = new HCViewCompatImpl();
302560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        } else if (version >= 9) {
303560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            IMPL = new GBViewCompatImpl();
304bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        } else {
305bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new BaseViewCompatImpl();
306bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
307bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
308bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
3090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled horizontally in a certain direction.
3110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling left, positive to check scrolling right.
3140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
3150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
316bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollHorizontally(View v, int direction) {
317bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollHorizontally(v, direction);
318bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
319bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
3200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled vertically in a certain direction.
3220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling up, positive to check scrolling down.
3250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
3260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
327bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollVertically(View v, int direction) {
328bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollVertically(v, direction);
329bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
330560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
3310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Returns the over-scroll mode for this view. The result will be
3330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
3340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
3350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
3360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return This view's over-scroll mode.
3390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
340560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static int getOverScrollMode(View v) {
341560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        return IMPL.getOverScrollMode(v);
342560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
343560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
3440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Set the over-scroll mode for this view. Valid over-scroll modes are
3460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
3470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
3480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
3490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Setting the over-scroll mode of a view will have an effect only if the
3510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * view is capable of scrolling.
3520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param overScrollMode The new over-scroll mode for this view.
3550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    public static void setOverScrollMode(View v, int overScrollMode) {
3570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov        IMPL.setOverScrollMode(v, overScrollMode);
358560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
3599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
3600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)}
3620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * giving a chance to this View to populate the accessibility event with its
3630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * text content. While this method is free to modify event
3640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * attributes other than text content, doing so should normally be performed in
3650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}.
3660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Adding formatted date string to an accessibility event in addition
3680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to the text added by the super implementation:
3690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
3700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onPopulateAccessibilityEvent(event);
3710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
3720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     String selectedDateUtterance = DateUtils.formatDateTime(mContext,
3730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *         mCurrentDate.getTimeInMillis(), flags);
3740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.getText().add(selectedDateUtterance);
3750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
3760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
3780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
3790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View,
3800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
3810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
3820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
3840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
3850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The accessibility event which to populate.
3890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
3910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
3920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3939648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
3949648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onPopulateAccessibilityEvent(v, event);
3959648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
3969648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
3970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link AccessibilityEvent} with information about
3990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * this View which is the event source. In other words, the source of
4000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * an accessibility event is the view whose state change triggered firing
4010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * the event.
4020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Setting the password property of an event in addition
4040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to properties set by the super implementation:
4050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
4060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onInitializeAccessibilityEvent(event);
4070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.setPassword(true);
4080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
4090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
4110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
4120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View,
4130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
4140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
4150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
4170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
4180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The event to initialize.
4220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
4240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
4250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4269648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
4279648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityEvent(v, event);
4289648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
4299648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information
4320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * about this view. The base implementation sets:
4330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <ul>
4340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},</li>
4350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},</li>
4360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},</li>
4370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},</li>
4380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},</li>
4390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},</li>
4400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},</li>
4410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},</li>
4420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},</li>
4430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},</li>
4440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},</li>
4450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},</li>
4460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </ul>
4470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Subclasses should override this method, call the super implementation,
4490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * and set additional attributes.
4500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
4530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
4540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View,
4550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  android.view.accessibility.AccessibilityNodeInfo)}
4560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
4570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param info The instance to initialize.
4610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
4639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityNodeInfo(v, info);
4649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
4659648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Sets a delegate for implementing accessibility support via compositon as
4680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * opposed to inheritance. The delegate's primary use is for implementing
4690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * backwards compatible widgets. For more details see
4700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate}.
4710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param delegate The delegate instance.
4740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see android.view.View.AccessibilityDelegate
4760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4779648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
4789648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.setAccessibilityDelegate(v, delegate);
4799648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
480c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
481c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
482c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Indicates whether the view is currently tracking transient state that the
483c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * app should not need to concern itself with saving and restoring, but that
484c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * the framework should take special note to preserve when possible.
485c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
486c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View to check for transient state
487c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @return true if the view has transient state
488c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
489c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static boolean hasTransientState(View view) {
490c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        return IMPL.hasTransientState(view);
491c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
492c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
493c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
494c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Set whether this view is currently tracking transient state that the
495c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * framework should attempt to preserve when possible.
496c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
497c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View tracking transient state
498c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param hasTransientState true if this view has transient state
499c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
500c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static void setHasTransientState(View view, boolean hasTransientState) {
501c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        IMPL.setHasTransientState(view, hasTransientState);
502c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
503ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
504ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
505ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate to happen on the next animation time step, typically the
506ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * next display frame.</p>
507ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
508ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
509ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
510ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
511ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
512ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
513ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view) {
514ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view);
515ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
516ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
517ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
518ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate of the specified area to happen on the next animation
519ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * time step, typically the next display frame.</p>
520ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
521ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
522ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
523ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
524ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
525ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param left The left coordinate of the rectangle to invalidate.
526ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param top The top coordinate of the rectangle to invalidate.
527ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param right The right coordinate of the rectangle to invalidate.
528ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param bottom The bottom coordinate of the rectangle to invalidate.
529ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
530ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view, int left, int top,
531ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            int right, int bottom) {
532ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view, left, top, right, bottom);
533ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
534ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
535ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
536ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step.
537ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
538ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
539ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
540ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
541ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
542ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to post this Runnable to
543ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
544ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
545ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimation(View view, Runnable action) {
546ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimation(view, action);
547ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
548ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
549ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
550ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step,
551ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * after the specified amount of time elapses.
552ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
553ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
554ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
555ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
556ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
557ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view The view to post this Runnable to
558ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
559ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param delayMillis The delay (in milliseconds) until the Runnable
560ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *        will be executed.
561ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
562ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
563ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimationDelayed(view, action, delayMillis);
564ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
56525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
56625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
56725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the mode for determining whether this View is important for accessibility
56825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
56925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
57025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
57125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
57225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The mode for determining whether a View is important for accessibility.
57325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
57425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
57525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
57625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
57725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
57825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static int getImportantForAccessibility(View view) {
57925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getImportantForAccessibility(view);
58025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
58125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
58225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
58325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Sets how to determine whether this view is important for accessibility
58425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
58525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
58625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
58725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to set.
58825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param mode How to determine whether this view is important for accessibility.
58925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
59025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
59125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
59225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
59325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
59425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static void setImportantForAccessibility(View view, int mode) {
59525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        IMPL.setImportantForAccessibility(view, mode);
59625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
59725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
59825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
5990d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * Performs the specified accessibility action on the view. For
6000d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * possible accessibility actions look at {@link AccessibilityNodeInfoCompat}.
6010d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * <p>
6020d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * If an {@link AccessibilityDelegateCompat} has been specified via calling
6030d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its
6040d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link AccessibilityDelegateCompat#performAccessibilityAction(View, int, Bundle)}
6050d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * is responsible for handling this call.
6060d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * </p>
6070d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     *
6080d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param action The action to perform.
6090d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param arguments Optional action arguments.
6100d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @return Whether the action was performed.
6110d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     */
6120d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    public static boolean performAccessibilityAction(View view, int action, Bundle arguments) {
6130d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        return IMPL.performAccessibilityAction(view, action, arguments);
6140d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    }
6150d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv
6160d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    /**
61725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the provider for managing a virtual view hierarchy rooted at this View
618e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * and reported to {@link android.accessibilityservice.AccessibilityService}s
61925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * that explore the window content.
62025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
62125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If this method returns an instance, this instance is responsible for managing
622e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * {@link AccessibilityNodeInfoCompat}s describing the virtual sub-tree rooted at
62325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * this View including the one representing the View itself. Similarly the returned
62425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * instance is responsible for performing accessibility actions on any virtual
62525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * view or the root view itself.
62625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
62725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
62825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If an {@link AccessibilityDelegateCompat} has been specified via calling
629e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat) its
63025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * {@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)}
63125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * is responsible for handling this call.
63225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
63325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
63425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
63525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The provider.
63625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
63725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see AccessibilityNodeProviderCompat
63825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
63925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
64025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getAccessibilityNodeProvider(view);
64125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
6428a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
6438a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
6448a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Specifies the type of layer backing this view. The layer can be
6458a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_NONE disabled}, {@link #LAYER_TYPE_SOFTWARE software} or
6468a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_HARDWARE hardware}.</p>
6478a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6488a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A layer is associated with an optional {@link android.graphics.Paint}
6498a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * instance that controls how the layer is composed on screen. The following
6508a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * properties of the paint are taken into account when composing the layer:</p>
6518a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <ul>
6528a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
6538a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
6548a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
6558a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * </ul>
6568a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6578a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>If this view has an alpha value set to < 1.0 by calling
6588a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * setAlpha(float), the alpha value of the layer's paint is replaced by
6598a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * this view's alpha value. Calling setAlpha(float) is therefore
6608a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * equivalent to setting a hardware layer on this view and providing a paint with
6618a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * the desired alpha value.<p>
6628a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6638a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Refer to the documentation of {@link #LAYER_TYPE_NONE disabled},
6648a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_SOFTWARE software} and {@link #LAYER_TYPE_HARDWARE hardware}
6658a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * for more information on when and how to use layers.</p>
6668a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6678a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The ype of layer to use with this view, must be one of
6688a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
6698a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
6708a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
6718a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
6728a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
6738a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6748a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param view View to set the layer type for
6758a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The type of layer to use with this view, must be one of
6768a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
6778a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
6788a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
6798a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
6808a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
6818a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
6828a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static void setLayerType(View view, int layerType, Paint paint) {
6838a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        IMPL.setLayerType(view, layerType, paint);
6848a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    }
685bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell}
686