mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 02:38:20 +00:00
Merge "Remove obsolete desktop stashing logic from platform/packages/apps/Launcher3 [5/n]" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
571c9b288d
@@ -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 {
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user