|
40 | 40 | import android.os.ServiceManager; |
41 | 41 | import android.os.SystemClock; |
42 | 42 | import android.provider.Settings; |
| 43 | +import android.text.TextUtils; |
43 | 44 | import android.util.Property; |
44 | 45 | import android.util.Slog; |
45 | 46 | import android.view.Display; |
|
71 | 72 | import java.util.ArrayList; |
72 | 73 | import java.util.Collections; |
73 | 74 | import java.util.Comparator; |
| 75 | +import java.util.Locale; |
74 | 76 |
|
75 | 77 | /** |
76 | 78 | * This class handles the screen magnification when accessibility is enabled. |
@@ -1000,45 +1002,44 @@ private void handleOnWindowTransition(int transition, WindowInfo info) { |
1000 | 1002 | mViewport.recomputeBounds(mMagnificationController.isMagnifying()); |
1001 | 1003 | } break; |
1002 | 1004 | } |
1003 | | - } else { |
1004 | | - switch (transition) { |
1005 | | - case WindowManagerPolicy.TRANSIT_ENTER: |
1006 | | - case WindowManagerPolicy.TRANSIT_SHOW: { |
1007 | | - if (!magnifying || !isScreenMagnificationAutoUpdateEnabled(mContext)) { |
1008 | | - break; |
1009 | | - } |
1010 | | - final int type = info.type; |
1011 | | - switch (type) { |
1012 | | - // TODO: Are these all the windows we want to make |
1013 | | - // visible when they appear on the screen? |
1014 | | - // Do we need to take some of them out? |
1015 | | - case WindowManager.LayoutParams.TYPE_APPLICATION: |
1016 | | - case WindowManager.LayoutParams.TYPE_APPLICATION_PANEL: |
1017 | | - case WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA: |
1018 | | - case WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL: |
1019 | | - case WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG: |
1020 | | - case WindowManager.LayoutParams.TYPE_SEARCH_BAR: |
1021 | | - case WindowManager.LayoutParams.TYPE_PHONE: |
1022 | | - case WindowManager.LayoutParams.TYPE_SYSTEM_ALERT: |
1023 | | - case WindowManager.LayoutParams.TYPE_TOAST: |
1024 | | - case WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY: |
1025 | | - case WindowManager.LayoutParams.TYPE_PRIORITY_PHONE: |
1026 | | - case WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG: |
1027 | | - case WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG: |
1028 | | - case WindowManager.LayoutParams.TYPE_SYSTEM_ERROR: |
1029 | | - case WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY: |
1030 | | - case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL: |
1031 | | - case WindowManager.LayoutParams.TYPE_RECENTS_OVERLAY: { |
1032 | | - Rect magnifiedRegionBounds = mMagnificationController |
1033 | | - .getMagnifiedRegionBounds(); |
1034 | | - Rect touchableRegion = info.touchableRegion; |
1035 | | - if (!magnifiedRegionBounds.intersect(touchableRegion)) { |
1036 | | - ensureRectangleInMagnifiedRegionBounds( |
1037 | | - magnifiedRegionBounds, touchableRegion); |
1038 | | - } |
1039 | | - } break; |
1040 | | - } break; |
| 1005 | + } |
| 1006 | + switch (transition) { |
| 1007 | + case WindowManagerPolicy.TRANSIT_ENTER: |
| 1008 | + case WindowManagerPolicy.TRANSIT_SHOW: { |
| 1009 | + if (!magnifying || !isScreenMagnificationAutoUpdateEnabled(mContext)) { |
| 1010 | + break; |
1041 | 1011 | } |
| 1012 | + final int type = info.type; |
| 1013 | + switch (type) { |
| 1014 | + // TODO: Are these all the windows we want to make |
| 1015 | + // visible when they appear on the screen? |
| 1016 | + // Do we need to take some of them out? |
| 1017 | + case WindowManager.LayoutParams.TYPE_APPLICATION: |
| 1018 | + case WindowManager.LayoutParams.TYPE_APPLICATION_PANEL: |
| 1019 | + case WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA: |
| 1020 | + case WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL: |
| 1021 | + case WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1022 | + case WindowManager.LayoutParams.TYPE_SEARCH_BAR: |
| 1023 | + case WindowManager.LayoutParams.TYPE_PHONE: |
| 1024 | + case WindowManager.LayoutParams.TYPE_SYSTEM_ALERT: |
| 1025 | + case WindowManager.LayoutParams.TYPE_TOAST: |
| 1026 | + case WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY: |
| 1027 | + case WindowManager.LayoutParams.TYPE_PRIORITY_PHONE: |
| 1028 | + case WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG: |
| 1029 | + case WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG: |
| 1030 | + case WindowManager.LayoutParams.TYPE_SYSTEM_ERROR: |
| 1031 | + case WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY: |
| 1032 | + case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL: |
| 1033 | + case WindowManager.LayoutParams.TYPE_RECENTS_OVERLAY: { |
| 1034 | + Rect magnifiedRegionBounds = mMagnificationController |
| 1035 | + .getMagnifiedRegionBounds(); |
| 1036 | + Rect touchableRegion = info.touchableRegion; |
| 1037 | + if (!magnifiedRegionBounds.intersect(touchableRegion)) { |
| 1038 | + ensureRectangleInMagnifiedRegionBounds( |
| 1039 | + magnifiedRegionBounds, touchableRegion); |
| 1040 | + } |
| 1041 | + } break; |
| 1042 | + } break; |
1042 | 1043 | } |
1043 | 1044 | } |
1044 | 1045 | } finally { |
@@ -1067,7 +1068,12 @@ private void ensureRectangleInMagnifiedRegionBounds(Rect magnifiedRegionBounds, |
1067 | 1068 | final float scrollX; |
1068 | 1069 | final float scrollY; |
1069 | 1070 | if (rectangle.width() > magnifiedRegionBounds.width()) { |
1070 | | - scrollX = rectangle.left - magnifiedRegionBounds.left; |
| 1071 | + final int direction = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()); |
| 1072 | + if (direction == View.LAYOUT_DIRECTION_LTR) { |
| 1073 | + scrollX = rectangle.left - magnifiedRegionBounds.left; |
| 1074 | + } else { |
| 1075 | + scrollX = rectangle.right - magnifiedRegionBounds.right; |
| 1076 | + } |
1071 | 1077 | } else if (rectangle.left < magnifiedRegionBounds.left) { |
1072 | 1078 | scrollX = rectangle.left - magnifiedRegionBounds.left; |
1073 | 1079 | } else if (rectangle.right > magnifiedRegionBounds.right) { |
|
0 commit comments