Adding A Minimize Button

Added minimize button in the new WM shell to current caption and set its visibility to gone since Andoid UX is still debating on whether they will have it on by default in captions.

Bug: 242094334
Test: Used acloud to visualize and manually test changes
Change-Id: Iabeb0e94ae4adb2009dcfe7a365f9c8c9a7aa38f
This commit is contained in:
Maryam
2022-08-09 12:50:46 -07:00
committed by Maryam Dehaini
parent 2701e8074c
commit 6d80b7d676
7 changed files with 73 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
<!--
~ 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white" android:pathData="M6,21V19H18V21Z"/>
</vector>

View File

@@ -21,6 +21,17 @@
android:layout_height="wrap_content"
android:gravity="end"
android:background="@drawable/decor_caption_title">
<Button
android:id="@+id/minimize_window"
android:visibility="gone"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="5dp"
android:padding="4dp"
android:layout_gravity="top|end"
android:contentDescription="@string/maximize_button_text"
android:background="@drawable/decor_minimize_button_dark"
android:duplicateParentState="true"/>
<Button
android:id="@+id/maximize_window"
android:layout_width="32dp"
@@ -42,4 +53,3 @@
android:background="@drawable/decor_close_button_dark"
android:duplicateParentState="true"/>
</com.android.wm.shell.windowdecor.WindowDecorLinearLayout>

View File

@@ -192,6 +192,8 @@
<!-- Freeform window caption strings -->
<!-- Accessibility text for the maximize window button [CHAR LIMIT=NONE] -->
<string name="maximize_button_text">Maximize</string>
<!-- Accessibility text for the minimize window button [CHAR LIMIT=NONE] -->
<string name="minimize_button_text">Minimize</string>
<!-- Accessibility text for the close window button [CHAR LIMIT=NONE] -->
<string name="close_button_text">Close</string>
</resources>

View File

@@ -91,6 +91,12 @@ public class FreeformTaskTransitionHandler
mPendingTransitionTokens.add(token);
}
@Override
public void startMinimizedModeTransition(WindowContainerTransaction wct) {
final int type = WindowManager.TRANSIT_TO_BACK;
mPendingTransitionTokens.add(mTransitions.startTransition(type, wct, this));
}
@Override
public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction startT,
@@ -121,6 +127,8 @@ public class FreeformTaskTransitionHandler
transition, info.getType(), change, startT, finishT);
break;
case WindowManager.TRANSIT_TO_BACK:
transitionHandled |= startMinimizeTransition(transition);
break;
case WindowManager.TRANSIT_TO_FRONT:
break;
}
@@ -169,6 +177,13 @@ public class FreeformTaskTransitionHandler
return false;
}
private boolean startMinimizeTransition(IBinder transition) {
if (!mPendingTransitionTokens.contains(transition)) {
return false;
}
return true;
}
private boolean startChangeTransition(
IBinder transition,
int type,
@@ -243,4 +258,5 @@ public class FreeformTaskTransitionHandler
return null;
}
}
}

View File

@@ -29,6 +29,15 @@ public interface FreeformTaskTransitionStarter {
*
* @param targetWindowingMode the target windowing mode
* @param wct the {@link WindowContainerTransaction} that changes the windowing mode
*
*/
void startWindowingModeTransition(int targetWindowingMode, WindowContainerTransaction wct);
}
/**
* Starts window minimization transition
*
* @param wct the {@link WindowContainerTransaction} that changes the windowing mode
*
*/
void startMinimizedModeTransition(WindowContainerTransaction wct);
}

View File

@@ -51,7 +51,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
private final Choreographer mMainChoreographer;
private final DisplayController mDisplayController;
private final SyncTransactionQueue mSyncQueue;
private FreeformTaskTransitionStarter mTransitionStarter;
public CaptionWindowDecorViewModel(
@@ -168,6 +167,14 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
} else {
mSyncQueue.queue(wct);
}
} else if (id == R.id.minimize_window) {
WindowContainerTransaction wct = new WindowContainerTransaction();
wct.reorder(mTaskToken, false);
if (Transitions.ENABLE_SHELL_TRANSITIONS) {
mTransitionStarter.startMinimizedModeTransition(wct);
} else {
mSyncQueue.queue(wct);
}
}
}

View File

@@ -161,12 +161,13 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
*/
private void setupRootView() {
View caption = mResult.mRootView.findViewById(R.id.caption);
caption.setOnTouchListener(mOnCaptionTouchListener);
View maximize = caption.findViewById(R.id.maximize_window);
maximize.setOnClickListener(mOnCaptionButtonClickListener);
View close = caption.findViewById(R.id.close_window);
close.setOnClickListener(mOnCaptionButtonClickListener);
View minimize = caption.findViewById(R.id.minimize_window);
minimize.setOnClickListener(mOnCaptionButtonClickListener);
}
void setCaptionColor(int captionColor) {