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

Commit d8f81e9b authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge changes from topic "allapps_bottomsheet_motion" into tm-dev

* changes:
  Tune AllApps bottom sheet VisD and motion
  Put taskbar all apps in separate overlay window and stash taskbar.
parents bfb275bf b8c22e11
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -14,12 +14,12 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.launcher3.taskbar.TaskbarAllAppsSlideInView
<com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.android.launcher3.taskbar.TaskbarAllAppsContainerView
    <com.android.launcher3.taskbar.allapps.TaskbarAllAppsContainerView
        android:id="@+id/apps_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
@@ -52,5 +52,5 @@
        </com.android.launcher3.allapps.FloatingHeaderView>

        <include layout="@layout/all_apps_fast_scroller" />
    </com.android.launcher3.taskbar.TaskbarAllAppsContainerView>
</com.android.launcher3.taskbar.TaskbarAllAppsSlideInView>
    </com.android.launcher3.taskbar.allapps.TaskbarAllAppsContainerView>
</com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView>
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.taskbar;

import android.content.Context;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;

import java.util.ArrayList;
import java.util.List;

// TODO(b/218912746): Share more behavior to avoid all apps context depending directly on taskbar.
/** Base for common behavior between taskbar window contexts. */
public abstract class BaseTaskbarContext extends ContextThemeWrapper implements ActivityContext,
        DeviceProfileListenable {

    protected final LayoutInflater mLayoutInflater;
    private final List<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();

    protected DeviceProfile mDeviceProfile;

    public BaseTaskbarContext(Context windowContext) {
        super(windowContext, Themes.getActivityThemeRes(windowContext));
        mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);
    }

    @Override
    public final LayoutInflater getLayoutInflater() {
        return mLayoutInflater;
    }

    @Override
    public final DeviceProfile getDeviceProfile() {
        return mDeviceProfile;
    }

    @Override
    public final List<OnDeviceProfileChangeListener> getOnDeviceProfileChangeListeners() {
        return mDPChangeListeners;
    }

    /** Updates the {@link DeviceProfile} instance to the latest representation of the screen. */
    public abstract void updateDeviceProfile(DeviceProfile dp);

    /** Callback invoked when a drag is initiated within this context. */
    public abstract void onDragStart();

    /** Callback invoked when a popup is shown or closed within this context. */
    public abstract void onPopupVisibilityChanged(boolean isVisible);
}
+15 −53
Original line number Diff line number Diff line
@@ -42,10 +42,8 @@ import android.os.Process;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.RoundedCorner;
import android.view.View;
import android.view.WindowManager;
@@ -58,11 +56,8 @@ import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
@@ -72,11 +67,10 @@ 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.allapps.TaskbarAllAppsController;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.SettingsCache;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.ActivityContext;
@@ -89,16 +83,13 @@ import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * The {@link ActivityContext} with which we inflate Taskbar-related Views. This allows UI elements
 * that are used by both Launcher and Taskbar (such as Folder) to reference a generic
 * ActivityContext and BaseDragLayer instead of the Launcher activity and its DragLayer.
 */
