ViewCompat.java revision c096ad1894f1a4543e703ddc9d279fbd3b596c53
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;
26a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powellimport android.util.Log;
27bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellimport android.view.View;
283cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powellimport android.view.ViewParent;
299648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.accessibility.AccessibilityEvent;
30bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
31a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powellimport java.lang.reflect.InvocationTargetException;
32a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powellimport java.lang.reflect.Method;
33a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell
34bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/**
350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link View} introduced after API
360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * level 4 in a backwards compatible fashion.
37bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */
38bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpublic class ViewCompat {
39a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell    private static final String TAG = "ViewCompat";
40a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell
41560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
42560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Always allow a user to over-scroll this view, provided it is a
43560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * view that can scroll.
44560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
45560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_ALWAYS = 0;
46560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
47560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
48560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Allow a user to over-scroll this view only if the content is large
49560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * enough to meaningfully scroll, provided it is a view that can scroll.
50560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
51560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_IF_CONTENT_SCROLLS = 1;
52560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
53560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
54560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Never allow a user to over-scroll this view.
55560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
56560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_NEVER = 2;
57560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
58ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    private static final long FAKE_FRAME_TIME = 10;
59ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
6025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
6125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Automatically determine whether a view is important for accessibility.
6225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
6325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = 0x00000000;
6425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
6525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
6625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * The view is important for accessibility.
6725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
6825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 0x00000001;
6925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
7025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
7125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * The view is not important for accessibility.
7225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
7325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002;
7425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
758a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
76b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     * The view is not important for accessibility, nor are any of its
77b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     * descendant views.
78b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     */
79b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette    public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS = 0x00000004;
80b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette
81b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette    /**
82086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Live region mode specifying that accessibility services should not
83086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * automatically announce changes to this view. This is the default live
84086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * region mode for most views.
85086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
86086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Use with {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.
87086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
88086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0x00000000;
89086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
90086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
91086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Live region mode specifying that accessibility services should announce
92086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * changes to this view.
93086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
94086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Use with {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.
95086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
96086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 0x00000001;
97086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
98086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
99086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Live region mode specifying that accessibility services should interrupt
100086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * ongoing speech to immediately announce changes to this view.
101086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
102086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Use with {@link ViewCompat#setAccessibilityLiveRegion(View, int)}.
103086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
104086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    public static final int ACCESSIBILITY_LIVE_REGION_ASSERTIVE = 0x00000002;
105086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
106086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
1078a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * Indicates that the view does not have a layer.
1088a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
1098a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_NONE = 0;
1108a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
1118a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
1128a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Indicates that the view has a software layer. A software layer is backed
1138a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * by a bitmap and causes the view to be rendered using Android's software
1148a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rendering pipeline, even if hardware acceleration is enabled.</p>
1158a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
1168a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Software layers have various usages:</p>
1178a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>When the application is not using hardware acceleration, a software layer
1188a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * is useful to apply a specific color filter and/or blending mode and/or
1198a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * translucency to a view and all its children.</p>
1208a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>When the application is using hardware acceleration, a software layer
1218a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * is useful to render drawing primitives not supported by the hardware
1228a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * accelerated pipeline. It can also be used to cache a complex view tree
1238a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * into a texture and reduce the complexity of drawing operations. For instance,
1248a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * when animating a complex view tree with a translation, a software layer can
1258a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * be used to render the view tree only once.</p>
1268a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Software layers should be avoided when the affected view tree updates
1278a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * often. Every update will require to re-render the software layer, which can
1288a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * potentially be slow (particularly when hardware acceleration is turned on
1298a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * since the layer will have to be uploaded into a hardware texture after every
1308a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * update.)</p>
1318a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
1328a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_SOFTWARE = 1;
1338a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
1348a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
1358a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Indicates that the view has a hardware layer. A hardware layer is backed
1368a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * by a hardware specific texture (generally Frame Buffer Objects or FBO on
1378a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * OpenGL hardware) and causes the view to be rendered using Android's hardware
1388a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rendering pipeline, but only if hardware acceleration is turned on for the
1398a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * view hierarchy. When hardware acceleration is turned off, hardware layers
1408a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * behave exactly as {@link #LAYER_TYPE_SOFTWARE software layers}.</p>
1418a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
1428a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer is useful to apply a specific color filter and/or
1438a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * blending mode and/or translucency to a view and all its children.</p>
1448a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer can be used to cache a complex view tree into a
1458a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * texture and reduce the complexity of drawing operations. For instance,
1468a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * when animating a complex view tree with a translation, a hardware layer can
1478a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * be used to render the view tree only once.</p>
1488a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A hardware layer can also be used to increase the rendering quality when
1498a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * rotation transformations are applied on a view. It can also be used to
1508a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * prevent potential clipping issues when applying 3D transforms on a view.</p>
1518a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
1528a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static final int LAYER_TYPE_HARDWARE = 2;
1538a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
1541d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
1551d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Horizontal layout direction of this view is from Left to Right.
1561d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
1571d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static final int LAYOUT_DIRECTION_LTR = 0;
1581d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
1591d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
1601d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Horizontal layout direction of this view is from Right to Left.
1611d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
1621d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static final int LAYOUT_DIRECTION_RTL = 1;
1631d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
1641d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
1651d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Horizontal layout direction of this view is inherited from its parent.
1661d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Use with {@link #setLayoutDirection}.
1671d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
1681d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static final int LAYOUT_DIRECTION_INHERIT = 2;
1691d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
1701d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
1711d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Horizontal layout direction of this view is from deduced from the default language
1721d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * script for the locale. Use with {@link #setLayoutDirection}.
1731d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
1741d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static final int LAYOUT_DIRECTION_LOCALE = 3;
1751d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
176b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
177b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Bits of {@link #getMeasuredWidthAndState} and
178b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #getMeasuredWidthAndState} that provide the actual measured size.
179b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
180b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static final int MEASURED_SIZE_MASK = 0x00ffffff;
181b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
182b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
183b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Bits of {@link #getMeasuredWidthAndState} and
184b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #getMeasuredWidthAndState} that provide the additional state bits.
185b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
186b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static final int MEASURED_STATE_MASK = 0xff000000;
187b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
188b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
189b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Bit shift of {@link #MEASURED_STATE_MASK} to get to the height bits
190b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * for functions that combine both width and height into a single int,
191b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * such as {@link #getMeasuredState} and the childState argument of
192b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #resolveSizeAndState(int, int, int)}.
193b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
194b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static final int MEASURED_HEIGHT_STATE_SHIFT = 16;
195b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
196b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
197b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Bit of {@link #getMeasuredWidthAndState} and
198b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #getMeasuredWidthAndState} that indicates the measured size
199b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * is smaller that the space the view would like to have.
200b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
201b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static final int MEASURED_STATE_TOO_SMALL = 0x01000000;
202b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
203bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    interface ViewCompatImpl {
204bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction);
205bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction);
206560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v);
207560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode);
2089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event);
2099648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event);
2109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info);
2119648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate);
212c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view);
213c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState);
214ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view);
215ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom);
216ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action);
217ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis);
21825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view);
21925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode);
2200d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments);
22125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view);
22214631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public float getAlpha(View view);
2238a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        public void setLayerType(View view, int layerType, Paint paint);
22497341bdc5bea1d7bf777de65228039142d249f38Adam Powell        public int getLayerType(View view);
2250af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view);
2266debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLabelFor(View view, int id);
2276debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint);
2281d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public int getLayoutDirection(View view);
2291d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public void setLayoutDirection(View view, int layoutDirection);
2303cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        public ViewParent getParentForAccessibility(View view);
231c029e15f5a4709214cb433a562256586824a0f33Adam Powell        public boolean isOpaque(View view);
232b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int resolveSizeAndState(int size, int measureSpec, int childMeasuredState);
233b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredWidthAndState(View view);
234b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredHeightAndState(View view);
235b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredState(View view);
236086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public int getAccessibilityLiveRegion(View view);
237086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public void setAccessibilityLiveRegion(View view, int mode);
238e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public int getPaddingStart(View view);
239e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public int getPaddingEnd(View view);
240e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public void setPaddingRelative(View view, int start, int top, int end, int bottom);
241a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        public void dispatchStartTemporaryDetach(View view);
242a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        public void dispatchFinishTemporaryDetach(View view);
243c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        public float getTranslationX(View view);
244c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        public float getTranslationY(View view);
245bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
246bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
247bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static class BaseViewCompatImpl implements ViewCompatImpl {
248a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        private Method mDispatchStartTemporaryDetach;
249a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        private Method mDispatchFinishTemporaryDetach;
250a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        private boolean mTempDetachBound;
251a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell
252bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
253bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
254bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
255bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
256bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
257bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
258560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
259560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return OVER_SCROLL_NEVER;
260560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
261560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
262560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            // Do nothing; API doesn't exist
263560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
2649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
2659648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
2669648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2679648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
2689648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
2699648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
2719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov         // Do nothing; API doesn't exist
2729648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
2739648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
2749648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
2759648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
276c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
277c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // A view can't have transient state if transient state wasn't supported.
278c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return false;
279c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
280c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
281c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // Do nothing; API doesn't exist
282c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
283ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
284009b4ef9d97e1cc237477e3284fc305bb1438cc9Adam Powell            view.invalidate();
285ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
286ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
287009b4ef9d97e1cc237477e3284fc305bb1438cc9Adam Powell            view.invalidate(left, top, right, bottom);
288ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
289ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
290ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime());
291ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
292ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
293ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime() + delayMillis);
294ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
295ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
296ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return FAKE_FRAME_TIME;
297ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
29825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
29925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return 0;
30025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
30125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
30225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
30325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
3040d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
3050d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return false;
3060d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
30725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
30825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
30925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
31014631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public float getAlpha(View view) {
31114631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette            return 1.0f;
31214631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        }
3138a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        public void setLayerType(View view, int layerType, Paint paint) {
3146debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // No-op until layers became available (HC)
3158a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
31697341bdc5bea1d7bf777de65228039142d249f38Adam Powell        public int getLayerType(View view) {
31797341bdc5bea1d7bf777de65228039142d249f38Adam Powell            return LAYER_TYPE_NONE;
31897341bdc5bea1d7bf777de65228039142d249f38Adam Powell        }
3190af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view) {
3200af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            return 0;
3210af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
3220af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id) {
3230af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
3240af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
3256debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint p) {
3266debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // No-op until layers became available (HC)
3276debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
3281d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
3291d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        @Override
3301d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public int getLayoutDirection(View view) {
3311d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell            return LAYOUT_DIRECTION_LTR;
3321d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        }
3331d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
3341d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        @Override
3351d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public void setLayoutDirection(View view, int layoutDirection) {
3361d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell            // No-op
3371d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        }
3383cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell
3393cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        @Override
3403cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        public ViewParent getParentForAccessibility(View view) {
3413cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell            return view.getParent();
3423cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        }
343c029e15f5a4709214cb433a562256586824a0f33Adam Powell
344c029e15f5a4709214cb433a562256586824a0f33Adam Powell        @Override
345c029e15f5a4709214cb433a562256586824a0f33Adam Powell        public boolean isOpaque(View view) {
346c029e15f5a4709214cb433a562256586824a0f33Adam Powell            final Drawable bg = view.getBackground();
347c029e15f5a4709214cb433a562256586824a0f33Adam Powell            if (bg != null) {
348c029e15f5a4709214cb433a562256586824a0f33Adam Powell                return bg.getOpacity() == PixelFormat.OPAQUE;
349c029e15f5a4709214cb433a562256586824a0f33Adam Powell            }
350c029e15f5a4709214cb433a562256586824a0f33Adam Powell            return false;
351c029e15f5a4709214cb433a562256586824a0f33Adam Powell        }
352b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
353b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) {
354b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return View.resolveSize(size, measureSpec);
355b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
356b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
357b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
358b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredWidthAndState(View view) {
359b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return view.getMeasuredWidth();
360b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
361b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
362b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
363b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredHeightAndState(View view) {
364b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return view.getMeasuredHeight();
365b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
366b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
367b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
368b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredState(View view) {
369b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return 0;
370b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
371086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
372086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        @Override
373086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public int getAccessibilityLiveRegion(View view) {
374086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            return ACCESSIBILITY_LIVE_REGION_NONE;
375086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        }
376086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
377086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        @Override
378086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public void setAccessibilityLiveRegion(View view, int mode) {
379086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            // No-op
380086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        }
381e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
382e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        @Override
383e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public int getPaddingStart(View view) {
384e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell            return view.getPaddingLeft();
385e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        }
386e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
387e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        @Override
388e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public int getPaddingEnd(View view) {
389e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell            return view.getPaddingRight();
390e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        }
391e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
392e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        @Override
393e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public void setPaddingRelative(View view, int start, int top, int end, int bottom) {
394e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell            view.setPadding(start, top, end, bottom);
395e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        }
396a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell
397a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        @Override
398a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        public void dispatchStartTemporaryDetach(View view) {
399a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            if (!mTempDetachBound) {
400a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                bindTempDetach();
401a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            }
402a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            if (mDispatchStartTemporaryDetach != null) {
403a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                try {
404a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                    mDispatchStartTemporaryDetach.invoke(view);
405a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                } catch (Exception e) {
406a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                    Log.d(TAG, "Error calling dispatchStartTemporaryDetach", e);
407a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                }
408a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            } else {
409a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                // Try this instead
410a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                view.onStartTemporaryDetach();
411a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            }
412a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        }
413a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell
414a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        @Override
415a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        public void dispatchFinishTemporaryDetach(View view) {
416a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            if (!mTempDetachBound) {
417a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                bindTempDetach();
418a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            }
419a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            if (mDispatchFinishTemporaryDetach != null) {
420a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                try {
421a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                    mDispatchFinishTemporaryDetach.invoke(view);
422a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                } catch (Exception e) {
423a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                    Log.d(TAG, "Error calling dispatchFinishTemporaryDetach", e);
424a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                }
425a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            } else {
426a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                // Try this instead
427a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                view.onFinishTemporaryDetach();
428a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            }
429a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        }
430a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell
431a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        private void bindTempDetach() {
432a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            try {
433a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                mDispatchStartTemporaryDetach = View.class.getDeclaredMethod(
434a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                        "dispatchStartTemporaryDetach");
435a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                mDispatchFinishTemporaryDetach = View.class.getDeclaredMethod(
436a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                        "dispatchFinishTemporaryDetach");
437a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            } catch (NoSuchMethodException e) {
438a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell                Log.e(TAG, "Couldn't find method", e);
439a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            }
440a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell            mTempDetachBound = true;
441a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        }
442c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell
443c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        @Override
444c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        public float getTranslationX(View view) {
445c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell            return 0;
446c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        }
447c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell
448c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        @Override
449c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        public float getTranslationY(View view) {
450c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell            return 0;
451c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        }
452bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
453bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
454c029e15f5a4709214cb433a562256586824a0f33Adam Powell    static class EclairMr1ViewCompatImpl extends BaseViewCompatImpl {
455c029e15f5a4709214cb433a562256586824a0f33Adam Powell        @Override
456c029e15f5a4709214cb433a562256586824a0f33Adam Powell        public boolean isOpaque(View view) {
457c029e15f5a4709214cb433a562256586824a0f33Adam Powell            return ViewCompatEclairMr1.isOpaque(view);
458c029e15f5a4709214cb433a562256586824a0f33Adam Powell        }
459c029e15f5a4709214cb433a562256586824a0f33Adam Powell    }
460c029e15f5a4709214cb433a562256586824a0f33Adam Powell
461c029e15f5a4709214cb433a562256586824a0f33Adam Powell    static class GBViewCompatImpl extends EclairMr1ViewCompatImpl {
4629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
463560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
464560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return ViewCompatGingerbread.getOverScrollMode(v);
465560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
4669648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
467560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
468560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            ViewCompatGingerbread.setOverScrollMode(v, mode);
469560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
470560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
471560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
472ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class HCViewCompatImpl extends GBViewCompatImpl {
47314631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        @Override
474ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
475ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return ViewCompatHC.getFrameTime();
476ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
47714631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        @Override
47814631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public float getAlpha(View view) {
47914631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette            return ViewCompatHC.getAlpha(view);
48014631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        }
48114631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        @Override
48214631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public void setLayerType(View view, int layerType, Paint paint) {
4838a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell            ViewCompatHC.setLayerType(view, layerType, paint);
4848a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        }
48514631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        @Override
48614631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        public int getLayerType(View view)  {
48797341bdc5bea1d7bf777de65228039142d249f38Adam Powell            return ViewCompatHC.getLayerType(view);
48897341bdc5bea1d7bf777de65228039142d249f38Adam Powell        }
4896debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        @Override
4906debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint) {
4916debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // Make sure the paint is correct; this will be cheap if it's the same
4926debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // instance as was used to call setLayerType earlier.
4936debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            setLayerType(view, getLayerType(view), paint);
4946debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            // This is expensive, but the only way to accomplish this before JB-MR1.
4956debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            view.invalidate();
4966debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
497b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
498b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) {
499b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return ViewCompatHC.resolveSizeAndState(size, measureSpec, childMeasuredState);
500b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
501b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
502b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredWidthAndState(View view) {
503b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return ViewCompatHC.getMeasuredWidthAndState(view);
504b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
505b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
506b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredHeightAndState(View view) {
507b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return ViewCompatHC.getMeasuredHeightAndState(view);
508b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
509b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        @Override
510b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        public int getMeasuredState(View view) {
511b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell            return ViewCompatHC.getMeasuredState(view);
512b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        }
513c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        @Override
514c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        public float getTranslationX(View view) {
515c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell            return ViewCompatHC.getTranslationX(view);
516c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        }
517c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        @Override
518c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        public float getTranslationY(View view) {
519c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell            return ViewCompatHC.getTranslationY(view);
520c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        }
521ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
522ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
523ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class ICSViewCompatImpl extends HCViewCompatImpl {
5249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
525bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
526bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollHorizontally(v, direction);
527bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
5289648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
529bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
530bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollVertically(v, direction);
531bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
5329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
5339648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
5349648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onPopulateAccessibilityEvent(v, event);
5359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
5369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
5379648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
5389648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityEvent(v, event);
5399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
5409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
5419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
542956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityNodeInfo(v, info.getInfo());
5439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
5449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
5459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
5469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.setAccessibilityDelegate(v, delegate.getBridge());
5479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
548bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
549bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
550c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    static class JBViewCompatImpl extends ICSViewCompatImpl {
551c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
552c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
553c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return ViewCompatJB.hasTransientState(view);
554c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
555c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
556c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
557c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            ViewCompatJB.setHasTransientState(view, hasTransientState);
558c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
559ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
560ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
561ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view);
562ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
563ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
564ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
565ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view, left, top, right, bottom);
566ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
567ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
568ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
569ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimation(view, action);
570ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
571ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
572ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
573ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimationDelayed(view, action, delayMillis);
574ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
57525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
57625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
57725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return ViewCompatJB.getImportantForAccessibility(view);
57825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
57925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
58025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
58125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            ViewCompatJB.setImportantForAccessibility(view, mode);
58225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
58325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
5840d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        public boolean performAccessibilityAction(View view, int action, Bundle arguments) {
5850d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv            return ViewCompatJB.performAccessibilityAction(view, action, arguments);
5860d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        }
5870d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        @Override
58825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
58925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            Object compat = ViewCompatJB.getAccessibilityNodeProvider(view);
59025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            if (compat != null) {
59125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov                return new AccessibilityNodeProviderCompat(compat);
59225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            }
59325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
59425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
5953cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell
5963cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        @Override
5973cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        public ViewParent getParentForAccessibility(View view) {
5983cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell            return ViewCompatJB.getParentForAccessibility(view);
5993cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        }
600c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
601c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
6020af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    static class JbMr1ViewCompatImpl extends JBViewCompatImpl {
6030af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
6040af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        @Override
6050af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public int getLabelFor(View view) {
6060af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            return ViewCompatJellybeanMr1.getLabelFor(view);
6070af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
6080af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
6090af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        @Override
6100af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        public void setLabelFor(View view, int id) {
6110af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            ViewCompatJellybeanMr1.setLabelFor(view, id);
6120af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        }
6136debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell
6146debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        @Override
6156debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        public void setLayerPaint(View view, Paint paint) {
6166debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell            ViewCompatJellybeanMr1.setLayerPaint(view, paint);
6176debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        }
6181d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
6191d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        @Override
6201d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public int getLayoutDirection(View view) {
6211d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell            return ViewCompatJellybeanMr1.getLayoutDirection(view);
6221d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        }
6231d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
6241d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        @Override
6251d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        public void setLayoutDirection(View view, int layoutDirection) {
6261d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell            ViewCompatJellybeanMr1.setLayoutDirection(view, layoutDirection);
6271d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        }
628e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
629e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        @Override
630e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public int getPaddingStart(View view) {
631e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell            return ViewCompatJellybeanMr1.getPaddingStart(view);
632e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        }
633e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
634e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        @Override
635e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public int getPaddingEnd(View view) {
636e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell            return ViewCompatJellybeanMr1.getPaddingEnd(view);
637e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        }
638e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
639e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        @Override
640e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        public void setPaddingRelative(View view, int start, int top, int end, int bottom) {
641e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell            ViewCompatJellybeanMr1.setPaddingRelative(view, start, top, end, bottom);
642e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        }
6430af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
6440af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
645086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    static class KitKatViewCompatImpl extends JbMr1ViewCompatImpl {
646086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        @Override
647086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public int getAccessibilityLiveRegion(View view) {
648086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            return ViewCompatKitKat.getAccessibilityLiveRegion(view);
649086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        }
650086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
651086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        @Override
652086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        public void setAccessibilityLiveRegion(View view, int mode) {
653086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            ViewCompatKitKat.setAccessibilityLiveRegion(view, mode);
654086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        }
655086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    }
656086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
657bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static final ViewCompatImpl IMPL;
658bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static {
659560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        final int version = android.os.Build.VERSION.SDK_INT;
660086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        if (version >= 19) {
661086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette            IMPL = new KitKatViewCompatImpl();
662086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        } else if (version >= 17) {
6630af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov            IMPL = new JbMr1ViewCompatImpl();
6640af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        } else if (version >= 16) {
665c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            IMPL = new JBViewCompatImpl();
666c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        } else if (version >= 14) {
667bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new ICSViewCompatImpl();
668ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        } else if (version >= 11) {
669ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            IMPL = new HCViewCompatImpl();
670560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        } else if (version >= 9) {
671560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            IMPL = new GBViewCompatImpl();
672bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        } else {
673bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new BaseViewCompatImpl();
674bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
675bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
676bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
6770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
6780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled horizontally in a certain direction.
6790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
6800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
6810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling left, positive to check scrolling right.
6820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
6830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
684bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollHorizontally(View v, int direction) {
685bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollHorizontally(v, direction);
686bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
687bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
6880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
6890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled vertically in a certain direction.
6900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
6910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
6920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling up, positive to check scrolling down.
6930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
6940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
695bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollVertically(View v, int direction) {
696bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollVertically(v, direction);
697bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
698560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
6990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
7000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Returns the over-scroll mode for this view. The result will be
7010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
7020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
7030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
7040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
7060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return This view's over-scroll mode.
7070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
708560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static int getOverScrollMode(View v) {
709560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        return IMPL.getOverScrollMode(v);
710560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
711560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
7120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
7130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Set the over-scroll mode for this view. Valid over-scroll modes are
7140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
7150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
7160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
7170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Setting the over-scroll mode of a view will have an effect only if the
7190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * view is capable of scrolling.
7200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
7220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param overScrollMode The new over-scroll mode for this view.
7230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
7240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    public static void setOverScrollMode(View v, int overScrollMode) {
7250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov        IMPL.setOverScrollMode(v, overScrollMode);
726560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
7279648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
7280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
7290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)}
7300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * giving a chance to this View to populate the accessibility event with its
7310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * text content. While this method is free to modify event
7320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * attributes other than text content, doing so should normally be performed in
7330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}.
7340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
7350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Adding formatted date string to an accessibility event in addition
7360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to the text added by the super implementation:
7370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
7380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onPopulateAccessibilityEvent(event);
7390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
7400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     String selectedDateUtterance = DateUtils.formatDateTime(mContext,
7410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *         mCurrentDate.getTimeInMillis(), flags);
7420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.getText().add(selectedDateUtterance);
7430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
7440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
7450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
7460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
7470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View,
7480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
7490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
7500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
7510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
7520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
7530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
7540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
7560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The accessibility event which to populate.
7570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
7590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
7600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
7619648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
7629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onPopulateAccessibilityEvent(v, event);
7639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
7649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
7650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
7660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link AccessibilityEvent} with information about
7670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * this View which is the event source. In other words, the source of
7680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * an accessibility event is the view whose state change triggered firing
7690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * the event.
7700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
7710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Setting the password property of an event in addition
7720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to properties set by the super implementation:
7730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
7740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onInitializeAccessibilityEvent(event);
7750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.setPassword(true);
7760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
7770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
7780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
7790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
7800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View,
7810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
7820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
7830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
7840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
7850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
7860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
7870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
7890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The event to initialize.
7900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
7910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
7920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
7930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
7949648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
7959648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityEvent(v, event);
7969648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
7979648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
7980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
7990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information
8000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * about this view. The base implementation sets:
8010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <ul>
8020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},</li>
8030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},</li>
8040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},</li>
8050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},</li>
8060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},</li>
8070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},</li>
8080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},</li>
8090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},</li>
8100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},</li>
8110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},</li>
8120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},</li>
8130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},</li>
8140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </ul>
8150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
8160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Subclasses should override this method, call the super implementation,
8170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * and set additional attributes.
8180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
8190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
8200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
8210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
8220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View,
8230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  android.view.accessibility.AccessibilityNodeInfo)}
8240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
8250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
8260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
8270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
8280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param info The instance to initialize.
8290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
8309648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
8319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityNodeInfo(v, info);
8329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
8339648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
8340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
8350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Sets a delegate for implementing accessibility support via compositon as
8360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * opposed to inheritance. The delegate's primary use is for implementing
8370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * backwards compatible widgets. For more details see
8380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate}.
8390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
8400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
8410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param delegate The delegate instance.
8420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
8430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see android.view.View.AccessibilityDelegate
8440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
8459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
8469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.setAccessibilityDelegate(v, delegate);
8479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
848c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
849c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
850c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Indicates whether the view is currently tracking transient state that the
851c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * app should not need to concern itself with saving and restoring, but that
852c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * the framework should take special note to preserve when possible.
853c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
854c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View to check for transient state
855c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @return true if the view has transient state
856c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
857c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static boolean hasTransientState(View view) {
858c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        return IMPL.hasTransientState(view);
859c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
860c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
861c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
862c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Set whether this view is currently tracking transient state that the
863c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * framework should attempt to preserve when possible.
864c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
865c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View tracking transient state
866c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param hasTransientState true if this view has transient state
867c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
868c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static void setHasTransientState(View view, boolean hasTransientState) {
869c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        IMPL.setHasTransientState(view, hasTransientState);
870c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
871ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
872ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
873ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate to happen on the next animation time step, typically the
874ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * next display frame.</p>
875ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
876ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
877ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
878ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
879ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
880ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
881ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view) {
882ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view);
883ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
884ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
885ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
886ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate of the specified area to happen on the next animation
887ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * time step, typically the next display frame.</p>
888ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
889ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
890ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
891ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
892ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
893ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param left The left coordinate of the rectangle to invalidate.
894ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param top The top coordinate of the rectangle to invalidate.
895ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param right The right coordinate of the rectangle to invalidate.
896ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param bottom The bottom coordinate of the rectangle to invalidate.
897ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
898ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view, int left, int top,
899ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            int right, int bottom) {
900ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view, left, top, right, bottom);
901ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
902ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
903ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
904ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step.
905ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
906ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
907ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
908ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
909ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
910ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to post this Runnable to
911ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
912ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
913ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimation(View view, Runnable action) {
914ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimation(view, action);
915ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
916ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
917ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
918ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step,
919ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * after the specified amount of time elapses.
920ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
921ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
922ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
923ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
924ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
925ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view The view to post this Runnable to
926ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
927ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param delayMillis The delay (in milliseconds) until the Runnable
928ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *        will be executed.
929ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
930ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
931ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimationDelayed(view, action, delayMillis);
932ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
93325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
93425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
93525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the mode for determining whether this View is important for accessibility
93625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
93725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
93825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
93925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
94025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The mode for determining whether a View is important for accessibility.
94125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
94225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
94325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
944b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
94525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
94625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
94725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static int getImportantForAccessibility(View view) {
94825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getImportantForAccessibility(view);
94925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
95025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
95125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
95225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Sets how to determine whether this view is important for accessibility
95325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
95425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
95525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
95625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to set.
95725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param mode How to determine whether this view is important for accessibility.
95825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
95925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
96025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
961b5b909e4544fd4d1d0bdf445b8588a7233d5c71fAlan Viverette     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
96225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
96325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
96425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static void setImportantForAccessibility(View view, int mode) {
96525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        IMPL.setImportantForAccessibility(view, mode);
96625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
96725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
96825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
9690d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * Performs the specified accessibility action on the view. For
9700d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * possible accessibility actions look at {@link AccessibilityNodeInfoCompat}.
9710d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * <p>
9720d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * If an {@link AccessibilityDelegateCompat} has been specified via calling
9730d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its
9740d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * {@link AccessibilityDelegateCompat#performAccessibilityAction(View, int, Bundle)}
9750d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * is responsible for handling this call.
9760d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * </p>
9770d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     *
9780d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param action The action to perform.
9790d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @param arguments Optional action arguments.
9800d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     * @return Whether the action was performed.
9810d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv     */
9820d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    public static boolean performAccessibilityAction(View view, int action, Bundle arguments) {
9830d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv        return IMPL.performAccessibilityAction(view, action, arguments);
9840d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    }
9850d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv
9860d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv    /**
98725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the provider for managing a virtual view hierarchy rooted at this View
988e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * and reported to {@link android.accessibilityservice.AccessibilityService}s
98925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * that explore the window content.
99025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
99125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If this method returns an instance, this instance is responsible for managing
992e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov     * {@link AccessibilityNodeInfoCompat}s describing the virtual sub-tree rooted at
99325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * this View including the one representing the View itself. Similarly the returned
99425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * instance is responsible for performing accessibility actions on any virtual
99525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * view or the root view itself.
99625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
99725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
99825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If an {@link AccessibilityDelegateCompat} has been specified via calling
99914631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its
100025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * {@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)}
100125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * is responsible for handling this call.
100225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
100325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
100425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
100525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The provider.
100625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
100725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see AccessibilityNodeProviderCompat
100825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
100925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
101025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getAccessibilityNodeProvider(view);
101125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
10128a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell
10138a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    /**
101414631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * The opacity of the view. This is a value from 0 to 1, where 0 means the view is
101514631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * completely transparent and 1 means the view is completely opaque.
101614631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     *
101714631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * <p>By default this is 1.0f. Prior to API 11, the returned value is always 1.0f.
101814631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     * @return The opacity of the view.
101914631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette     */
102014631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette    public static float getAlpha(View view) {
102114631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette        return IMPL.getAlpha(view);
102214631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette    }
102314631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette
102414631dece1ee9ddd5f430aa4b8eb048e27065d71Alan Viverette    /**
10258a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Specifies the type of layer backing this view. The layer can be
10268a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_NONE disabled}, {@link #LAYER_TYPE_SOFTWARE software} or
10278a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_HARDWARE hardware}.</p>
10288a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
10298a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>A layer is associated with an optional {@link android.graphics.Paint}
10308a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * instance that controls how the layer is composed on screen. The following
10318a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * properties of the paint are taken into account when composing the layer:</p>
10328a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <ul>
10338a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
10348a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
10358a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
10368a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * </ul>
10378a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
10388a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>If this view has an alpha value set to < 1.0 by calling
10398a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * setAlpha(float), the alpha value of the layer's paint is replaced by
10408a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * this view's alpha value. Calling setAlpha(float) is therefore
10418a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * equivalent to setting a hardware layer on this view and providing a paint with
10428a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * the desired alpha value.<p>
10438a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
10448a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * <p>Refer to the documentation of {@link #LAYER_TYPE_NONE disabled},
10458a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * {@link #LAYER_TYPE_SOFTWARE software} and {@link #LAYER_TYPE_HARDWARE hardware}
10468a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * for more information on when and how to use layers.</p>
10478a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
10488a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The ype of layer to use with this view, must be one of
10498a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
10508a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
10518a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
10528a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
10538a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
10548a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *
10558a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param view View to set the layer type for
10568a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param layerType The type of layer to use with this view, must be one of
10578a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
10588a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_HARDWARE}
10598a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     * @param paint The paint used to compose the layer. This argument is optional
10608a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        and can be null. It is ignored when the layer type is
10618a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     *        {@link #LAYER_TYPE_NONE}
10628a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell     */
10638a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    public static void setLayerType(View view, int layerType, Paint paint) {
10648a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell        IMPL.setLayerType(view, layerType, paint);
10658a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell    }
106697341bdc5bea1d7bf777de65228039142d249f38Adam Powell
106797341bdc5bea1d7bf777de65228039142d249f38Adam Powell    /**
106897341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * Indicates what type of layer is currently associated with this view. By default
106997341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * a view does not have a layer, and the layer type is {@link #LAYER_TYPE_NONE}.
107097341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * Refer to the documentation of
107197341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * {@link #setLayerType(android.view.View, int, android.graphics.Paint)}
107297341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * for more information on the different types of layers.
107397341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *
107497341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @param view The view to fetch the layer type from
107597341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @return {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
107697341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *         {@link #LAYER_TYPE_HARDWARE}
107797341bdc5bea1d7bf777de65228039142d249f38Adam Powell     *
107897341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #setLayerType(android.view.View, int, android.graphics.Paint)
107997341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_NONE
108097341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_SOFTWARE
108197341bdc5bea1d7bf777de65228039142d249f38Adam Powell     * @see #LAYER_TYPE_HARDWARE
108297341bdc5bea1d7bf777de65228039142d249f38Adam Powell     */
108397341bdc5bea1d7bf777de65228039142d249f38Adam Powell    public static int getLayerType(View view) {
108497341bdc5bea1d7bf777de65228039142d249f38Adam Powell        return IMPL.getLayerType(view);
108597341bdc5bea1d7bf777de65228039142d249f38Adam Powell    }
10860af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
10870af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    /**
10880af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * Gets the id of a view for which a given view serves as a label for
10890af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * accessibility purposes.
10900af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     *
10910af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param view The view on which to invoke the corresponding method.
10920af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @return The labeled view id.
10930af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     */
10940af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    public static int getLabelFor(View view) {
10950af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        return IMPL.getLabelFor(view);
10960af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
10970af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov
10980af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    /**
10990af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * Sets the id of a view for which a given view serves as a label for
11000af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * accessibility purposes.
11010af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     *
11020af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param view The view on which to invoke the corresponding method.
11030af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     * @param labeledId The labeled view id.
11040af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov     */
11050af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    public static void setLabelFor(View view, int labeledId) {
11060af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov        IMPL.setLabelFor(view, labeledId);
11070af001b9e0d173f6b9836e66539bf764b897c36fSvetoslav Ganov    }
11086debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell
11096debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    /**
11106debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * Updates the {@link Paint} object used with the current layer (used only if the current
11116debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * layer type is not set to {@link #LAYER_TYPE_NONE}). Changed properties of the Paint
11126debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * provided to {@link #setLayerType(android.view.View, int, android.graphics.Paint)}
11136debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * will be used the next time the View is redrawn, but
11146debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * {@link #setLayerPaint(android.view.View, android.graphics.Paint)}
11156debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * must be called to ensure that the view gets redrawn immediately.
11166debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
11176debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <p>A layer is associated with an optional {@link android.graphics.Paint}
11186debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * instance that controls how the layer is composed on screen. The following
11196debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * properties of the paint are taken into account when composing the layer:</p>
11206debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <ul>
11216debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
11226debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
11236debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
11246debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * </ul>
11256debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
11266debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * <p>If this view has an alpha value set to < 1.0 by calling
11276debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * View#setAlpha(float), the alpha value of the layer's paint is replaced by
11286debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * this view's alpha value. Calling View#setAlpha(float) is therefore
11296debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * equivalent to setting a hardware layer on this view and providing a paint with
11306debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * the desired alpha value.</p>
11316debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
11321d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @param view View to set a layer paint for
11336debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     * @param paint The paint used to compose the layer. This argument is optional
11346debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *        and can be null. It is ignored when the layer type is
11356debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *        {@link #LAYER_TYPE_NONE}
11366debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     *
11371d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @see #setLayerType(View, int, android.graphics.Paint)
11386debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell     */
11396debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    public static void setLayerPaint(View view, Paint paint) {
11406debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell        IMPL.setLayerPaint(view, paint);
11416debd2bbcae1cd285d2e21db633998b7801f9f40Adam Powell    }
11421d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
11431d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
11441d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Returns the resolved layout direction for this view.
11451d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
11461d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @param view View to get layout direction for
11471d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @return {@link #LAYOUT_DIRECTION_RTL} if the layout direction is RTL or returns
11481d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_LTR} if the layout direction is not RTL.
11491d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
11501d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * For compatibility, this will return {@link #LAYOUT_DIRECTION_LTR} if API version
11511d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * is lower than Jellybean MR1 (API 17)
11521d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
11531d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static int getLayoutDirection(View view) {
11541d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        return IMPL.getLayoutDirection(view);
11551d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    }
11561d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell
11571d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    /**
11581d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Set the layout direction for this view. This will propagate a reset of layout direction
11591d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * resolution to the view's children and resolve layout direction for this view.
11601d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
11611d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @param view View to set layout direction for
11621d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * @param layoutDirection the layout direction to set. Should be one of:
11631d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
11641d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_LTR},
11651d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_RTL},
11661d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_INHERIT},
11671d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * {@link #LAYOUT_DIRECTION_LOCALE}.
11681d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     *
11691d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * Resolution will be done if the value is set to LAYOUT_DIRECTION_INHERIT. The resolution
11701d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * proceeds up the parent chain of the view to get the value. If there is no parent, then it
11711d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     * will return the default {@link #LAYOUT_DIRECTION_LTR}.
11721d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell     */
11731d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    public static void setLayoutDirection(View view, int layoutDirection) {
11741d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell        IMPL.setLayoutDirection(view, layoutDirection);
11751d26501f0c8e9f3577f651938a03f6b3a1a672c7Adam Powell    }
11763cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell
11773cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell    /**
11783cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * Gets the parent for accessibility purposes. Note that the parent for
11793cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * accessibility is not necessary the immediate parent. It is the first
11803cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * predecessor that is important for accessibility.
11813cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     *
11823cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * @param view View to retrieve parent for
11833cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     * @return The parent for use in accessibility inspection
11843cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell     */
11853cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell    public static ViewParent getParentForAccessibility(View view) {
11863cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell        return IMPL.getParentForAccessibility(view);
11873cf6141d516a0a6170823b1bda5c0b6d7500e76cAdam Powell    }
1188c029e15f5a4709214cb433a562256586824a0f33Adam Powell
1189c029e15f5a4709214cb433a562256586824a0f33Adam Powell    /**
1190c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * Indicates whether this View is opaque. An opaque View guarantees that it will
1191c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * draw all the pixels overlapping its bounds using a fully opaque color.
1192c029e15f5a4709214cb433a562256586824a0f33Adam Powell     *
1193c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * On API 7 and above this will call View's true isOpaque method. On previous platform
1194c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * versions it will check the opacity of the view's background drawable if present.
1195c029e15f5a4709214cb433a562256586824a0f33Adam Powell     *
1196c029e15f5a4709214cb433a562256586824a0f33Adam Powell     * @return True if this View is guaranteed to be fully opaque, false otherwise.
1197c029e15f5a4709214cb433a562256586824a0f33Adam Powell     */
1198c029e15f5a4709214cb433a562256586824a0f33Adam Powell    public static boolean isOpaque(View view) {
1199c029e15f5a4709214cb433a562256586824a0f33Adam Powell        return IMPL.isOpaque(view);
1200c029e15f5a4709214cb433a562256586824a0f33Adam Powell    }
1201b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
1202b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
1203b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Utility to reconcile a desired size and state, with constraints imposed
1204b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * by a MeasureSpec.  Will take the desired size, unless a different size
1205b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * is imposed by the constraints.  The returned value is a compound integer,
1206b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * with the resolved size in the {@link #MEASURED_SIZE_MASK} bits and
1207b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * optionally the bit {@link #MEASURED_STATE_TOO_SMALL} set if the resulting
1208b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * size is smaller than the size the view wants to be.
1209b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     *
1210b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @param size How big the view wants to be
1211b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @param measureSpec Constraints imposed by the parent
1212b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @return Size information bit mask as defined by
1213b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #MEASURED_SIZE_MASK} and {@link #MEASURED_STATE_TOO_SMALL}.
1214b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
1215b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) {
1216b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        return IMPL.resolveSizeAndState(size, measureSpec, childMeasuredState);
1217b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    }
1218b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
1219b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
1220b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Return the full width measurement information for this view as computed
1221b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * by the most recent call to {@link android.view.View#measure(int, int)}.
1222b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * This result is a bit mask as defined by {@link #MEASURED_SIZE_MASK} and
1223b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #MEASURED_STATE_TOO_SMALL}.
1224b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * This should be used during measurement and layout calculations only. Use
1225b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link android.view.View#getWidth()} to see how wide a view is after layout.
1226b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     *
1227b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @return The measured width of this view as a bit mask.
1228b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
1229b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static int getMeasuredWidthAndState(View view) {
1230b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        return IMPL.getMeasuredWidthAndState(view);
1231b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    }
1232b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
1233b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
1234b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Return the full height measurement information for this view as computed
1235b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * by the most recent call to {@link android.view.View#measure(int, int)}.
1236b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * This result is a bit mask as defined by {@link #MEASURED_SIZE_MASK} and
1237b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #MEASURED_STATE_TOO_SMALL}.
1238b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * This should be used during measurement and layout calculations only. Use
1239b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link android.view.View#getHeight()} to see how wide a view is after layout.
1240b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     *
1241b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * @return The measured width of this view as a bit mask.
1242b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
1243b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static int getMeasuredHeightAndState(View view) {
1244b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        return IMPL.getMeasuredHeightAndState(view);
1245b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    }
1246b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell
1247b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    /**
1248b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * Return only the state bits of {@link #getMeasuredWidthAndState}
1249b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * and {@link #getMeasuredHeightAndState}, combined into one integer.
1250b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * The width component is in the regular bits {@link #MEASURED_STATE_MASK}
1251b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * and the height component is at the shifted bits
1252b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}.
1253b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell     */
1254b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    public static int getMeasuredState(View view) {
1255b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell        return IMPL.getMeasuredState(view);
1256b12ba0547b2fad1c4dfc12dec36c5e7893974e67Adam Powell    }
1257086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
1258086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
1259086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Gets the live region mode for the specified View.
1260086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *
1261086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @param view The view from which to obtain the live region mode
1262086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @return The live region mode for the view.
1263086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *
1264086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @see ViewCompat#setAccessibilityLiveRegion(View, int)
1265086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
1266e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    public static int getAccessibilityLiveRegion(View view) {
1267086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        return IMPL.getAccessibilityLiveRegion(view);
1268086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    }
1269086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette
1270086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    /**
1271086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * Sets the live region mode for the specified view. This indicates to
1272086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * accessibility services whether they should automatically notify the user
1273086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * about changes to the view's content description or text, or to the
1274086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * content descriptions or text of the view's children (where applicable).
1275086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
1276086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * For example, in a login screen with a TextView that displays an "incorrect
1277086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * password" notification, that view should be marked as a live region with
1278086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * mode {@link #ACCESSIBILITY_LIVE_REGION_POLITE}.
1279086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
1280086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * To disable change notifications for this view, use
1281086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * {@link #ACCESSIBILITY_LIVE_REGION_NONE}. This is the default live region
1282086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * mode for most views.
1283086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
1284086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * To indicate that the user should be notified of changes, use
1285086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * {@link #ACCESSIBILITY_LIVE_REGION_POLITE}.
1286086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * <p>
1287086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * If the view's changes should interrupt ongoing speech and notify the user
1288086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * immediately, use {@link #ACCESSIBILITY_LIVE_REGION_ASSERTIVE}.
1289086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *
1290086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @param view The view on which to set the live region mode
1291086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     * @param mode The live region mode for this view, one of:
1292086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        <ul>
1293086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        <li>{@link #ACCESSIBILITY_LIVE_REGION_NONE}
1294086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        <li>{@link #ACCESSIBILITY_LIVE_REGION_POLITE}
1295086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        <li>{@link #ACCESSIBILITY_LIVE_REGION_ASSERTIVE}
1296086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     *        </ul>
1297086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette     */
1298e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    public static void setAccessibilityLiveRegion(View view, int mode) {
1299086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette        IMPL.setAccessibilityLiveRegion(view, mode);
1300086e7db1ab6ef49b4b7974c471b70f81b2d13aefAlan Viverette    }
1301e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
1302e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    /**
1303e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * Returns the start padding of the specified view depending on its resolved layout direction.
1304e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * If there are inset and enabled scrollbars, this value may include the space
1305e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * required to display the scrollbars as well.
1306e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     *
1307e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @param view The view to get padding for
1308e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @return the start padding in pixels
1309e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     */
1310e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    public static int getPaddingStart(View view) {
1311e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        return IMPL.getPaddingStart(view);
1312e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    }
1313e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
1314e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    /**
1315e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * Returns the end padding of the specified view depending on its resolved layout direction.
1316e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * If there are inset and enabled scrollbars, this value may include the space
1317e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * required to display the scrollbars as well.
1318e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     *
1319e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @param view The view to get padding for
1320e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @return the end padding in pixels
1321e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     */
1322e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    public static int getPaddingEnd(View view) {
1323e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        return IMPL.getPaddingEnd(view);
1324e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    }
1325e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell
1326e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    /**
1327e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * Sets the relative padding. The view may add on the space required to display
1328e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * the scrollbars, depending on the style and visibility of the scrollbars.
1329e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * So the values returned from {@link #getPaddingStart}, {@link View#getPaddingTop},
1330e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * {@link #getPaddingEnd} and {@link View#getPaddingBottom} may be different
1331e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * from the values set in this call.
1332e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     *
1333e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @param view The view on which to set relative padding
1334e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @param start the start padding in pixels
1335e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @param top the top padding in pixels
1336e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @param end the end padding in pixels
1337e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     * @param bottom the bottom padding in pixels
1338e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell     */
1339e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    public static void setPaddingRelative(View view, int start, int top, int end, int bottom) {
1340e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell        IMPL.setPaddingRelative(view, start, top, end, bottom);
1341e096e4c526feeb64833b5a75649ec36d75d7cbbfAdam Powell    }
1342a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell
1343a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell    /**
1344a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell     * Notify a view that it is being temporarily detached.
1345a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell     */
1346a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell    public static void dispatchStartTemporaryDetach(View view) {
1347a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        IMPL.dispatchStartTemporaryDetach(view);
1348a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell    }
1349a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell
1350a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell    /**
1351a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell     * Notify a view that its temporary detach has ended; the view is now reattached.
1352a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell     */
1353a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell    public static void dispatchFinishTemporaryDetach(View view) {
1354a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell        IMPL.dispatchFinishTemporaryDetach(view);
1355a6613ed42e0dee0cac3da01f5450e2d61c270b52Adam Powell    }
1356c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell
1357c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell    /**
1358c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     * The horizontal location of this view relative to its {@link View#getLeft() left} position.
1359c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     * This position is post-layout, in addition to wherever the object's
1360c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     * layout placed it.
1361c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     *
1362c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     * @return The horizontal position of this view relative to its left position, in pixels.
1363c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     */
1364c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell    public static float getTranslationX(View child) {
1365c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        return IMPL.getTranslationX(child);
1366c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell    }
1367c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell
1368c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell    /**
1369c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     * The vertical location of this view relative to its {@link View#getTop() left} position.
1370c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     * This position is post-layout, in addition to wherever the object's
1371c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     * layout placed it.
1372c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     *
1373c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     * @return The vertical position of this view relative to its top position, in pixels.
1374c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell     */
1375c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell    public static float getTranslationY(View child) {
1376c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell        return IMPL.getTranslationY(child);
1377c096ad1894f1a4543e703ddc9d279fbd3b596c53Adam Powell    }
1378bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell}
1379