Android SeekBars announce their value (flutter/engine#4289)
* Android SeekBars announce their value * style
This commit is contained in:
committed by
GitHub
parent
166b7b7651
commit
3a386bd49e
@@ -211,6 +211,9 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
// TODO(ianh): bidi support using textDirection
|
||||
mOwner.dispatchSemanticsAction(virtualViewId, SEMANTICS_ACTION_SCROLL_LEFT);
|
||||
} else if ((object.actions & SEMANTICS_ACTION_INCREASE) != 0) {
|
||||
object.value = object.increasedValue;
|
||||
// Event causes Android to read out the updated value.
|
||||
sendAccessibilityEvent(virtualViewId, AccessibilityEvent.TYPE_VIEW_SELECTED);
|
||||
mOwner.dispatchSemanticsAction(virtualViewId, SEMANTICS_ACTION_INCREASE);
|
||||
} else {
|
||||
return false;
|
||||
@@ -224,6 +227,9 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
// TODO(ianh): bidi support using textDirection
|
||||
mOwner.dispatchSemanticsAction(virtualViewId, SEMANTICS_ACTION_SCROLL_RIGHT);
|
||||
} else if ((object.actions & SEMANTICS_ACTION_DECREASE) != 0) {
|
||||
object.value = object.decreasedValue;
|
||||
// Event causes Android to read out the updated value.
|
||||
sendAccessibilityEvent(virtualViewId, AccessibilityEvent.TYPE_VIEW_SELECTED);
|
||||
mOwner.dispatchSemanticsAction(virtualViewId, SEMANTICS_ACTION_DECREASE);
|
||||
} else {
|
||||
return false;
|
||||
@@ -237,6 +243,7 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
}
|
||||
case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: {
|
||||
sendAccessibilityEvent(virtualViewId, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
|
||||
|
||||
if (mFocusedObject == null) {
|
||||
// When Android focuses a node, it doesn't invalidate the view.
|
||||
// (It does when it sends ACTION_CLEAR_ACCESSIBILITY_FOCUS, so
|
||||
@@ -244,6 +251,12 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
mOwner.invalidate();
|
||||
}
|
||||
mFocusedObject = object;
|
||||
|
||||
if ((object.actions & (SEMANTICS_ACTION_INCREASE | SEMANTICS_ACTION_DECREASE)) != 0) {
|
||||
// SeekBars only announce themselves after this event.
|
||||
sendAccessibilityEvent(virtualViewId, AccessibilityEvent.TYPE_VIEW_SELECTED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// TODO(goderbauer): Use ACTION_SHOW_ON_SCREEN from Android Support Library after
|
||||
@@ -435,6 +448,8 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
int actions;
|
||||
String label;
|
||||
String value;
|
||||
String increasedValue;
|
||||
String decreasedValue;
|
||||
String hint;
|
||||
TextDirection textDirection;
|
||||
|
||||
@@ -476,6 +491,12 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
stringIndex = buffer.getInt();
|
||||
value = stringIndex == -1 ? null : strings[stringIndex];
|
||||
|
||||
stringIndex = buffer.getInt();
|
||||
increasedValue = stringIndex == -1 ? null : strings[stringIndex];
|
||||
|
||||
stringIndex = buffer.getInt();
|
||||
decreasedValue = stringIndex == -1 ? null : strings[stringIndex];
|
||||
|
||||
stringIndex = buffer.getInt();
|
||||
hint = stringIndex == -1 ? null : strings[stringIndex];
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ bool PlatformViewAndroid::ResourceContextMakeCurrent() {
|
||||
|
||||
void PlatformViewAndroid::UpdateSemantics(
|
||||
std::vector<blink::SemanticsNode> update) {
|
||||
constexpr size_t kBytesPerNode = 28 * sizeof(int32_t);
|
||||
constexpr size_t kBytesPerNode = 30 * sizeof(int32_t);
|
||||
constexpr size_t kBytesPerChild = sizeof(int32_t);
|
||||
|
||||
JNIEnv* env = fml::jni::AttachCurrentThread();
|
||||
@@ -468,6 +468,18 @@ void PlatformViewAndroid::UpdateSemantics(
|
||||
buffer_int32[position++] = strings.size();
|
||||
strings.push_back(node.value);
|
||||
}
|
||||
if (node.increasedValue.empty()) {
|
||||
buffer_int32[position++] = -1;
|
||||
} else {
|
||||
buffer_int32[position++] = strings.size();
|
||||
strings.push_back(node.increasedValue);
|
||||
}
|
||||
if (node.decreasedValue.empty()) {
|
||||
buffer_int32[position++] = -1;
|
||||
} else {
|
||||
buffer_int32[position++] = strings.size();
|
||||
strings.push_back(node.decreasedValue);
|
||||
}
|
||||
if (node.hint.empty()) {
|
||||
buffer_int32[position++] = -1;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user