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

Commit 10f2250f authored by Ats Jenk's avatar Ats Jenk
Browse files

Hide some options when desktop mode is available

When desktop mode is available (flag enabled), hide some freeform
specific buttons:
- hide freeform from app menu in recents
- hide maximize button from window captions

Bug: 242906219
Test: test that buttons are not shown when desktop mode is enabled
Change-Id: I4c3e3f5ce1221eef853d73e2b395b362037c9cca
parent 3fc369ff
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.common.TransactionPool;
import com.android.wm.shell.common.annotations.ShellBackgroundThread;
import com.android.wm.shell.common.annotations.ShellBackgroundThread;
import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.desktopmode.DesktopModeConstants;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.freeform.FreeformComponents;
import com.android.wm.shell.freeform.FreeformComponents;
@@ -587,7 +588,7 @@ public abstract class WMShellModule {
            RootDisplayAreaOrganizer rootDisplayAreaOrganizer,
            RootDisplayAreaOrganizer rootDisplayAreaOrganizer,
            @ShellMainThread Handler mainHandler
            @ShellMainThread Handler mainHandler
    ) {
    ) {
        if (DesktopModeController.IS_FEATURE_ENABLED) {
        if (DesktopModeConstants.IS_FEATURE_ENABLED) {
            return Optional.of(new DesktopModeController(context, shellInit, shellTaskOrganizer,
            return Optional.of(new DesktopModeController(context, shellInit, shellTaskOrganizer,
                    rootDisplayAreaOrganizer,
                    rootDisplayAreaOrganizer,
                    mainHandler));
                    mainHandler));
+31 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.desktopmode;

import android.os.SystemProperties;

/**
 * Constants for desktop mode feature
 */
public class DesktopModeConstants {

    /**
     * Flag to indicate whether desktop mode is available on the device
     */
    public static final boolean IS_FEATURE_ENABLED = SystemProperties.getBoolean(
            "persist.wm.debug.desktop_mode", false);
}
+0 −4
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.Context;
import android.database.ContentObserver;
import android.database.ContentObserver;
import android.net.Uri;
import android.net.Uri;
import android.os.Handler;
import android.os.Handler;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings;
import android.window.WindowContainerTransaction;
import android.window.WindowContainerTransaction;
@@ -44,9 +43,6 @@ import com.android.wm.shell.sysui.ShellInit;
 */
 */
public class DesktopModeController {
public class DesktopModeController {


    public static final boolean IS_FEATURE_ENABLED = SystemProperties.getBoolean(
            "persist.wm.debug.desktop_mode", false);

    private final Context mContext;
    private final Context mContext;
    private final ShellTaskOrganizer mShellTaskOrganizer;
    private final ShellTaskOrganizer mShellTaskOrganizer;
    private final RootDisplayAreaOrganizer mRootDisplayAreaOrganizer;
    private final RootDisplayAreaOrganizer mRootDisplayAreaOrganizer;
+8 −1
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.desktopmode.DesktopModeConstants;


/**
/**
 * Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with
 * Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with
@@ -163,7 +164,13 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
        View caption = mResult.mRootView.findViewById(R.id.caption);
        View caption = mResult.mRootView.findViewById(R.id.caption);
        caption.setOnTouchListener(mOnCaptionTouchListener);
        caption.setOnTouchListener(mOnCaptionTouchListener);
        View maximize = caption.findViewById(R.id.maximize_window);
        View maximize = caption.findViewById(R.id.maximize_window);
        if (DesktopModeConstants.IS_FEATURE_ENABLED) {
            // Hide maximize button when desktop mode is available
            maximize.setVisibility(View.GONE);
        } else {
            maximize.setVisibility(View.VISIBLE);
            maximize.setOnClickListener(mOnCaptionButtonClickListener);
            maximize.setOnClickListener(mOnCaptionButtonClickListener);
        }
        View close = caption.findViewById(R.id.close_window);
        View close = caption.findViewById(R.id.close_window);
        close.setOnClickListener(mOnCaptionButtonClickListener);
        close.setOnClickListener(mOnCaptionButtonClickListener);
        View minimize = caption.findViewById(R.id.minimize_window);
        View minimize = caption.findViewById(R.id.minimize_window);