Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
100cf21e
Unverified
Commit
100cf21e
authored
Mar 23, 2023
by
Bernardo Ferrari
Committed by
GitHub
Mar 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer enum over class. (#123312)
Convert `AndroidSemanticsAction` to enum.
parent
716d2524
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
116 deletions
+52
-116
constants.dart
...on_tests/android_semantics_testing/lib/src/constants.dart
+49
-113
box.dart
packages/flutter/lib/src/rendering/box.dart
+1
-1
overscroll_indicator.dart
packages/flutter/lib/src/widgets/overscroll_indicator.dart
+1
-1
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+1
-1
No files found.
dev/integration_tests/android_semantics_testing/lib/src/constants.dart
View file @
100cf21e
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:meta/meta.dart'
;
/// Class name constants which correspond to the class names used by the
/// Android accessibility bridge.
class
AndroidClassName
{
...
...
@@ -30,147 +28,97 @@ class AndroidClassName {
}
/// Action constants which correspond to `AccessibilityAction` in Android.
@immutable
class
AndroidSemanticsAction
{
const
AndroidSemanticsAction
.
_
(
this
.
id
);
/// The Android id of the action.
final
int
id
;
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
;
enum
AndroidSemanticsAction
{
/// Matches `AccessibilityAction.ACTION_FOCUS`.
static
const
AndroidSemanticsAction
focus
=
AndroidSemanticsAction
.
_
(
_kFocusIndex
);
focus
(
_kFocusIndex
),
/// Matches `AccessibilityAction.ACTION_CLEAR_FOCUS`.
static
const
AndroidSemanticsAction
clearFocus
=
AndroidSemanticsAction
.
_
(
_kClearFocusIndex
);
clearFocus
(
_kClearFocusIndex
),
/// Matches `AccessibilityAction.ACTION_SELECT`.
s
tatic
const
AndroidSemanticsAction
select
=
AndroidSemanticsAction
.
_
(
_kSelectIndex
);
s
elect
(
_kSelectIndex
),
/// Matches `AccessibilityAction.ACTION_CLEAR_SELECTION`.
static
const
AndroidSemanticsAction
clearSelection
=
AndroidSemanticsAction
.
_
(
_kClearSelectionIndex
);
clearSelection
(
_kClearSelectionIndex
),
/// Matches `AccessibilityAction.ACTION_CLICK`.
static
const
AndroidSemanticsAction
click
=
AndroidSemanticsAction
.
_
(
_kClickIndex
);
click
(
_kClickIndex
),
/// Matches `AccessibilityAction.ACTION_LONG_CLICK`.
static
const
AndroidSemanticsAction
longClick
=
AndroidSemanticsAction
.
_
(
_kLongClickIndex
);
longClick
(
_kLongClickIndex
),
/// Matches `AccessibilityAction.ACTION_ACCESSIBILITY_FOCUS`.
static
const
AndroidSemanticsAction
accessibilityFocus
=
AndroidSemanticsAction
.
_
(
_kAccessibilityFocusIndex
);
accessibilityFocus
(
_kAccessibilityFocusIndex
),
/// Matches `AccessibilityAction.ACTION_CLEAR_ACCESSIBILITY_FOCUS`.
static
const
AndroidSemanticsAction
clearAccessibilityFocus
=
AndroidSemanticsAction
.
_
(
_kClearAccessibilityFocusIndex
);
clearAccessibilityFocus
(
_kClearAccessibilityFocusIndex
),
/// Matches `AccessibilityAction.ACTION_NEXT_AT_MOVEMENT_GRANULARITY`.
static
const
AndroidSemanticsAction
nextAtMovementGranularity
=
AndroidSemanticsAction
.
_
(
_kNextAtMovementGranularityIndex
);
nextAtMovementGranularity
(
_kNextAtMovementGranularityIndex
),
/// Matches `AccessibilityAction.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY`.
static
const
AndroidSemanticsAction
previousAtMovementGranularity
=
AndroidSemanticsAction
.
_
(
_kPreviousAtMovementGranularityIndex
);
previousAtMovementGranularity
(
_kPreviousAtMovementGranularityIndex
),
/// Matches `AccessibilityAction.ACTION_NEXT_HTML_ELEMENT`.
static
const
AndroidSemanticsAction
nextHtmlElement
=
AndroidSemanticsAction
.
_
(
_kNextHtmlElementIndex
);
nextHtmlElement
(
_kNextHtmlElementIndex
),
/// Matches `AccessibilityAction.ACTION_PREVIOUS_HTML_ELEMENT`.
static
const
AndroidSemanticsAction
previousHtmlElement
=
AndroidSemanticsAction
.
_
(
_kPreviousHtmlElementIndex
);
previousHtmlElement
(
_kPreviousHtmlElementIndex
),
/// Matches `AccessibilityAction.ACTION_SCROLL_FORWARD`.
s
tatic
const
AndroidSemanticsAction
scrollForward
=
AndroidSemanticsAction
.
_
(
_kScrollForwardIndex
);
s
crollForward
(
_kScrollForwardIndex
),
/// Matches `AccessibilityAction.ACTION_SCROLL_BACKWARD`.
s
tatic
const
AndroidSemanticsAction
scrollBackward
=
AndroidSemanticsAction
.
_
(
_kScrollBackwardIndex
);
s
crollBackward
(
_kScrollBackwardIndex
),
/// Matches `AccessibilityAction.ACTION_CUT`.
static
const
AndroidSemanticsAction
cut
=
AndroidSemanticsAction
.
_
(
_kCutIndex
);
cut
(
_kCutIndex
),
/// Matches `AccessibilityAction.ACTION_COPY`.
static
const
AndroidSemanticsAction
copy
=
AndroidSemanticsAction
.
_
(
_kCopyIndex
);
copy
(
_kCopyIndex
),
/// Matches `AccessibilityAction.ACTION_PASTE`.
static
const
AndroidSemanticsAction
paste
=
AndroidSemanticsAction
.
_
(
_kPasteIndex
);
paste
(
_kPasteIndex
),
/// Matches `AccessibilityAction.ACTION_SET_SELECTION`.
s
tatic
const
AndroidSemanticsAction
setSelection
=
AndroidSemanticsAction
.
_
(
_kSetSelectionIndex
);
s
etSelection
(
_kSetSelectionIndex
),
/// Matches `AccessibilityAction.ACTION_EXPAND`.
static
const
AndroidSemanticsAction
expand
=
AndroidSemanticsAction
.
_
(
_kExpandIndex
);
expand
(
_kExpandIndex
),
/// Matches `AccessibilityAction.ACTION_COLLAPSE`.
static
const
AndroidSemanticsAction
collapse
=
AndroidSemanticsAction
.
_
(
_kCollapseIndex
);
collapse
(
_kCollapseIndex
),
/// Matches `AccessibilityAction.SET_TEXT`.
static
const
AndroidSemanticsAction
setText
=
AndroidSemanticsAction
.
_
(
_kSetText
);
@override
String
toString
()
{
switch
(
id
)
{
case
_kFocusIndex:
return
'AndroidSemanticsAction.focus'
;
case
_kClearFocusIndex:
return
'AndroidSemanticsAction.clearFocus'
;
case
_kSelectIndex:
return
'AndroidSemanticsAction.select'
;
case
_kClearSelectionIndex:
return
'AndroidSemanticsAction.clearSelection'
;
case
_kClickIndex:
return
'AndroidSemanticsAction.click'
;
case
_kLongClickIndex:
return
'AndroidSemanticsAction.longClick'
;
case
_kAccessibilityFocusIndex:
return
'AndroidSemanticsAction.accessibilityFocus'
;
case
_kClearAccessibilityFocusIndex:
return
'AndroidSemanticsAction.clearAccessibilityFocus'
;
case
_kNextAtMovementGranularityIndex:
return
'AndroidSemanticsAction.nextAtMovementGranularity'
;
case
_kPreviousAtMovementGranularityIndex:
return
'AndroidSemanticsAction.previousAtMovementGranularity'
;
case
_kNextHtmlElementIndex:
return
'AndroidSemanticsAction.nextHtmlElement'
;
case
_kPreviousHtmlElementIndex:
return
'AndroidSemanticsAction.previousHtmlElement'
;
case
_kScrollForwardIndex:
return
'AndroidSemanticsAction.scrollForward'
;
case
_kScrollBackwardIndex:
return
'AndroidSemanticsAction.scrollBackward'
;
case
_kCutIndex:
return
'AndroidSemanticsAction.cut'
;
case
_kCopyIndex:
return
'AndroidSemanticsAction.copy'
;
case
_kPasteIndex:
return
'AndroidSemanticsAction.paste'
;
case
_kSetSelectionIndex:
return
'AndroidSemanticsAction.setSelection'
;
case
_kExpandIndex:
return
'AndroidSemanticsAction.expand'
;
case
_kCollapseIndex:
return
'AndroidSemanticsAction.collapse'
;
case
_kSetText:
return
'AndroidSemanticsAction.setText'
;
default
:
throw
UnimplementedError
();
}
}
setText
(
_kSetText
);
const
AndroidSemanticsAction
(
this
.
id
);
/// The Android id of the action.
final
int
id
;
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
,
...
...
@@ -196,18 +144,6 @@ class AndroidSemanticsAction {
_kSetText:
setText
,
};
@override
int
get
hashCode
=>
id
.
hashCode
;
@override
bool
operator
==(
Object
other
)
{
if
(
other
.
runtimeType
!=
runtimeType
)
{
return
false
;
}
return
other
is
AndroidSemanticsAction
&&
other
.
id
==
id
;
}
/// Creates a new [AndroidSemanticsAction] from an integer `value`.
///
/// Returns `null` if the id is not a known Android accessibility action.
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
100cf21e
...
...
@@ -1390,7 +1390,7 @@ abstract class RenderBox extends RenderObject {
}
else
{
debugTimelineArguments
=
<
String
,
String
>{};
}
debugTimelineArguments
![
'intrinsics dimension'
]
=
d
escribeEnum
(
dimension
)
;
debugTimelineArguments
![
'intrinsics dimension'
]
=
d
imension
.
name
;
debugTimelineArguments
![
'intrinsics argument'
]
=
'
$argument
'
;
return
true
;
}());
...
...
packages/flutter/lib/src/widgets/overscroll_indicator.dart
View file @
100cf21e
...
...
@@ -524,7 +524,7 @@ class _GlowController extends ChangeNotifier {
@override
String
toString
()
{
return
'_GlowController(color:
$color
, axis:
${
describeEnum(axis)
}
)'
;
return
'_GlowController(color:
$color
, axis:
${
axis.name
}
)'
;
}
}
...
...
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
100cf21e
...
...
@@ -2118,7 +2118,7 @@ mixin WidgetInspectorService {
if
(
parentData
is
FlexParentData
)
{
additionalJson
[
'flexFactor'
]
=
parentData
.
flex
!;
additionalJson
[
'flexFit'
]
=
describeEnum
(
parentData
.
fit
??
FlexFit
.
tight
)
;
(
parentData
.
fit
??
FlexFit
.
tight
).
name
;
}
else
if
(
parentData
is
BoxParentData
)
{
final
Offset
offset
=
parentData
.
offset
;
additionalJson
[
'parentData'
]
=
<
String
,
Object
>{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment