
This adds a Semantics node to the Focus and FocusScope widgets, setting the focused and focusable attributes so that the accessibility subsystem can be told when a control has the input focus. Includes an engine roll to flutter/engine@77252d2, and the following 8 engine changes: flutter/engine@77252d2 Greg Spencer Add missing focusable testing info (flutter/engine#13013) flutter/engine@0e42a29 skia-flutter-.. Roll src/third_party/skia 54548626a977..e27a503a0a21 (1 commits) (flutter/engine#13024) flutter/engine@6b56ed7 gaaclarke Refactor: FlutterDartProject (flutter/engine#13006) flutter/engine@393480c skia-flutter-.. Roll src/third_party/skia 77dde599c98a..54548626a977 (1 commits) (flutter/engine#13023) flutter/engine@080b89d skia-flutter-.. Roll src/third_party/skia 2b1a25a4d324..77dde599c98a (1 commits) (flutter/engine#13021) flutter/engine@90b0f30 Ben Konyi Roll src/third_party/dart f4a72bfc64..bb04f145b2 (18 commits) (flutter/engine#13020) flutter/engine@049fb89 skia-flutter-.. Roll fuchsia/sdk/core/linux-amd64 from q_uYX... to cknsi... (flutter/engine#13019) flutter/engine@6925b2a skia-flutter-.. Roll fuchsia/sdk/core/mac-amd64 from wuAtw... to u0JpE... (flutter/engine#13018) Related Issues Addresses #40101 Landing on red in order to fix the build: it's red because of the needed engine roll.
210 lines
8.5 KiB
Dart
210 lines
8.5 KiB
Dart
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// 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 {
|
|
/// 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.
|
|
@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;
|
|
|
|
/// Matches `AccessibilityAction.ACTION_FOCUS`.
|
|
static const AndroidSemanticsAction focus = AndroidSemanticsAction._(_kFocusIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_CLEAR_FOCUS`.
|
|
static const AndroidSemanticsAction clearFocus = AndroidSemanticsAction._(_kClearFocusIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_SELECT`.
|
|
static const AndroidSemanticsAction select = AndroidSemanticsAction._(_kSelectIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_CLEAR_SELECTION`.
|
|
static const AndroidSemanticsAction clearSelection = AndroidSemanticsAction._(_kClearSelectionIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_CLICK`.
|
|
static const AndroidSemanticsAction click = AndroidSemanticsAction._(_kClickIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_LONG_CLICK`.
|
|
static const AndroidSemanticsAction longClick = AndroidSemanticsAction._(_kLongClickIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_ACCESSIBILITY_FOCUS`.
|
|
static const AndroidSemanticsAction accessibilityFocus = AndroidSemanticsAction._(_kAccessibilityFocusIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_CLEAR_ACCESSIBILITY_FOCUS`.
|
|
static const AndroidSemanticsAction clearAccessibilityFocus = AndroidSemanticsAction._(_kClearAccessibilityFocusIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_NEXT_AT_MOVEMENT_GRANULARITY`.
|
|
static const AndroidSemanticsAction nextAtMovementGranularity = AndroidSemanticsAction._(_kNextAtMovementGranularityIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY`.
|
|
static const AndroidSemanticsAction previousAtMovementGranularity = AndroidSemanticsAction._(_kPreviousAtMovementGranularityIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_NEXT_HTML_ELEMENT`.
|
|
static const AndroidSemanticsAction nextHtmlElement = AndroidSemanticsAction._(_kNextHtmlElementIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_PREVIOUS_HTML_ELEMENT`.
|
|
static const AndroidSemanticsAction previousHtmlElement = AndroidSemanticsAction._(_kPreviousHtmlElementIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_SCROLL_FORWARD`.
|
|
static const AndroidSemanticsAction scrollForward = AndroidSemanticsAction._(_kScrollForwardIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_SCROLL_BACKWARD`.
|
|
static const AndroidSemanticsAction scrollBackward = AndroidSemanticsAction._(_kScrollBackwardIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_CUT`.
|
|
static const AndroidSemanticsAction cut = AndroidSemanticsAction._(_kCutIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_COPY`.
|
|
static const AndroidSemanticsAction copy = AndroidSemanticsAction._(_kCopyIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_PASTE`.
|
|
static const AndroidSemanticsAction paste = AndroidSemanticsAction._(_kPasteIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_SET_SELECTION`.
|
|
static const AndroidSemanticsAction setSelection = AndroidSemanticsAction._(_kSetSelectionIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_EXPAND`.
|
|
static const AndroidSemanticsAction expand = AndroidSemanticsAction._(_kExpandIndex);
|
|
|
|
/// Matches `AccessibilityAction.ACTION_COLLAPSE`.
|
|
static const AndroidSemanticsAction collapse = AndroidSemanticsAction._(_kCollapseIndex);
|
|
|
|
@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.nextAtMovementGranularity';
|
|
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';
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
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: nextAtMovementGranularity,
|
|
_kNextHtmlElementIndex: nextHtmlElement,
|
|
_kPreviousHtmlElementIndex: previousHtmlElement,
|
|
_kScrollForwardIndex: scrollForward,
|
|
_kScrollBackwardIndex: scrollBackward,
|
|
_kCutIndex: cut,
|
|
_kCopyIndex: copy,
|
|
_kPasteIndex: paste,
|
|
_kSetSelectionIndex: setSelection,
|
|
_kExpandIndex: expand,
|
|
_kCollapseIndex: collapse,
|
|
};
|
|
|
|
@override
|
|
int get hashCode => id.hashCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (other.runtimeType != runtimeType)
|
|
return false;
|
|
final AndroidSemanticsAction typedOther = other;
|
|
return id == typedOther.id;
|
|
}
|
|
|
|
/// 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];
|
|
}
|
|
}
|