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

Commit ae72b46b authored by Tony Wickham's avatar Tony Wickham
Browse files

Replace taskbar hotseat with real hotseat when folder is open

- Seamlessly show real hotseat and hide taskbar hotseat, while
  keeping rest of taskbar visible
- Update MultiValueAlpha to allow for taking max alpha instead
  of blending, and use that for Hotseat
- Fix folder open bounds on home screen when taskbar is present

Test: Open folder from taskbar on home, can drag out items
Bug: 182079330
Bug: 171917176
Change-Id: I7c1983e3219b1341cf233260f0ccac9051c4dc14
parent 462384db
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@color/taskbar_background"
        android:gravity="center"
        android:animateLayoutChanges="true"/>
        android:gravity="center"/>

</com.android.launcher3.taskbar.TaskbarContainerView>
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -315,6 +315,10 @@ public abstract class BaseQuickstepLauncher extends Launcher
    @Override
    public void onDragLayerHierarchyChanged() {
        onLauncherStateOrFocusChanged();

        if (mTaskbarController != null) {
            mTaskbarController.onLauncherDragLayerHierarchyChanged();
        }
    }

    @Override
+69 −16
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;

import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_REPLACE_TASKBAR_WITH_HOTSEAT;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
@@ -40,6 +42,7 @@ import androidx.annotation.Nullable;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.Hotseat;
import com.android.launcher3.LauncherState;
import com.android.launcher3.QuickstepAppTransitionManagerImpl;
import com.android.launcher3.R;
@@ -144,7 +147,33 @@ public class TaskbarController {
                        ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key,
                                ActivityOptions.makeBasic());
                    } else if (tag instanceof FolderInfo) {
                        if (mLauncher.hasBeenResumed()) {
                            FolderInfo folderInfo = (FolderInfo) tag;
                            onClickedOnFolderFromHome(folderInfo);
                        } else {
                            FolderIcon folderIcon = (FolderIcon) view;
                            onClickedOnFolderInApp(folderIcon);
                        }
                    } else {
                        ItemClickHandler.INSTANCE.onClick(view);
                    }

                    AbstractFloatingView.closeAllOpenViews(
                            mTaskbarContainerView.getTaskbarActivityContext());
                };
            }

            // Open the real folder in Launcher.
            private void onClickedOnFolderFromHome(FolderInfo folderInfo) {
                alignRealHotseatWithTaskbar();

                FolderIcon folderIcon = (FolderIcon) mLauncher.getHotseat()
                        .getFirstItemMatch((info, v) -> info == folderInfo);
                folderIcon.post(folderIcon::performClick);
            }

            // Open the Taskbar folder, and handle clicks on folder items.
            private void onClickedOnFolderInApp(FolderIcon folderIcon) {
                Folder folder = folderIcon.getFolder();

                setTaskbarWindowFullscreen(true);
@@ -160,13 +189,6 @@ public class TaskbarController {
                        return false;
                    });
                });
                    } else {
                        ItemClickHandler.INSTANCE.onClick(view);
                    }

                    AbstractFloatingView.closeAllOpenViews(
                            mTaskbarContainerView.getTaskbarActivityContext());
                };
            }

            @Override
@@ -306,6 +328,7 @@ public class TaskbarController {
            mAnimator = createAnimToLauncher(null, duration);
        } else {
            mAnimator = createAnimToApp(duration);
            replaceTaskbarWithHotseatOrViceVersa();
        }
        mAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
@@ -355,6 +378,7 @@ public class TaskbarController {
            @Override
            public void onAnimationStart(Animator animation) {
                mTaskbarView.updateHotseatItemsVisibility();
                setReplaceTaskbarWithHotseat(false);
            }
        });
        return anim.buildAnim();
