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

Commit d09ebe66 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Enable live tile in 3 button mode

- Previously we rely on whether launcher is resumed as a signal to see what "toggle" means. This no longer works since launcher is not resumed in Overview. Instead, we need to check the live tile signals.
- Use screenshot doesn't propagate after setting a new current task. So followed the logic around mRunningTaskIconScaledDown to work it out.
- Get rid of NavigationModeFeatureFlag, pending on 3rd party launcher change ag/14409355

Fixes: 185934639
Test: (1) Toggle overview from home screen and toggle back to fullscreen. (2) Toggle overview from app and keep toggling.

Change-Id: Iffaea18afb2179b5bb7dadda49e56efefa5658bc
parent e526fd6a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -20,11 +20,11 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON;
import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.NO_OFFSET;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS;
import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;

import android.animation.AnimatorSet;
@@ -185,7 +185,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
    @Override
    protected void onScreenOff() {
        super.onScreenOff();
        if (LIVE_TILE.get()) {
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            RecentsView recentsView = getOverviewPanel();
            recentsView.finishRecentsAnimation(true /* toRecents */, null);
        }
@@ -483,7 +483,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
        super.onDisplayInfoChanged(context, info, flags);
        // When changing screens with live tile active, finish the recents animation to close
        // overview as it should be an interim state
        if ((flags & CHANGE_ACTIVE_SCREEN) != 0 && LIVE_TILE.get()) {
        if ((flags & CHANGE_ACTIVE_SCREEN) != 0 && ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            RecentsView recentsView = getOverviewPanel();
            recentsView.finishRecentsAnimation(/* toRecents= */ true, null);
        }
+3 −3
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@ import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_EDU;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE;
import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;

import android.animation.ValueAnimator;
@@ -140,7 +140,7 @@ public class NavBarToHomeTouchController implements TouchController,
            AnimatorControllerWithResistance.createRecentsResistanceFromOverviewAnim(mLauncher,
                    builder);

            if (LIVE_TILE.get()) {
            if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
                builder.addOnFrameCallback(recentsView::redrawLiveTile);
            }

@@ -189,7 +189,7 @@ public class NavBarToHomeTouchController implements TouchController,
        boolean success = interpolatedProgress >= SUCCESS_TRANSITION_PROGRESS
                || (velocity < 0 && fling);
        if (success) {
            if (LIVE_TILE.get()) {
            if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
                RecentsView recentsView = mLauncher.getOverviewPanel();
                recentsView.switchToScreenshot(null,
                        () -> recentsView.finishRecentsAnimation(true /* toRecents */, null));
+8 −8
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAG
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE;
@@ -45,7 +46,6 @@ import static com.android.quickstep.GestureState.STATE_END_TARGET_SET;
import static com.android.quickstep.GestureState.STATE_RECENTS_ANIMATION_CANCELED;
import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHED;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME;
@@ -327,7 +327,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        mStateCallback.runOnceAtState(STATE_HANDLER_INVALIDATED | STATE_FINISH_WITH_NO_END,
                this::resetStateForAnimationCancel);

        if (!LIVE_TILE.get()) {
        if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            mStateCallback.addChangeListener(STATE_APP_CONTROLLER_RECEIVED | STATE_LAUNCHER_PRESENT
                            | STATE_SCREENSHOT_VIEW_SHOWN | STATE_CAPTURE_SCREENSHOT,
                    (b) -> mRecentsView.setRunningTaskHidden(!b));
@@ -490,7 +490,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    }

    private void onDeferredActivityLaunch() {
        if (LIVE_TILE.get()) {
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            mActivityInterface.switchRunningTaskViewToScreenshot(
                    null, () -> {
                        mTaskAnimationManager.finishRunningRecentsAnimation(true /* toHome */);
@@ -1430,7 +1430,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    }

    private void invalidateHandler() {
        if (!LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode()
        if (!ENABLE_QUICKSTEP_LIVE_TILE.get() || !mActivityInterface.isInLiveTileMode()
                || mGestureState.getEndTarget() != RECENTS) {
            mInputConsumerProxy.destroy();
            mTaskAnimationManager.setLiveTileCleanUpHandler(null);
@@ -1475,7 +1475,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
     */
    private void resetLauncherListeners() {
        // Reset the callback for deferred activity launches
        if (!LIVE_TILE.get()) {
        if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            mActivityInterface.setOnDeferredActivityLaunchCallback(null);
        }
        mActivity.getRootView().setOnApplyWindowInsetsListener(null);
@@ -1499,7 +1499,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
            mStateCallback.setStateOnUiThread(STATE_SCREENSHOT_CAPTURED);
        } else {
            final int runningTaskId = mGestureState.getRunningTaskId();
            final boolean refreshView = !LIVE_TILE.get() /* refreshView */;
            final boolean refreshView = !ENABLE_QUICKSTEP_LIVE_TILE.get() /* refreshView */;
            boolean finishTransitionPosted = false;
            if (mRecentsAnimationController != null) {
                // Update the screenshot of the task
@@ -1555,7 +1555,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
    }

    private void finishCurrentTransitionToRecents() {
        if (LIVE_TILE.get()) {
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED);
            if (mRecentsAnimationController != null) {
                mRecentsAnimationController.detachNavigationBarFromApp(true);
@@ -1609,7 +1609,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
        }
        endLauncherTransitionController();
        mRecentsView.onSwipeUpAnimationSuccess();
        if (LIVE_TILE.get()) {
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            mTaskAnimationManager.setLiveTileCleanUpHandler(mInputConsumerProxy::destroy);
            mTaskAnimationManager.enableLiveTileRestartListener();
        }
+7 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.quickstep;

import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
import static com.android.quickstep.fallback.RecentsState.BACKGROUND_APP;
import static com.android.quickstep.fallback.RecentsState.DEFAULT;
@@ -105,8 +106,12 @@ public final class FallbackActivityInterface extends
    @Override
    public RecentsView getVisibleRecentsView() {
        RecentsActivity activity = getCreatedActivity();
        if (activity != null && activity.hasBeenResumed()) {
            return activity.getOverviewPanel();
        if (activity != null) {
            RecentsView recentsView = activity.getOverviewPanel();
            if (activity.hasBeenResumed() || (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode()
                    && recentsView.getRunningTaskId() == -1)) {
                return recentsView;
            }
        }
        return null;
    }
+19 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.QUICK_SWITCH;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;

import android.animation.Animator;
@@ -184,16 +185,24 @@ public final class LauncherActivityInterface extends
    @Override
    public RecentsView getVisibleRecentsView() {
        Launcher launcher = getVisibleLauncher();
        return launcher != null && launcher.getStateManager().getState().overviewUi
        RecentsView recentsView =
                launcher != null && launcher.getStateManager().getState().overviewUi
                        ? launcher.getOverviewPanel() : null;
        if (recentsView == null || (!launcher.hasBeenResumed()
                && recentsView.getRunningTaskId() == -1)) {
            // If live tile has ended, return null.
            return null;
        }
        return recentsView;
    }

    @Nullable
    @UiThread
    private Launcher getVisibleLauncher() {
        Launcher launcher = getCreatedActivity();
        return (launcher != null) && launcher.isStarted() && launcher.hasBeenResumed()
                ? launcher : null;
        return (launcher != null) && launcher.isStarted()
                && ((ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode())
                || launcher.hasBeenResumed()) ? launcher : null;
    }

    @Override
@@ -202,6 +211,12 @@ public final class LauncherActivityInterface extends
        if (launcher == null) {
            return false;
        }
        if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isInLiveTileMode()) {
            RecentsView recentsView = getVisibleRecentsView();
            if (recentsView == null) {
                return false;
            }
        }

        closeOverlay();
        launcher.getStateManager().goToState(OVERVIEW,
Loading