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

Commit b95c4ff8 authored by Jon Miranda's avatar Jon Miranda Committed by Android (Google) Code Review
Browse files

Merge "Add a way to stash/unstash transient taskbar." into tm-qpr-dev

parents 1b14a732 6163e2d3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -292,6 +292,7 @@
    <dimen name="taskbar_app_window_threshold">150dp</dimen>
    <dimen name="taskbar_home_overview_threshold">225dp</dimen>
    <dimen name="taskbar_catch_up_threshold">300dp</dimen>
    <dimen name="taskbar_nav_threshold">40dp</dimen>

    <!--  Taskbar 3 button spacing  -->
    <dimen name="taskbar_button_space_inbetween">24dp</dimen>
+40 −9
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
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.TaskbarManager.FLAG_HIDE_NAVBAR_WINDOW;
import static com.android.launcher3.testing.shared.ResourceUtils.getBoolByName;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
@@ -75,6 +77,7 @@ import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.AutohideSuspendFlag;
import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
import com.android.launcher3.testing.TestLogging;
@@ -303,7 +306,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                type,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_SLIPPERY
                        | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
                        | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                        | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                PixelFormat.TRANSLUCENT);
        windowLayoutParams.setTitle(WINDOW_TITLE);
        windowLayoutParams.packageName = getPackageName();
@@ -467,7 +472,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {

    @Override
    public void onDragEnd() {
        maybeSetTaskbarWindowNotFullscreen();
        onDragEndOrViewRemoved();
    }

    @Override
@@ -571,25 +576,34 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                .updateValue(darkIntensity);
    }

    /**
     * Called to update a {@link AutohideSuspendFlag} with a new value.
     */
    public void setAutohideSuspendFlag(@AutohideSuspendFlag int flag, boolean newValue) {
        mControllers.taskbarAutohideSuspendController.updateFlag(flag, newValue);
    }

    /**
     * Updates the TaskbarContainer to MATCH_PARENT vs original Taskbar size.
     */
    public void setTaskbarWindowFullscreen(boolean fullscreen) {
        mControllers.taskbarAutohideSuspendController.updateFlag(
                TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN, fullscreen);
        setAutohideSuspendFlag(FLAG_AUTOHIDE_SUSPEND_FULLSCREEN, fullscreen);
        mIsFullscreen = fullscreen;
        setTaskbarWindowHeight(fullscreen ? MATCH_PARENT : mLastRequestedNonFullscreenHeight);
    }

    /**
     * Reverts Taskbar window to its original size, if all floating views are closed and there is
     * no system drag operation in progress.
     * Called when drag ends or when a view is removed from the DragLayer.
     */
    void maybeSetTaskbarWindowNotFullscreen() {
        if (AbstractFloatingView.getAnyView(this, TYPE_ALL) == null
                && !mControllers.taskbarDragController.isSystemDragInProgress()) {
    void onDragEndOrViewRemoved() {
        boolean isDragInProgress = mControllers.taskbarDragController.isSystemDragInProgress();

        if (!isDragInProgress && !AbstractFloatingView.hasOpenView(this, TYPE_ALL)) {
            // Reverts Taskbar window to its original size
            setTaskbarWindowFullscreen(false);
        }

        setAutohideSuspendFlag(FLAG_AUTOHIDE_SUSPEND_DRAGGING, isDragInProgress);
    }

    public boolean isTaskbarWindowFullscreen() {
@@ -703,6 +717,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
            Task task = (Task) tag;
            ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key,
                    ActivityOptions.makeBasic());
            mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
        } else if (tag instanceof FolderInfo) {
            FolderIcon folderIcon = (FolderIcon) view;
            Folder folder = folderIcon.getFolder();
@@ -762,6 +777,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                    }

                    mControllers.uiController.onTaskbarIconLaunched(info);
                    mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
                } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
                    Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT)
                            .show();
@@ -771,6 +787,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        } else if (tag instanceof AppInfo) {
            startItemInfoActivity((AppInfo) tag);
            mControllers.uiController.onTaskbarIconLaunched((AppInfo) tag);
            mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
        } else {
            Log.e(TAG, "Unknown type clicked: " + tag);
        }
