ViewCompat.java revision 215e3168c4d2171531295532b5c80861925c97c8
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);
13497341bdc5bea1d7bf777de65228039142d249f38Adam Powell        public int getLayerType(View view);
1350af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view);
1360af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id);;
137bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
138bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
139bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static class BaseViewCompatImpl implements ViewCompatImpl {
140bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
141bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
142bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
143bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
144bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
145bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
146560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
147560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return OVER_SCROLL_NEVER;
148560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
149560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
150560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            // Do nothing; API doesn't exist
151560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
1529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
1539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
1569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
1599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov         // Do nothing; API doesn't exist
1609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1619648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
1629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
164c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
165c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // A view can't have transient state if transient state wasn't supported.
166c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return false;
167c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
168c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
169c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // Do nothing; API doesn't exist
170c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
171ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
172ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime());
173ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
174ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
175ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime(), left, top, right, bottom);
176ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
177ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
178ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime());
179ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
180ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
181ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime() + delayMillis);
182ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
183ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
184ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return FAKE_FRAME_TIME;
185ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
18625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
18725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return 0;
18825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
18925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
19025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
19125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
1920d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
1930d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return false;
1940d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
19525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
19625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
19725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
1988a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        public void setLayerType(View view, int layerType, Paint paint) {
1998a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
20097341bdc5bea1d7bf777de65228039142d249f38Adam Powell        public int getLayerType(View view) {
20197341bdc5bea1d7bf777de65228039142d249f38Adam Powell            return LAYER_TYPE_NONE;
20297341bdc5bea1d7bf777de65228039142d249f38Adam Powell        }
2030af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view) {
2040af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            return 0;
2050af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
2060af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id) {
2070af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
2080af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
209bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
210bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
211560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    static class GBViewCompatImpl extends BaseViewCompatImpl {
2129648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
213560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
214560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return ViewCompatGingerbread.getOverScrollMode(v);
215560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
2169648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
217560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
218560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            ViewCompatGingerbread.setOverScrollMode(v, mode);
219560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
220560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
221560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
222ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class HCViewCompatImpl extends GBViewCompatImpl {
223ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
224ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return ViewCompatHC.getFrameTime();
225ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
2268a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        @Override public void setLayerType(View view, int layerType, Paint paint) {
2278a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell            ViewCompatHC.setLayerType(view, layerType, paint);
2288a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
22997341bdc5bea1d7bf777de65228039142d249f38Adam Powell        @Override public int getLayerType(View view)  {
23097341bdc5bea1d7bf777de65228039142d249f38Adam Powell            return ViewCompatHC.getLayerType(view);
23197341bdc5bea1d7bf777de65228039142d249f38Adam Powell        }
232ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
233ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
234ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class ICSViewCompatImpl extends HCViewCompatImpl {
2359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
236bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
237bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollHorizontally(v, direction);
238bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
2399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
240bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
241bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollVertically(v, direction);
242bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
2439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
2459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onPopulateAccessibilityEvent(v, event);
2469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
2499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityEvent(v, event);
2509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
253956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityNodeInfo(v, info.getInfo());
2549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
2579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.setAccessibilityDelegate(v, delegate.getBridge());
2589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
259bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
260bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
261c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    static class JBViewCompatImpl extends ICSViewCompatImpl {
262c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
263c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
264c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return ViewCompatJB.hasTransientState(view);
265c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
266c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
267c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
268c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            ViewCompatJB.setHasTransientState(view, hasTransientState);
269c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
270ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
271ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
272ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view);
273ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
274ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
275ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
276ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view, left, top, right, bottom);
277ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
278ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
279ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
280ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimation(view, action);
281ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
282ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
283ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
284ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimationDelayed(view, action, delayMillis);
285ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
28625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
28725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
28825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return ViewCompatJB.getImportantForAccessibility(view);
28925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
29025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
29125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
29225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            ViewCompatJB.setImportantForAccessibility(view, mode);
29325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
29425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
2950d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
2960d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return ViewCompatJB.performAccessibilityAction(view, action, arguments);
2970d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
2980d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        @Override
29925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
30025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            Object compat = ViewCompatJB.getAccessibilityNodeProvider(view);
30125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            if (compat != null) {
30225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov                return new AccessibilityNodeProviderCompat(compat);
30325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            }
30425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
30525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
306c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
307c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
3080af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    static class JbMr1ViewCompatImpl extends JBViewCompatImpl {
3090af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
3100af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        @Override
3110af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view) {
3120af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            return ViewCompatJellybeanMr1.getLabelFor(view);
3130af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
3140af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
3150af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        @Override
3160af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id) {
3170af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            ViewCompatJellybeanMr1.setLabelFor(view, id);
3180af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
3190af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
3200af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
321bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static final ViewCompatImpl IMPL;
322bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static {
323560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        final int version = android.os.Build.VERSION.SDK_INT;
324215e3168c4d2171531295532b5c80861925c97c8Svetoslav Ganov        if (version >= 17) {
3250af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            IMPL = new JbMr1ViewCompatImpl();
3260af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        } else if (version >= 16) {
327c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            IMPL = new JBViewCompatImpl();
328c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        } else if (version >= 14) {
329bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new ICSViewCompatImpl();
330ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        } else if (version >= 11) {
331ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            IMPL = new HCViewCompatImpl();
332560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        } else if (version >= 9) {
333560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            IMPL = new GBViewCompatImpl();
334bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        } else {
335bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new BaseViewCompatImpl();
336bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
337bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
338bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
3390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled horizontally in a certain direction.
3410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling left, positive to check scrolling right.
3440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
3450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
346bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollHorizontally(View v, int direction) {
347bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollHorizontally(v, direction);
348bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
349bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
3500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled vertically in a certain direction.
3520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling up, positive to check scrolling down.
3550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
3560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
357bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollVertically(View v, int direction) {
358bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollVertically(v, direction);
359bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
360560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
3610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Returns the over-scroll mode for this view. The result will be
3630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
3640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
3650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
3660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return This view's over-scroll mode.
3690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
370560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static int getOverScrollMode(View v) {
371560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        return IMPL.getOverScrollMode(v);
372560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
373560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
3740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Set the over-scroll mode for this view. Valid over-scroll modes are
3760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
3770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
3780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
3790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Setting the over-scroll mode of a view will have an effect only if the
3810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * view is capable of scrolling.
3820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param overScrollMode The new over-scroll mode for this view.
3850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    public static void setOverScrollMode(View v, int overScrollMode) {
3870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov        IMPL.setOverScrollMode(v, overScrollMode);
388560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
3899648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
3900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)}
3920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * giving a chance to this View to populate the accessibility event with its
3930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * text content. While this method is free to modify event
3940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * attributes other than text content, doing so should normally be performed in
3950574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}.
3960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Adding formatted date string to an accessibility event in addition
3980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to the text added by the super implementation:
3990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
4000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onPopulateAccessibilityEvent(event);
4010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
4020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     String selectedDateUtterance = DateUtils.formatDateTime(mContext,
4030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *         mCurrentDate.getTimeInMillis(), flags);
4040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.getText().add(selectedDateUtterance);
4050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
4060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
4080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
4090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View,
4100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
4110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
4120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
4140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
4150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The accessibility event which to populate.
4190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
4210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
4220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4239648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
4249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onPopulateAccessibilityEvent(v, event);
4259648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
4269648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link AccessibilityEvent} with information about
4290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * this View which is the event source. In other words, the source of
4300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * an accessibility event is the view whose state change triggered firing
4310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * the event.
4320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Setting the password property of an event in addition
4340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to properties set by the super implementation:
4350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
4360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onInitializeAccessibilityEvent(event);
4370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.setPassword(true);
4380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
4390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
4410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
4420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View,
4430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
4440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
4450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
4470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
4480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The event to initialize.
4520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
4540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
4550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
4579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityEvent(v, event);
4589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
4599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information
4620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * about this view. The base implementation sets:
4630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <ul>
4640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},</li>
4650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},</li>
4660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},</li>
4670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},</li>
4680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},</li>
4690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},</li>
4700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},</li>
4710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},</li>
4720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},</li>
4730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},</li>
4740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},</li>
4750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},</li>
4760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </ul>
4770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Subclasses should override this method, call the super implementation,
4790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * and set additional attributes.
4800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
4830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
4840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View,
4850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  android.view.accessibility.AccessibilityNodeInfo)}
4860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
4870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param info The instance to initialize.
4910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4929648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
4939648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityNodeInfo(v, info);
4949648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
4959648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Sets a delegate for implementing accessibility support via compositon as
4980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * opposed to inheritance. The delegate's primary use is for implementing
4990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * backwards compatible widgets. For more details see
5000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate}.
5010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
5020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
5030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param delegate The delegate instance.
5040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
5050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see android.view.View.AccessibilityDelegate
5060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
5079648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
5089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.setAccessibilityDelegate(v, delegate);
5099648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
510c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
511c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
512c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Indicates whether the view is currently tracking transient state that the
513c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * app should not need to concern itself with saving and restoring, but that
514c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * the framework should take special note to preserve when possible.
515c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
516c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View to check for transient state
517c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @return true if the view has transient state
518c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
519c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static boolean hasTransientState(View view) {
520c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        return IMPL.hasTransientState(view);
521c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
522c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
523c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
524c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Set whether this view is currently tracking transient state that the
525c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * framework should attempt to preserve when possible.
526c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
527c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View tracking transient state
528c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param hasTransientState true if this view has transient state
529c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
530c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static void setHasTransientState(View view, boolean hasTransientState) {
531c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        IMPL.setHasTransientState(view, hasTransientState);
532c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
533ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
534ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
535ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate to happen on the next animation time step, typically the
536ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * next display frame.</p>
537ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
538ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
539ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
540ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
541ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
542ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
543ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view) {
544ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view);
545ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
546ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
547ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
548ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate of the specified area to happen on the next animation
549ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * time step, typically the next display frame.</p>
550ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
551ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
552ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
553ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
554ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
555ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param left The left coordinate of the rectangle to invalidate.
556ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param top The top coordinate of the rectangle to invalidate.
557ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param right The right coordinate of the rectangle to invalidate.
558ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param bottom The bottom coordinate of the rectangle to invalidate.
559ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
560ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view, int left, int top,
561ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            int right, int bottom) {
562ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view, left, top, right, bottom);
563ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
564ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
565ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
566ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step.
567ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
568ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
569ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
570ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
571ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
572ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to post this Runnable to
573ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
574ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
575ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimation(View view, Runnable action) {
576ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimation(view, action);
577ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
578ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
579ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
580ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step,
581ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * after the specified amount of time elapses.
582ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
583ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
584ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
585ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
586ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
587ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view The view to post this Runnable to
588ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
589ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param delayMillis The delay (in milliseconds) until the Runnable
590ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *        will be executed.
591ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
592ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
593ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimationDelayed(view, action, delayMillis);
594ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
59525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
59625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
59725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the mode for determining whether this View is important for accessibility
59825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
59925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
60025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
60125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
60225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The mode for determining whether a View is important for accessibility.
60325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
60425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
60525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
60625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
60725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
60825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static int getImportantForAccessibility(View view) {
60925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getImportantForAccessibility(view);
61025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
61125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
61225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
61325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Sets how to determine whether this view is important for accessibility
61425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
61525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
61625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
61725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to set.
61825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param mode How to determine whether this view is important for accessibility.
61925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
62025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
62125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
62225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
62325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
62425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static void setImportantForAccessibility(View view, int mode) {
62525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        IMPL.setImportantForAccessibility(view, mode);
62625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
62725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
62825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
6290d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * Performs the specified accessibility action on the view. For
6300d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * possible accessibility actions look at {@link AccessibilityNodeInfoCompat}.
6310d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * <p>
6320d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * If an {@link AccessibilityDelegateCompat} has been specified via calling
6330d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its
6340d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link AccessibilityDelegateCompat#performAccessibilityAction(View, int, Bundle)}
6350d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * is responsible for handling this call.
6360d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * </p>
6370d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     *
6380d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param action The action to perform.
6390d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param arguments Optional action arguments.
6400d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @return Whether the action was performed.
6410d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     */
6420d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    public static boolean performAccessibilityAction(View view, int action, Bundle arguments) {
6430d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        return IMPL.performAccessibilityAction(view, action, arguments);
6440d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    }
6450d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv
6460d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    /**
64725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the provider for managing a virtual view hierarchy rooted at this View
648e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * and reported to {@link android.accessibilityservice.AccessibilityService}s
64925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * that explore the window content.
65025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
65125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If this method returns an instance, this instance is responsible for managing
652e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * {@link AccessibilityNodeInfoCompat}s describing the virtual sub-tree rooted at
65325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * this View including the one representing the View itself. Similarly the returned
65425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * instance is responsible for performing accessibility actions on any virtual
65525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * view or the root view itself.
65625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
65725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
65825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If an {@link AccessibilityDelegateCompat} has been specified via calling
659e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat) its
66025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * {@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)}
66125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * is responsible for handling this call.
66225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
66325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
66425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
66525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The provider.
66625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
66725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see AccessibilityNodeProviderCompat
66825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
66925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
67025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getAccessibilityNodeProvider(view);
67125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
6728a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
6738a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
6748a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Specifies the type of layer backing this view. The layer can be
6758a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_NONE disabled}, {@link #LAYER_TYPE_SOFTWARE software} or
6768a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_HARDWARE hardware}.</p>
6778a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6788a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A layer is associated with an optional {@link android.graphics.Paint}
6798a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * instance that controls how the layer is composed on screen. The following
6808a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * properties of the paint are taken into account when composing the layer:</p>
6818a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <ul>
6828a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
6838a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
6848a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
6858a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * </ul>
6868a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6878a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>If this view has an alpha value set to < 1.0 by calling
6888a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * setAlpha(float), the alpha value of the layer's paint is replaced by
6898a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * this view's alpha value. Calling setAlpha(float) is therefore
6908a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * equivalent to setting a hardware layer on this view and providing a paint with
6918a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * the desired alpha value.<p>
6928a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6938a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Refer to the documentation of {@link #LAYER_TYPE_NONE disabled},
6948a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_SOFTWARE software} and {@link #LAYER_TYPE_HARDWARE hardware}
6958a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * for more information on when and how to use layers.</p>
6968a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6978a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The ype of layer to use with this view, must be one of
6988a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
6998a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
7008a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
7018a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
7028a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
7038a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
7048a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param view View to set the layer type for
7058a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The type of layer to use with this view, must be one of
7068a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
7078a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
7088a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
7098a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
7108a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
7118a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
7128a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static void setLayerType(View view, int layerType, Paint paint) {
7138a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        IMPL.setLayerType(view, layerType, paint);
7148a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    }
71597341bdc5bea1d7bf777de65228039142d249f38Adam Powell
71697341bdc5bea1d7bf777de65228039142d249f38Adam Powell    /**
71797341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * Indicates what type of layer is currently associated with this view. By default
71897341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * a view does not have a layer, and the layer type is {@link #LAYER_TYPE_NONE}.
71997341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * Refer to the documentation of
72097341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * {@link #setLayerType(android.view.View, int, android.graphics.Paint)}
72197341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * for more information on the different types of layers.
72297341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *
72397341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @param view The view to fetch the layer type from
72497341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @return {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
72597341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *         {@link #LAYER_TYPE_HARDWARE}
72697341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *
72797341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #setLayerType(android.view.View, int, android.graphics.Paint)
72897341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_NONE
72997341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_SOFTWARE
73097341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_HARDWARE
73197341bdc5bea1d7bf777de65228039142d249f38Adam Powell     */
73297341bdc5bea1d7bf777de65228039142d249f38Adam Powell    public static int getLayerType(View view) {
73397341bdc5bea1d7bf777de65228039142d249f38Adam Powell        return IMPL.getLayerType(view);
73497341bdc5bea1d7bf777de65228039142d249f38Adam Powell    }
7350af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
7360af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    /**
7370af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * Gets the id of a view for which a given view serves as a label for
7380af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * accessibility purposes.
7390af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     *
7400af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param view The view on which to invoke the corresponding method.
7410af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @return The labeled view id.
7420af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     */
7430af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    public static int getLabelFor(View view) {
7440af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        return IMPL.getLabelFor(view);
7450af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
7460af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
7470af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    /**
7480af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * Sets the id of a view for which a given view serves as a label for
7490af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * accessibility purposes.
7500af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     *
7510af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param view The view on which to invoke the corresponding method.
7520af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param labeledId The labeled view id.
7530af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     */
7540af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    public static void setLabelFor(View view, int labeledId) {
7550af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        IMPL.setLabelFor(view, labeledId);
7560af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
757bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell}
758