1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Class name constants which correspond to the class names used by the
/// Android accessibility bridge.
class AndroidClassName {
/// The class name used for checkboxes.
static const String checkBox = 'android.widget.CheckBox';
/// The default className if none is provided by flutter.
static const String view = 'android.view.View';
/// The class name used for radio buttons.
static const String radio = 'android.widget.RadioButton';
/// The class name used for editable text fields.
static const String editText = 'android.widget.EditText';
/// The class name used for read only text fields.
static const String textView = 'android.widget.TextView';
/// The class name used for toggle switches.
static const String toggleSwitch = 'android.widget.Switch';
/// The default className for buttons.
static const String button = 'android.widget.Button';
}
/// Action constants which correspond to `AccessibilityAction` in Android.
enum AndroidSemanticsAction {
/// Matches `AccessibilityAction.ACTION_FOCUS`.
focus(_kFocusIndex),
/// Matches `AccessibilityAction.ACTION_CLEAR_FOCUS`.
clearFocus(_kClearFocusIndex),
/// Matches `AccessibilityAction.ACTION_SELECT`.
select(_kSelectIndex),
/// Matches `AccessibilityAction.ACTION_CLEAR_SELECTION`.
clearSelection(_kClearSelectionIndex),
/// Matches `AccessibilityAction.ACTION_CLICK`.
click(_kClickIndex),
/// Matches `AccessibilityAction.ACTION_LONG_CLICK`.
longClick(_kLongClickIndex),
/// Matches `AccessibilityAction.ACTION_ACCESSIBILITY_FOCUS`.
accessibilityFocus(_kAccessibilityFocusIndex),
/// Matches `AccessibilityAction.ACTION_CLEAR_ACCESSIBILITY_FOCUS`.
clearAccessibilityFocus(_kClearAccessibilityFocusIndex),
/// Matches `AccessibilityAction.ACTION_NEXT_AT_MOVEMENT_GRANULARITY`.
nextAtMovementGranularity(_kNextAtMovementGranularityIndex),
/// Matches `AccessibilityAction.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY`.
previousAtMovementGranularity(_kPreviousAtMovementGranularityIndex),
/// Matches `AccessibilityAction.ACTION_NEXT_HTML_ELEMENT`.
nextHtmlElement(_kNextHtmlElementIndex),
/// Matches `AccessibilityAction.ACTION_PREVIOUS_HTML_ELEMENT`.
previousHtmlElement(_kPreviousHtmlElementIndex),
/// Matches `AccessibilityAction.ACTION_SCROLL_FORWARD`.
scrollForward(_kScrollForwardIndex),
/// Matches `AccessibilityAction.ACTION_SCROLL_BACKWARD`.
scrollBackward(_kScrollBackwardIndex),
/// Matches `AccessibilityAction.ACTION_CUT`.
cut(_kCutIndex),
/// Matches `AccessibilityAction.ACTION_COPY`.
copy(_kCopyIndex),
/// Matches `AccessibilityAction.ACTION_PASTE`.
paste(_kPasteIndex),
/// Matches `AccessibilityAction.ACTION_SET_SELECTION`.
setSelection(_kSetSelectionIndex),
/// Matches `AccessibilityAction.ACTION_EXPAND`.
expand(_kExpandIndex),
/// Matches `AccessibilityAction.ACTION_COLLAPSE`.
collapse(_kCollapseIndex),
/// Matches `AccessibilityAction.SET_TEXT`.
setText(_kSetText);
const AndroidSemanticsAction(this.id);
/// The Android id of the action.
final int id;
// These indices need to be in sync with android_semantics_testing/android/app/src/main/java/com/yourcompany/platforminteraction/MainActivity.java
static const int _kFocusIndex = 1 << 0;
static const int _kClearFocusIndex = 1 << 1;
static const int _kSelectIndex = 1 << 2;
static const int _kClearSelectionIndex = 1 << 3;
static const int _kClickIndex = 1 << 4;
static const int _kLongClickIndex = 1 << 5;
static const int _kAccessibilityFocusIndex = 1 << 6;
static const int _kClearAccessibilityFocusIndex = 1 << 7;
static const int _kNextAtMovementGranularityIndex = 1 << 8;
static const int _kPreviousAtMovementGranularityIndex = 1 << 9;
static const int _kNextHtmlElementIndex = 1 << 10;
static const int _kPreviousHtmlElementIndex = 1 << 11;
static const int _kScrollForwardIndex = 1 << 12;
static const int _kScrollBackwardIndex = 1 << 13;
static const int _kCutIndex = 1 << 14;
static const int _kCopyIndex = 1 << 15;
static const int _kPasteIndex = 1 << 16;
static const int _kSetSelectionIndex = 1 << 17;
static const int _kExpandIndex = 1 << 18;
static const int _kCollapseIndex = 1 << 19;
static const int _kSetText = 1 << 21;
static const Map<int, AndroidSemanticsAction> _kActionById = <int, AndroidSemanticsAction>{
_kFocusIndex: focus,
_kClearFocusIndex: clearFocus,
_kSelectIndex: select,
_kClearSelectionIndex: clearSelection,
_kClickIndex: click,
_kLongClickIndex: longClick,
_kAccessibilityFocusIndex: accessibilityFocus,
_kClearAccessibilityFocusIndex: clearAccessibilityFocus,
_kNextAtMovementGranularityIndex: nextAtMovementGranularity,
_kPreviousAtMovementGranularityIndex: previousAtMovementGranularity,
_kNextHtmlElementIndex: nextHtmlElement,
_kPreviousHtmlElementIndex: previousHtmlElement,
_kScrollForwardIndex: scrollForward,
_kScrollBackwardIndex: scrollBackward,
_kCutIndex: cut,
_kCopyIndex: copy,
_kPasteIndex: paste,
_kSetSelectionIndex: setSelection,
_kExpandIndex: expand,
_kCollapseIndex: collapse,
_kSetText: setText,
};
/// Creates a new [AndroidSemanticsAction] from an integer `value`.
///
/// Returns `null` if the id is not a known Android accessibility action.
static AndroidSemanticsAction? deserialize(int value) {
return _kActionById[value];
}
}