@@ -451,6 +475,35 @@ public class TaskbarController {
                mTaskbarView.getHeight() - hotseatBounds.bottom);
    }

    /**
     * A view was added or removed from DragLayer, check if we need to hide our hotseat copy and
     * show the real one instead.
     */
    public void onLauncherDragLayerHierarchyChanged() {
        replaceTaskbarWithHotseatOrViceVersa();
    }

    private void replaceTaskbarWithHotseatOrViceVersa() {
        boolean replaceTaskbarWithHotseat = AbstractFloatingView.getTopOpenViewWithType(mLauncher,
                TYPE_ALL & TYPE_REPLACE_TASKBAR_WITH_HOTSEAT) != null;
        if (!mLauncher.hasBeenResumed()) {
            replaceTaskbarWithHotseat = false;
        }
        setReplaceTaskbarWithHotseat(replaceTaskbarWithHotseat);
    }

    private void setReplaceTaskbarWithHotseat(boolean replaceTaskbarWithHotseat) {
        Hotseat hotseat = mLauncher.getHotseat();
        if (replaceTaskbarWithHotseat) {
            alignRealHotseatWithTaskbar();
            hotseat.getReplaceTaskbarAlpha().setValue(1f);
            mTaskbarView.setHotseatViewsHidden(true);
        } else {
            hotseat.getReplaceTaskbarAlpha().setValue(0f);
            mTaskbarView.setHotseatViewsHidden(false);
        }
    }

    private float getTaskbarScaleOnHome() {
        return 1f / mTaskbarContainerView.getTaskbarActivityContext().getTaskbarIconScale();
    }
+21 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.launcher3.taskbar;

import android.animation.LayoutTransition;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
@@ -63,6 +64,7 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
    private TaskbarController.TaskbarViewCallbacks mControllerCallbacks;

    // Initialized in init().
    private LayoutTransition mLayoutTransition;
    private int mHotseatStartIndex;
    private int mHotseatEndIndex;
    private View mHotseatRecentsDivider;
@@ -76,6 +78,7 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
    private boolean mIsDraggingItem;
    // Only non-null when the corresponding Folder is open.
    private @Nullable FolderIcon mLeaveBehindFolderIcon;
    private boolean mIsHotseatHidden;

    public TaskbarView(@NonNull Context context) {
        this(context, null);
@@ -107,6 +110,9 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
    }

    protected void init(int numHotseatIcons, int numRecentIcons) {
        mLayoutTransition = new LayoutTransition();
        setLayoutTransitionsEnabled(true);

        mHotseatStartIndex = 0;
        mHotseatEndIndex = mHotseatStartIndex + numHotseatIcons - 1;
        updateHotseatItems(new ItemInfo[numHotseatIcons]);
@@ -119,6 +125,10 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
        updateRecentTasks(new Task[numRecentIcons]);
    }

    private void setLayoutTransitionsEnabled(boolean enabled) {
        setLayoutTransition(enabled ? mLayoutTransition : null);
    }

    protected void cleanup() {
        removeAllViews();
    }
@@ -206,9 +216,19 @@ public class TaskbarView extends LinearLayout implements FolderIcon.FolderIconPa
        }
    }

    /**
     * Hides or shows the hotseat items immediately (without layout transitions).
     */
    protected void setHotseatViewsHidden(boolean hidden) {
        mIsHotseatHidden = hidden;
        setLayoutTransitionsEnabled(false);
        updateHotseatItemsVisibility();
        setLayoutTransitionsEnabled(true);
    }

    private void updateHotseatItemVisibility(View hotseatView) {
        if (hotseatView.getTag() != null) {
            hotseatView.setVisibility(VISIBLE);
            hotseatView.setVisibility(mIsHotseatHidden ? INVISIBLE : VISIBLE);
        } else {
            int oldVisibility = hotseatView.getVisibility();
            int newVisibility = mControllerCallbacks.getEmptyHotseatViewVisibility();
+3 −0
Original line number Diff line number Diff line
@@ -98,6 +98,9 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
    public static final int TYPE_HIDE_BACK_BUTTON = TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE
            | TYPE_SNACKBAR | TYPE_WIDGET_RESIZE_FRAME | TYPE_LISTENER;

    // When these types of floating views are open, hide the taskbar hotseat and show the real one.
    public static final int TYPE_REPLACE_TASKBAR_WITH_HOTSEAT = TYPE_FOLDER | TYPE_ACTION_POPUP;

    public static final int TYPE_ACCESSIBLE = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE & ~TYPE_LISTENER
            & ~TYPE_ALL_APPS_EDU;

Loading