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

Commit 228153d9 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Updating landscape layout for launcher/quickstep

> Hotseat is tied to navbar (on left in seascape)
> Search box shows up in Overview (clicking it would crash for now)
> All-apps is no longer fullscreen in landscape
> Recents cards are appropriately scaled down
> Hotseat is visible in Overview

Bug: 70179916
Change-Id: I53149eaeac9557e8a01021b7e2d139f3d6ceef37
parent 07b1d670
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -24,4 +24,7 @@
    <dimen name="quickstep_fling_min_velocity">250dp</dimen>

    <dimen name="workspace_overview_offset_x">-30dp</dimen>

    <!-- TODO: This can be calculated using other resource values -->
    <dimen name="all_apps_search_box_full_height">90dp</dimen>
</resources>
+11 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public class AllAppsState extends LauncherState {
    };

    public AllAppsState(int id) {
        super(id, ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, 0f, STATE_FLAGS);
        super(id, ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, STATE_FLAGS);
    }

    @Override
@@ -60,6 +60,11 @@ public class AllAppsState extends LauncherState {
        return launcher.getString(R.string.all_apps_button_label);
    }

    @Override
    public float getVerticalProgress(Launcher launcher) {
        return 0f;
    }

    @Override
    public View getFinalFocus(Launcher launcher) {
        return launcher.getAppsView();
@@ -75,4 +80,9 @@ public class AllAppsState extends LauncherState {
    public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
        return PAGE_ALPHA_PROVIDER;
    }

    @Override
    public float getHoseatAlpha(Launcher launcher) {
        return launcher.getDeviceProfile().isVerticalBarLayout() ? 0 : 1;
    }
}
+38 −12
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@
package com.android.launcher3.uioverrides;

import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;

import android.graphics.Rect;
import android.view.View;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
@@ -38,7 +40,7 @@ public class OverviewState extends LauncherState {
    private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED;

    public OverviewState(int id) {
        super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
        super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
    }

    @Override
@@ -58,11 +60,6 @@ public class OverviewState extends LauncherState {
        return getScaleAndTranslationForPageRect(launcher, overlap, pageRect);
    }

    @Override
    public float getHoseatAlpha(Launcher launcher) {
        return launcher.getDeviceProfile().isVerticalBarLayout() ? 0 : 1;
    }

    @Override
    public void onStateEnabled(Launcher launcher) {
        RecentsView rv = launcher.getOverviewPanel();
@@ -75,28 +72,57 @@ public class OverviewState extends LauncherState {
        rv.setOverviewStateEnabled(false);
    }

    @Override
    public float getVerticalProgress(Launcher launcher) {
        DeviceProfile grid = launcher.getDeviceProfile();
        if (!grid.isVerticalBarLayout()) {
            return 1f;
        }

        float total = grid.heightPx;
        float searchHeight = total - grid.availableHeightPx +
                launcher.getResources().getDimension(R.dimen.all_apps_search_box_full_height);
        return 1 - (searchHeight / total);
    }

    @Override
    public View getFinalFocus(Launcher launcher) {
        return launcher.getOverviewPanel();
    }

    public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
        final int centerPage = launcher.getWorkspace().getNextPage();
        return new PageAlphaProvider(ACCEL_2) {
            @Override
            public float getPageAlpha(int pageIndex) {
                return  pageIndex != centerPage ? 0 : 1f;
            }
        };
    }

    public static float[] getScaleAndTranslationForPageRect(Launcher launcher, float offsetX,
            Rect pageRect) {
        Workspace ws = launcher.getWorkspace();
        float childWidth = ws.getNormalChildWidth();
        float childHeight = ws.getNormalChildHeight();

        Rect insets = launcher.getDragLayer().getInsets();
        float scale = pageRect.width() / childWidth;

        float translationX = offsetX / scale;
        if (Utilities.isRtl(launcher.getResources())) {
            translationX = -translationX;
        }
        float scale = Math.min(pageRect.width() / childWidth, pageRect.height() / childHeight);

        float halfHeight = ws.getHeight() / 2;
        float childTop = halfHeight - scale * (halfHeight - ws.getPaddingTop() - insets.top);
        float translationY = pageRect.top - childTop;

        float halfWidth = ws.getWidth() / 2;
        float translationX;
        if (Utilities.isRtl(launcher.getResources())) {
            float childRight = halfWidth + scale * (halfWidth - ws.getPaddingRight() - insets.right);
            translationX = childRight - pageRect.right - offsetX / scale;
        } else {
            float childLeft = halfWidth - scale * (halfWidth - ws.getPaddingLeft() - insets.left);
            translationX = pageRect.left - childLeft + offsetX / scale;
        }

        return new float[] {scale, translationX, translationY};
    }
}
+9 −1
Original line number Diff line number Diff line
@@ -38,7 +38,15 @@ public class OverviewSwipeUpController extends VerticalSwipeController {

    @Override
    protected boolean shouldInterceptTouch(MotionEvent ev) {
        return mLauncher.isInState(OVERVIEW) && mLauncher.getDragLayer().isEventOverHotseat(ev);
        if (!mLauncher.isInState(OVERVIEW)) {
            return false;
        }
        if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
            return ev.getY() >
                    mLauncher.getDragLayer().getHeight() * OVERVIEW.getVerticalProgress(mLauncher);
        } else {
            return mLauncher.getDragLayer().isEventOverHotseat(ev);
        }
    }

    @Override
