ViewCompat.java revision 25121559b53b9f6c7ef7159203d42e11b9aee281
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
190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganovimport android.graphics.Rect;
209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
2125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeProviderCompat;
22bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellimport android.view.View;
239648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.accessibility.AccessibilityEvent;
24bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
25bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/**
260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link View} introduced after API
270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * level 4 in a backwards compatible fashion.
28bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */
29bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpublic class ViewCompat {
30560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
31560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Always allow a user to over-scroll this view, provided it is a
32560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * view that can scroll.
33560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
34560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_ALWAYS = 0;
35560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
36560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
37560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Allow a user to over-scroll this view only if the content is large
38560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * enough to meaningfully scroll, provided it is a view that can scroll.
39560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
40560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_IF_CONTENT_SCROLLS = 1;
41560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
42560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
43560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Never allow a user to over-scroll this view.
44560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
45560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_NEVER = 2;
46560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
47ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    private static final long FAKE_FRAME_TIME = 10;
48ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
4925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
5025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Automatically determine whether a view is important for accessibility.
5125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
5225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = 0x00000000;
5325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
5425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
5525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * The view is important for accessibility.
5625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
5725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 0x00000001;
5825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
5925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
6025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * The view is not important for accessibility.
6125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
6225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002;
6325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
64bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    interface ViewCompatImpl {
65bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction);
66bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction);
67560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v);
68560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode);
699648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event);
709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event);
719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info);
729648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate);
73c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view);
74c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState);
75ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view);
76ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom);
77ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action);
78ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis);
7925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view);
8025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode);
8125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view);
82bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
83bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
84bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static class BaseViewCompatImpl implements ViewCompatImpl {
85bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
86bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
87bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
88bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
89bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
90bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
91560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
92560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return OVER_SCROLL_NEVER;
93560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
94560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
95560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            // Do nothing; API doesn't exist
96560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
979648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
989648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
999648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1009648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
1019648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1029648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1039648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
1049648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov         // Do nothing; API doesn't exist
1059648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1069648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
1079648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
1089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
109c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
110c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // A view can't have transient state if transient state wasn't supported.
111c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return false;
112c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
113c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
114c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // Do nothing; API doesn't exist
115c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
116ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
117ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime());
118ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
119ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
120ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime(), left, top, right, bottom);
121ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
122ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
123ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime());
124ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
125ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
126ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime() + delayMillis);
127ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
128ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
129ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return FAKE_FRAME_TIME;
130ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
13125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
13225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return 0;
13325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
13425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
13525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
13625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
13725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
13825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
13925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
140bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
141bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
142560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    static class GBViewCompatImpl extends BaseViewCompatImpl {
1439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
144560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
145560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return ViewCompatGingerbread.getOverScrollMode(v);
146560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
1479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
148560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
149560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            ViewCompatGingerbread.setOverScrollMode(v, mode);
150560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
151560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
152560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
153ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class HCViewCompatImpl extends GBViewCompatImpl {
154ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
155ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return ViewCompatHC.getFrameTime();
156ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
157ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
158ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
159ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class ICSViewCompatImpl extends HCViewCompatImpl {
1609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
161bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
162bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollHorizontally(v, direction);
163bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
1649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
165bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
166bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollVertically(v, direction);
167bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
1689648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
1699648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
1709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onPopulateAccessibilityEvent(v, event);
1719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1729648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
1739648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
1749648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityEvent(v, event);
1759648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1769648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
1779648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
178956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityNodeInfo(v, info.getInfo());
1799648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1809648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
1819648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
1829648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.setAccessibilityDelegate(v, delegate.getBridge());
1839648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
184bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
185bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
186c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    static class JBViewCompatImpl extends ICSViewCompatImpl {
187c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
188c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
189c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return ViewCompatJB.hasTransientState(view);
190c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
191c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
192c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
193c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            ViewCompatJB.setHasTransientState(view, hasTransientState);
194c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
195ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
196ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
197ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view);
198ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
199ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
200ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
201ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view, left, top, right, bottom);
202ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
203ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
204ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
205ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimation(view, action);
206ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
207ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
208ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
209ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimationDelayed(view, action, delayMillis);
210ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
21125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
21225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public int getImportantForAccessibility(View view) {
21325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return ViewCompatJB.getImportantForAccessibility(view);
21425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
21525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
21625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public void setImportantForAccessibility(View view, int mode) {
21725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            ViewCompatJB.setImportantForAccessibility(view, mode);
21825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
21925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        @Override
22025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
22125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            Object compat = ViewCompatJB.getAccessibilityNodeProvider(view);
22225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            if (compat != null) {
22325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov                return new AccessibilityNodeProviderCompat(compat);
22425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            }
22525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov            return null;
22625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        }
227c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
228c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
229bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static final ViewCompatImpl IMPL;
230bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static {
231560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        final int version = android.os.Build.VERSION.SDK_INT;
232c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        if (version >= 16 || android.os.Build.VERSION.CODENAME.equals("JellyBean")) {
233c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            IMPL = new JBViewCompatImpl();
234c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        } else if (version >= 14) {
235bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new ICSViewCompatImpl();
236ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        } else if (version >= 11) {
237ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            IMPL = new HCViewCompatImpl();
238560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        } else if (version >= 9) {
239560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            IMPL = new GBViewCompatImpl();
240bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        } else {
241bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new BaseViewCompatImpl();
242bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
243bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
244bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
2450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled horizontally in a certain direction.
2470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling left, positive to check scrolling right.
2500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
2510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
252bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollHorizontally(View v, int direction) {
253bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollHorizontally(v, direction);
254bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
255bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
2560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled vertically in a certain direction.
2580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling up, positive to check scrolling down.
2610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
2620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
263bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollVertically(View v, int direction) {
264bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollVertically(v, direction);
265bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
266560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
2670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Returns the over-scroll mode for this view. The result will be
2690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
2700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
2710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
2720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return This view's over-scroll mode.
2750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
276560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static int getOverScrollMode(View v) {
277560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        return IMPL.getOverScrollMode(v);
278560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
279560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
2800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Set the over-scroll mode for this view. Valid over-scroll modes are
2820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
2830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
2840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
2850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Setting the over-scroll mode of a view will have an effect only if the
2870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * view is capable of scrolling.
2880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param overScrollMode The new over-scroll mode for this view.
2910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
2920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    public static void setOverScrollMode(View v, int overScrollMode) {
2930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov        IMPL.setOverScrollMode(v, overScrollMode);
294560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
2959648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
2960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)}
2980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * giving a chance to this View to populate the accessibility event with its
2990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * text content. While this method is free to modify event
3000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * attributes other than text content, doing so should normally be performed in
3010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}.
3020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Adding formatted date string to an accessibility event in addition
3040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to the text added by the super implementation:
3050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
3060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onPopulateAccessibilityEvent(event);
3070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
3080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     String selectedDateUtterance = DateUtils.formatDateTime(mContext,
3090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *         mCurrentDate.getTimeInMillis(), flags);
3100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.getText().add(selectedDateUtterance);
3110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
3120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
3140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
3150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View,
3160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
3170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
3180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
3200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
3210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The accessibility event which to populate.
3250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
3270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
3280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3299648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
3309648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onPopulateAccessibilityEvent(v, event);
3319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
3329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
3330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link AccessibilityEvent} with information about
3350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * this View which is the event source. In other words, the source of
3360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * an accessibility event is the view whose state change triggered firing
3370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * the event.
3380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Setting the password property of an event in addition
3400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to properties set by the super implementation:
3410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
3420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onInitializeAccessibilityEvent(event);
3430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.setPassword(true);
3440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
3450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
3470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
3480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View,
3490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
3500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
3510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
3530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
3540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The event to initialize.
3580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
3600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
3610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
3639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityEvent(v, event);
3649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
3659648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
3660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information
3680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * about this view. The base implementation sets:
3690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <ul>
3700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},</li>
3710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},</li>
3720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},</li>
3730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},</li>
3740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},</li>
3750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},</li>
3760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},</li>
3770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},</li>
3780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},</li>
3790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},</li>
3800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},</li>
3810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},</li>
3820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </ul>
3830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Subclasses should override this method, call the super implementation,
3850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * and set additional attributes.
3860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
3890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
3900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View,
3910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  android.view.accessibility.AccessibilityNodeInfo)}
3920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
3930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3950574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param info The instance to initialize.
3970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3989648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
3999648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityNodeInfo(v, info);
4009648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
4019648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
4020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
4030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Sets a delegate for implementing accessibility support via compositon as
4040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * opposed to inheritance. The delegate's primary use is for implementing
4050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * backwards compatible widgets. For more details see
4060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate}.
4070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
4090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param delegate The delegate instance.
4100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
4110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see android.view.View.AccessibilityDelegate
4120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
4139648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
4149648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.setAccessibilityDelegate(v, delegate);
4159648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
416c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
417c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
418c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Indicates whether the view is currently tracking transient state that the
419c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * app should not need to concern itself with saving and restoring, but that
420c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * the framework should take special note to preserve when possible.
421c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
422c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View to check for transient state
423c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @return true if the view has transient state
424c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
425c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static boolean hasTransientState(View view) {
426c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        return IMPL.hasTransientState(view);
427c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
428c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
429c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
430c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Set whether this view is currently tracking transient state that the
431c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * framework should attempt to preserve when possible.
432c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
433c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View tracking transient state
434c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param hasTransientState true if this view has transient state
435c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
436c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static void setHasTransientState(View view, boolean hasTransientState) {
437c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        IMPL.setHasTransientState(view, hasTransientState);
438c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
439ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
440ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
441ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate to happen on the next animation time step, typically the
442ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * next display frame.</p>
443ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
444ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
445ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
446ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
447ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
448ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
449ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view) {
450ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view);
451ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
452ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
453ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
454ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate of the specified area to happen on the next animation
455ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * time step, typically the next display frame.</p>
456ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
457ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
458ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
459ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
460ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
461ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param left The left coordinate of the rectangle to invalidate.
462ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param top The top coordinate of the rectangle to invalidate.
463ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param right The right coordinate of the rectangle to invalidate.
464ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param bottom The bottom coordinate of the rectangle to invalidate.
465ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
466ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view, int left, int top,
467ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            int right, int bottom) {
468ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view, left, top, right, bottom);
469ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
470ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
471ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
472ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step.
473ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
474ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
475ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
476ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
477ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
478ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to post this Runnable to
479ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
480ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
481ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimation(View view, Runnable action) {
482ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimation(view, action);
483ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
484ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
485ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
486ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step,
487ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * after the specified amount of time elapses.
488ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
489ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
490ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
491ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
492ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
493ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view The view to post this Runnable to
494ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
495ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param delayMillis The delay (in milliseconds) until the Runnable
496ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *        will be executed.
497ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
498ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
499ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimationDelayed(view, action, delayMillis);
500ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
50125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
50225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
50325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the mode for determining whether this View is important for accessibility
50425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
50525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
50625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
50725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
50825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The mode for determining whether a View is important for accessibility.
50925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
51025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
51125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
51225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
51325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
51425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static int getImportantForAccessibility(View view) {
51525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getImportantForAccessibility(view);
51625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
51725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
51825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
51925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Sets how to determine whether this view is important for accessibility
52025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * which is if it fires accessibility events and if it is reported to
52125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * accessibility services that query the screen.
52225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
52325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to set.
52425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param mode How to determine whether this view is important for accessibility.
52525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
52625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_YES
52725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_NO
52825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO
52925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
53025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static void setImportantForAccessibility(View view, int mode) {
53125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        IMPL.setImportantForAccessibility(view, mode);
53225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
53325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov
53425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    /**
53525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * Gets the provider for managing a virtual view hierarchy rooted at this View
53625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * and reported to {@link android.accessibilityservice.AccessibilityServiceCompat}s
53725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * that explore the window content.
53825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
53925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If this method returns an instance, this instance is responsible for managing
54025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * {@link AccessibilityNodeInfoComapt}s describing the virtual sub-tree rooted at
54125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * this View including the one representing the View itself. Similarly the returned
54225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * instance is responsible for performing accessibility actions on any virtual
54325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * view or the root view itself.
54425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
54525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * <p>
54625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * If an {@link AccessibilityDelegateCompat} has been specified via calling
54725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * {@link #setAccessibilityDelegate(AccessibilityDelegate)} its
54825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * {@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)}
54925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * is responsible for handling this call.
55025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * </p>
55125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
55225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @param view The view whose property to get.
55325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @return The provider.
55425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     *
55525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     * @see AccessibilityNodeProviderCompat
55625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov     */
55725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) {
55825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov        return IMPL.getAccessibilityNodeProvider(view);
55925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov    }
560bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell}
561