Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7551607 authored by Phil Weaver's avatar Phil Weaver
Browse files

Ensure nav bar contrast under magnification

When the nav bar is transparent, the app background
provides adequate contrast with the buttons (at least,
it seems to). But magnification zooms in on the app
window but not the nav bar, which can bring a section
of the UI behind the nav bar that is the same color
as the nav bar buttons. That makes the nav bar quite
difficult to see.

This change makes PhoneWindowManager listen for
magnification updates. When magnification is zooming
in, it makes the nav bar opaque.

The callbacks happen when magnification goes from 1x to
not 1x, and from not 1x to 1x. So we only call back when
the nav bar needs to change, not for every movement made
by magnification.

Bug: 36677486
Test: Enable magnification, zoom in, and watch the nav
bar become opaque. Watch it become transparent again
when we zoom out.

Change-Id: Id9b2c57af98f6cefc81ecf3d7bdab4e49ac07474
parent f157b9f9
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -785,6 +785,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    private int mCurrentUserId;

    /* Whether accessibility is magnifying the screen */
    private boolean mScreenMagnificationActive;

    // Maps global key codes to the components that will handle them.
    private GlobalKeyManager mGlobalKeyManager;

@@ -8164,7 +8167,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     */
    private int configureNavBarOpacity(int visibility, boolean dockedStackVisible,
            boolean freeformStackVisible, boolean isDockedDividerResizing) {
        if (mNavBarOpacityMode == NAV_BAR_OPAQUE_WHEN_FREEFORM_OR_DOCKED) {
        if (mScreenMagnificationActive) {
            // When the screen is magnified, the nav bar should be opaque since its background
            // can vary as the user pans and zooms
            visibility = setNavBarOpaqueFlag(visibility);
        } else if (mNavBarOpacityMode == NAV_BAR_OPAQUE_WHEN_FREEFORM_OR_DOCKED) {
            if (dockedStackVisible || freeformStackVisible || isDockedDividerResizing) {
                visibility = setNavBarOpaqueFlag(visibility);
            }
@@ -8318,6 +8325,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return false;
    }

    @Override
    public void onScreenMagnificationStateChanged(boolean active) {
        synchronized (mWindowManagerFuncs.getWindowManagerLock()) {
            mScreenMagnificationActive = active;
            updateSystemUiVisibilityLw();
        }
    }

    @Override
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
        final long token = proto.start(fieldId);
+7 −0
Original line number Diff line number Diff line
@@ -1699,6 +1699,13 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     */
    boolean canDismissBootAnimation();

    /**
     * Called when the magnification state changes.
     *
     * @param active Whether magnification is active (that is, we are zoomed in).
     */
    void onScreenMagnificationStateChanged(boolean active);

    /**
     * Convert the user rotation mode to a human readable format.
     */
+7 −0
Original line number Diff line number Diff line
@@ -87,6 +87,8 @@ final class AccessibilityController {

    private WindowsForAccessibilityObserver mWindowsForAccessibilityObserver;

    private boolean mScreenMagnificationActive;

    public void setMagnificationCallbacksLocked(MagnificationCallbacks callbacks) {
        if (callbacks != null) {
            if (mDisplayMagnifier != null) {
@@ -136,6 +138,11 @@ final class AccessibilityController {
        if (mWindowsForAccessibilityObserver != null) {
            mWindowsForAccessibilityObserver.scheduleComputeChangedWindowsLocked();
        }
        boolean nowActive = !spec.isNop();
        if (nowActive != mScreenMagnificationActive) {
            mScreenMagnificationActive = nowActive;
            mService.mPolicy.onScreenMagnificationStateChanged(nowActive);
        }
    }

    public void getMagnificationRegionLocked(Region outMagnificationRegion) {
+4 −0
Original line number Diff line number Diff line
@@ -644,4 +644,8 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
    public boolean canDismissBootAnimation() {
        return true;
    }

    @Override
    public void onScreenMagnificationStateChanged(boolean active) {
    }
}