public class TaskbarActivityContext extends ContextThemeWrapper implements ActivityContext,
        DeviceProfileListenable {
public class TaskbarActivityContext extends BaseTaskbarContext {

    private static final boolean ENABLE_THREE_BUTTON_TASKBAR =
            SystemProperties.getBoolean("persist.debug.taskbar_three_button", false);
@@ -106,13 +97,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ

    private static final String WINDOW_TITLE = "Taskbar";

    private final LayoutInflater mLayoutInflater;
    private final TaskbarDragLayer mDragLayer;
    private final TaskbarAllAppsContainerView mAppsView;
    private final TaskbarControllers mControllers;
    private final List<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();

    private DeviceProfile mDeviceProfile;

    private final WindowManager mWindowManager;
    private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
@@ -135,14 +121,12 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
    private boolean mBindingItems = false;

    private final TaskbarShortcutMenuAccessibilityDelegate mAccessibilityDelegate;
    private final OnboardingPrefs<TaskbarActivityContext> mOnboardingPrefs;

    public TaskbarActivityContext(Context windowContext, DeviceProfile dp,
            TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
            unfoldTransitionProgressProvider) {
        super(windowContext, Themes.getActivityThemeRes(windowContext));
        super(windowContext);
        mDeviceProfile = dp;
        mOnboardingPrefs = new OnboardingPrefs<>(this, Utilities.getPrefs(this));

        mNavMode = SysUINavigationMode.getMode(windowContext);
        mImeDrawsImeNavBar = SysUINavigationMode.getImeDrawsImeNavBar(windowContext);
@@ -158,8 +142,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ

        mTaskbarHeightForIme = resources.getDimensionPixelSize(R.dimen.taskbar_ime_size);

        mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);

        // Inflate views.
        mDragLayer = (TaskbarDragLayer) mLayoutInflater.inflate(
                R.layout.taskbar, null, false);
@@ -168,11 +150,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        FrameLayout navButtonsView = mDragLayer.findViewById(R.id.navbuttons_view);
        StashedHandleView stashedHandleView = mDragLayer.findViewById(R.id.stashed_handle);

        TaskbarAllAppsSlideInView appsSlideInView =
                (TaskbarAllAppsSlideInView) mLayoutInflater.inflate(R.layout.taskbar_all_apps,
                        mDragLayer, false);
        mAppsView = appsSlideInView.getAppsView();

        Display display = windowContext.getDisplay();
        Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
                ? windowContext.getApplicationContext()
@@ -210,7 +187,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                new TaskbarAutohideSuspendController(this),
                new TaskbarPopupController(this),
                new TaskbarForceVisibleImmersiveController(this),
                new TaskbarAllAppsViewController(this, appsSlideInView));
                new TaskbarAllAppsController(this));
    }

    public void init(TaskbarSharedState sharedState) {
@@ -236,7 +213,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        mWindowManager.addView(mDragLayer, mWindowLayoutParams);
    }

    /** Updates the Device profile instance to the latest representation of the screen. */
    @Override
    public void updateDeviceProfile(DeviceProfile dp) {
        mDeviceProfile = dp;
        updateIconSize(getResources());
@@ -296,31 +273,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        return mRightCorner == null ? 0 : mRightCorner.getRadius();
    }

    @Override
    public LayoutInflater getLayoutInflater() {
        return mLayoutInflater;
    }

    @Override
    public TaskbarDragLayer getDragLayer() {
        return mDragLayer;
    }

    @Override
    public TaskbarAllAppsContainerView getAppsView() {
        return mAppsView;
    }

    @Override
    public DeviceProfile getDeviceProfile() {
        return mDeviceProfile;
    }

    @Override
    public List<OnDeviceProfileChangeListener> getOnDeviceProfileChangeListeners() {
        return mDPChangeListeners;
    }

    @Override
    public Rect getFolderBoundingBox() {
        return mControllers.taskbarDragLayerController.getFolderBoundingBox();
@@ -411,11 +368,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        return mAccessibilityDelegate;
    }

    @Override
    public OnboardingPrefs<TaskbarActivityContext> getOnboardingPrefs() {
        return mOnboardingPrefs;
    }

    @Override
    public boolean isBindingItems() {
        return mBindingItems;
@@ -425,6 +377,16 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        mBindingItems = bindingItems;
    }

    @Override
    public void onDragStart() {
        setTaskbarWindowFullscreen(true);
    }

    @Override
    public void onPopupVisibilityChanged(boolean isVisible) {
        setTaskbarWindowFocusable(isVisible);
    }

    /**
     * Sets a new data-source for this taskbar instance
     */
+5 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.pm.ActivityInfo.Config;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController;
import com.android.systemui.shared.rotation.RotationButtonController;

