Skip to content

Commit 80ce3d8

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Magnifier not respecting RTL/LTR direction and keyguard dialogs not properly centered." into jb-mr1-dev
2 parents be2a4a5 + 444e8aa commit 80ce3d8

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

services/java/com/android/server/accessibility/ScreenMagnifier.java

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import android.os.ServiceManager;
4141
import android.os.SystemClock;
4242
import android.provider.Settings;
43+
import android.text.TextUtils;
4344
import android.util.Property;
4445
import android.util.Slog;
4546
import android.view.Display;
@@ -71,6 +72,7 @@
7172
import java.util.ArrayList;
7273
import java.util.Collections;
7374
import java.util.Comparator;
75+
import java.util.Locale;
7476

7577
/**
7678
* This class handles the screen magnification when accessibility is enabled.
@@ -1000,45 +1002,44 @@ private void handleOnWindowTransition(int transition, WindowInfo info) {
10001002
mViewport.recomputeBounds(mMagnificationController.isMagnifying());
10011003
} break;
10021004
}
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;
10411011
}
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;
10421043
}
10431044
}
10441045
} finally {
@@ -1067,7 +1068,12 @@ private void ensureRectangleInMagnifiedRegionBounds(Rect magnifiedRegionBounds,
10671068
final float scrollX;
10681069
final float scrollY;
10691070
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+
}
10711077
} else if (rectangle.left < magnifiedRegionBounds.left) {
10721078
scrollX = rectangle.left - magnifiedRegionBounds.left;
10731079
} else if (rectangle.right > magnifiedRegionBounds.right) {

0 commit comments

Comments
 (0)