|
4 | 4 |
|
5 | 5 | package io.flutter.view; |
6 | 6 |
|
| 7 | +import android.app.Activity; |
| 8 | +import android.content.Context; |
7 | 9 | import android.graphics.Rect; |
8 | 10 | import android.opengl.Matrix; |
9 | 11 | import android.os.Build; |
@@ -41,6 +43,8 @@ class AccessibilityBridge |
41 | 43 | private SemanticsObject mHoveredObject; |
42 | 44 | private int previousRouteId = ROOT_NODE_ID; |
43 | 45 | private List<Integer> previousRoutes; |
| 46 | + private final View mDecorView; |
| 47 | + private Integer mLastLeftFrameInset = 0; |
44 | 48 |
|
45 | 49 | private final BasicMessageChannel<Object> mFlutterAccessibilityChannel; |
46 | 50 |
|
@@ -110,6 +114,7 @@ enum Flag { |
110 | 114 | previousRoutes = new ArrayList<>(); |
111 | 115 | mFlutterAccessibilityChannel = new BasicMessageChannel<>( |
112 | 116 | owner, "flutter/accessibility", StandardMessageCodec.INSTANCE); |
| 117 | + mDecorView = ((Activity) owner.getContext()).getWindow().getDecorView(); |
113 | 118 | } |
114 | 119 |
|
115 | 120 | void setAccessibilityEnabled(boolean accessibilityEnabled) { |
@@ -620,6 +625,19 @@ void updateSemantics(ByteBuffer buffer, String[] strings) { |
620 | 625 | if (rootObject != null) { |
621 | 626 | final float[] identity = new float[16]; |
622 | 627 | Matrix.setIdentityM(identity, 0); |
| 628 | + // in android devices above AP 23, the system nav bar can be placed on the left side |
| 629 | + // of the screen in landscape mode. We must handle the translation ourselves for the |
| 630 | + // a11y nodes. |
| 631 | + if (Build.VERSION.SDK_INT >= 23) { |
| 632 | + Rect visibleFrame = new Rect(); |
| 633 | + mDecorView.getWindowVisibleDisplayFrame(visibleFrame); |
| 634 | + if (!mLastLeftFrameInset.equals(visibleFrame.left)) { |
| 635 | + rootObject.globalGeometryDirty = true; |
| 636 | + rootObject.inverseTransformDirty = true; |
| 637 | + } |
| 638 | + mLastLeftFrameInset = visibleFrame.left; |
| 639 | + Matrix.translateM(identity, 0, visibleFrame.left, 0, 0); |
| 640 | + } |
623 | 641 | rootObject.updateRecursively(identity, visitedObjects, false); |
624 | 642 | rootObject.collectRoutes(newRoutes); |
625 | 643 | } |
|
0 commit comments