ViewCompat.java revision 6debd2bbcae1cd285d2e21db633998b7801f9f40
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);
1366debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLabelFor(View view, int id);
1376debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint);
138bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
139bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
140bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static class BaseViewCompatImpl implements ViewCompatImpl {
141bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
142bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
143bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
144bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
145bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
146bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
147560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
148560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return OVER_SCROLL_NEVER;
149560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
150560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
151560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            // Do nothing; API doesn't exist
152560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
1539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
1549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
1579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
1609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov         // Do nothing; API doesn't exist
1619648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
1639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
165c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
166c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // A view can't have transient state if transient state wasn't supported.
167c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return false;
168c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
169c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
170c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // Do nothing; API doesn't exist
171c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
172ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
173ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime());
174ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
175ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
176ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime(), left, top, right, bottom);
177ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
178ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
179ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime());
180ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
181ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
182ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime() + delayMillis);
183ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
184ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
185ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return FAKE_FRAME_TIME;
186ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
18725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
18825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return 0;
18925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
19025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
19125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
19225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
1930d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
1940d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return false;
1950d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
19625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
19725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
19825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
1998a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        public void setLayerType(View view, int layerType, Paint paint) {
2006debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // No-op until layers became available (HC)
2018a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
20297341bdc5bea1d7bf777de65228039142d249f38Adam Powell        public int getLayerType(View view) {
20397341bdc5bea1d7bf777de65228039142d249f38Adam Powell            return LAYER_TYPE_NONE;
20497341bdc5bea1d7bf777de65228039142d249f38Adam Powell        }
2050af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view) {
2060af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            return 0;
2070af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
2080af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id) {
2090af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
2100af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
2116debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint p) {
2126debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // No-op until layers became available (HC)
2136debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
214bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
215bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
216560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    static class GBViewCompatImpl extends BaseViewCompatImpl {
2179648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
218560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
219560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return ViewCompatGingerbread.getOverScrollMode(v);
220560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
2219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
222560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
223560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            ViewCompatGingerbread.setOverScrollMode(v, mode);
224560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
225560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
226560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
227ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class HCViewCompatImpl extends GBViewCompatImpl {
228ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
229ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return ViewCompatHC.getFrameTime();
230ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
2318a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        @Override public void setLayerType(View view, int layerType, Paint paint) {
2328a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell            ViewCompatHC.setLayerType(view, layerType, paint);
2338a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
23497341bdc5bea1d7bf777de65228039142d249f38Adam Powell        @Override public int getLayerType(View view)  {
23597341bdc5bea1d7bf777de65228039142d249f38Adam Powell            return ViewCompatHC.getLayerType(view);
23697341bdc5bea1d7bf777de65228039142d249f38Adam Powell        }
2376debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        @Override
2386debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint) {
2396debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // Make sure the paint is correct; this will be cheap if it's the same
2406debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // instance as was used to call setLayerType earlier.
2416debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            setLayerType(view, getLayerType(view), paint);
2426debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // This is expensive, but the only way to accomplish this before JB-MR1.
2436debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            view.invalidate();
2446debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
245ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
246ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
247ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class ICSViewCompatImpl extends HCViewCompatImpl {
2489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
249bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
250bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollHorizontally(v, direction);
251bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
2529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
253bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
254bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollVertically(v, direction);
255bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
2569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
2589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onPopulateAccessibilityEvent(v, event);
2599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2619648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
2629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityEvent(v, event);
2639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2659648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
266956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityNodeInfo(v, info.getInfo());
2679648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2689648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
2699648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
2709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.setAccessibilityDelegate(v, delegate.getBridge());
2719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
272bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
273bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
274c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    static class JBViewCompatImpl extends ICSViewCompatImpl {
275c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
276c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
277c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return ViewCompatJB.hasTransientState(view);
278c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
279c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
280c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
281c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            ViewCompatJB.setHasTransientState(view, hasTransientState);
282c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
283ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
284ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
285ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view);
286ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
287ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
288ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
289ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view, left, top, right, bottom);
290ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
291ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
292ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
293ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimation(view, action);
294ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
295ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
296ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
297ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimationDelayed(view, action, delayMillis);
298ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
29925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
30025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
30125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return ViewCompatJB.getImportantForAccessibility(view);
30225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
30325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
30425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
30525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            ViewCompatJB.setImportantForAccessibility(view, mode);
30625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
30725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
3080d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
3090d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return ViewCompatJB.performAccessibilityAction(view, action, arguments);
3100d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
3110d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        @Override
31225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
31325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            Object compat = ViewCompatJB.getAccessibilityNodeProvider(view);
31425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            if (compat != null) {
31525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov                return new AccessibilityNodeProviderCompat(compat);
31625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            }
31725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
31825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
319c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
320c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
3210af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    static class JbMr1ViewCompatImpl extends JBViewCompatImpl {
3220af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
3230af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        @Override
3240af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view) {
3250af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            return ViewCompatJellybeanMr1.getLabelFor(view);
3260af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
3270af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
3280af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        @Override
3290af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id) {
3300af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            ViewCompatJellybeanMr1.setLabelFor(view, id);
3310af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
3326debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell
3336debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        @Override
3346debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint) {
3356debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            ViewCompatJellybeanMr1.setLayerPaint(view, paint);
3366debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
3370af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
3380af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
339bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static final ViewCompatImpl IMPL;
340bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static {
341560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        final int version = android.os.Build.VERSION.SDK_INT;
342215e3168c4d2171531295532b5c80861925c97c8Svetoslav Ganov        if (version >= 17) {
3430af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            IMPL = new JbMr1ViewCompatImpl();
3440af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        } else if (version >= 16) {
345c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            IMPL = new JBViewCompatImpl();
346c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        } else if (version >= 14) {
347bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new ICSViewCompatImpl();
348ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        } else if (version >= 11) {
349ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            IMPL = new HCViewCompatImpl();
350560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        } else if (version >= 9) {
351560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            IMPL = new GBViewCompatImpl();
352bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        } else {
353bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new BaseViewCompatImpl();
354bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
355bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
356bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
3570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled horizontally in a certain direction.
3590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling left, positive to check scrolling right.
3620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
3630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
364bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollHorizontally(View v, int direction) {
365bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollHorizontally(v, direction);
366bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
367bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
3680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled vertically in a certain direction.
3700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling up, positive to check scrolling down.
3730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
3740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
375bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollVertically(View v, int direction) {
376bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollVertically(v, direction);
377bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
378560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
3790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Returns the over-scroll mode for this view. The result will be
3810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
3820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
3830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
3840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return This view's over-scroll mode.
3870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
388560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static int getOverScrollMode(View v) {
389560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        return IMPL.getOverScrollMode(v);
390560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
391560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
3920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Set the over-scroll mode for this view. Valid over-scroll modes are
3940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
3950574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
3960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
3970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Setting the over-scroll mode of a view will have an effect only if the
3990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * view is capable of scrolling.
4000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param overScrollMode The new over-scroll mode for this view.
4030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    public static void setOverScrollMode(View v, int overScrollMode) {
4050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov        IMPL.setOverScrollMode(v, overScrollMode);
406560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
4079648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)}
4100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * giving a chance to this View to populate the accessibility event with its
4110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * text content. While this method is free to modify event
4120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * attributes other than text content, doing so should normally be performed in
4130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}.
4140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Adding formatted date string to an accessibility event in addition
4160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to the text added by the super implementation:
4170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
4180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onPopulateAccessibilityEvent(event);
4190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
4200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     String selectedDateUtterance = DateUtils.formatDateTime(mContext,
4210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *         mCurrentDate.getTimeInMillis(), flags);
4220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.getText().add(selectedDateUtterance);
4230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
4240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
4260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
4270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View,
4280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
4290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
4300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
4320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
4330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The accessibility event which to populate.
4370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
4390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
4400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
4429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onPopulateAccessibilityEvent(v, event);
4439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
4449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link AccessibilityEvent} with information about
4470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * this View which is the event source. In other words, the source of
4480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * an accessibility event is the view whose state change triggered firing
4490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * the event.
4500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Setting the password property of an event in addition
4520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to properties set by the super implementation:
4530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
4540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onInitializeAccessibilityEvent(event);
4550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.setPassword(true);
4560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
4570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
4590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
4600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View,
4610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
4620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
4630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
4650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
4660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The event to initialize.
4700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
4720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
4730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4749648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
4759648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityEvent(v, event);
4769648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
4779648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information
4800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * about this view. The base implementation sets:
4810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <ul>
4820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},</li>
4830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},</li>
4840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},</li>
4850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},</li>
4860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},</li>
4870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},</li>
4880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},</li>
4890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},</li>
4900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},</li>
4910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},</li>
4920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},</li>
4930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},</li>
4940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </ul>
4950574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
4960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Subclasses should override this method, call the super implementation,
4970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * and set additional attributes.
4980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
4990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
5000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
5010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
5020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View,
5030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  android.view.accessibility.AccessibilityNodeInfo)}
5040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
5050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
5060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
5070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
5080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param info The instance to initialize.
5090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
5109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
5119648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityNodeInfo(v, info);
5129648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
5139648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
5140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
5150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Sets a delegate for implementing accessibility support via compositon as
5160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * opposed to inheritance. The delegate's primary use is for implementing
5170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * backwards compatible widgets. For more details see
5180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate}.
5190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
5200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
5210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param delegate The delegate instance.
5220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
5230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see android.view.View.AccessibilityDelegate
5240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
5259648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
5269648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.setAccessibilityDelegate(v, delegate);
5279648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
528c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
529c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
530c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Indicates whether the view is currently tracking transient state that the
531c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * app should not need to concern itself with saving and restoring, but that
532c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * the framework should take special note to preserve when possible.
533c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
534c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View to check for transient state
535c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @return true if the view has transient state
536c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
537c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static boolean hasTransientState(View view) {
538c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        return IMPL.hasTransientState(view);
539c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
540c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
541c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
542c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Set whether this view is currently tracking transient state that the
543c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * framework should attempt to preserve when possible.
544c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
545c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View tracking transient state
546c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param hasTransientState true if this view has transient state
547c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
548c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static void setHasTransientState(View view, boolean hasTransientState) {
549c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        IMPL.setHasTransientState(view, hasTransientState);
550c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
551ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
552ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
553ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate to happen on the next animation time step, typically the
554ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * next display frame.</p>
555ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
556ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
557ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
558ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
559ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
560ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
561ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view) {
562ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view);
563ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
564ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
565ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
566ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate of the specified area to happen on the next animation
567ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * time step, typically the next display frame.</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 invalidate
573ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param left The left coordinate of the rectangle to invalidate.
574ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param top The top coordinate of the rectangle to invalidate.
575ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param right The right coordinate of the rectangle to invalidate.
576ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param bottom The bottom coordinate of the rectangle to invalidate.
577ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
578ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view, int left, int top,
579ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            int right, int bottom) {
580ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view, left, top, right, bottom);
581ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
582ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
583ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
584ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step.
585ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
586ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
587ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
588ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
589ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
590ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to post this Runnable to
591ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
592ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
593ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimation(View view, Runnable action) {
594ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimation(view, action);
595ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
596ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
597ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
598ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step,
599ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * after the specified amount of time elapses.
600ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
601ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
602ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
603ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
604ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
605ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view The view to post this Runnable to
606ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
607ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param delayMillis The delay (in milliseconds) until the Runnable
608ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *        will be executed.
609ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
610ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
611ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimationDelayed(view, action, delayMillis);
612ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
61325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
61425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
61525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the mode for determining whether this View is important for accessibility
61625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
61725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
61825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
61925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
62025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The mode for determining whether a View is important for accessibility.
62125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
62225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
62325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
62425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
62525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
62625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static int getImportantForAccessibility(View view) {
62725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getImportantForAccessibility(view);
62825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
62925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
63025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
63125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Sets how to determine whether this view is important for accessibility
63225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
63325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
63425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
63525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to set.
63625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param mode How to determine whether this view is important for accessibility.
63725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
63825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
63925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
64025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
64125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
64225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static void setImportantForAccessibility(View view, int mode) {
64325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        IMPL.setImportantForAccessibility(view, mode);
64425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
64525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
64625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
6470d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * Performs the specified accessibility action on the view. For
6480d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * possible accessibility actions look at {@link AccessibilityNodeInfoCompat}.
6490d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * <p>
6500d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * If an {@link AccessibilityDelegateCompat} has been specified via calling
6510d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its
6520d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link AccessibilityDelegateCompat#performAccessibilityAction(View, int, Bundle)}
6530d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * is responsible for handling this call.
6540d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * </p>
6550d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     *
6560d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param action The action to perform.
6570d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param arguments Optional action arguments.
6580d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @return Whether the action was performed.
6590d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     */
6600d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    public static boolean performAccessibilityAction(View view, int action, Bundle arguments) {
6610d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        return IMPL.performAccessibilityAction(view, action, arguments);
6620d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    }
6630d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv
6640d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    /**
66525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the provider for managing a virtual view hierarchy rooted at this View
666e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * and reported to {@link android.accessibilityservice.AccessibilityService}s
66725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * that explore the window content.
66825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
66925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If this method returns an instance, this instance is responsible for managing
670e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * {@link AccessibilityNodeInfoCompat}s describing the virtual sub-tree rooted at
67125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * this View including the one representing the View itself. Similarly the returned
67225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * instance is responsible for performing accessibility actions on any virtual
67325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * view or the root view itself.
67425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
67525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
67625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If an {@link AccessibilityDelegateCompat} has been specified via calling
677e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat) its
67825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * {@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)}
67925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * is responsible for handling this call.
68025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
68125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
68225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
68325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The provider.
68425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
68525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see AccessibilityNodeProviderCompat
68625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
68725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
68825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getAccessibilityNodeProvider(view);
68925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
6908a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
6918a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
6928a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Specifies the type of layer backing this view. The layer can be
6938a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_NONE disabled}, {@link #LAYER_TYPE_SOFTWARE software} or
6948a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_HARDWARE hardware}.</p>
6958a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
6968a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A layer is associated with an optional {@link android.graphics.Paint}
6978a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * instance that controls how the layer is composed on screen. The following
6988a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * properties of the paint are taken into account when composing the layer:</p>
6998a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <ul>
7008a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
7018a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
7028a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
7038a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * </ul>
7048a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
7058a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>If this view has an alpha value set to < 1.0 by calling
7068a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * setAlpha(float), the alpha value of the layer's paint is replaced by
7078a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * this view's alpha value. Calling setAlpha(float) is therefore
7088a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * equivalent to setting a hardware layer on this view and providing a paint with
7098a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * the desired alpha value.<p>
7108a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
7118a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Refer to the documentation of {@link #LAYER_TYPE_NONE disabled},
7128a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_SOFTWARE software} and {@link #LAYER_TYPE_HARDWARE hardware}
7138a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * for more information on when and how to use layers.</p>
7148a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
7158a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The ype of layer to use with this view, must be one of
7168a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
7178a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
7188a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
7198a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
7208a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
7218a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
7228a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param view View to set the layer type for
7238a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The type of layer to use with this view, must be one of
7248a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
7258a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
7268a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
7278a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
7288a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
7298a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
7308a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static void setLayerType(View view, int layerType, Paint paint) {
7318a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        IMPL.setLayerType(view, layerType, paint);
7328a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    }
73397341bdc5bea1d7bf777de65228039142d249f38Adam Powell
73497341bdc5bea1d7bf777de65228039142d249f38Adam Powell    /**
73597341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * Indicates what type of layer is currently associated with this view. By default
73697341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * a view does not have a layer, and the layer type is {@link #LAYER_TYPE_NONE}.
73797341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * Refer to the documentation of
73897341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * {@link #setLayerType(android.view.View, int, android.graphics.Paint)}
73997341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * for more information on the different types of layers.
74097341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *
74197341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @param view The view to fetch the layer type from
74297341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @return {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
74397341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *         {@link #LAYER_TYPE_HARDWARE}
74497341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *
74597341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #setLayerType(android.view.View, int, android.graphics.Paint)
74697341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_NONE
74797341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_SOFTWARE
74897341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_HARDWARE
74997341bdc5bea1d7bf777de65228039142d249f38Adam Powell     */
75097341bdc5bea1d7bf777de65228039142d249f38Adam Powell    public static int getLayerType(View view) {
75197341bdc5bea1d7bf777de65228039142d249f38Adam Powell        return IMPL.getLayerType(view);
75297341bdc5bea1d7bf777de65228039142d249f38Adam Powell    }
7530af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
7540af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    /**
7550af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * Gets the id of a view for which a given view serves as a label for
7560af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * accessibility purposes.
7570af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     *
7580af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param view The view on which to invoke the corresponding method.
7590af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @return The labeled view id.
7600af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     */
7610af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    public static int getLabelFor(View view) {
7620af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        return IMPL.getLabelFor(view);
7630af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
7640af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
7650af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    /**
7660af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * Sets the id of a view for which a given view serves as a label for
7670af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * accessibility purposes.
7680af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     *
7690af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param view The view on which to invoke the corresponding method.
7700af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param labeledId The labeled view id.
7710af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     */
7720af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    public static void setLabelFor(View view, int labeledId) {
7730af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        IMPL.setLabelFor(view, labeledId);
7740af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
7756debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell
7766debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    /**
7776debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * Updates the {@link Paint} object used with the current layer (used only if the current
7786debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * layer type is not set to {@link #LAYER_TYPE_NONE}). Changed properties of the Paint
7796debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * provided to {@link #setLayerType(android.view.View, int, android.graphics.Paint)}
7806debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * will be used the next time the View is redrawn, but
7816debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * {@link #setLayerPaint(android.view.View, android.graphics.Paint)}
7826debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * must be called to ensure that the view gets redrawn immediately.
7836debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
7846debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <p>A layer is associated with an optional {@link android.graphics.Paint}
7856debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * instance that controls how the layer is composed on screen. The following
7866debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * properties of the paint are taken into account when composing the layer:</p>
7876debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <ul>
7886debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
7896debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
7906debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
7916debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * </ul>
7926debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
7936debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <p>If this view has an alpha value set to < 1.0 by calling
7946debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * View#setAlpha(float), the alpha value of the layer's paint is replaced by
7956debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * this view's alpha value. Calling View#setAlpha(float) is therefore
7966debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * equivalent to setting a hardware layer on this view and providing a paint with
7976debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * the desired alpha value.</p>
7986debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
7996debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * @param paint The paint used to compose the layer. This argument is optional
8006debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *        and can be null. It is ignored when the layer type is
8016debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *        {@link #LAYER_TYPE_NONE}
8026debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
8036debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * @see #setLayerType(int, android.graphics.Paint)
8046debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     */
8056debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    public static void setLayerPaint(View view, Paint paint) {
8066debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        IMPL.setLayerPaint(view, paint);
8076debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    }
808bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell}
809