import java.io.PrintWriter;
@@ -48,7 +49,7 @@ public class TaskbarControllers {
    public final TaskbarAutohideSuspendController taskbarAutohideSuspendController;
    public final TaskbarPopupController taskbarPopupController;
    public final TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController;
    public final TaskbarAllAppsViewController taskbarAllAppsViewController;
    public final TaskbarAllAppsController taskbarAllAppsController;

    @Nullable private LoggableTaskbarController[] mControllersToLog = null;

@@ -74,7 +75,7 @@ public class TaskbarControllers {
            TaskbarAutohideSuspendController taskbarAutoHideSuspendController,
            TaskbarPopupController taskbarPopupController,
            TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController,
            TaskbarAllAppsViewController taskbarAllAppsViewController) {
            TaskbarAllAppsController taskbarAllAppsController) {
        this.taskbarActivityContext = taskbarActivityContext;
        this.taskbarDragController = taskbarDragController;
        this.navButtonController = navButtonController;
@@ -91,7 +92,7 @@ public class TaskbarControllers {
        this.taskbarAutohideSuspendController = taskbarAutoHideSuspendController;
        this.taskbarPopupController = taskbarPopupController;
        this.taskbarForceVisibleImmersiveController = taskbarForceVisibleImmersiveController;
        this.taskbarAllAppsViewController = taskbarAllAppsViewController;
        this.taskbarAllAppsController = taskbarAllAppsController;
    }

    /**
@@ -115,7 +116,7 @@ public class TaskbarControllers {
        taskbarEduController.init(this);
        taskbarPopupController.init(this);
        taskbarForceVisibleImmersiveController.init(this);
        taskbarAllAppsViewController.init(this);
        taskbarAllAppsController.init(this);

        mControllersToLog = new LoggableTaskbarController[] {
                taskbarDragController, navButtonController, navbarButtonsViewController,
+5 −6
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ import java.util.Arrays;
/**
 * Handles long click on Taskbar items to start a system drag and drop operation.
 */
public class TaskbarDragController extends DragController<TaskbarActivityContext> implements
public class TaskbarDragController extends DragController<BaseTaskbarContext> implements
        TaskbarControllers.LoggableTaskbarController {

    private static boolean DEBUG_DRAG_SHADOW_SURFACE = false;
@@ -95,7 +95,7 @@ public class TaskbarDragController extends DragController<TaskbarActivityContext
    // Animation for the drag shadow back into position after an unsuccessful drag
    private ValueAnimator mReturnAnimator;

    public TaskbarDragController(TaskbarActivityContext activity) {
    public TaskbarDragController(BaseTaskbarContext activity) {
        super(activity);
        Resources resources = mActivity.getResources();
        mDragIconSize = resources.getDimensionPixelSize(R.dimen.taskbar_icon_drag_icon_size);
@@ -110,7 +110,7 @@ public class TaskbarDragController extends DragController<TaskbarActivityContext
     * generate the ClipDescription and Intent.
     * @return Whether {@link View#startDragAndDrop} started successfully.
     */
    protected boolean startDragOnLongClick(View view) {
    public boolean startDragOnLongClick(View view) {
        return startDragOnLongClick(view, null, null);
    }

@@ -131,8 +131,7 @@ public class TaskbarDragController extends DragController<TaskbarActivityContext
        }

        BubbleTextView btv = (BubbleTextView) view;

        mActivity.setTaskbarWindowFullscreen(true);
        mActivity.onDragStart();
        btv.post(() -> {
            DragView dragView = startInternalDrag(btv, dragPreviewProvider);
            if (iconShift != null) {
@@ -185,7 +184,7 @@ public class TaskbarDragController extends DragController<TaskbarActivityContext
            }
        };
        if (FeatureFlags.ENABLE_TASKBAR_POPUP_MENU.get()) {
            PopupContainerWithArrow<TaskbarActivityContext> popupContainer =
            PopupContainerWithArrow<BaseTaskbarContext> popupContainer =
                    mControllers.taskbarPopupController.showForIcon(btv);
            if (popupContainer != null) {
                dragOptions.preDragCondition = popupContainer.createPreDragCondition(false);
Loading