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

Commit 66d1c2fa authored by Tony Wickham's avatar Tony Wickham
Browse files

Hide Clear all button during quick switch

- Add support for mMinScrollX to PagedView
- Add RECENTS_CLEAR_ALL_BUTTON as a state-specified visible element
- In BackgroundAppState, set Clear all invisible and bound RecentsView
  scroll to the last task

Test:
- Open an app, quick switch until reaching the end, ensure Clear all
  does not show up and an overscroll effect is performed
- Enter overview, scroll to the end and ensure Clear all shows up
- Same tests in RTL and 3rd party launcher

Bug: 130160876
Change-Id: I5fb958744d0055b83ced1f8b0d7face0e06a0cc5
parent b0c81fc0
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.launcher3.uioverrides;

import static com.android.launcher3.LauncherState.RECENTS_CLEAR_ALL_BUTTON;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;

import android.animation.ValueAnimator;
@@ -22,15 +24,17 @@ import android.annotation.TargetApi;
import android.os.Build;
import android.util.FloatProperty;

import androidx.annotation.NonNull;

import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.PropertySetter;
import com.android.quickstep.views.ClearAllButton;
import com.android.quickstep.views.LauncherRecentsView;
import com.android.quickstep.views.RecentsView;

import androidx.annotation.NonNull;

/**
 * State handler for handling UI changes for {@link LauncherRecentsView}. In addition to managing
 * the basic view properties, this class also manages changes in the task visuals.
@@ -50,6 +54,7 @@ public final class RecentsViewStateController extends
            mRecentsView.updateEmptyMessage();
            mRecentsView.resetTaskVisuals();
        }
        setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, state.getVisibleElements(mLauncher));
    }

    @Override
@@ -71,6 +76,14 @@ public final class RecentsViewStateController extends
            builder.play(updateAnim);
            mRecentsView.updateEmptyMessage();
        }

        setAlphas(config.getPropertySetter(builder), toState.getVisibleElements(mLauncher));
    }

    private void setAlphas(PropertySetter propertySetter, int visibleElements) {
        boolean hasClearAllButton = (visibleElements & RECENTS_CLEAR_ALL_BUTTON) != 0;
        propertySetter.setFloat(mRecentsView.getClearAllButton(), ClearAllButton.VISIBILITY_ALPHA,
                hasClearAllButton ? 1f : 0f, LINEAR);
    }

    @Override
+5 −2
Original line number Diff line number Diff line
@@ -18,11 +18,10 @@ package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;

import android.os.RemoteException;

import com.android.launcher3.Launcher;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.recents.ISystemUiProxy;
@@ -75,4 +74,8 @@ public class BackgroundAppState extends OverviewState {
        return new ScaleAndTranslation(scale, 0f, 0f);
    }

    @Override
    public int getVisibleElements(Launcher launcher) {
        return super.getVisibleElements(launcher) & ~RECENTS_CLEAR_ALL_BUTTON;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -116,9 +116,9 @@ public class OverviewState extends LauncherState {
    @Override
    public int getVisibleElements(Launcher launcher) {
        if (launcher.getDeviceProfile().isVerticalBarLayout()) {
            return VERTICAL_SWIPE_INDICATOR;
            return VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON;
        } else {
            return HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR |
            return HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON |
                    (launcher.getAppsView().getFloatingHeaderView().hasVisibleContent()
                            ? ALL_APPS_HEADER_EXTRA : HOTSEAT_ICONS);
        }
+8 −5
Original line number Diff line number Diff line
@@ -26,11 +26,13 @@ import android.content.Context;
import android.graphics.Rect;
import android.graphics.RectF;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.views.RecentsView;
@@ -39,9 +41,6 @@ import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import java.util.function.BiPredicate;
import java.util.function.Consumer;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * {@link ActivityControlHelper} for recents when the default launcher is different than the
 * currently running one and apps should interact with the {@link RecentsActivity} as opposed
@@ -72,7 +71,9 @@ public final class FallbackActivityControllerHelper implements

    @Override
    public void onSwipeUpComplete(RecentsActivity activity) {
        // TODO:
        RecentsView recentsView = activity.getOverviewPanel();
        recentsView.getClearAllButton().setVisibilityAlpha(1);
        recentsView.setDisallowScrollToClearAll(false);
    }

    @Override
@@ -121,6 +122,8 @@ public final class FallbackActivityControllerHelper implements

        RecentsView rv = activity.getOverviewPanel();
        rv.setContentAlpha(0);
        rv.getClearAllButton().setVisibilityAlpha(0);
        rv.setDisallowScrollToClearAll(true);

        return new AnimationFactory() {

+1 −10
Original line number Diff line number Diff line
@@ -744,14 +744,10 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
        float endShift;
        final float startShift;
        Interpolator interpolator = DEACCEL;
        int nextPage = 0;
        int taskToLaunch = 0;
        final boolean goingToNewTask;
        if (mRecentsView != null) {
            nextPage = mRecentsView.getNextPage();
            final int lastTaskIndex = mRecentsView.getTaskViewCount() - 1;
            final int runningTaskIndex = mRecentsView.getRunningTaskIndex();
            taskToLaunch = nextPage <= lastTaskIndex ? nextPage : lastTaskIndex;
            final int taskToLaunch = mRecentsView.getNextPage();
            goingToNewTask = runningTaskIndex >= 0 && taskToLaunch != runningTaskIndex;
        } else {
            goingToNewTask = false;
@@ -817,11 +813,6 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
            }
        }

        if (mRecentsView != null && !endTarget.isLauncher && taskToLaunch != nextPage) {
            // Scrolled to Clear all button, snap back to last task and launch it.
            mRecentsView.snapToPage(taskToLaunch, Math.toIntExact(duration), interpolator);
        }

        if (endTarget == HOME) {
            setShelfState(ShelfAnimState.CANCEL, LINEAR, 0);
            duration = Math.max(MIN_OVERSHOOT_DURATION, duration);
Loading