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

Commit a27e7a13 authored by Minche Li's avatar Minche Li Committed by Android (Google) Code Review
Browse files

Merge "Update window magnifier UI when onConfigurationChanged. (1/n)"

parents d4a5c9cd 5fbfc532
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.systemui.accessibility;
package com.android.systemui.accessibility;


import android.content.Context;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.database.ContentObserver;
import android.os.Handler;
import android.os.Handler;
import android.provider.Settings;
import android.provider.Settings;
@@ -35,10 +37,25 @@ public class WindowMagnification extends SystemUI {
    private WindowMagnificationController mWindowMagnificationController;
    private WindowMagnificationController mWindowMagnificationController;
    private final Handler mHandler;
    private final Handler mHandler;


    private Configuration mLastConfiguration;

    @Inject
    @Inject
    public WindowMagnification(Context context, @Main Handler mainHandler) {
    public WindowMagnification(Context context, @Main Handler mainHandler) {
        super(context);
        super(context);
        mHandler = mainHandler;
        mHandler = mainHandler;
        mLastConfiguration = new Configuration(context.getResources().getConfiguration());
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        final int configDiff = newConfig.diff(mLastConfiguration);
        if ((configDiff & ActivityInfo.CONFIG_DENSITY) == 0) {
            return;
        }
        mLastConfiguration.setTo(newConfig);
        if (mWindowMagnificationController != null) {
            mWindowMagnificationController.onConfigurationChanged(configDiff);
        }
    }
    }


    @Override
    @Override
+14 −2
Original line number Original line Diff line number Diff line
@@ -113,6 +113,7 @@ public class WindowMagnificationController implements View.OnClickListener,
        if (mMirrorView != null) {
        if (mMirrorView != null) {
            return;
            return;
        }
        }
        setInitialStartBounds();
        createOverlayWindow();
        createOverlayWindow();
    }
    }


@@ -178,9 +179,20 @@ public class WindowMagnificationController implements View.OnClickListener,
        }
        }
    }
    }


    private void createMirrorWindow() {
    /**
        setInitialStartBounds();
     * Called when the configuration has changed, and it updates window magnification UI.
     *
     * @param configDiff a bit mask of the differences between the configurations
     */
    void onConfigurationChanged(int configDiff) {
        // TODO(b/145780606): update toggle button UI.
        if (mMirrorView != null) {
            mWm.removeView(mMirrorView);
            createMirrorWindow();
        }
    }


    private void createMirrorWindow() {
        // The window should be the size the mirrored surface will be but also add room for the
        // The window should be the size the mirrored surface will be but also add room for the
        // border and the drag handle.
        // border and the drag handle.
        int dragViewHeight = (int) mContext.getResources().getDimension(
        int dragViewHeight = (int) mContext.getResources().getDimension(