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

Commit 514dfa2d authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Changing actions button visibility to match clear-all button

> Removing translation when animating actions button

Change-Id: I6875e03f9c55f00232c605743348175ea132cb15
parent c2203b13
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -15,18 +15,22 @@
 */
package com.android.launcher3.uioverrides;

import static com.android.launcher3.LauncherState.RECENTS_CLEAR_ALL_BUTTON;
import static com.android.launcher3.LauncherState.OVERVIEW_BUTTONS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE;
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;

import android.annotation.TargetApi;
import android.os.Build;
import android.util.FloatProperty;
import android.view.View;
import android.view.animation.Interpolator;

import androidx.annotation.NonNull;

import com.android.launcher3.Launcher;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.PendingAnimation;
@@ -44,7 +48,7 @@ import com.android.quickstep.views.RecentsView;
public final class RecentsViewStateController extends
        BaseRecentsViewStateController<LauncherRecentsView> {

    public RecentsViewStateController(Launcher launcher) {
    public RecentsViewStateController(BaseQuickstepLauncher launcher) {
        super(launcher);
    }

@@ -55,7 +59,7 @@ public final class RecentsViewStateController extends
            mRecentsView.updateEmptyMessage();
            mRecentsView.resetTaskVisuals();
        }
        setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, state.getVisibleElements(mLauncher));
        setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, state, LINEAR);
        mRecentsView.setFullscreenProgress(state.getOverviewFullscreenProgress());
    }

@@ -73,15 +77,22 @@ public final class RecentsViewStateController extends
                    AnimationSuccessListener.forRunnable(mRecentsView::resetTaskVisuals));
        }

        setAlphas(builder, toState.getVisibleElements(mLauncher));
        setAlphas(builder, toState,
                config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
        builder.setFloat(mRecentsView, FULLSCREEN_PROGRESS,
                toState.getOverviewFullscreenProgress(), LINEAR);
    }

    private void setAlphas(PropertySetter propertySetter, int visibleElements) {
        boolean hasClearAllButton = (visibleElements & RECENTS_CLEAR_ALL_BUTTON) != 0;
    private void setAlphas(PropertySetter propertySetter, LauncherState state,
            Interpolator actionInterpolator) {
        float buttonAlpha = (state.getVisibleElements(mLauncher) & OVERVIEW_BUTTONS) != 0 ? 1 : 0;
        propertySetter.setFloat(mRecentsView.getClearAllButton(), ClearAllButton.VISIBILITY_ALPHA,
                hasClearAllButton ? 1f : 0f, LINEAR);
                buttonAlpha, LINEAR);

        View actionsView = mLauncher.getActionsView();
        if (actionsView != null) {
            propertySetter.setViewAlpha(actionsView, buttonAlpha, actionInterpolator);
        }
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ public class BackgroundAppState extends OverviewState {
    @Override
    public int getVisibleElements(Launcher launcher) {
        return super.getVisibleElements(launcher)
                & ~RECENTS_CLEAR_ALL_BUTTON & ~VERTICAL_SWIPE_INDICATOR;
                & ~OVERVIEW_BUTTONS & ~VERTICAL_SWIPE_INDICATOR;
    }

    @Override
+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TR
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.states.StateAnimationConfig;

public class OverviewPeekState extends OverviewState {
@@ -37,6 +38,9 @@ public class OverviewPeekState extends OverviewState {
        ScaleAndTranslation result = super.getOverviewScaleAndTranslation(launcher);
        result.translationX = NORMAL.getOverviewScaleAndTranslation(launcher).translationX
                - launcher.getResources().getDimension(R.dimen.overview_peek_distance);
        if (Utilities.isRtl(launcher.getResources())) {
            result.translationX = -result.translationX;
        }
        return result;
    }

+4 −4
Original line number Diff line number Diff line
@@ -165,14 +165,14 @@ public class OverviewState extends LauncherState {
    @Override
    public int getVisibleElements(Launcher launcher) {
        if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(launcher)) {
            return RECENTS_CLEAR_ALL_BUTTON;
            return OVERVIEW_BUTTONS;
        } else if (launcher.getDeviceProfile().isVerticalBarLayout()) {
            return VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON;
            return VERTICAL_SWIPE_INDICATOR | OVERVIEW_BUTTONS;
        } else {
            boolean hasAllAppsHeaderExtra = launcher.getAppsView() != null
                    && launcher.getAppsView().getFloatingHeaderView().hasVisibleContent();
            return HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR | RECENTS_CLEAR_ALL_BUTTON |
                    (hasAllAppsHeaderExtra ? ALL_APPS_HEADER_EXTRA : HOTSEAT_ICONS);
            return HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR | OVERVIEW_BUTTONS
                    | (hasAllAppsHeaderExtra ? ALL_APPS_HEADER_EXTRA : HOTSEAT_ICONS);
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.RECENTS_CLEAR_ALL_BUTTON;
import static com.android.launcher3.LauncherState.OVERVIEW_BUTTONS;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
import static com.android.launcher3.QuickstepAppTransitionManagerImpl.ALL_APPS_PROGRESS_OFF_SCREEN;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
@@ -323,7 +323,7 @@ public class LauncherRecentsView extends RecentsView<BaseQuickstepLauncher>
        if (enabled) {
            LauncherState state = mActivity.getStateManager().getState();
            boolean hasClearAllButton = (state.getVisibleElements(mActivity)
                    & RECENTS_CLEAR_ALL_BUTTON) != 0;
                    & OVERVIEW_BUTTONS) != 0;
            setDisallowScrollToClearAll(!hasClearAllButton);
        }
    }
Loading