Merge "Remove obsolete desktop stashing logic from platform/packages/apps/Launcher3 [5/n]" into main

This commit is contained in:
Pragya Bajoria
2024-05-16 09:50:17 +00:00
committed by Android (Google) Code Review
8 changed files with 1 additions and 338 deletions

View File

@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2023 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.
-->
<com.android.quickstep.views.DesktopAppSelectView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:layout_width="wrap_content"
android:layout_height="@dimen/desktop_mode_floating_app_select_height"
android:layout_gravity="top|center_horizontal"
android:background="@drawable/bg_floating_desktop_select"
android:elevation="@dimen/desktop_mode_floating_app_select_elevation"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/desktop_app_select_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/desktop_mode_floating_app_select_text_margin"
android:layout_marginStart="@dimen/desktop_mode_floating_app_select_margin"
android:drawablePadding="@dimen/desktop_mode_floating_app_select_text_margin"
android:drawableStart="@drawable/ic_desktop"
android:drawableTint="?androidprv:attr/materialColorOnPrimaryContainer"
android:fontFamily="google-sans-medium"
android:gravity="center_vertical"
android:text="@string/desktop_select_app_toast"
android:textColor="?androidprv:attr/materialColorOnPrimaryContainer"
android:textSize="@dimen/desktop_mode_floating_app_select_text_size" />
<Button
android:id="@+id/close_button"
style="@android:style/Widget.DeviceDefault.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/desktop_mode_floating_app_select_margin"
android:minWidth="0dp"
android:fontFamily="google-sans-medium"
android:text="@string/desktop_button_close_app_toast"
android:textAllCaps="false"
android:textColor="?androidprv:attr/materialColorPrimary"
android:textSize="@dimen/desktop_mode_floating_app_select_text_size" />
</com.android.quickstep.views.DesktopAppSelectView>

View File

@@ -484,11 +484,4 @@
<dimen name="keyboard_quick_switch_no_recent_items_icon_size">24dp</dimen>
<dimen name="keyboard_quick_switch_no_recent_items_icon_margin">8dp</dimen>
<!-- Desktop mode -->
<dimen name="desktop_mode_floating_app_select_height">56dp</dimen>
<dimen name="desktop_mode_floating_app_select_elevation">4dp</dimen>
<dimen name="desktop_mode_floating_app_select_margin">16dp</dimen>
<dimen name="desktop_mode_floating_app_select_text_size">14sp</dimen>
<dimen name="desktop_mode_floating_app_select_text_margin">8dp</dimen>
</resources>

View File

@@ -332,10 +332,4 @@
<!-- Accessibility label for quick switch tiles showing split tasks [CHAR LIMIT=NONE] -->
<string name="quick_switch_split_task"><xliff:g id="app_name_1" example="Chrome">%1$s</xliff:g> and <xliff:g id="app_name_2" example="Gmail">%2$s</xliff:g></string>
<!-- ******* Desktop ******* -->
<!-- Text shown in popup to choose a desktop app. [CHAR LIMIT=60] -->
<string name="desktop_select_app_toast">Adding app to Desktop</string>
<!-- Text shown on a button that closes the popup for choosing a desktop app. [CHAR_LIMIT=40] -->
<string name="desktop_button_close_app_toast">Cancel</string>
</resources>

View File

