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

Commit a39544d5 authored by Zak Cohen's avatar Zak Cohen
Browse files

OverviewActions - Use launcher state to track modal state.

Test:local

Change-Id: I44e25b95095b9a7aac4b4172c9c91fbfbf4d9ec7
parent 2f04a9d2
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.launcher3.uioverrides;

import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;

import android.content.Intent;
@@ -219,7 +220,12 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {

        @Override
        protected boolean isRecentsInteractive() {
            return mActivity.isInState(OVERVIEW);
            return mActivity.isInState(OVERVIEW) || mActivity.isInState(OVERVIEW_MODAL_TASK);
        }

        @Override
        protected boolean isRecentsModal() {
            return mActivity.isInState(OVERVIEW_MODAL_TASK);
        }

        @Override
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW_BUTTONS;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
import static com.android.quickstep.views.RecentsView.TASK_MODALNESS;

import android.annotation.TargetApi;
import android.os.Build;
@@ -87,6 +88,11 @@ public final class RecentsViewStateController extends
                MultiValueAlpha.VALUE, buttonAlpha, LINEAR);
    }

    @Override
    FloatProperty<RecentsView> getTaskModalnessProperty() {
        return TASK_MODALNESS;
    }

    @Override
    FloatProperty<RecentsView> getContentAlphaProperty() {
        return CONTENT_ALPHA;
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.launcher3.uioverrides.states;

import android.content.res.Resources;
import android.graphics.Rect;

import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.quickstep.views.RecentsView;

/**
 * An Overview state that shows the current task in a modal fashion. Modal state is where the
 * current task is shown on its own without other tasks visible.
 */
public class OverviewModalTaskState extends OverviewState {

    private static final int STATE_FLAGS =
            FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY;

    public OverviewModalTaskState(int id) {
        super(id, ContainerType.OVERVIEW, STATE_FLAGS);
    }

    @Override
    public int getTransitionDuration(Launcher launcher) {
        return 100;
    }

    @Override
    public int getVisibleElements(Launcher launcher) {
        return OVERVIEW_BUTTONS;
    }

    @Override
    public float[] getOverviewScaleAndOffset(Launcher launcher) {
        Resources res = launcher.getBaseContext().getResources();

        Rect out = new Rect();
        launcher.<RecentsView>getOverviewPanel().getTaskSize(out);
        int taskHeight = out.height();

        float topMargin = res.getDimension(R.dimen.task_thumbnail_top_margin);
        float bottomMargin = res.getDimension(R.dimen.task_thumbnail_bottom_margin_with_actions);
        float newHeight = taskHeight + topMargin + bottomMargin;
        float scale = newHeight / taskHeight;

        return new float[] {scale, 0};
    }

    @Override
    public float getOverviewModalness() {
        return 1.0f;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -259,4 +259,11 @@ public class OverviewState extends LauncherState {
    public static OverviewState newSwitchState(int id) {
        return new QuickSwitchState(id);
    }

    /**
     *  New Overview substate that represents the overview in modal mode (one task shown on its own)
     */
    public static OverviewState newModalTaskState(int id) {
        return new OverviewModalTaskState(id);
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.launcher3.uioverrides.touchcontrollers;

import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
@@ -99,7 +98,7 @@ public class NavBarToHomeTouchController implements TouchController,
        if (!cameFromNavBar) {
            return false;
        }
        if (mStartState == OVERVIEW || mStartState == ALL_APPS) {
        if (mStartState.overviewUi || mStartState == ALL_APPS) {
            return true;
        }
        if (AbstractFloatingView.getTopOpenView(mLauncher) != null) {
@@ -129,7 +128,7 @@ public class NavBarToHomeTouchController implements TouchController,
    private void initCurrentAnimation() {
        long accuracy = (long) (getShiftRange() * 2);
        final PendingAnimation builder = new PendingAnimation(accuracy);
        if (mStartState == OVERVIEW) {
        if (mStartState.overviewUi) {
            RecentsView recentsView = mLauncher.getOverviewPanel();
            builder.setFloat(recentsView, ADJACENT_PAGE_OFFSET,
                    -mPullbackDistance / recentsView.getPageOffsetScale(), PULLBACK_INTERPOLATOR);
Loading