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;
20c029e15f5a4709214cb433a562256586824a0f33Adam Powellimport android.graphics.PixelFormat;
210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganovimport android.graphics.Rect;
22c029e15f5a4709214cb433a562256586824a0f33Adam Powellimport android.graphics.drawable.Drawable;
230d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanvimport android.os.Bundle;
249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
2525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeProviderCompat;
26bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellimport android.view.View;
273cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powellimport android.view.ViewParent;
289648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.accessibility.AccessibilityEvent;
29bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
30bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/**
310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link View} introduced after API
320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * level 4 in a backwards compatible fashion.
33bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */
34bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpublic class ViewCompat {
35560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
36560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Always allow a user to over-scroll this view, provided it is a
37560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * view that can scroll.
38560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
39560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_ALWAYS = 0;
40560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
41560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
42560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Allow a user to over-scroll this view only if the content is large
43560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * enough to meaningfully scroll, provided it is a view that can scroll.
44560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
45560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_IF_CONTENT_SCROLLS = 1;
46560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
47560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
48560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Never allow a user to over-scroll this view.
49560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
50560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_NEVER = 2;
51560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
52ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    private static final long FAKE_FRAME_TIME = 10;
53ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
5425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
5525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Automatically determine whether a view is important for accessibility.
5625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
5725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = 0x00000000;
5825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
5925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
6025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * The view is important for accessibility.
6125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
6225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 0x00000001;
6325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
6425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
6525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * The view is not important for accessibility.
6625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
6725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002;
6825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
698a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
70b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     * The view is not important for accessibility, nor are any of its
71b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     * descendant views.
72b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     */
73b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette    public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS = 0x00000004;
74b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette
75b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette    /**
76086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Live region mode specifying that accessibility services should not
77086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * automatically announce changes to this view. This is the default live
78086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * region mode for most views.
79086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
80086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Use with {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.
81086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
82086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0x00000000;
83086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
84086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
85086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Live region mode specifying that accessibility services should announce
86086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * changes to this view.
87086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
88086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Use with {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.
89086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
90086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 0x00000001;
91086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
92086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
93086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Live region mode specifying that accessibility services should interrupt
94086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * ongoing speech to immediately announce changes to this view.
95086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
96086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Use with {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.
97086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
98086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    public static final int ACCESSIBILITY_LIVE_REGION_ASSERTIVE = 0x00000002;
99086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
100086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
1018a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * Indicates that the view does not have a layer.
1028a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
1038a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_NONE = 0;
1048a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
1058a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
1068a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Indicates that the view has a software layer. A software layer is backed
1078a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * by a bitmap and causes the view to be rendered using Android's software
1088a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rendering pipeline, even if hardware acceleration is enabled.</p>
1098a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
1108a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Software layers have various usages:</p>
1118a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>When the application is not using hardware acceleration, a software layer
1128a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * is useful to apply a specific color filter and/or blending mode and/or
1138a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * translucency to a view and all its children.</p>
1148a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>When the application is using hardware acceleration, a software layer
1158a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * is useful to render drawing primitives not supported by the hardware
1168a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * accelerated pipeline. It can also be used to cache a complex view tree
1178a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * into a texture and reduce the complexity of drawing operations. For instance,
1188a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * when animating a complex view tree with a translation, a software layer can
1198a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * be used to render the view tree only once.</p>
1208a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Software layers should be avoided when the affected view tree updates
1218a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * often. Every update will require to re-render the software layer, which can
1228a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * potentially be slow (particularly when hardware acceleration is turned on
1238a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * since the layer will have to be uploaded into a hardware texture after every
1248a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * update.)</p>
1258a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
1268a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_SOFTWARE = 1;
1278a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
1288a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
1298a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Indicates that the view has a hardware layer. A hardware layer is backed
1308a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * by a hardware specific texture (generally Frame Buffer Objects or FBO on
1318a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * OpenGL hardware) and causes the view to be rendered using Android's hardware
1328a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rendering pipeline, but only if hardware acceleration is turned on for the
1338a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * view hierarchy. When hardware acceleration is turned off, hardware layers
1348a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * behave exactly as {@link #LAYER_TYPE_SOFTWARE software layers}.</p>
1358a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
1368a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer is useful to apply a specific color filter and/or
1378a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * blending mode and/or translucency to a view and all its children.</p>
1388a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer can be used to cache a complex view tree into a
1398a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * texture and reduce the complexity of drawing operations. For instance,
1408a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * when animating a complex view tree with a translation, a hardware layer can
1418a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * be used to render the view tree only once.</p>
1428a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer can also be used to increase the rendering quality when
1438a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rotation transformations are applied on a view. It can also be used to
1448a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * prevent potential clipping issues when applying 3D transforms on a view.</p>
1458a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
1468a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_HARDWARE = 2;
1478a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
1481d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
1491d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Horizontal layout direction of this view is from Left to Right.
1501d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
1511d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static final int LAYOUT_DIRECTION_LTR = 0;
1521d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
1531d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
1541d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Horizontal layout direction of this view is from Right to Left.
1551d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
1561d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static final int LAYOUT_DIRECTION_RTL = 1;
1571d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
1581d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
1591d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Horizontal layout direction of this view is inherited from its parent.
1601d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Use with {@link #setLayoutDirection}.
1611d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
1621d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static final int LAYOUT_DIRECTION_INHERIT = 2;
1631d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
1641d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
1651d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Horizontal layout direction of this view is from deduced from the default language
1661d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * script for the locale. Use with {@link #setLayoutDirection}.
1671d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
1681d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static final int LAYOUT_DIRECTION_LOCALE = 3;
1691d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
170b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
171b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Bits of {@link #getMeasuredWidthAndState} and
172b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #getMeasuredWidthAndState} that provide the actual measured size.
173b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
174b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static final int MEASURED_SIZE_MASK = 0x00ffffff;
175b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
176b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
177b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Bits of {@link #getMeasuredWidthAndState} and
178b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #getMeasuredWidthAndState} that provide the additional state bits.
179b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
180b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static final int MEASURED_STATE_MASK = 0xff000000;
181b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
182b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
183b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Bit shift of {@link #MEASURED_STATE_MASK} to get to the height bits
184b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * for functions that combine both width and height into a single int,
185b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * such as {@link #getMeasuredState} and the childState argument of
186b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #resolveSizeAndState(int, int, int)}.
187b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
188b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static final int MEASURED_HEIGHT_STATE_SHIFT = 16;
189b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
190b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
191b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Bit of {@link #getMeasuredWidthAndState} and
192b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #getMeasuredWidthAndState} that indicates the measured size
193b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * is smaller that the space the view would like to have.
194b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
195b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static final int MEASURED_STATE_TOO_SMALL = 0x01000000;
196b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
197bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    interface ViewCompatImpl {
198bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction);
199bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction);
200560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v);
201560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode);
2029648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event);
2039648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event);
2049648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info);
2059648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate);
206c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view);
207c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState);
208ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view);
209ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom);
210ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action);
211ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis);
21225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view);
21325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode);
2140d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments);
21525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view);
21614631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public float getAlpha(View view);
2178a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        public void setLayerType(View view, int layerType, Paint paint);
21897341bdc5bea1d7bf777de65228039142d249f38Adam Powell        public int getLayerType(View view);
2190af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view);
2206debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLabelFor(View view, int id);
2216debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint);
2221d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public int getLayoutDirection(View view);
2231d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public void setLayoutDirection(View view, int layoutDirection);
2243cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        public ViewParent getParentForAccessibility(View view);
225c029e15f5a4709214cb433a562256586824a0f33Adam Powell        public boolean isOpaque(View view);
226b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int resolveSizeAndState(int size, int measureSpec, int childMeasuredState);
227b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredWidthAndState(View view);
228b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredHeightAndState(View view);
229b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredState(View view);
230086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public int getAccessibilityLiveRegion(View view);
231086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public void setAccessibilityLiveRegion(View view, int mode);
232bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
233bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
234bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static class BaseViewCompatImpl implements ViewCompatImpl {
235bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
236bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
237bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
238bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
239bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
240bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
241560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
242560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return OVER_SCROLL_NEVER;
243560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
244560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
245560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            // Do nothing; API doesn't exist
246560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
2479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
2489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
2499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
2519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
2529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
2549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov         // Do nothing; API doesn't exist
2559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
2579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
2589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
259c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
260c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // A view can't have transient state if transient state wasn't supported.
261c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return false;
262c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
263c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
264c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // Do nothing; API doesn't exist
265c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
266ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
267ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime());
268ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
269ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
270ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime(), left, top, right, bottom);
271ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
272ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
273ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime());
274ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
275ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
276ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime() + delayMillis);
277ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
278ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
279ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return FAKE_FRAME_TIME;
280ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
28125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
28225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return 0;
28325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
28425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
28525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
28625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
2870d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
2880d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return false;
2890d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
29025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
29125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
29225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
29314631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public float getAlpha(View view) {
29414631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette            return 1.0f;
29514631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        }
2968a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        public void setLayerType(View view, int layerType, Paint paint) {
2976debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // No-op until layers became available (HC)
2988a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
29997341bdc5bea1d7bf777de65228039142d249f38Adam Powell        public int getLayerType(View view) {
30097341bdc5bea1d7bf777de65228039142d249f38Adam Powell            return LAYER_TYPE_NONE;
30197341bdc5bea1d7bf777de65228039142d249f38Adam Powell        }
3020af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view) {
3030af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            return 0;
3040af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
3050af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id) {
3060af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
3070af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
3086debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint p) {
3096debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // No-op until layers became available (HC)
3106debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
3111d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
3121d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        @Override
3131d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public int getLayoutDirection(View view) {
3141d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell            return LAYOUT_DIRECTION_LTR;
3151d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        }
3161d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
3171d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        @Override
3181d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public void setLayoutDirection(View view, int layoutDirection) {
3191d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell            // No-op
3201d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        }
3213cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell
3223cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        @Override
3233cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        public ViewParent getParentForAccessibility(View view) {
3243cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell            return view.getParent();
3253cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        }
326c029e15f5a4709214cb433a562256586824a0f33Adam Powell
327c029e15f5a4709214cb433a562256586824a0f33Adam Powell        @Override
328c029e15f5a4709214cb433a562256586824a0f33Adam Powell        public boolean isOpaque(View view) {
329c029e15f5a4709214cb433a562256586824a0f33Adam Powell            final Drawable bg = view.getBackground();
330c029e15f5a4709214cb433a562256586824a0f33Adam Powell            if (bg != null) {
331c029e15f5a4709214cb433a562256586824a0f33Adam Powell                return bg.getOpacity() == PixelFormat.OPAQUE;
332c029e15f5a4709214cb433a562256586824a0f33Adam Powell            }
333c029e15f5a4709214cb433a562256586824a0f33Adam Powell            return false;
334c029e15f5a4709214cb433a562256586824a0f33Adam Powell        }
335b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
336b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) {
337b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return View.resolveSize(size, measureSpec);
338b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
339b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
340b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
341b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredWidthAndState(View view) {
342b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return view.getMeasuredWidth();
343b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
344b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
345b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
346b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredHeightAndState(View view) {
347b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return view.getMeasuredHeight();
348b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
349b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
350b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
351b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredState(View view) {
352b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return 0;
353b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
354086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
355086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        @Override
356086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public int getAccessibilityLiveRegion(View view) {
357086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            return ACCESSIBILITY_LIVE_REGION_NONE;
358086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        }
359086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
360086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        @Override
361086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public void setAccessibilityLiveRegion(View view, int mode) {
362086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            // No-op
363086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        }
364bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
365bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
366c029e15f5a4709214cb433a562256586824a0f33Adam Powell    static class EclairMr1ViewCompatImpl extends BaseViewCompatImpl {
367c029e15f5a4709214cb433a562256586824a0f33Adam Powell        @Override
368c029e15f5a4709214cb433a562256586824a0f33Adam Powell        public boolean isOpaque(View view) {
369c029e15f5a4709214cb433a562256586824a0f33Adam Powell            return ViewCompatEclairMr1.isOpaque(view);
370c029e15f5a4709214cb433a562256586824a0f33Adam Powell        }
371c029e15f5a4709214cb433a562256586824a0f33Adam Powell    }
372c029e15f5a4709214cb433a562256586824a0f33Adam Powell
373c029e15f5a4709214cb433a562256586824a0f33Adam Powell    static class GBViewCompatImpl extends EclairMr1ViewCompatImpl {
3749648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
375560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
376560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return ViewCompatGingerbread.getOverScrollMode(v);
377560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
3789648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
379560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
380560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            ViewCompatGingerbread.setOverScrollMode(v, mode);
381560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
382560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
383560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
384ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class HCViewCompatImpl extends GBViewCompatImpl {
38514631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        @Override
386ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
387ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return ViewCompatHC.getFrameTime();
388ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
38914631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        @Override
39014631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public float getAlpha(View view) {
39114631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette            return ViewCompatHC.getAlpha(view);
39214631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        }
39314631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        @Override
39414631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public void setLayerType(View view, int layerType, Paint paint) {
3958a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell            ViewCompatHC.setLayerType(view, layerType, paint);
3968a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
39714631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        @Override
39814631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public int getLayerType(View view)  {
39997341bdc5bea1d7bf777de65228039142d249f38Adam Powell            return ViewCompatHC.getLayerType(view);
40097341bdc5bea1d7bf777de65228039142d249f38Adam Powell        }
4016debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        @Override
4026debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint) {
4036debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // Make sure the paint is correct; this will be cheap if it's the same
4046debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // instance as was used to call setLayerType earlier.
4056debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            setLayerType(view, getLayerType(view), paint);
4066debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // This is expensive, but the only way to accomplish this before JB-MR1.
4076debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            view.invalidate();
4086debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
409b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
410b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) {
411b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return ViewCompatHC.resolveSizeAndState(size, measureSpec, childMeasuredState);
412b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
413b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
414b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredWidthAndState(View view) {
415b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return ViewCompatHC.getMeasuredWidthAndState(view);
416b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
417b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
418b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredHeightAndState(View view) {
419b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return ViewCompatHC.getMeasuredHeightAndState(view);
420b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
421b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
422b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredState(View view) {
423b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return ViewCompatHC.getMeasuredState(view);
424b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
425ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
426ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
427ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class ICSViewCompatImpl extends HCViewCompatImpl {
4289648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
429bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
430bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollHorizontally(v, direction);
431bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
4329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
433bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
434bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollVertically(v, direction);
435bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
4369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
4379648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
4389648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onPopulateAccessibilityEvent(v, event);
4399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
4409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
4419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
4429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityEvent(v, event);
4439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
4449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
4459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
446956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityNodeInfo(v, info.getInfo());
4479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
4489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
4499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
4509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.setAccessibilityDelegate(v, delegate.getBridge());
4519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
452bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
453bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
454c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    static class JBViewCompatImpl extends ICSViewCompatImpl {
455c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
456c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
457c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return ViewCompatJB.hasTransientState(view);
458c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
459c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
460c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
461c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            ViewCompatJB.setHasTransientState(view, hasTransientState);
462c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
463ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
464ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
465ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view);
466ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
467ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
468ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
469ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view, left, top, right, bottom);
470ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
471ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
472ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
473ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimation(view, action);
474ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
475ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
476ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
477ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimationDelayed(view, action, delayMillis);
478ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
47925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
48025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
48125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return ViewCompatJB.getImportantForAccessibility(view);
48225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
48325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
48425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
48525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            ViewCompatJB.setImportantForAccessibility(view, mode);
48625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
48725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
4880d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
4890d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return ViewCompatJB.performAccessibilityAction(view, action, arguments);
4900d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
4910d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        @Override
49225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
49325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            Object compat = ViewCompatJB.getAccessibilityNodeProvider(view);
49425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            if (compat != null) {
49525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov                return new AccessibilityNodeProviderCompat(compat);
49625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            }
49725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
49825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
4993cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell
5003cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        @Override
5013cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        public ViewParent getParentForAccessibility(View view) {
5023cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell            return ViewCompatJB.getParentForAccessibility(view);
5033cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        }
504c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
505c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
5060af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    static class JbMr1ViewCompatImpl extends JBViewCompatImpl {
5070af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
5080af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        @Override
5090af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view) {
5100af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            return ViewCompatJellybeanMr1.getLabelFor(view);
5110af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
5120af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
5130af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        @Override
5140af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id) {
5150af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            ViewCompatJellybeanMr1.setLabelFor(view, id);
5160af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
5176debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell
5186debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        @Override
5196debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint) {
5206debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            ViewCompatJellybeanMr1.setLayerPaint(view, paint);
5216debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
5221d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
5231d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        @Override
5241d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public int getLayoutDirection(View view) {
5251d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell            return ViewCompatJellybeanMr1.getLayoutDirection(view);
5261d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        }
5271d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
5281d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        @Override
5291d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public void setLayoutDirection(View view, int layoutDirection) {
5301d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell            ViewCompatJellybeanMr1.setLayoutDirection(view, layoutDirection);
5311d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        }
5320af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
5330af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
534086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    static class KitKatViewCompatImpl extends JbMr1ViewCompatImpl {
535086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        @Override
536086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public int getAccessibilityLiveRegion(View view) {
537086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            return ViewCompatKitKat.getAccessibilityLiveRegion(view);
538086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        }
539086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
540086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        @Override
541086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public void setAccessibilityLiveRegion(View view, int mode) {
542086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            ViewCompatKitKat.setAccessibilityLiveRegion(view, mode);
543086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        }
544086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    }
545086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
546bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static final ViewCompatImpl IMPL;
547bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static {
548560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        final int version = android.os.Build.VERSION.SDK_INT;
549086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        if (version >= 19) {
550086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            IMPL = new KitKatViewCompatImpl();
551086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        } else if (version >= 17) {
5520af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            IMPL = new JbMr1ViewCompatImpl();
5530af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        } else if (version >= 16) {
554c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            IMPL = new JBViewCompatImpl();
555c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        } else if (version >= 14) {
556bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new ICSViewCompatImpl();
557ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        } else if (version >= 11) {
558ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            IMPL = new HCViewCompatImpl();
559560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        } else if (version >= 9) {
560560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            IMPL = new GBViewCompatImpl();
561bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        } else {
562bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new BaseViewCompatImpl();
563bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
564bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
565bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
5660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
5670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled horizontally in a certain direction.
5680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
5690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
5700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling left, positive to check scrolling right.
5710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
5720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
573bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollHorizontally(View v, int direction) {
574bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollHorizontally(v, direction);
575bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
576bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
5770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
5780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled vertically in a certain direction.
5790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
5800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
5810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling up, positive to check scrolling down.
5820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
5830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
584bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollVertically(View v, int direction) {
585bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollVertically(v, direction);
586bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
587560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
5880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
5890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Returns the over-scroll mode for this view. The result will be
5900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
5910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
5920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
5930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
5940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
5950574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return This view's over-scroll mode.
5960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
597560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static int getOverScrollMode(View v) {
598560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        return IMPL.getOverScrollMode(v);
599560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
600560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
6010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
6020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Set the over-scroll mode for this view. Valid over-scroll modes are
6030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
6040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
6050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
6060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
6070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Setting the over-scroll mode of a view will have an effect only if the
6080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * view is capable of scrolling.
6090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
6100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
6110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param overScrollMode The new over-scroll mode for this view.
6120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
6130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    public static void setOverScrollMode(View v, int overScrollMode) {
6140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov        IMPL.setOverScrollMode(v, overScrollMode);
615560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
6169648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
6170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
6180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)}
6190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * giving a chance to this View to populate the accessibility event with its
6200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * text content. While this method is free to modify event
6210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * attributes other than text content, doing so should normally be performed in
6220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}.
6230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
6240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Adding formatted date string to an accessibility event in addition
6250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to the text added by the super implementation:
6260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
6270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onPopulateAccessibilityEvent(event);
6280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
6290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     String selectedDateUtterance = DateUtils.formatDateTime(mContext,
6300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *         mCurrentDate.getTimeInMillis(), flags);
6310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.getText().add(selectedDateUtterance);
6320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
6330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
6340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
6350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
6360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View,
6370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
6380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
6390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
6400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
6410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
6420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
6430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
6440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
6450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The accessibility event which to populate.
6460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
6470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
6480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
6490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
6509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
6519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onPopulateAccessibilityEvent(v, event);
6529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
6539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
6540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
6550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link AccessibilityEvent} with information about
6560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * this View which is the event source. In other words, the source of
6570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * an accessibility event is the view whose state change triggered firing
6580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * the event.
6590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
6600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Setting the password property of an event in addition
6610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to properties set by the super implementation:
6620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
6630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onInitializeAccessibilityEvent(event);
6640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.setPassword(true);
6650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
6660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
6670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
6680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
6690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View,
6700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
6710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
6720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
6730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
6740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
6750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
6760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
6770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
6780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The event to initialize.
6790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
6800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
6810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
6820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
6839648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
6849648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityEvent(v, event);
6859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
6869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
6870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
6880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information
6890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * about this view. The base implementation sets:
6900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <ul>
6910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},</li>
6920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},</li>
6930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},</li>
6940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},</li>
6950574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},</li>
6960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},</li>
6970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},</li>
6980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},</li>
6990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},</li>
7000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},</li>
7010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},</li>
7020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},</li>
7030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </ul>
7040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
7050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Subclasses should override this method, call the super implementation,
7060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * and set additional attributes.
7070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
7080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
7090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
7100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
7110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View,
7120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  android.view.accessibility.AccessibilityNodeInfo)}
7130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
7140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
7150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
7170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param info The instance to initialize.
7180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
7199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
7209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityNodeInfo(v, info);
7219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
7229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
7230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
7240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Sets a delegate for implementing accessibility support via compositon as
7250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * opposed to inheritance. The delegate's primary use is for implementing
7260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * backwards compatible widgets. For more details see
7270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate}.
7280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
7300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param delegate The delegate instance.
7310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see android.view.View.AccessibilityDelegate
7330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
7349648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
7359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.setAccessibilityDelegate(v, delegate);
7369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
737c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
738c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
739c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Indicates whether the view is currently tracking transient state that the
740c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * app should not need to concern itself with saving and restoring, but that
741c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * the framework should take special note to preserve when possible.
742c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
743c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View to check for transient state
744c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @return true if the view has transient state
745c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
746c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static boolean hasTransientState(View view) {
747c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        return IMPL.hasTransientState(view);
748c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
749c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
750c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
751c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Set whether this view is currently tracking transient state that the
752c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * framework should attempt to preserve when possible.
753c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
754c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View tracking transient state
755c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param hasTransientState true if this view has transient state
756c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
757c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static void setHasTransientState(View view, boolean hasTransientState) {
758c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        IMPL.setHasTransientState(view, hasTransientState);
759c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
760ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
761ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
762ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate to happen on the next animation time step, typically the
763ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * next display frame.</p>
764ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
765ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
766ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
767ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
768ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
769ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
770ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view) {
771ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view);
772ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
773ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
774ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
775ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate of the specified area to happen on the next animation
776ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * time step, typically the next display frame.</p>
777ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
778ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
779ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
780ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
781ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
782ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param left The left coordinate of the rectangle to invalidate.
783ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param top The top coordinate of the rectangle to invalidate.
784ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param right The right coordinate of the rectangle to invalidate.
785ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param bottom The bottom coordinate of the rectangle to invalidate.
786ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
787ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view, int left, int top,
788ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            int right, int bottom) {
789ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view, left, top, right, bottom);
790ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
791ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
792ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
793ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step.
794ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
795ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
796ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
797ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
798ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
799ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to post this Runnable to
800ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
801ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
802ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimation(View view, Runnable action) {
803ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimation(view, action);
804ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
805ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
806ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
807ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step,
808ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * after the specified amount of time elapses.
809ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
810ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
811ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
812ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
813ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
814ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view The view to post this Runnable to
815ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
816ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param delayMillis The delay (in milliseconds) until the Runnable
817ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *        will be executed.
818ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
819ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
820ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimationDelayed(view, action, delayMillis);
821ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
82225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
82325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
82425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the mode for determining whether this View is important for accessibility
82525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
82625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
82725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
82825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
82925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The mode for determining whether a View is important for accessibility.
83025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
83125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
83225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
833b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
83425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
83525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
83625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static int getImportantForAccessibility(View view) {
83725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getImportantForAccessibility(view);
83825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
83925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
84025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
84125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Sets how to determine whether this view is important for accessibility
84225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
84325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
84425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
84525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to set.
84625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param mode How to determine whether this view is important for accessibility.
84725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
84825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
84925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
850b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
85125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
85225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
85325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static void setImportantForAccessibility(View view, int mode) {
85425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        IMPL.setImportantForAccessibility(view, mode);
85525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
85625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
85725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
8580d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * Performs the specified accessibility action on the view. For
8590d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * possible accessibility actions look at {@link AccessibilityNodeInfoCompat}.
8600d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * <p>
8610d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * If an {@link AccessibilityDelegateCompat} has been specified via calling
8620d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its
8630d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link AccessibilityDelegateCompat#performAccessibilityAction(View, int, Bundle)}
8640d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * is responsible for handling this call.
8650d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * </p>
8660d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     *
8670d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param action The action to perform.
8680d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param arguments Optional action arguments.
8690d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @return Whether the action was performed.
8700d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     */
8710d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    public static boolean performAccessibilityAction(View view, int action, Bundle arguments) {
8720d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        return IMPL.performAccessibilityAction(view, action, arguments);
8730d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    }
8740d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv
8750d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    /**
87625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the provider for managing a virtual view hierarchy rooted at this View
877e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * and reported to {@link android.accessibilityservice.AccessibilityService}s
87825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * that explore the window content.
87925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
88025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If this method returns an instance, this instance is responsible for managing
881e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * {@link AccessibilityNodeInfoCompat}s describing the virtual sub-tree rooted at
88225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * this View including the one representing the View itself. Similarly the returned
88325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * instance is responsible for performing accessibility actions on any virtual
88425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * view or the root view itself.
88525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
88625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
88725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If an {@link AccessibilityDelegateCompat} has been specified via calling
88814631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its
88925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * {@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)}
89025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * is responsible for handling this call.
89125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
89225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
89325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
89425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The provider.
89525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
89625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see AccessibilityNodeProviderCompat
89725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
89825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
89925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getAccessibilityNodeProvider(view);
90025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
9018a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
9028a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
90314631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * The opacity of the view. This is a value from 0 to 1, where 0 means the view is
90414631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * completely transparent and 1 means the view is completely opaque.
90514631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     *
90614631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * <p>By default this is 1.0f. Prior to API 11, the returned value is always 1.0f.
90714631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * @return The opacity of the view.
90814631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     */
90914631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette    public static float getAlpha(View view) {
91014631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        return IMPL.getAlpha(view);
91114631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette    }
91214631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette
91314631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette    /**
9148a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Specifies the type of layer backing this view. The layer can be
9158a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_NONE disabled}, {@link #LAYER_TYPE_SOFTWARE software} or
9168a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_HARDWARE hardware}.</p>
9178a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
9188a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A layer is associated with an optional {@link android.graphics.Paint}
9198a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * instance that controls how the layer is composed on screen. The following
9208a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * properties of the paint are taken into account when composing the layer:</p>
9218a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <ul>
9228a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
9238a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
9248a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
9258a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * </ul>
9268a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
9278a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>If this view has an alpha value set to < 1.0 by calling
9288a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * setAlpha(float), the alpha value of the layer's paint is replaced by
9298a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * this view's alpha value. Calling setAlpha(float) is therefore
9308a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * equivalent to setting a hardware layer on this view and providing a paint with
9318a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * the desired alpha value.<p>
9328a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
9338a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Refer to the documentation of {@link #LAYER_TYPE_NONE disabled},
9348a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_SOFTWARE software} and {@link #LAYER_TYPE_HARDWARE hardware}
9358a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * for more information on when and how to use layers.</p>
9368a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
9378a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The ype of layer to use with this view, must be one of
9388a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
9398a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
9408a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
9418a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
9428a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
9438a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
9448a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param view View to set the layer type for
9458a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The type of layer to use with this view, must be one of
9468a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
9478a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
9488a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
9498a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
9508a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
9518a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
9528a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static void setLayerType(View view, int layerType, Paint paint) {
9538a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        IMPL.setLayerType(view, layerType, paint);
9548a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    }
95597341bdc5bea1d7bf777de65228039142d249f38Adam Powell
95697341bdc5bea1d7bf777de65228039142d249f38Adam Powell    /**
95797341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * Indicates what type of layer is currently associated with this view. By default
95897341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * a view does not have a layer, and the layer type is {@link #LAYER_TYPE_NONE}.
95997341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * Refer to the documentation of
96097341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * {@link #setLayerType(android.view.View, int, android.graphics.Paint)}
96197341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * for more information on the different types of layers.
96297341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *
96397341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @param view The view to fetch the layer type from
96497341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @return {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
96597341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *         {@link #LAYER_TYPE_HARDWARE}
96697341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *
96797341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #setLayerType(android.view.View, int, android.graphics.Paint)
96897341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_NONE
96997341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_SOFTWARE
97097341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_HARDWARE
97197341bdc5bea1d7bf777de65228039142d249f38Adam Powell     */
97297341bdc5bea1d7bf777de65228039142d249f38Adam Powell    public static int getLayerType(View view) {
97397341bdc5bea1d7bf777de65228039142d249f38Adam Powell        return IMPL.getLayerType(view);
97497341bdc5bea1d7bf777de65228039142d249f38Adam Powell    }
9750af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
9760af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    /**
9770af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * Gets the id of a view for which a given view serves as a label for
9780af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * accessibility purposes.
9790af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     *
9800af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param view The view on which to invoke the corresponding method.
9810af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @return The labeled view id.
9820af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     */
9830af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    public static int getLabelFor(View view) {
9840af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        return IMPL.getLabelFor(view);
9850af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
9860af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
9870af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    /**
9880af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * Sets the id of a view for which a given view serves as a label for
9890af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * accessibility purposes.
9900af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     *
9910af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param view The view on which to invoke the corresponding method.
9920af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param labeledId The labeled view id.
9930af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     */
9940af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    public static void setLabelFor(View view, int labeledId) {
9950af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        IMPL.setLabelFor(view, labeledId);
9960af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
9976debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell
9986debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    /**
9996debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * Updates the {@link Paint} object used with the current layer (used only if the current
10006debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * layer type is not set to {@link #LAYER_TYPE_NONE}). Changed properties of the Paint
10016debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * provided to {@link #setLayerType(android.view.View, int, android.graphics.Paint)}
10026debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * will be used the next time the View is redrawn, but
10036debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * {@link #setLayerPaint(android.view.View, android.graphics.Paint)}
10046debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * must be called to ensure that the view gets redrawn immediately.
10056debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
10066debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <p>A layer is associated with an optional {@link android.graphics.Paint}
10076debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * instance that controls how the layer is composed on screen. The following
10086debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * properties of the paint are taken into account when composing the layer:</p>
10096debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <ul>
10106debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
10116debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
10126debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
10136debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * </ul>
10146debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
10156debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <p>If this view has an alpha value set to < 1.0 by calling
10166debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * View#setAlpha(float), the alpha value of the layer's paint is replaced by
10176debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * this view's alpha value. Calling View#setAlpha(float) is therefore
10186debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * equivalent to setting a hardware layer on this view and providing a paint with
10196debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * the desired alpha value.</p>
10206debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
10211d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @param view View to set a layer paint for
10226debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * @param paint The paint used to compose the layer. This argument is optional
10236debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *        and can be null. It is ignored when the layer type is
10246debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *        {@link #LAYER_TYPE_NONE}
10256debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
10261d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @see #setLayerType(View, int, android.graphics.Paint)
10276debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     */
10286debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    public static void setLayerPaint(View view, Paint paint) {
10296debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        IMPL.setLayerPaint(view, paint);
10306debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    }
10311d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
10321d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
10331d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Returns the resolved layout direction for this view.
10341d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
10351d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @param view View to get layout direction for
10361d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @return {@link #LAYOUT_DIRECTION_RTL} if the layout direction is RTL or returns
10371d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_LTR} if the layout direction is not RTL.
10381d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
10391d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * For compatibility, this will return {@link #LAYOUT_DIRECTION_LTR} if API version
10401d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * is lower than Jellybean MR1 (API 17)
10411d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
10421d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static int getLayoutDirection(View view) {
10431d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        return IMPL.getLayoutDirection(view);
10441d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    }
10451d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
10461d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
10471d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Set the layout direction for this view. This will propagate a reset of layout direction
10481d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * resolution to the view's children and resolve layout direction for this view.
10491d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
10501d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @param view View to set layout direction for
10511d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @param layoutDirection the layout direction to set. Should be one of:
10521d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
10531d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_LTR},
10541d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_RTL},
10551d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_INHERIT},
10561d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_LOCALE}.
10571d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
10581d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Resolution will be done if the value is set to LAYOUT_DIRECTION_INHERIT. The resolution
10591d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * proceeds up the parent chain of the view to get the value. If there is no parent, then it
10601d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * will return the default {@link #LAYOUT_DIRECTION_LTR}.
10611d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
10621d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static void setLayoutDirection(View view, int layoutDirection) {
10631d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        IMPL.setLayoutDirection(view, layoutDirection);
10641d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    }
10653cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell
10663cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell    /**
10673cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * Gets the parent for accessibility purposes. Note that the parent for
10683cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * accessibility is not necessary the immediate parent. It is the first
10693cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * predecessor that is important for accessibility.
10703cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     *
10713cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * @param view View to retrieve parent for
10723cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * @return The parent for use in accessibility inspection
10733cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     */
10743cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell    public static ViewParent getParentForAccessibility(View view) {
10753cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        return IMPL.getParentForAccessibility(view);
10763cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell    }
1077c029e15f5a4709214cb433a562256586824a0f33Adam Powell
1078c029e15f5a4709214cb433a562256586824a0f33Adam Powell    /**
1079c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * Indicates whether this View is opaque. An opaque View guarantees that it will
1080c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * draw all the pixels overlapping its bounds using a fully opaque color.
1081c029e15f5a4709214cb433a562256586824a0f33Adam Powell     *
1082c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * On API 7 and above this will call View's true isOpaque method. On previous platform
1083c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * versions it will check the opacity of the view's background drawable if present.
1084c029e15f5a4709214cb433a562256586824a0f33Adam Powell     *
1085c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * @return True if this View is guaranteed to be fully opaque, false otherwise.
1086c029e15f5a4709214cb433a562256586824a0f33Adam Powell     */
1087c029e15f5a4709214cb433a562256586824a0f33Adam Powell    public static boolean isOpaque(View view) {
1088c029e15f5a4709214cb433a562256586824a0f33Adam Powell        return IMPL.isOpaque(view);
1089c029e15f5a4709214cb433a562256586824a0f33Adam Powell    }
1090b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
1091b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
1092b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Utility to reconcile a desired size and state, with constraints imposed
1093b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * by a MeasureSpec.  Will take the desired size, unless a different size
1094b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * is imposed by the constraints.  The returned value is a compound integer,
1095b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * with the resolved size in the {@link #MEASURED_SIZE_MASK} bits and
1096b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * optionally the bit {@link #MEASURED_STATE_TOO_SMALL} set if the resulting
1097b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * size is smaller than the size the view wants to be.
1098b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     *
1099b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @param size How big the view wants to be
1100b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @param measureSpec Constraints imposed by the parent
1101b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @return Size information bit mask as defined by
1102b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #MEASURED_SIZE_MASK} and {@link #MEASURED_STATE_TOO_SMALL}.
1103b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
1104b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) {
1105b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        return IMPL.resolveSizeAndState(size, measureSpec, childMeasuredState);
1106b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    }
1107b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
1108b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
1109b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Return the full width measurement information for this view as computed
1110b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * by the most recent call to {@link android.view.View#measure(int, int)}.
1111b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * This result is a bit mask as defined by {@link #MEASURED_SIZE_MASK} and
1112b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #MEASURED_STATE_TOO_SMALL}.
1113b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * This should be used during measurement and layout calculations only. Use
1114b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link android.view.View#getWidth()} to see how wide a view is after layout.
1115b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     *
1116b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @return The measured width of this view as a bit mask.
1117b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
1118b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static int getMeasuredWidthAndState(View view) {
1119b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        return IMPL.getMeasuredWidthAndState(view);
1120b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    }
1121b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
1122b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
1123b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Return the full height measurement information for this view as computed
1124b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * by the most recent call to {@link android.view.View#measure(int, int)}.
1125b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * This result is a bit mask as defined by {@link #MEASURED_SIZE_MASK} and
1126b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #MEASURED_STATE_TOO_SMALL}.
1127b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * This should be used during measurement and layout calculations only. Use
1128b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link android.view.View#getHeight()} to see how wide a view is after layout.
1129b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     *
1130b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @return The measured width of this view as a bit mask.
1131b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
1132b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static int getMeasuredHeightAndState(View view) {
1133b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        return IMPL.getMeasuredHeightAndState(view);
1134b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    }
1135b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
1136b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
1137b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Return only the state bits of {@link #getMeasuredWidthAndState}
1138b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * and {@link #getMeasuredHeightAndState}, combined into one integer.
1139b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * The width component is in the regular bits {@link #MEASURED_STATE_MASK}
1140b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * and the height component is at the shifted bits
1141b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}.
1142b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
1143b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static int getMeasuredState(View view) {
1144b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        return IMPL.getMeasuredState(view);
1145b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    }
1146086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
1147086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
1148086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Gets the live region mode for the specified View.
1149086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *
1150086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @param view The view from which to obtain the live region mode
1151086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @return The live region mode for the view.
1152086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *
1153086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @see ViewCompat#setAccessibilityLiveRegion(View, int)
1154086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
1155086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    public int getAccessibilityLiveRegion(View view) {
1156086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        return IMPL.getAccessibilityLiveRegion(view);
1157086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    }
1158086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
1159086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
1160086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Sets the live region mode for the specified view. This indicates to
1161086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * accessibility services whether they should automatically notify the user
1162086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * about changes to the view's content description or text, or to the
1163086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * content descriptions or text of the view's children (where applicable).
1164086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
1165086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * For example, in a login screen with a TextView that displays an "incorrect
1166086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * password" notification, that view should be marked as a live region with
1167086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * mode {@link #ACCESSIBILITY_LIVE_REGION_POLITE}.
1168086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
1169086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * To disable change notifications for this view, use
1170086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * {@link #ACCESSIBILITY_LIVE_REGION_NONE}. This is the default live region
1171086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * mode for most views.
1172086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
1173086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * To indicate that the user should be notified of changes, use
1174086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * {@link #ACCESSIBILITY_LIVE_REGION_POLITE}.
1175086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
1176086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * If the view's changes should interrupt ongoing speech and notify the user
1177086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * immediately, use {@link #ACCESSIBILITY_LIVE_REGION_ASSERTIVE}.
1178086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *
1179086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @param view The view on which to set the live region mode
1180086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @param mode The live region mode for this view, one of:
1181086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        <ul>
1182086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        <li>{@link #ACCESSIBILITY_LIVE_REGION_NONE}
1183086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        <li>{@link #ACCESSIBILITY_LIVE_REGION_POLITE}
1184086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        <li>{@link #ACCESSIBILITY_LIVE_REGION_ASSERTIVE}
1185086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        </ul>
1186086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
1187086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    public void setAccessibilityLiveRegion(View view, int mode) {
1188086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        IMPL.setAccessibilityLiveRegion(view, mode);
1189086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    }
1190bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell}
1191