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

Commit 92f9d10c authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Hide task bar when folding before the new config renders the correct task bar" into main

parents 02848260 dfb334f1
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -36,12 +36,14 @@ import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN;
import static com.android.launcher3.taskbar.TaskbarDragLayerController.TASKBAR_REAPPEAR_DELAY_MS;
import static com.android.launcher3.testing.shared.ResourceUtils.getBoolByName;
import static com.android.quickstep.util.AnimUtils.completeRunnableListCallback;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_VISIBLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
@@ -77,6 +79,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.apppairs.AppPairIcon;
import com.android.launcher3.config.FeatureFlags;
@@ -1377,6 +1380,23 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        });
    }

    public void hideTaskbarWhenFolding() {
        AnimatedFloat alphaAnim = mControllers.taskbarDragLayerController.getTaskbarAlpha();
        alphaAnim.cancelAnimation();
        alphaAnim.updateValue(0);
        ObjectAnimator animator = alphaAnim.animateToValue(1).setDuration(0);
        animator.setStartDelay(TASKBAR_REAPPEAR_DELAY_MS);
        animator.start();
    }

    public void cancelHideTaskbarWhenFolding() {
        mControllers.taskbarDragLayerController.getTaskbarAlpha().cancelAnimation();
    }

    public void resetHideTaskbarWhenUnfolding() {
        mControllers.taskbarDragLayerController.getTaskbarAlpha().updateValue(1);
    }

    protected boolean isUserSetupComplete() {
        return mIsUserSetupComplete;
    }
+6 −0
Original line number Diff line number Diff line
@@ -44,6 +44,12 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
    private static final boolean DEBUG = SystemProperties.getBoolean(
            "persist.debug.draw_taskbar_debug_ui", false);

    // Delay to reset the task bar alpha back to 1 after fading it for transition from unfold to
    // fold. Normally this is not needed since the new task bar is recreated after fading, but in
    // case something goes wrong this provides a fallback mechanism to make sure the task bar is
    // visible after the transition finishes.
    public static final long TASKBAR_REAPPEAR_DELAY_MS = 2000;

    private final TaskbarActivityContext mActivity;
    private final TaskbarDragLayer mTaskbarDragLayer;
    private final int mFolderMargin;
+32 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING;
import static com.android.launcher3.util.DisplayController.TASKBAR_NOT_DESTROYED_TAG;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
import static com.android.quickstep.util.SystemActionConstants.ACTION_SHOW_TASKBAR;
@@ -43,6 +44,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.hardware.devicestate.DeviceStateManager;
import android.hardware.display.DisplayManager;
import android.net.Uri;
import android.os.Handler;
@@ -109,6 +111,7 @@ public class TaskbarManager {

    private final Context mContext;
    private final @Nullable Context mNavigationBarPanelContext;
    private final DeviceStateManager mDeviceStateManager;
    private WindowManager mWindowManager;
    private FrameLayout mTaskbarRootLayout;
    private boolean mAddedWindow;
@@ -175,7 +178,8 @@ public class TaskbarManager {
        }
    };

    UnfoldTransitionProgressProvider.TransitionProgressListener mUnfoldTransitionProgressListener =
    private final UnfoldTransitionProgressProvider.TransitionProgressListener
            mUnfoldTransitionProgressListener =
            new UnfoldTransitionProgressProvider.TransitionProgressListener() {
                @Override
                public void onTransitionStarted() {
@@ -204,6 +208,9 @@ public class TaskbarManager {
                }
            };

    private final DeviceStateManager.FoldStateListener mFoldStateListener;
    private Boolean mFolded;

    @SuppressLint("WrongConstant")
    public TaskbarManager(TouchInteractionService service) {
        Display display =
@@ -229,6 +236,29 @@ public class TaskbarManager {
                }
            };
        }
        // Temporary solution to mitigate the visual jump from folding the device. Currently, the
        // screen turns on much earlier than we receive the onConfigurationChanged callback or
        // receiving the correct device profile. While the ideal the solution is to align turning
        // the screen on after onConfigurationChanged (by either delaying turning on the screen or
        // figuring out what is causing the delay in getting onConfigurationChanged callback), one
        // easy temporary mitigation is to dimming the bar so that the visual jump isn't as glaring.
        mFoldStateListener = new DeviceStateManager.FoldStateListener(mContext, folded -> {
            boolean firstTime = mFolded == null;
            if (mTaskbarActivityContext == null) {
                return;
            }
            if (!firstTime && mFolded.booleanValue() != folded) {
                mTaskbarActivityContext.cancelHideTaskbarWhenFolding();
            }
            mFolded = folded;
            if (folded && !firstTime) {
                mTaskbarActivityContext.hideTaskbarWhenFolding();
            } else {
                mTaskbarActivityContext.resetHideTaskbarWhenUnfolding();
            }
        });
        mDeviceStateManager = mContext.getSystemService(DeviceStateManager.class);
        mDeviceStateManager.registerCallback(MAIN_EXECUTOR, mFoldStateListener);
        mNavButtonController = new TaskbarNavButtonController(service,
                SystemUiProxy.INSTANCE.get(mContext), new Handler(),
                AssistUtils.newInstance(mContext));
@@ -588,6 +618,7 @@ public class TaskbarManager {
        Log.d(TASKBAR_NOT_DESTROYED_TAG, "unregistering component callbacks from destroy().");
        mContext.unregisterComponentCallbacks(mComponentCallbacks);
        mContext.unregisterReceiver(mShutdownReceiver);
        mDeviceStateManager.unregisterCallback(mFoldStateListener);
    }

    public @Nullable TaskbarActivityContext getCurrentActivityContext() {