19648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov/* 29648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Copyright (C) 2011 The Android Open Source Project 39648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 49648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Licensed under the Apache License, Version 2.0 (the "License"); 59648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * you may not use this file except in compliance with the License. 69648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * You may obtain a copy of the License at 79648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 89648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * http://www.apache.org/licenses/LICENSE-2.0 99648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Unless required by applicable law or agreed to in writing, software 119648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * distributed under the License is distributed on an "AS IS" BASIS, 129648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * See the License for the specific language governing permissions and 149648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * limitations under the License. 159648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 169648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 179648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovpackage android.support.v4.view; 189648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.os.Build; 2025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganovimport android.os.Bundle; 212a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikasimport android.support.annotation.RequiresApi; 229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; 23956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeProviderCompat; 249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.View; 252a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikasimport android.view.View.AccessibilityDelegate; 269648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.ViewGroup; 279648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.accessibility.AccessibilityEvent; 282a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikasimport android.view.accessibility.AccessibilityNodeInfo; 299c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikasimport android.view.accessibility.AccessibilityNodeProvider; 309648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov/** 32645e5c8aa6b31961c5f73f3d30bb5261d5e04aebKirill Grouchnikov * Helper for accessing {@link AccessibilityDelegate}. 33db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * <p> 34db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * <strong>Note:</strong> On platform versions prior to 35db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * {@link android.os.Build.VERSION_CODES#M API 23}, delegate methods on 36db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * views in the {@code android.widget.*} package are called <i>before</i> 37db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * host methods. This prevents certain properties such as class name from 38db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * being modified by overriding 39db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * {@link AccessibilityDelegateCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat)}, 40db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * as any changes will be overwritten by the host class. 41db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * <p> 42db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * Starting in {@link android.os.Build.VERSION_CODES#M API 23}, delegate 43db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * methods are called <i>after</i> host methods, which all properties to be 44db728e758ef69282dd83685cb96cb02e5064cbc2Alan Viverette * modified without being overwritten by the host class. 459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovpublic class AccessibilityDelegateCompat { 479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 489c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas static class AccessibilityDelegateBaseImpl { 492a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas public AccessibilityDelegate newAccessibilityDelegateBridge( 502a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas final AccessibilityDelegateCompat compat) { 519c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas return new AccessibilityDelegate() { 529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public boolean dispatchPopulateAccessibilityEvent(View host, 549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov AccessibilityEvent event) { 559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return compat.dispatchPopulateAccessibilityEvent(host, event); 569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { 609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov compat.onInitializeAccessibilityEvent(host, event); 619648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 649c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas public void onInitializeAccessibilityNodeInfo( 659c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas View host, AccessibilityNodeInfo info) { 669648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov compat.onInitializeAccessibilityNodeInfo(host, 67f87440725bb18397f734233f422c3429e7f284ebAurimas Liutikas AccessibilityNodeInfoCompat.wrap(info)); 689648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 699648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) { 729648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov compat.onPopulateAccessibilityEvent(host, event); 739648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 749648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 759648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 769648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, 779648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov AccessibilityEvent event) { 789648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return compat.onRequestSendAccessibilityEvent(host, child, event); 799648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 809648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 819648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 829648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void sendAccessibilityEvent(View host, int eventType) { 839648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov compat.sendAccessibilityEvent(host, eventType); 849648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov @Override 879648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void sendAccessibilityEventUnchecked(View host, AccessibilityEvent event) { 889648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov compat.sendAccessibilityEventUnchecked(host, event); 899648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 909c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas }; 919648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 929648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 932a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas public AccessibilityNodeProviderCompat getAccessibilityNodeProvider( 942a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas AccessibilityDelegate delegate, View host) { 952a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas // Do nothing. Added in API 16. 962a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas return null; 979648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 989648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 992a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas public boolean performAccessibilityAction(AccessibilityDelegate delegate, View host, 1002a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas int action, Bundle args) { 1012a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas // Do nothing. Added in API 16. 1022a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas return false; 1039648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1049648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1059648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 1062a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas @RequiresApi(16) 1072a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas static class AccessibilityDelegateApi16Impl extends AccessibilityDelegateBaseImpl { 108956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 1092a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas public AccessibilityDelegate newAccessibilityDelegateBridge( 1102a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas final AccessibilityDelegateCompat compat) { 1119c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas return new AccessibilityDelegate() { 112956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 113956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov public boolean dispatchPopulateAccessibilityEvent(View host, 114956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov AccessibilityEvent event) { 115956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov return compat.dispatchPopulateAccessibilityEvent(host, event); 116956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 117956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 118956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 119956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { 120956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov compat.onInitializeAccessibilityEvent(host, event); 121956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 122956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 123956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 1249c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas public void onInitializeAccessibilityNodeInfo( 1259c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas View host, AccessibilityNodeInfo info) { 126956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov compat.onInitializeAccessibilityNodeInfo(host, 127f87440725bb18397f734233f422c3429e7f284ebAurimas Liutikas AccessibilityNodeInfoCompat.wrap(info)); 128956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 129956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 130956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 131956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) { 132956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov compat.onPopulateAccessibilityEvent(host, event); 133956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 134956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 135956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 136956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, 137956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov AccessibilityEvent event) { 138956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov return compat.onRequestSendAccessibilityEvent(host, child, event); 139956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 140956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 141956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 142956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov public void sendAccessibilityEvent(View host, int eventType) { 143956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov compat.sendAccessibilityEvent(host, eventType); 144956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 145956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 146956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 147956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov public void sendAccessibilityEventUnchecked(View host, AccessibilityEvent event) { 148956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov compat.sendAccessibilityEventUnchecked(host, event); 149956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 150956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 151956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 1529c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas public AccessibilityNodeProvider getAccessibilityNodeProvider(View host) { 15325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov AccessibilityNodeProviderCompat provider = 15425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov compat.getAccessibilityNodeProvider(host); 1559c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas return (provider != null) 1569c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas ? (AccessibilityNodeProvider) provider.getProvider() : null; 15725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 15825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 15925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov @Override 16025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public boolean performAccessibilityAction(View host, int action, Bundle args) { 16125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return compat.performAccessibilityAction(host, action, args); 162956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 1639c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas }; 164956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 165956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 166956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov @Override 1672a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas public AccessibilityNodeProviderCompat getAccessibilityNodeProvider( 1682a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas AccessibilityDelegate delegate, View host) { 1699c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas Object provider = delegate.getAccessibilityNodeProvider(host); 170956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov if (provider != null) { 171956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov return new AccessibilityNodeProviderCompat(provider); 172956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 173956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov return null; 174956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 17525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 17625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov @Override 1772a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas public boolean performAccessibilityAction(AccessibilityDelegate delegate, View host, 1782a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas int action, Bundle args) { 1799c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas return delegate.performAccessibilityAction(host, action, args); 18025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 181956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 182956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 1839c9ffe6d9e72c043e2ac37ce2e3d90f43f7a2ea0Aurimas Liutikas private static final AccessibilityDelegateBaseImpl IMPL; 1842a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas private static final AccessibilityDelegate DEFAULT_DELEGATE; 1859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 1869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov static { 187f3ed7c56e6c409d27c60f7d74c026906593c21d4Svetoslav Ganov if (Build.VERSION.SDK_INT >= 16) { // JellyBean 1882a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas IMPL = new AccessibilityDelegateApi16Impl(); 1899648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } else { 1902a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas IMPL = new AccessibilityDelegateBaseImpl(); 1919648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1922a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas DEFAULT_DELEGATE = new AccessibilityDelegate(); 1939648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 1949648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 1952a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas final AccessibilityDelegate mBridge; 1969648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 1979648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 1989648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Creates a new instance. 1999648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 2009648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public AccessibilityDelegateCompat() { 2012a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas mBridge = IMPL.newAccessibilityDelegateBridge(this); 2029648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2039648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2049648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 2059648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return The wrapped bridge implementation. 2069648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 2072a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas AccessibilityDelegate getBridge() { 2089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov return mBridge; 2099648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2119648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 2129648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Sends an accessibility event of the given type. If accessibility is not 2139648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * enabled this method has no effect. 2149648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 2159648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The default implementation behaves as {@link View#sendAccessibilityEvent(int) 2169648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * View#sendAccessibilityEvent(int)} for the case of no accessibility delegate 2179648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * been set. 2189648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 2199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param host The View hosting the delegate. 2219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param eventType The type of the event to send. 2229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2239648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see View#sendAccessibilityEvent(int) View#sendAccessibilityEvent(int) 2249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 2259648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void sendAccessibilityEvent(View host, int eventType) { 2262a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas DEFAULT_DELEGATE.sendAccessibilityEvent(host, eventType); 2279648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2289648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2299648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 2309648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Sends an accessibility event. This method behaves exactly as 2319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link #sendAccessibilityEvent(View, int)} but takes as an argument an 2329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * empty {@link AccessibilityEvent} and does not perform a check whether 2339648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * accessibility is enabled. 2349648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 2359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The default implementation behaves as 2369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link View#sendAccessibilityEventUnchecked(AccessibilityEvent) 2379648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * View#sendAccessibilityEventUnchecked(AccessibilityEvent)} for 2389648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * the case of no accessibility delegate been set. 2399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 2409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param host The View hosting the delegate. 2429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param event The event to send. 2439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see View#sendAccessibilityEventUnchecked(AccessibilityEvent) 2459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * View#sendAccessibilityEventUnchecked(AccessibilityEvent) 2469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 2479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void sendAccessibilityEventUnchecked(View host, AccessibilityEvent event) { 2482a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas DEFAULT_DELEGATE.sendAccessibilityEventUnchecked(host, event); 2499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 2529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Dispatches an {@link AccessibilityEvent} to the host {@link View} first and then 2539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * to its children for adding their text content to the event. 2549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 2559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The default implementation behaves as 2569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) 2579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)} for 2589648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * the case of no accessibility delegate been set. 2599648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 2609648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2619648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param host The View hosting the delegate. 2629648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param event The event. 2639648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return True if the event population was completed. 2649648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2659648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) 2669648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) 2679648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 2689648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public boolean dispatchPopulateAccessibilityEvent(View host, AccessibilityEvent event) { 2692a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas return DEFAULT_DELEGATE.dispatchPopulateAccessibilityEvent(host, event); 2709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2729648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 2739648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Gives a chance to the host View to populate the accessibility event with its 2749648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * text content. 2759648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 2769648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The default implementation behaves as 2779648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link ViewCompat#onPopulateAccessibilityEvent(View, AccessibilityEvent) 2789648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * ViewCompat#onPopulateAccessibilityEvent(AccessibilityEvent)} for 2799648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * the case of no accessibility delegate been set. 2809648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 2819648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2829648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param host The View hosting the delegate. 2839648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param event The accessibility event which to populate. 2849648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 2859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see ViewCompat#onPopulateAccessibilityEvent(View ,AccessibilityEvent) 2869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * ViewCompat#onPopulateAccessibilityEvent(View, AccessibilityEvent) 2879648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 2889648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) { 2892a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas DEFAULT_DELEGATE.onPopulateAccessibilityEvent(host, event); 2909648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 2919648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 2929648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 2939648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Initializes an {@link AccessibilityEvent} with information about the 2949648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * the host View which is the event source. 2959648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 2969648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The default implementation behaves as 2979648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link ViewCompat#onInitializeAccessibilityEvent(View v, AccessibilityEvent event) 2989648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * ViewCompat#onInitalizeAccessibilityEvent(View v, AccessibilityEvent event)} for 2999648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * the case of no accessibility delegate been set. 3009648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 3019648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3029648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param host The View hosting the delegate. 3039648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param event The event to initialize. 3049648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3059648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see ViewCompat#onInitializeAccessibilityEvent(View, AccessibilityEvent) 3069648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * ViewCompat#onInitializeAccessibilityEvent(View, AccessibilityEvent) 3079648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3089648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { 3092a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas DEFAULT_DELEGATE.onInitializeAccessibilityEvent(host, event); 3109648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 3119648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 3129648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 3139648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Initializes an {@link AccessibilityNodeInfoCompat} with information about the host view. 3149648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 3159648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The default implementation behaves as 3169648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat) 3179648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat)} for 3189648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * the case of no accessibility delegate been set. 3199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 3209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param host The View hosting the delegate. 3229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param info The instance to initialize. 3239648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3249648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat) 3259648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat) 3269648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3279648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) { 3282a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas DEFAULT_DELEGATE.onInitializeAccessibilityNodeInfo( 329f87440725bb18397f734233f422c3429e7f284ebAurimas Liutikas host, info.unwrap()); 3309648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 3319648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov 3329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov /** 3339648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * Called when a child of the host View has requested sending an 3349648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link AccessibilityEvent} and gives an opportunity to the parent (the host) 3359648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * to augment the event. 3369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * <p> 3379648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * The default implementation behaves as 3389648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * {@link ViewGroupCompat#onRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent) 3399648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * ViewGroupCompat#onRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent)} for 3409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * the case of no accessibility delegate been set. 3419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * </p> 3429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param host The View hosting the delegate. 3449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param child The child which requests sending the event. 3459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @param event The event to be sent. 3469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @return True if the event should be sent 3479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * 3489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * @see ViewGroupCompat#onRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent) 3499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov * ViewGroupCompat#onRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent) 3509648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov */ 3519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, 3529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov AccessibilityEvent event) { 3532a596d57ec25cdbd574fb3cb71739771fe5e7f18Aurimas Liutikas return DEFAULT_DELEGATE.onRequestSendAccessibilityEvent(host, child, event); 3549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov } 355956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov 356956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov /** 357956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * Gets the provider for managing a virtual view hierarchy rooted at this View 358956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * and reported to {@link android.accessibilityservice.AccessibilityService}s 359956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * that explore the window content. 360956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * <p> 361956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * The default implementation behaves as 362989cd2fb6badb029b74cf4c88bbf74b1d912bdcaSvetoslav Ganov * {@link ViewCompat#getAccessibilityNodeProvider(View) ViewCompat#getAccessibilityNodeProvider(View)} 36325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * for the case of no accessibility delegate been set. 364956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * </p> 365956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * 366956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * @return The provider. 367956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * 368956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov * @see AccessibilityNodeProviderCompat 369956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov */ 370956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov public AccessibilityNodeProviderCompat getAccessibilityNodeProvider(View host) { 371956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov return IMPL.getAccessibilityNodeProvider(DEFAULT_DELEGATE, host); 372956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov } 37325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov 37425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov /** 37525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * Performs the specified accessibility action on the view. For 37625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * possible accessibility actions look at {@link AccessibilityNodeInfoCompat}. 37725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * <p> 37825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * The default implementation behaves as 37925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * {@link View#performAccessibilityAction(int, Bundle) 38025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * View#performAccessibilityAction(int, Bundle)} for the case of 38125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * no accessibility delegate been set. 38225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * </p> 38325121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * 38425121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @param action The action to perform. 38525121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @return Whether the action was performed. 38625121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * 38725121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * @see View#performAccessibilityAction(int, Bundle) 38825121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov * View#performAccessibilityAction(int, Bundle) 38925121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov */ 39025121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov public boolean performAccessibilityAction(View host, int action, Bundle args) { 39125121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov return IMPL.performAccessibilityAction(DEFAULT_DELEGATE, host, action, args); 39225121559b53b9f6c7ef7159203d42e11b9aee281Svetoslav Ganov } 3939648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov} 394