@@ -35,7 +35,6 @@ import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.quickstep.GestureState;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.views.DesktopAppSelectView;
import com.android.wm.shell.desktopmode.IDesktopTaskListener;
import java.util.HashSet;
@@ -49,8 +48,6 @@ public class DesktopVisibilityController {
private static final String TAG = "DesktopVisController";
private static final boolean DEBUG = false;
private static final boolean IS_STASHING_ENABLED = SystemProperties.getBoolean(
"persist.wm.debug.desktop_stashing", false);
private final Launcher mLauncher;
private final Set<DesktopVisibilityListener> mDesktopVisibilityListeners = new HashSet<>();
@@ -61,7 +58,6 @@ public class DesktopVisibilityController {
@Nullable
private IDesktopTaskListener mDesktopTaskListener;
private DesktopAppSelectView mSelectAppToast;
public DesktopVisibilityController(Launcher launcher) {
mLauncher = launcher;
@@ -86,21 +82,7 @@ public class DesktopVisibilityController {
@Override
public void onStashedChanged(int displayId, boolean stashed) {
if (!IS_STASHING_ENABLED) {
return;
}
MAIN_EXECUTOR.execute(() -> {
if (displayId == mLauncher.getDisplayId()) {
if (DEBUG) {
Log.d(TAG, "desktop stashed changed value=" + stashed);
}
if (stashed) {
showSelectAppToast();
} else {
hideSelectAppToast();
}
}
});
Log.w(TAG, "IDesktopTaskListener: onStashedChanged is deprecated");
}
};
SystemUiProxy.INSTANCE.get(mLauncher).setDesktopTaskListener(mDesktopTaskListener);
@@ -302,15 +284,6 @@ public class DesktopVisibilityController {
}
}
/**
* Handle launcher moving to home due to home gesture or home button press.
*/
public void onHomeActionTriggered() {
if (IS_STASHING_ENABLED && areDesktopTasksVisible()) {
SystemUiProxy.INSTANCE.get(mLauncher).stashDesktopApps(mLauncher.getDisplayId());
}
}
/**
* TODO: b/333533253 - Remove after flag rollout
*/
@@ -373,30 +346,6 @@ public class DesktopVisibilityController {
}
}
private void showSelectAppToast() {
if (mSelectAppToast != null) {
return;
}
if (DEBUG) {
Log.d(TAG, "show toast to select desktop apps");
}
Runnable onCloseCallback = () -> {
SystemUiProxy.INSTANCE.get(mLauncher).hideStashedDesktopApps(mLauncher.getDisplayId());
};
mSelectAppToast = DesktopAppSelectView.show(mLauncher, onCloseCallback);
}
private void hideSelectAppToast() {
if (mSelectAppToast == null) {
return;
}
if (DEBUG) {
Log.d(TAG, "hide toast to select desktop apps");
}
mSelectAppToast.hide();
mSelectAppToast = null;
}
/** A listener for when the user enters/exits Desktop Mode. */
public interface DesktopVisibilityListener {
/**

View File

@@ -44,10 +44,8 @@ import androidx.annotation.StringRes;
import com.android.launcher3.R;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.statehandlers.DesktopVisibilityController;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.quickstep.LauncherActivityInterface;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.util.AssistUtils;
@@ -285,13 +283,6 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
private void navigateHome() {
TaskUtils.closeSystemWindowsAsync(CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY);
DesktopVisibilityController desktopVisibilityController =
LauncherActivityInterface.INSTANCE.getDesktopVisibilityController();
if (desktopVisibilityController != null) {
desktopVisibilityController.onHomeActionTriggered();
}
mCallbacks.onNavigateHome();
}

View File

@@ -1173,12 +1173,6 @@ public abstract class AbsSwipeUpHandler<T extends RecentsViewContainer,
mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
// Notify the SysUI to use fade-in animation when entering PiP
SystemUiProxy.INSTANCE.get(mContext).setPipAnimationTypeToAlpha();
DesktopVisibilityController desktopVisibilityController =
mContainerInterface.getDesktopVisibilityController();
if (desktopVisibilityController != null) {
// Notify the SysUI to stash desktop apps if they are visible
desktopVisibilityController.onHomeActionTriggered();
}
break;
case RECENTS:
mStateCallback.setState(STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT

View File

@@ -1443,28 +1443,6 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable {
}
}
/** Call shell to stash desktop apps */
public void stashDesktopApps(int displayId) {
if (mDesktopMode != null) {
try {
mDesktopMode.stashDesktopApps(displayId);
} catch (RemoteException e) {
Log.w(TAG, "Failed call stashDesktopApps", e);
}
}
}
/** Call shell to hide desktop apps that may be stashed */
public void hideStashedDesktopApps(int displayId) {
if (mDesktopMode != null) {
try {
mDesktopMode.hideStashedDesktopApps(displayId);
} catch (RemoteException e) {
Log.w(TAG, "Failed call hideStashedDesktopApps", e);
}
}
}
/**
* If task with the given id is on the desktop, bring it to front
*/

View File

@@ -1,180 +0,0 @@
/*
* Copyright (C) 2023 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.quickstep.views;
import static com.android.app.animation.Interpolators.EMPHASIZED_DECELERATE;
import static com.android.app.animation.Interpolators.LINEAR;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.uioverrides.QuickstepLauncher;
/**
* Floating view show on launcher home screen that notifies the user that an app will be launched to
* the desktop.
*/
public class DesktopAppSelectView extends LinearLayout {
private static final int SHOW_INITIAL_HEIGHT_DP = 7;
private static final int SHOW_CONTAINER_SCALE_DURATION = 333;
private static final int SHOW_CONTAINER_ALPHA_DURATION = 83;
private static final int SHOW_CONTENT_ALPHA_DELAY = 67;
private static final int SHOW_CONTENT_ALPHA_DURATION = 83;
private static final int HIDE_DURATION = 83;
private final RecentsViewContainer mContainer;
private View mText;
private View mCloseButton;
@Nullable
private Runnable mOnCloseCallback;
private AnimatorSet mShowAnimation;
private Animator mHideAnimation;
public DesktopAppSelectView(Context context) {
this(context, null);
}
public DesktopAppSelectView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public DesktopAppSelectView(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public DesktopAppSelectView(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mContainer = RecentsViewContainer.containerFromContext(context);
}
/**
* Show the popup on launcher home screen
*
* @param onCloseCallback optional callback that is called when user clicks the close button
* @return the created view
*/
public static DesktopAppSelectView show(Launcher launcher, @Nullable Runnable onCloseCallback) {
DesktopAppSelectView view = (DesktopAppSelectView) launcher.getLayoutInflater().inflate(
R.layout.floating_desktop_app_select, launcher.getDragLayer(), false);
view.setOnCloseClickCallback(onCloseCallback);
view.show();
return view;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mText = findViewById(R.id.desktop_app_select_text);
mCloseButton = findViewById(R.id.close_button);
mCloseButton.setOnClickListener(v -> {
if (mHideAnimation == null) {
hide();
if (mOnCloseCallback != null) {
mOnCloseCallback.run();
}
}
});
}
private void show() {
mContainer.getDragLayer().addView(this);
// Set up initial values
getBackground().setAlpha(0);
mText.setAlpha(0);
mCloseButton.setAlpha(0);
int initialHeightPx = Utilities.dpToPx(SHOW_INITIAL_HEIGHT_DP);
int finalHeight = getResources().getDimensionPixelSize(
R.dimen.desktop_mode_floating_app_select_height);
float initialScale = initialHeightPx / (float) finalHeight;
setScaleY(initialScale);
setPivotY(0);
// Animate the container
ValueAnimator containerBackground = ValueAnimator.ofInt(0, 255);
containerBackground.addUpdateListener(
animation -> getBackground().setAlpha((Integer) animation.getAnimatedValue()));
containerBackground.setDuration(SHOW_CONTAINER_ALPHA_DURATION);
containerBackground.setInterpolator(LINEAR);
ObjectAnimator containerSize = ObjectAnimator.ofFloat(this, SCALE_Y, 1f);
containerSize.setDuration(SHOW_CONTAINER_SCALE_DURATION);
containerSize.setInterpolator(EMPHASIZED_DECELERATE);
// Animate the contents
ObjectAnimator textAlpha = ObjectAnimator.ofFloat(mText, ALPHA, 1);
ObjectAnimator buttonAlpha = ObjectAnimator.ofFloat(mCloseButton, ALPHA, 1);
AnimatorSet contentAlpha = new AnimatorSet();
contentAlpha.playTogether(textAlpha, buttonAlpha);
contentAlpha.setStartDelay(SHOW_CONTENT_ALPHA_DELAY);
contentAlpha.setDuration(SHOW_CONTENT_ALPHA_DURATION);
contentAlpha.setInterpolator(LINEAR);
// Start the animation
mShowAnimation = new AnimatorSet();
mShowAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mShowAnimation = null;
}
});
mShowAnimation.playTogether(containerBackground, containerSize, contentAlpha);
mShowAnimation.start();
}
/**
* Hide the floating view
*/
public void hide() {
if (mShowAnimation != null) {
mShowAnimation.cancel();
}
mHideAnimation = ObjectAnimator.ofFloat(this, ALPHA, 0);
mHideAnimation.setDuration(HIDE_DURATION).setInterpolator(LINEAR);
mHideAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mContainer.getDragLayer().removeView(DesktopAppSelectView.this);
mHideAnimation = null;
}
});
mHideAnimation.start();
}
/**
* Add a callback that is called when close button is clicked
*/
public void setOnCloseClickCallback(@Nullable Runnable callback) {
mOnCloseCallback = callback;
}
}