+22 −25
Original line number Diff line number Diff line
@@ -318,32 +318,17 @@ public class TwoStepSwipeController extends AnimatorListenerAdapter
    public void onDragEnd(float velocity, boolean fling) {
        mDragPauseDetector.addDisabledFlags(FLAG_OVERVIEW_DISABLED_FLING);

        final long animationDuration;
        final int logAction;
        LauncherState targetState;
        final float progress = mCurrentAnimation.getProgressFraction();

        if (fling) {
            logAction = Touch.FLING;
            if (velocity < 0) {
                targetState = ALL_APPS;
                animationDuration = SwipeDetector.calculateDuration(velocity,
                        mToState == ALL_APPS ? (1 - progress) : progress);
            } else {
                targetState = NORMAL;
                animationDuration = SwipeDetector.calculateDuration(velocity,
                        mToState == ALL_APPS ? progress : (1 - progress));
            }
            targetState = velocity < 0 ? ALL_APPS : NORMAL;
            // snap to top or bottom using the release velocity
        } else {
            logAction = Touch.SWIPE;
            if (progress > SUCCESS_TRANSITION_PROGRESS) {
                targetState = mToState;
                animationDuration = SwipeDetector.calculateDuration(velocity, 1 - progress);
            } else {
                targetState = mFromState;
                animationDuration = SwipeDetector.calculateDuration(velocity, progress);
            }
            targetState = (progress > SUCCESS_TRANSITION_PROGRESS) ? mToState : mFromState;
        }

        if (fling && targetState == ALL_APPS) {
@@ -352,20 +337,32 @@ public class TwoStepSwipeController extends AnimatorListenerAdapter
                h.animateToFinalPosition(0 /* pos */, 1 /* startValue */);
            }
        }
        mCurrentAnimation.setEndAction(() -> {
            LauncherState finalState = targetState;

        float endProgress;

        if (mDragPauseDetector.isTriggered() && targetState == NORMAL) {
                finalState = OVERVIEW;
            targetState = OVERVIEW;
            endProgress = OVERVIEW.getVerticalProgress(mLauncher);
            if (mFromState == NORMAL) {
                endProgress = 1 - endProgress;
            }
            onSwipeInteractionCompleted(finalState, logAction);
        });
        } else if (targetState == mToState) {
            endProgress = 1;
        } else {
            endProgress = 0;
        }

        LauncherState targetStateFinal = targetState;
        mCurrentAnimation.setEndAction(() ->
                onSwipeInteractionCompleted(targetStateFinal, logAction));

        float nextFrameProgress = Utilities.boundToRange(
                progress + velocity * SINGLE_FRAME_MS / getShiftRange(), 0f, 1f);

        ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
        anim.setFloatValues(nextFrameProgress, targetState == mToState ? 1f : 0f);
        anim.setDuration(animationDuration);
        anim.setFloatValues(nextFrameProgress, endProgress);
        anim.setDuration(
                SwipeDetector.calculateDuration(velocity, Math.abs(endProgress - progress)));
        anim.setInterpolator(scrollInterpolatorForVelocity(velocity));
        anim.start();
    }
Loading