ViewCompat.java revision 97341bdc5bea1d7bf777de65228039142d249f38
1bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/* 2bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Copyright (C) 2011 The Android Open Source Project 3bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * 4bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 5bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * you may not use this file except in compliance with the License. 6bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * You may obtain a copy of the License at 7bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * 8bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * http://www.apache.org/licenses/LICENSE-2.0 9bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * 10bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Unless required by applicable law or agreed to in writing, software 11bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * distributed under the License is distributed on an "AS IS" BASIS, 12bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * See the License for the specific language governing permissions and 14bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * limitations under the License. 15bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */ 16bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell 17bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpackage android.support.v4.view; 18bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell 198a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powellimport android.graphics.Paint; 200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganovimport android.graphics.Rect; 210d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanvimport android.os.Bundle; 229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; 2325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeProviderCompat; 24bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellimport android.view.View; 259648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.accessibility.AccessibilityEvent; 26bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell 27bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/** 280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link View} introduced after API 290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * level 4 in a backwards compatible fashion. 30bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */ 31bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpublic class ViewCompat { 32560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell /** 33560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell * Always allow a user to over-scroll this view, provided it is a 34560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell * view that can scroll. 35560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell */ 36560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public static final int OVER_SCROLL_ALWAYS = 0; 37560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell 38560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell /** 39560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell * Allow a user to over-scroll this view only if the content is large 40560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell * enough to meaningfully scroll, provided it is a view that can scroll. 41560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell */ 42560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public static final int OVER_SCROLL_IF_CONTENT_SCROLLS = 1; 43560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell 44560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell /** 45560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell * Never allow a user to over-scroll this view. 46560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell */ 47560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public static final int OVER_SCROLL_NEVER = 2; 48560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell 49ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell private static final long FAKE_FRAME_TIME = 10; 50ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell 5125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov /** 5225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * Automatically determine whether a view is important for accessibility. 5325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov */ 5425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = 0x00000000; 5525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 5625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov /** 5725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * The view is important for accessibility. 5825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov */ 5925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 0x00000001; 6025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 6125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov /** 6225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * The view is not important for accessibility. 6325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov */ 6425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002; 6525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 668a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell /** 678a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * Indicates that the view does not have a layer. 688a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell */ 698a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell public static final int LAYER_TYPE_NONE = 0; 708a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell 718a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell /** 728a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>Indicates that the view has a software layer. A software layer is backed 738a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * by a bitmap and causes the view to be rendered using Android's software 748a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * rendering pipeline, even if hardware acceleration is enabled.</p> 758a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * 768a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>Software layers have various usages:</p> 778a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>When the application is not using hardware acceleration, a software layer 788a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * is useful to apply a specific color filter and/or blending mode and/or 798a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * translucency to a view and all its children.</p> 808a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>When the application is using hardware acceleration, a software layer 818a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * is useful to render drawing primitives not supported by the hardware 828a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * accelerated pipeline. It can also be used to cache a complex view tree 838a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * into a texture and reduce the complexity of drawing operations. For instance, 848a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * when animating a complex view tree with a translation, a software layer can 858a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * be used to render the view tree only once.</p> 868a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>Software layers should be avoided when the affected view tree updates 878a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * often. Every update will require to re-render the software layer, which can 888a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * potentially be slow (particularly when hardware acceleration is turned on 898a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * since the layer will have to be uploaded into a hardware texture after every 908a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * update.)</p> 918a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell */ 928a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell public static final int LAYER_TYPE_SOFTWARE = 1; 938a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell 948a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell /** 958a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>Indicates that the view has a hardware layer. A hardware layer is backed 968a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * by a hardware specific texture (generally Frame Buffer Objects or FBO on 978a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * OpenGL hardware) and causes the view to be rendered using Android's hardware 988a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * rendering pipeline, but only if hardware acceleration is turned on for the 998a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * view hierarchy. When hardware acceleration is turned off, hardware layers 1008a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * behave exactly as {@link #LAYER_TYPE_SOFTWARE software layers}.</p> 1018a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * 1028a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>A hardware layer is useful to apply a specific color filter and/or 1038a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * blending mode and/or translucency to a view and all its children.</p> 1048a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>A hardware layer can be used to cache a complex view tree into a 1058a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * texture and reduce the complexity of drawing operations. For instance, 1068a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * when animating a complex view tree with a translation, a hardware layer can 1078a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * be used to render the view tree only once.</p> 1088a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>A hardware layer can also be used to increase the rendering quality when 1098a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * rotation transformations are applied on a view. It can also be used to 1108a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * prevent potential clipping issues when applying 3D transforms on a view.</p> 1118a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell */ 1128a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell public static final int LAYER_TYPE_HARDWARE = 2; 1138a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell 114bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell interface ViewCompatImpl { 115bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell public boolean canScrollHorizontally(View v, int direction); 116bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell public boolean canScrollVertically(View v, int direction); 117560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public int getOverScrollMode(View v); 118560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public void setOverScrollMode(View v, int mode); 1199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event); 1209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event); 1219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info); 1229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate); 123c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell public boolean hasTransientState(View view); 124c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell public void setHasTransientState(View view, boolean hasTransientState); 125ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postInvalidateOnAnimation(View view); 126ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom); 127ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postOnAnimation(View view, Runnable action); 128ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postOnAnimationDelayed(View view, Runnable action, long delayMillis); 12925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public int getImportantForAccessibility(View view); 13025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public void setImportantForAccessibility(View view, int mode); 1310d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv public boolean performAccessibilityAction(View view, int action, Bundle arguments); 13225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view); 1338a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell public void setLayerType(View view, int layerType, Paint paint); 13497341bdc5bea1d7bf777de65228039142d249f38Adam Powell public int getLayerType(View view); 135bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 136bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell 137bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell static class BaseViewCompatImpl implements ViewCompatImpl { 138bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell public boolean canScrollHorizontally(View v, int direction) { 139bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell return false; 140bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 141bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell public boolean canScrollVertically(View v, int direction) { 142bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell return false; 143bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 144560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public int getOverScrollMode(View v) { 145560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell return OVER_SCROLL_NEVER; 146560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell } 147560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public void setOverScrollMode(View v, int mode) { 148560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell // Do nothing; API doesn't exist 149560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell } 1509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) { 1519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov // Do nothing; API doesn't exist 1529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) { 1549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov // Do nothing; API doesn't exist 1559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) { 1579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov // Do nothing; API doesn't exist 1589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) { 1609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov // Do nothing; API doesn't exist 1619648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 162c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell public boolean hasTransientState(View view) { 163c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell // A view can't have transient state if transient state wasn't supported. 164c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell return false; 165c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell } 166c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell public void setHasTransientState(View view, boolean hasTransientState) { 167c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell // Do nothing; API doesn't exist 168c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell } 169ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postInvalidateOnAnimation(View view) { 170ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell view.postInvalidateDelayed(getFrameTime()); 171ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 172ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) { 173ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell view.postInvalidateDelayed(getFrameTime(), left, top, right, bottom); 174ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 175ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postOnAnimation(View view, Runnable action) { 176ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell view.postDelayed(action, getFrameTime()); 177ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 178ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) { 179ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell view.postDelayed(action, getFrameTime() + delayMillis); 180ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 181ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell long getFrameTime() { 182ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell return FAKE_FRAME_TIME; 183ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 18425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public int getImportantForAccessibility(View view) { 18525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return 0; 18625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 18725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public void setImportantForAccessibility(View view, int mode) { 18825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 18925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 1900d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv public boolean performAccessibilityAction(View view, int action, Bundle arguments) { 1910d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv return false; 1920d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv } 19325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) { 19425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return null; 19525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 1968a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell public void setLayerType(View view, int layerType, Paint paint) { 1978a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell } 19897341bdc5bea1d7bf777de65228039142d249f38Adam Powell public int getLayerType(View view) { 19997341bdc5bea1d7bf777de65228039142d249f38Adam Powell return LAYER_TYPE_NONE; 20097341bdc5bea1d7bf777de65228039142d249f38Adam Powell } 201bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 202bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell 203560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell static class GBViewCompatImpl extends BaseViewCompatImpl { 2049648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 205560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public int getOverScrollMode(View v) { 206560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell return ViewCompatGingerbread.getOverScrollMode(v); 207560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell } 2089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 209560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public void setOverScrollMode(View v, int mode) { 210560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell ViewCompatGingerbread.setOverScrollMode(v, mode); 211560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell } 212560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell } 213560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell 214ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell static class HCViewCompatImpl extends GBViewCompatImpl { 215ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell long getFrameTime() { 216ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell return ViewCompatHC.getFrameTime(); 217ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 2188a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell @Override public void setLayerType(View view, int layerType, Paint paint) { 2198a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell ViewCompatHC.setLayerType(view, layerType, paint); 2208a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell } 22197341bdc5bea1d7bf777de65228039142d249f38Adam Powell @Override public int getLayerType(View view) { 22297341bdc5bea1d7bf777de65228039142d249f38Adam Powell return ViewCompatHC.getLayerType(view); 22397341bdc5bea1d7bf777de65228039142d249f38Adam Powell } 224ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 225ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell 226ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell static class ICSViewCompatImpl extends HCViewCompatImpl { 2279648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 228bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell public boolean canScrollHorizontally(View v, int direction) { 229bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell return ViewCompatICS.canScrollHorizontally(v, direction); 230bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 2319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 232bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell public boolean canScrollVertically(View v, int direction) { 233bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell return ViewCompatICS.canScrollVertically(v, direction); 234bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 2359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 2369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) { 2379648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov ViewCompatICS.onPopulateAccessibilityEvent(v, event); 2389648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 2409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) { 2419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov ViewCompatICS.onInitializeAccessibilityEvent(v, event); 2429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 2449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) { 245956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov ViewCompatICS.onInitializeAccessibilityNodeInfo(v, info.getInfo()); 2469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 2489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) { 2499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov ViewCompatICS.setAccessibilityDelegate(v, delegate.getBridge()); 2509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 251bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 252bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell 253c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell static class JBViewCompatImpl extends ICSViewCompatImpl { 254c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell @Override 255c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell public boolean hasTransientState(View view) { 256c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell return ViewCompatJB.hasTransientState(view); 257c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell } 258c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell @Override 259c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell public void setHasTransientState(View view, boolean hasTransientState) { 260c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell ViewCompatJB.setHasTransientState(view, hasTransientState); 261c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell } 262ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell @Override 263ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postInvalidateOnAnimation(View view) { 264ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell ViewCompatJB.postInvalidateOnAnimation(view); 265ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 266ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell @Override 267ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) { 268ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell ViewCompatJB.postInvalidateOnAnimation(view, left, top, right, bottom); 269ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 270ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell @Override 271ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postOnAnimation(View view, Runnable action) { 272ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell ViewCompatJB.postOnAnimation(view, action); 273ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 274ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell @Override 275ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) { 276ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell ViewCompatJB.postOnAnimationDelayed(view, action, delayMillis); 277ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 27825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov @Override 27925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public int getImportantForAccessibility(View view) { 28025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return ViewCompatJB.getImportantForAccessibility(view); 28125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 28225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov @Override 28325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public void setImportantForAccessibility(View view, int mode) { 28425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov ViewCompatJB.setImportantForAccessibility(view, mode); 28525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 28625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov @Override 2870d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv public boolean performAccessibilityAction(View view, int action, Bundle arguments) { 2880d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv return ViewCompatJB.performAccessibilityAction(view, action, arguments); 2890d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv } 2900d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv @Override 29125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) { 29225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov Object compat = ViewCompatJB.getAccessibilityNodeProvider(view); 29325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov if (compat != null) { 29425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return new AccessibilityNodeProviderCompat(compat); 29525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 29625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return null; 29725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 298c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell } 299c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell 300bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell static final ViewCompatImpl IMPL; 301bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell static { 302560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell final int version = android.os.Build.VERSION.SDK_INT; 303c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell if (version >= 16 || android.os.Build.VERSION.CODENAME.equals("JellyBean")) { 304c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell IMPL = new JBViewCompatImpl(); 305c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell } else if (version >= 14) { 306bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell IMPL = new ICSViewCompatImpl(); 307ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } else if (version >= 11) { 308ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell IMPL = new HCViewCompatImpl(); 309560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell } else if (version >= 9) { 310560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell IMPL = new GBViewCompatImpl(); 311bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } else { 312bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell IMPL = new BaseViewCompatImpl(); 313bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 314bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 315bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell 3160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov /** 3170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Check if this view can be scrolled horizontally in a certain direction. 3180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 3190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param v The View against which to invoke the method. 3200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param direction Negative to check scrolling left, positive to check scrolling right. 3210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @return true if this view can be scrolled in the specified direction, false otherwise. 3220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov */ 323bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell public static boolean canScrollHorizontally(View v, int direction) { 324bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell return IMPL.canScrollHorizontally(v, direction); 325bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 326bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell 3270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov /** 3280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Check if this view can be scrolled vertically in a certain direction. 3290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 3300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param v The View against which to invoke the method. 3310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param direction Negative to check scrolling up, positive to check scrolling down. 3320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @return true if this view can be scrolled in the specified direction, false otherwise. 3330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov */ 334bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell public static boolean canScrollVertically(View v, int direction) { 335bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell return IMPL.canScrollVertically(v, direction); 336bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell } 337560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell 3380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov /** 3390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Returns the over-scroll mode for this view. The result will be 3400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS} 3410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * (allow over-scrolling only if the view content is larger than the container), 3420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * or {@link #OVER_SCROLL_NEVER}. 3430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 3440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param v The View against which to invoke the method. 3450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @return This view's over-scroll mode. 3460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov */ 347560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell public static int getOverScrollMode(View v) { 348560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell return IMPL.getOverScrollMode(v); 349560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell } 350560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell 3510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov /** 3520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Set the over-scroll mode for this view. Valid over-scroll modes are 3530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS} 3540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * (allow over-scrolling only if the view content is larger than the container), 3550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * or {@link #OVER_SCROLL_NEVER}. 3560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 3570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Setting the over-scroll mode of a view will have an effect only if the 3580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * view is capable of scrolling. 3590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 3600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param v The View against which to invoke the method. 3610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param overScrollMode The new over-scroll mode for this view. 3620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov */ 3630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov public static void setOverScrollMode(View v, int overScrollMode) { 3640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov IMPL.setOverScrollMode(v, overScrollMode); 365560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell } 3669648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 3670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov /** 3680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)} 3690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * giving a chance to this View to populate the accessibility event with its 3700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * text content. While this method is free to modify event 3710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * attributes other than text content, doing so should normally be performed in 3720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}. 3730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <p> 3740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Example: Adding formatted date string to an accessibility event in addition 3750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * to the text added by the super implementation: 3760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <pre> public void onPopulateAccessibilityEvent(AccessibilityEvent event) { 3770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * super.onPopulateAccessibilityEvent(event); 3780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY; 3790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * String selectedDateUtterance = DateUtils.formatDateTime(mContext, 3800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * mCurrentDate.getTimeInMillis(), flags); 3810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * event.getText().add(selectedDateUtterance); 3820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * }</pre> 3830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <p> 3840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling 3850574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its 3860574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View, 3870574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * AccessibilityEvent)} 3880574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * is responsible for handling this call. 3890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * </p> 3900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <p class="note"><strong>Note:</strong> Always call the super implementation before adding 3910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * information to the event, in case the default implementation has basic information to add. 3920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * </p> 3930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 3940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param v The View against which to invoke the method. 3950574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param event The accessibility event which to populate. 3960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 3970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @see View#sendAccessibilityEvent(int) 3980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) 3990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov */ 4009648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) { 4019648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov IMPL.onPopulateAccessibilityEvent(v, event); 4029648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 4039648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 4040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov /** 4050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Initializes an {@link AccessibilityEvent} with information about 4060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * this View which is the event source. In other words, the source of 4070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * an accessibility event is the view whose state change triggered firing 4080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * the event. 4090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <p> 4100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Example: Setting the password property of an event in addition 4110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * to properties set by the super implementation: 4120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <pre> public void onInitializeAccessibilityEvent(AccessibilityEvent event) { 4130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * super.onInitializeAccessibilityEvent(event); 4140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * event.setPassword(true); 4150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * }</pre> 4160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <p> 4170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling 4180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its 4190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View, 4200574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * AccessibilityEvent)} 4210574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * is responsible for handling this call. 4220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * </p> 4230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <p class="note"><strong>Note:</strong> Always call the super implementation before adding 4240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * information to the event, in case the default implementation has basic information to add. 4250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * </p> 4260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 4270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param v The View against which to invoke the method. 4280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param event The event to initialize. 4290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 4300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @see View#sendAccessibilityEvent(int) 4310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) 4320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov */ 4339648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) { 4349648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov IMPL.onInitializeAccessibilityEvent(v, event); 4359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 4369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 4370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov /** 4380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information 4390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * about this view. The base implementation sets: 4400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <ul> 4410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},</li> 4420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},</li> 4430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},</li> 4440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},</li> 4450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},</li> 4460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},</li> 4470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},</li> 4480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},</li> 4490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},</li> 4500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},</li> 4510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},</li> 4520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},</li> 4530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * </ul> 4540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <p> 4550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Subclasses should override this method, call the super implementation, 4560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * and set additional attributes. 4570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * </p> 4580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * <p> 4590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling 4600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its 4610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View, 4620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * android.view.accessibility.AccessibilityNodeInfo)} 4630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * is responsible for handling this call. 4640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * </p> 4650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 4660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param v The View against which to invoke the method. 4670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param info The instance to initialize. 4680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov */ 4699648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) { 4709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov IMPL.onInitializeAccessibilityNodeInfo(v, info); 4719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 4729648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 4730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov /** 4740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Sets a delegate for implementing accessibility support via compositon as 4750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * opposed to inheritance. The delegate's primary use is for implementing 4760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * backwards compatible widgets. For more details see 4770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * {@link android.view.View.AccessibilityDelegate}. 4780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 4790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param v The View against which to invoke the method. 4800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @param delegate The delegate instance. 4810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 4820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @see android.view.View.AccessibilityDelegate 4830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov */ 4849648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) { 4859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov IMPL.setAccessibilityDelegate(v, delegate); 4869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 487c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell 488c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell /** 489c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * Indicates whether the view is currently tracking transient state that the 490c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * app should not need to concern itself with saving and restoring, but that 491c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * the framework should take special note to preserve when possible. 492c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * 493c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * @param view View to check for transient state 494c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * @return true if the view has transient state 495c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell */ 496c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell public static boolean hasTransientState(View view) { 497c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell return IMPL.hasTransientState(view); 498c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell } 499c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell 500c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell /** 501c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * Set whether this view is currently tracking transient state that the 502c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * framework should attempt to preserve when possible. 503c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * 504c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * @param view View tracking transient state 505c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell * @param hasTransientState true if this view has transient state 506c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell */ 507c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell public static void setHasTransientState(View view, boolean hasTransientState) { 508c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell IMPL.setHasTransientState(view, hasTransientState); 509c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell } 510ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell 511ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell /** 512ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * <p>Cause an invalidate to happen on the next animation time step, typically the 513ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * next display frame.</p> 514ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * 515ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * <p>This method can be invoked from outside of the UI thread 516ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * only when this View is attached to a window.</p> 517ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * 518ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param view View to invalidate 519ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell */ 520ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public static void postInvalidateOnAnimation(View view) { 521ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell IMPL.postInvalidateOnAnimation(view); 522ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 523ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell 524ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell /** 525ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * <p>Cause an invalidate of the specified area to happen on the next animation 526ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * time step, typically the next display frame.</p> 527ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * 528ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * <p>This method can be invoked from outside of the UI thread 529ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * only when this View is attached to a window.</p> 530ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * 531ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param view View to invalidate 532ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param left The left coordinate of the rectangle to invalidate. 533ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param top The top coordinate of the rectangle to invalidate. 534ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param right The right coordinate of the rectangle to invalidate. 535ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param bottom The bottom coordinate of the rectangle to invalidate. 536ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell */ 537ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public static void postInvalidateOnAnimation(View view, int left, int top, 538ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell int right, int bottom) { 539ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell IMPL.postInvalidateOnAnimation(view, left, top, right, bottom); 540ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 541ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell 542ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell /** 543ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * <p>Causes the Runnable to execute on the next animation time step. 544ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * The runnable will be run on the user interface thread.</p> 545ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * 546ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * <p>This method can be invoked from outside of the UI thread 547ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * only when this View is attached to a window.</p> 548ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * 549ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param view View to post this Runnable to 550ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param action The Runnable that will be executed. 551ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell */ 552ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public static void postOnAnimation(View view, Runnable action) { 553ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell IMPL.postOnAnimation(view, action); 554ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 555ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell 556ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell /** 557ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * <p>Causes the Runnable to execute on the next animation time step, 558ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * after the specified amount of time elapses. 559ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * The runnable will be run on the user interface thread.</p> 560ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * 561ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * <p>This method can be invoked from outside of the UI thread 562ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * only when this View is attached to a window.</p> 563ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * 564ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param view The view to post this Runnable to 565ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param action The Runnable that will be executed. 566ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * @param delayMillis The delay (in milliseconds) until the Runnable 567ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell * will be executed. 568ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell */ 569ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis) { 570ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell IMPL.postOnAnimationDelayed(view, action, delayMillis); 571ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell } 57225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 57325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov /** 57425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * Gets the mode for determining whether this View is important for accessibility 57525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * which is if it fires accessibility events and if it is reported to 57625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * accessibility services that query the screen. 57725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * 57825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @param view The view whose property to get. 57925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @return The mode for determining whether a View is important for accessibility. 58025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * 58125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @see #IMPORTANT_FOR_ACCESSIBILITY_YES 58225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @see #IMPORTANT_FOR_ACCESSIBILITY_NO 58325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO 58425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov */ 58525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public static int getImportantForAccessibility(View view) { 58625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return IMPL.getImportantForAccessibility(view); 58725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 58825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 58925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov /** 59025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * Sets how to determine whether this view is important for accessibility 59125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * which is if it fires accessibility events and if it is reported to 59225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * accessibility services that query the screen. 59325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * 59425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @param view The view whose property to set. 59525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @param mode How to determine whether this view is important for accessibility. 59625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * 59725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @see #IMPORTANT_FOR_ACCESSIBILITY_YES 59825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @see #IMPORTANT_FOR_ACCESSIBILITY_NO 59925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @see #IMPORTANT_FOR_ACCESSIBILITY_AUTO 60025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov */ 60125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public static void setImportantForAccessibility(View view, int mode) { 60225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov IMPL.setImportantForAccessibility(view, mode); 60325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 60425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 60525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov /** 6060d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * Performs the specified accessibility action on the view. For 6070d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * possible accessibility actions look at {@link AccessibilityNodeInfoCompat}. 6080d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * <p> 6090d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * If an {@link AccessibilityDelegateCompat} has been specified via calling 6100d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its 6110d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * {@link AccessibilityDelegateCompat#performAccessibilityAction(View, int, Bundle)} 6120d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * is responsible for handling this call. 6130d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * </p> 6140d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * 6150d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * @param action The action to perform. 6160d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * @param arguments Optional action arguments. 6170d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv * @return Whether the action was performed. 6180d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv */ 6190d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv public static boolean performAccessibilityAction(View view, int action, Bundle arguments) { 6200d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv return IMPL.performAccessibilityAction(view, action, arguments); 6210d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv } 6220d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv 6230d4ffdf13a16b1ce2f3bc458002374cdd25663c3alanv /** 62425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * Gets the provider for managing a virtual view hierarchy rooted at this View 625e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov * and reported to {@link android.accessibilityservice.AccessibilityService}s 62625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * that explore the window content. 62725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * <p> 62825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * If this method returns an instance, this instance is responsible for managing 629e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov * {@link AccessibilityNodeInfoCompat}s describing the virtual sub-tree rooted at 63025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * this View including the one representing the View itself. Similarly the returned 63125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * instance is responsible for performing accessibility actions on any virtual 63225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * view or the root view itself. 63325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * </p> 63425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * <p> 63525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * If an {@link AccessibilityDelegateCompat} has been specified via calling 636e13cf48dc33e3865794d145ae8f4daed0bb2274bSvetoslav Ganov * {@link #setAccessibilityDelegate(View, AccessibilityDelegateCompat) its 63725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * {@link AccessibilityDelegateCompat#getAccessibilityNodeProvider(View)} 63825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * is responsible for handling this call. 63925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * </p> 64025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * 64125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @param view The view whose property to get. 64225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @return The provider. 64325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * 64425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @see AccessibilityNodeProviderCompat 64525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov */ 64625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public static AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View view) { 64725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return IMPL.getAccessibilityNodeProvider(view); 64825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 6498a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell 6508a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell /** 6518a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>Specifies the type of layer backing this view. The layer can be 6528a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_NONE disabled}, {@link #LAYER_TYPE_SOFTWARE software} or 6538a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_HARDWARE hardware}.</p> 6548a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * 6558a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>A layer is associated with an optional {@link android.graphics.Paint} 6568a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * instance that controls how the layer is composed on screen. The following 6578a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * properties of the paint are taken into account when composing the layer:</p> 6588a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <ul> 6598a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li> 6608a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li> 6618a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li> 6628a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * </ul> 6638a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * 6648a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>If this view has an alpha value set to < 1.0 by calling 6658a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * setAlpha(float), the alpha value of the layer's paint is replaced by 6668a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * this view's alpha value. Calling setAlpha(float) is therefore 6678a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * equivalent to setting a hardware layer on this view and providing a paint with 6688a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * the desired alpha value.<p> 6698a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * 6708a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * <p>Refer to the documentation of {@link #LAYER_TYPE_NONE disabled}, 6718a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_SOFTWARE software} and {@link #LAYER_TYPE_HARDWARE hardware} 6728a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * for more information on when and how to use layers.</p> 6738a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * 6748a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * @param layerType The ype of layer to use with this view, must be one of 6758a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or 6768a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_HARDWARE} 6778a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * @param paint The paint used to compose the layer. This argument is optional 6788a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * and can be null. It is ignored when the layer type is 6798a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_NONE} 6808a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * 6818a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * @param view View to set the layer type for 6828a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * @param layerType The type of layer to use with this view, must be one of 6838a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or 6848a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_HARDWARE} 6858a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * @param paint The paint used to compose the layer. This argument is optional 6868a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * and can be null. It is ignored when the layer type is 6878a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell * {@link #LAYER_TYPE_NONE} 6888a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell */ 6898a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell public static void setLayerType(View view, int layerType, Paint paint) { 6908a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell IMPL.setLayerType(view, layerType, paint); 6918a0c51a3d438802df28612e02fdf0cc8fab06ddbAdam Powell } 69297341bdc5bea1d7bf777de65228039142d249f38Adam Powell 69397341bdc5bea1d7bf777de65228039142d249f38Adam Powell /** 69497341bdc5bea1d7bf777de65228039142d249f38Adam Powell * Indicates what type of layer is currently associated with this view. By default 69597341bdc5bea1d7bf777de65228039142d249f38Adam Powell * a view does not have a layer, and the layer type is {@link #LAYER_TYPE_NONE}. 69697341bdc5bea1d7bf777de65228039142d249f38Adam Powell * Refer to the documentation of 69797341bdc5bea1d7bf777de65228039142d249f38Adam Powell * {@link #setLayerType(android.view.View, int, android.graphics.Paint)} 69897341bdc5bea1d7bf777de65228039142d249f38Adam Powell * for more information on the different types of layers. 69997341bdc5bea1d7bf777de65228039142d249f38Adam Powell * 70097341bdc5bea1d7bf777de65228039142d249f38Adam Powell * @param view The view to fetch the layer type from 70197341bdc5bea1d7bf777de65228039142d249f38Adam Powell * @return {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or 70297341bdc5bea1d7bf777de65228039142d249f38Adam Powell * {@link #LAYER_TYPE_HARDWARE} 70397341bdc5bea1d7bf777de65228039142d249f38Adam Powell * 70497341bdc5bea1d7bf777de65228039142d249f38Adam Powell * @see #setLayerType(android.view.View, int, android.graphics.Paint) 70597341bdc5bea1d7bf777de65228039142d249f38Adam Powell * @see #LAYER_TYPE_NONE 70697341bdc5bea1d7bf777de65228039142d249f38Adam Powell * @see #LAYER_TYPE_SOFTWARE 70797341bdc5bea1d7bf777de65228039142d249f38Adam Powell * @see #LAYER_TYPE_HARDWARE 70897341bdc5bea1d7bf777de65228039142d249f38Adam Powell */ 70997341bdc5bea1d7bf777de65228039142d249f38Adam Powell public static int getLayerType(View view) { 71097341bdc5bea1d7bf777de65228039142d249f38Adam Powell return IMPL.getLayerType(view); 71197341bdc5bea1d7bf777de65228039142d249f38Adam Powell } 712bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell} 713