未验证 提交 c7ce6dd6 编写于 作者: J Jonah Williams 提交者: GitHub

Apply translation to accessibility tree when in landscape (#5950)

上级 aef94b73
......@@ -4,6 +4,8 @@
package io.flutter.view;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.opengl.Matrix;
import android.os.Build;
......@@ -41,6 +43,8 @@ class AccessibilityBridge
private SemanticsObject mHoveredObject;
private int previousRouteId = ROOT_NODE_ID;
private List<Integer> previousRoutes;
private final View mDecorView;
private Integer mLastLeftFrameInset = 0;
private final BasicMessageChannel<Object> mFlutterAccessibilityChannel;
......@@ -110,6 +114,7 @@ class AccessibilityBridge
previousRoutes = new ArrayList<>();
mFlutterAccessibilityChannel = new BasicMessageChannel<>(
owner, "flutter/accessibility", StandardMessageCodec.INSTANCE);
mDecorView = ((Activity) owner.getContext()).getWindow().getDecorView();
}
void setAccessibilityEnabled(boolean accessibilityEnabled) {
......@@ -620,6 +625,19 @@ class AccessibilityBridge
if (rootObject != null) {
final float[] identity = new float[16];
Matrix.setIdentityM(identity, 0);
// in android devices above AP 23, the system nav bar can be placed on the left side
// of the screen in landscape mode. We must handle the translation ourselves for the
// a11y nodes.
if (Build.VERSION.SDK_INT >= 23) {
Rect visibleFrame = new Rect();
mDecorView.getWindowVisibleDisplayFrame(visibleFrame);
if (!mLastLeftFrameInset.equals(visibleFrame.left)) {
rootObject.globalGeometryDirty = true;
rootObject.inverseTransformDirty = true;
}
mLastLeftFrameInset = visibleFrame.left;
Matrix.translateM(identity, 0, visibleFrame.left, 0, 0);
}
rootObject.updateRecursively(identity, visitedObjects, false);
rootObject.collectRoutes(newRoutes);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册