diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml index c7743eaaff..3b1d217ec5 100644 --- a/quickstep/res/layout/taskbar.xml +++ b/quickstep/res/layout/taskbar.xml @@ -82,8 +82,4 @@ android:clipToOutline="true" android:layout_gravity="bottom"/> - - \ No newline at end of file diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml index 4dbbcc7c79..2848b0f324 100644 --- a/quickstep/res/layout/taskbar_all_apps.xml +++ b/quickstep/res/layout/taskbar_all_apps.xml @@ -14,31 +14,37 @@ See the License for the specific language governing permissions and limitations under the License. --> - + android:layout_height="match_parent"> - - - + android:focusable="false" + android:saveEnabled="false" + android:theme="?attr/allAppsTheme"> - - + - - + + + + + + + + diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index be6376d4f2..e99edb5d13 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -154,7 +154,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ TaskbarScrimView taskbarScrimView = mDragLayer.findViewById(R.id.taskbar_scrim); FrameLayout navButtonsView = mDragLayer.findViewById(R.id.navbuttons_view); StashedHandleView stashedHandleView = mDragLayer.findViewById(R.id.stashed_handle); - mAppsView = mDragLayer.findViewById(R.id.apps_view); + + 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 @@ -193,7 +197,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ new TaskbarAutohideSuspendController(this), new TaskbarPopupController(this), new TaskbarForceVisibleImmersiveController(this), - new TaskbarAllAppsViewController(this, mAppsView)); + new TaskbarAllAppsViewController(this, appsSlideInView)); } public void init(TaskbarSharedState sharedState) { @@ -646,7 +650,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ } AbstractFloatingView.closeAllOpenViews(this); - mControllers.taskbarAllAppsViewController.hide(); } private void startItemInfoActivity(ItemInfo info) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsSlideInView.java new file mode 100644 index 0000000000..63690c4847 --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsSlideInView.java @@ -0,0 +1,101 @@ +/* + * 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 static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE; + +import android.animation.PropertyValuesHolder; +import android.content.Context; +import android.graphics.Rect; +import android.util.AttributeSet; +import android.view.MotionEvent; + +import com.android.launcher3.Insettable; +import com.android.launcher3.R; +import com.android.launcher3.views.AbstractSlideInView; + +/** Wrapper for taskbar all apps with slide-in behavior. */ +public class TaskbarAllAppsSlideInView extends + AbstractSlideInView implements Insettable { + + private static final int DEFAULT_OPEN_DURATION = 500; + private static final int DEFAULT_CLOSE_DURATION = 200; + + private TaskbarAllAppsContainerView mAppsView; + + public TaskbarAllAppsSlideInView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public TaskbarAllAppsSlideInView(Context context, AttributeSet attrs, + int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + /** Opens the all apps view. */ + public void show() { + if (mIsOpen || mOpenCloseAnimator.isRunning()) { + return; + } + mIsOpen = true; + attachToContainer(); + + mOpenCloseAnimator.setValues( + PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED)); + mOpenCloseAnimator.setInterpolator(AGGRESSIVE_EASE); + mOpenCloseAnimator.setDuration(DEFAULT_OPEN_DURATION).start(); + } + + /** The apps container inside this view. */ + public TaskbarAllAppsContainerView getAppsView() { + return mAppsView; + } + + @Override + protected void handleClose(boolean animate) { + handleClose(animate, DEFAULT_CLOSE_DURATION); + } + + @Override + protected boolean isOfType(int type) { + return (type & TYPE_TASKBAR_ALL_APPS) != 0; + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + mAppsView = findViewById(R.id.apps_view); + mContent = mAppsView; + } + + @Override + protected int getScrimColor(Context context) { + return context.getColor(R.color.widgets_picker_scrim); + } + + @Override + public boolean onControllerInterceptTouchEvent(MotionEvent ev) { + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + mNoIntercept = !mAppsView.shouldContainerScroll(ev); + } + return super.onControllerInterceptTouchEvent(ev); + } + + @Override + public void setInsets(Rect insets) { + mAppsView.setInsets(insets); + } +} diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsViewController.java index fb807aa594..0b53cc2c84 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsViewController.java @@ -15,28 +15,22 @@ */ package com.android.launcher3.taskbar; -import android.view.View; - -import com.android.launcher3.DropTarget; import com.android.launcher3.R; import com.android.launcher3.config.FeatureFlags; -import com.android.launcher3.dragndrop.DragController; -import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.model.data.AppInfo; /** Handles the {@link TaskbarAllAppsContainerView} initialization and updates. */ -public final class TaskbarAllAppsViewController implements DragController.DragListener { +public final class TaskbarAllAppsViewController { private final TaskbarActivityContext mContext; + private final TaskbarAllAppsSlideInView mSlideInView; private final TaskbarAllAppsContainerView mAppsView; - private TaskbarControllers mControllers; // Initialized in init. - private boolean mIsOpen; - public TaskbarAllAppsViewController( - TaskbarActivityContext context, TaskbarAllAppsContainerView appsView) { + TaskbarActivityContext context, TaskbarAllAppsSlideInView slideInView) { mContext = context; - mAppsView = appsView; + mSlideInView = slideInView; + mAppsView = mSlideInView.getAppsView(); } /** Initialize the controller. */ @@ -44,27 +38,12 @@ public final class TaskbarAllAppsViewController implements DragController.DragLi if (!FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) { return; } - mControllers = controllers; - mAppsView.setOnIconLongClickListener(icon -> { - mControllers.taskbarDragController.addDragListener(this); - mControllers.taskbarDragController.startDragOnLongClick(icon); - return true; - }); + mAppsView.setOnIconLongClickListener( + controllers.taskbarDragController::startDragOnLongClick); // TODO(b/205803230): Remove once entry point button is implemented. - mContext.getDragLayer().findViewById(R.id.taskbar_view).setOnClickListener(v -> { - if (mIsOpen) { - hide(); - } else { - show(); - } - }); - } - - /** The taskbar apps view. */ - public TaskbarAllAppsContainerView getAppsView() { - return mAppsView; + mContext.getDragLayer().findViewById(R.id.taskbar_view).setOnClickListener(v -> show()); } /** Binds the current {@link AppInfo} instances to the {@link TaskbarAllAppsContainerView}. */ @@ -77,28 +56,8 @@ public final class TaskbarAllAppsViewController implements DragController.DragLi /** Opens the {@link TaskbarAllAppsContainerView}. */ public void show() { if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) { - mIsOpen = true; mContext.setTaskbarWindowFullscreen(true); - mAppsView.setVisibility(View.VISIBLE); + mSlideInView.show(); } } - - /** Hides the {@link TaskbarAllAppsContainerView}. */ - public void hide() { - if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) { - mIsOpen = false; - mContext.setTaskbarWindowFullscreen(false); - mAppsView.setVisibility(View.GONE); - } - } - - @Override - public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) { - mControllers.taskbarDragController.removeDragListener(this); - mIsOpen = false; - mAppsView.setVisibility(View.GONE); - } - - @Override - public void onDragEnd() { } } diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java index e3cfb59b60..ceb38d0e77 100644 --- a/src/com/android/launcher3/AbstractFloatingView.java +++ b/src/com/android/launcher3/AbstractFloatingView.java @@ -65,7 +65,8 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch TYPE_ICON_SURFACE, TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP, TYPE_WIDGETS_EDUCATION_DIALOG, - TYPE_TASKBAR_EDUCATION_DIALOG + TYPE_TASKBAR_EDUCATION_DIALOG, + TYPE_TASKBAR_ALL_APPS }) @Retention(RetentionPolicy.SOURCE) public @interface FloatingViewType {} @@ -89,19 +90,20 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch public static final int TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP = 1 << 14; public static final int TYPE_WIDGETS_EDUCATION_DIALOG = 1 << 15; public static final int TYPE_TASKBAR_EDUCATION_DIALOG = 1 << 16; + public static final int TYPE_TASKBAR_ALL_APPS = 1 << 17; public static final int TYPE_ALL = TYPE_FOLDER | TYPE_ACTION_POPUP | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME | TYPE_WIDGETS_FULL_SHEET | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE | TYPE_TASK_MENU | TYPE_OPTIONS_POPUP | TYPE_SNACKBAR | TYPE_LISTENER | TYPE_ALL_APPS_EDU | TYPE_ICON_SURFACE | TYPE_DRAG_DROP_POPUP | TYPE_PIN_WIDGET_FROM_EXTERNAL_POPUP - | TYPE_WIDGETS_EDUCATION_DIALOG | TYPE_TASKBAR_EDUCATION_DIALOG; + | TYPE_WIDGETS_EDUCATION_DIALOG | TYPE_TASKBAR_EDUCATION_DIALOG | TYPE_TASKBAR_ALL_APPS; // Type of popups which should be kept open during launcher rebind public static final int TYPE_REBIND_SAFE = TYPE_WIDGETS_FULL_SHEET | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE | TYPE_ALL_APPS_EDU | TYPE_ICON_SURFACE | TYPE_WIDGETS_EDUCATION_DIALOG - | TYPE_TASKBAR_EDUCATION_DIALOG; + | TYPE_TASKBAR_EDUCATION_DIALOG | TYPE_TASKBAR_ALL_APPS; // Usually we show the back button when a floating view is open. Instead, hide for these types. public static final int TYPE_HIDE_BACK_BUTTON = TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java index 1253863893..b257407161 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java @@ -249,6 +249,10 @@ public abstract class BaseAllAppsContainerView mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { + mOpenCloseAnimator.removeListener(this); onCloseComplete(); } });