@@ -805,6 +822,20 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        return mControllers.taskbarStashController.onLongPressToUnstashTaskbar();
    }

    /**
     * Called when we want to unstash taskbar when user performs swipes up gesture.
     */
    public void onSwipeToUnstashTaskbar() {
        mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(false);
    }

    /**
     * Called when a transient Autohide flag suspend status changes.
     */
    public void onTransientAutohideSuspendFlagChanged(boolean isSuspended) {
        mControllers.taskbarStashController.updateTaskbarTimeout(isSuspended);
    }

    /**
     * Called when we detect a motion down or up/cancel in the nav region while stashed.
     * @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
+24 −1
Original line number Diff line number Diff line
@@ -33,21 +33,28 @@ import java.util.StringJoiner;
public class TaskbarAutohideSuspendController implements
        TaskbarControllers.LoggableTaskbarController {

    // Taskbar window is fullscreen.
    public static final int FLAG_AUTOHIDE_SUSPEND_FULLSCREEN = 1 << 0;
    // User is dragging item.
    public static final int FLAG_AUTOHIDE_SUSPEND_DRAGGING = 1 << 1;
    // User has touched down but has not lifted finger.
    public static final int FLAG_AUTOHIDE_SUSPEND_TOUCHING = 1 << 2;

    @IntDef(flag = true, value = {
            FLAG_AUTOHIDE_SUSPEND_FULLSCREEN,
            FLAG_AUTOHIDE_SUSPEND_DRAGGING,
            FLAG_AUTOHIDE_SUSPEND_TOUCHING,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface AutohideSuspendFlag {}

    private final TaskbarActivityContext mActivity;
    private final SystemUiProxy mSystemUiProxy;

    private @AutohideSuspendFlag int mAutohideSuspendFlags = 0;

    public TaskbarAutohideSuspendController(TaskbarActivityContext activity) {
        mActivity = activity;
        mSystemUiProxy = SystemUiProxy.INSTANCE.get(activity);
    }

@@ -59,12 +66,27 @@ public class TaskbarAutohideSuspendController implements
     * Adds or removes the given flag, then notifies system UI proxy whether to suspend auto-hide.
     */
    public void updateFlag(@AutohideSuspendFlag int flag, boolean enabled) {
        int flagsBefore = mAutohideSuspendFlags;
        if (enabled) {
            mAutohideSuspendFlags |= flag;
        } else {
            mAutohideSuspendFlags &= ~flag;
        }
        mSystemUiProxy.notifyTaskbarAutohideSuspend(mAutohideSuspendFlags != 0);
        if (flagsBefore == mAutohideSuspendFlags) {
            // Nothing has changed, no need to notify.
            return;
        }

        boolean isSuspended = isSuspended();
        mSystemUiProxy.notifyTaskbarAutohideSuspend(isSuspended);
        mActivity.onTransientAutohideSuspendFlagChanged(isSuspended);
    }

    /**
     * Returns true iff taskbar autohide is currently suspended.
     */
    public boolean isSuspended() {
        return mAutohideSuspendFlags != 0;
    }

    @Override
@@ -79,6 +101,7 @@ public class TaskbarAutohideSuspendController implements
        appendFlag(str, flags, FLAG_AUTOHIDE_SUSPEND_FULLSCREEN,
                "FLAG_AUTOHIDE_SUSPEND_FULLSCREEN");
        appendFlag(str, flags, FLAG_AUTOHIDE_SUSPEND_DRAGGING, "FLAG_AUTOHIDE_SUSPEND_DRAGGING");
        appendFlag(str, flags, FLAG_AUTOHIDE_SUSPEND_TOUCHING, "FLAG_AUTOHIDE_SUSPEND_TOUCHING");
        return str.toString();
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -115,6 +115,14 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
        return true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (mControllerCallbacks != null && ev.getAction() == MotionEvent.ACTION_OUTSIDE) {
            mControllerCallbacks.onActionOutsideEvent();
        }
        return super.onTouchEvent(ev);
    }

    @Override
    public void onViewRemoved(View child) {
        super.onViewRemoved(child);
+16 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.ViewTreeObserver;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.util.DimensionUtils;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.AnimatedFloat;

@@ -165,11 +166,25 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
            mControllers.taskbarInsetsController.updateInsetsTouchability(insetsInfo);
        }

        /**
         * Called whenever TaskbarDragLayer receives an ACTION_OUTSIDE event.
         */
        public void onActionOutsideEvent() {
            if (!DisplayController.isTransientTaskbar(mActivity)) {
                return;
            }
            if (mControllers.taskbarStashController.isStashed()) {
                return;
            }

            mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
        }

        /**
         * Called when a child is removed from TaskbarDragLayer.
         */
        public void onDragLayerViewRemoved() {
            mActivity.maybeSetTaskbarWindowNotFullscreen();
            mActivity.onDragEndOrViewRemoved();
        }

        /**
Loading