|
44 | 44 | import android.view.Menu;
|
45 | 45 | import android.view.View;
|
46 | 46 | import android.view.ViewGroup;
|
47 |
| -import android.view.accessibility.AccessibilityManager; |
48 |
| -import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener; |
49 | 47 | import android.view.accessibility.AccessibilityNodeInfo;
|
50 | 48 | import android.widget.EditText;
|
51 | 49 | import android.widget.ImageButton;
|
@@ -148,10 +146,6 @@ public class SearchBar extends Toolbar {
|
148 | 146 | private boolean defaultScrollFlagsEnabled;
|
149 | 147 | private MaterialShapeDrawable backgroundShape;
|
150 | 148 |
|
151 |
| - @Nullable private final AccessibilityManager accessibilityManager; |
152 |
| - private final TouchExplorationStateChangeListener touchExplorationStateChangeListener = |
153 |
| - (boolean enabled) -> setFocusableInTouchMode(enabled); |
154 |
| - |
155 | 149 | public SearchBar(@NonNull Context context) {
|
156 | 150 | this(context, null);
|
157 | 151 | }
|
@@ -209,35 +203,6 @@ public SearchBar(@NonNull Context context, @Nullable AttributeSet attrs, int def
|
209 | 203 | ViewCompat.setElevation(this, elevation);
|
210 | 204 | initTextView(textAppearanceResId, text, hint);
|
211 | 205 | initBackground(shapeAppearanceModel, backgroundColor, elevation, strokeWidth, strokeColor);
|
212 |
| - |
213 |
| - accessibilityManager = |
214 |
| - (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); |
215 |
| - setupTouchExplorationStateChangeListener(); |
216 |
| - } |
217 |
| - |
218 |
| - private void setupTouchExplorationStateChangeListener() { |
219 |
| - if (accessibilityManager != null) { |
220 |
| - // Handle the case where touch exploration is already enabled. |
221 |
| - if (accessibilityManager.isEnabled() && accessibilityManager.isTouchExplorationEnabled()) { |
222 |
| - setFocusableInTouchMode(true); |
223 |
| - } |
224 |
| - |
225 |
| - // Handle the case where touch exploration state can change while the view is active. |
226 |
| - addOnAttachStateChangeListener( |
227 |
| - new OnAttachStateChangeListener() { |
228 |
| - @Override |
229 |
| - public void onViewAttachedToWindow(View ignored) { |
230 |
| - accessibilityManager.addTouchExplorationStateChangeListener( |
231 |
| - touchExplorationStateChangeListener); |
232 |
| - } |
233 |
| - |
234 |
| - @Override |
235 |
| - public void onViewDetachedFromWindow(View ignored) { |
236 |
| - accessibilityManager.removeTouchExplorationStateChangeListener( |
237 |
| - touchExplorationStateChangeListener); |
238 |
| - } |
239 |
| - }); |
240 |
| - } |
241 | 206 | }
|
242 | 207 |
|
243 | 208 | private void validateAttributes(@Nullable AttributeSet attributeSet) {
|
|
0 commit comments