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

Commit 8eac42a8 authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Automerger Merge Worker
Browse files

Merge "Add shadow to view in sync with the handle menu appearing" into udc-dev...

Merge "Add shadow to view in sync with the handle menu appearing" into udc-dev am: f0e71f62 am: 61e2b8b3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22392708



Change-Id: Ib0243a7acd57a440136a4bd9af1b616fa0628694
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents af890419 61e2b8b3
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -303,6 +303,7 @@ public class SurfaceControlViewHost {
    /** @hide */
    /** @hide */
    public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d,
    public SurfaceControlViewHost(@NonNull Context c, @NonNull Display d,
            @NonNull WindowlessWindowManager wwm, @NonNull String callsite) {
            @NonNull WindowlessWindowManager wwm, @NonNull String callsite) {
        mSurfaceControl = wwm.mRootSurface;
        mWm = wwm;
        mWm = wwm;
        mViewRoot = new ViewRootImpl(c, d, mWm, new WindowlessWindowLayout());
        mViewRoot = new ViewRootImpl(c, d, mWm, new WindowlessWindowLayout());
        mCloseGuard.openWithCallSite("release", callsite);
        mCloseGuard.openWithCallSite("release", callsite);
+13 −13
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.TextView;
import android.window.SurfaceSyncGroup;
import android.window.WindowContainerTransaction;
import android.window.WindowContainerTransaction;


import com.android.launcher3.icons.IconProvider;
import com.android.launcher3.icons.IconProvider;
@@ -311,51 +312,50 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     * Create and display handle menu window
     * Create and display handle menu window
     */
     */
    void createHandleMenu() {
    void createHandleMenu() {
        final SurfaceSyncGroup ssg = new SurfaceSyncGroup(TAG);
        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        updateHandleMenuPillPositions();
        updateHandleMenuPillPositions();


        createAppInfoPill(t);
        createAppInfoPill(t, ssg);


        // Only show windowing buttons in proto2. Proto1 uses a system-level mode only.
        // Only show windowing buttons in proto2. Proto1 uses a system-level mode only.
        final boolean shouldShowWindowingPill = DesktopModeStatus.isProto2Enabled();
        final boolean shouldShowWindowingPill = DesktopModeStatus.isProto2Enabled();
        if (shouldShowWindowingPill) {
        if (shouldShowWindowingPill) {
            createWindowingPill(t);
            createWindowingPill(t, ssg);
        }
        }


        createMoreActionsPill(t);
        createMoreActionsPill(t, ssg);


        mSyncQueue.runInSync(transaction -> {
        ssg.addTransaction(t);
            transaction.merge(t);
        ssg.markSyncReady();
            t.close();
        });
        setupHandleMenu(shouldShowWindowingPill);
        setupHandleMenu(shouldShowWindowingPill);
    }
    }


    private void createAppInfoPill(SurfaceControl.Transaction t) {
    private void createAppInfoPill(SurfaceControl.Transaction t, SurfaceSyncGroup ssg) {
        final int x = (int) mHandleMenuAppInfoPillPosition.x;
        final int x = (int) mHandleMenuAppInfoPillPosition.x;
        final int y = (int) mHandleMenuAppInfoPillPosition.y;
        final int y = (int) mHandleMenuAppInfoPillPosition.y;
        mHandleMenuAppInfoPill = addWindow(
        mHandleMenuAppInfoPill = addWindow(
                R.layout.desktop_mode_window_decor_handle_menu_app_info_pill,
                R.layout.desktop_mode_window_decor_handle_menu_app_info_pill,
                "Menu's app info pill",
                "Menu's app info pill",
                t, x, y, mMenuWidth, mAppInfoPillHeight, mShadowRadius, mCornerRadius);
                t, ssg, x, y, mMenuWidth, mAppInfoPillHeight, mShadowRadius, mCornerRadius);
    }
    }


    private void createWindowingPill(SurfaceControl.Transaction t) {
    private void createWindowingPill(SurfaceControl.Transaction t, SurfaceSyncGroup ssg) {
        final int x = (int) mHandleMenuWindowingPillPosition.x;
        final int x = (int) mHandleMenuWindowingPillPosition.x;
        final int y = (int) mHandleMenuWindowingPillPosition.y;
        final int y = (int) mHandleMenuWindowingPillPosition.y;
        mHandleMenuWindowingPill = addWindow(
        mHandleMenuWindowingPill = addWindow(
                R.layout.desktop_mode_window_decor_handle_menu_windowing_pill,
                R.layout.desktop_mode_window_decor_handle_menu_windowing_pill,
                "Menu's windowing pill",
                "Menu's windowing pill",
                t, x, y, mMenuWidth, mWindowingPillHeight, mShadowRadius, mCornerRadius);
                t, ssg, x, y, mMenuWidth, mWindowingPillHeight, mShadowRadius, mCornerRadius);
    }
    }


    private void createMoreActionsPill(SurfaceControl.Transaction t) {
    private void createMoreActionsPill(SurfaceControl.Transaction t, SurfaceSyncGroup ssg) {
        final int x = (int) mHandleMenuMoreActionsPillPosition.x;
        final int x = (int) mHandleMenuMoreActionsPillPosition.x;
        final int y = (int) mHandleMenuMoreActionsPillPosition.y;
        final int y = (int) mHandleMenuMoreActionsPillPosition.y;
        mHandleMenuMoreActionsPill = addWindow(
        mHandleMenuMoreActionsPill = addWindow(
                R.layout.desktop_mode_window_decor_handle_menu_more_actions_pill,
                R.layout.desktop_mode_window_decor_handle_menu_more_actions_pill,
                "Menu's more actions pill",
                "Menu's more actions pill",
                t, x, y, mMenuWidth, mMoreActionsPillHeight, mShadowRadius, mCornerRadius);
                t, ssg, x, y, mMenuWidth, mMoreActionsPillHeight, mShadowRadius, mCornerRadius);
    }
    }


    private void setupHandleMenu(boolean windowingPillShown) {
    private void setupHandleMenu(boolean windowingPillShown) {
+14 −11
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import android.view.ViewRootImpl;
import android.view.WindowInsets;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManager;
import android.view.WindowlessWindowManager;
import android.view.WindowlessWindowManager;
import android.window.SurfaceSyncGroup;
import android.window.TaskConstants;
import android.window.TaskConstants;
import android.window.WindowContainerTransaction;
import android.window.WindowContainerTransaction;


@@ -382,6 +383,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
    /**
    /**
     * Create a window associated with this WindowDecoration.
     * Create a window associated with this WindowDecoration.
     * Note that subclass must dispose of this when the task is hidden/closed.
     * Note that subclass must dispose of this when the task is hidden/closed.
     *
     * @param layoutId     layout to make the window from
     * @param layoutId     layout to make the window from
     * @param t            the transaction to apply
     * @param t            the transaction to apply
     * @param xPos         x position of new window
     * @param xPos         x position of new window
@@ -393,7 +395,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
     * @return the {@link AdditionalWindow} that was added.
     * @return the {@link AdditionalWindow} that was added.
     */
     */
    AdditionalWindow addWindow(int layoutId, String namePrefix, SurfaceControl.Transaction t,
    AdditionalWindow addWindow(int layoutId, String namePrefix, SurfaceControl.Transaction t,
            int xPos, int yPos, int width, int height, int shadowRadius, int cornerRadius) {
            SurfaceSyncGroup ssg, int xPos, int yPos, int width, int height, int shadowRadius,
            int cornerRadius) {
        final SurfaceControl.Builder builder = mSurfaceControlBuilderSupplier.get();
        final SurfaceControl.Builder builder = mSurfaceControlBuilderSupplier.get();
        SurfaceControl windowSurfaceControl = builder
        SurfaceControl windowSurfaceControl = builder
                .setName(namePrefix + " of Task=" + mTaskInfo.taskId)
                .setName(namePrefix + " of Task=" + mTaskInfo.taskId)
@@ -417,7 +420,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
                windowSurfaceControl, null /* hostInputToken */);
                windowSurfaceControl, null /* hostInputToken */);
        SurfaceControlViewHost viewHost = mSurfaceControlViewHostFactory
        SurfaceControlViewHost viewHost = mSurfaceControlViewHostFactory
                .create(mDecorWindowContext, mDisplay, windowManager);
                .create(mDecorWindowContext, mDisplay, windowManager);
        viewHost.setView(v, lp);
        ssg.add(viewHost.getSurfacePackage(), () -> viewHost.setView(v, lp));
        return new AdditionalWindow(windowSurfaceControl, viewHost,
        return new AdditionalWindow(windowSurfaceControl, viewHost,
                mSurfaceControlTransactionSupplier);
                mSurfaceControlTransactionSupplier);
    }
    }
+4 −1
Original line number Original line Diff line number Diff line
@@ -49,6 +49,7 @@ import android.view.View;
import android.view.ViewRootImpl;
import android.view.ViewRootImpl;
import android.view.WindowInsets;
import android.view.WindowInsets;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManager.LayoutParams;
import android.window.SurfaceSyncGroup;
import android.window.TaskConstants;
import android.window.TaskConstants;
import android.window.WindowContainerTransaction;
import android.window.WindowContainerTransaction;


@@ -100,6 +101,8 @@ public class WindowDecorationTests extends ShellTestCase {
    private TestView mMockView;
    private TestView mMockView;
    @Mock
    @Mock
    private WindowContainerTransaction mMockWindowContainerTransaction;
    private WindowContainerTransaction mMockWindowContainerTransaction;
    @Mock
    private SurfaceSyncGroup mMockSurfaceSyncGroup;


    private final List<SurfaceControl.Transaction> mMockSurfaceControlTransactions =
    private final List<SurfaceControl.Transaction> mMockSurfaceControlTransactions =
            new ArrayList<>();
            new ArrayList<>();
@@ -553,7 +556,7 @@ public class WindowDecorationTests extends ShellTestCase {
            String name = "Test Window";
            String name = "Test Window";
            WindowDecoration.AdditionalWindow additionalWindow =
            WindowDecoration.AdditionalWindow additionalWindow =
                    addWindow(R.layout.desktop_mode_window_decor_handle_menu_app_info_pill, name,
                    addWindow(R.layout.desktop_mode_window_decor_handle_menu_app_info_pill, name,
                            mMockSurfaceControlAddWindowT, x, y,
                            mMockSurfaceControlAddWindowT, mMockSurfaceSyncGroup, x, y,
                            width, height, shadowRadius, cornerRadius);
                            width, height, shadowRadius, cornerRadius);
            return additionalWindow;
            return additionalWindow;
        }
        }