Inflate taskbar all apps in abstract slide-in view.

All apps can now be dismissed via the scrim or swiping down. To properly
behave as an AFW, the apps view can no longer be within the taskbar's
layout, and will instead add and remove itself from the drag layer.

Test: Manual
Bug: 204696617
Change-Id: I86a0ffc06faa653c65b3797a57ba6512c6874221
This commit is contained in:
Brian Isganitis committed 2022-01-28 15:21:11 -05:00
1 parent 4edf1da6e2
commit 9e80fb355c
8 files changed
+154 -82

No files matched your search

-4
View File
@@ -82,8 +82,4 @@
android:clipToOutline="true"
android:layout_gravity="bottom"/>
<include
layout="@layout/taskbar_all_apps"
android:visibility="gone" />
</com.android.launcher3.taskbar.TaskbarDragLayer>
+28 -22
View File
@@ -14,31 +14,37 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.android.launcher3.taskbar.TaskbarAllAppsContainerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/apps_view"
<com.android.launcher3.taskbar.TaskbarAllAppsSlideInView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="true"
android:clipToPadding="false"
android:focusable="false"
android:saveEnabled="false"
android:theme="?attr/allAppsTheme">
android:layout_height="match_parent">
<include
layout="@layout/all_apps_rv_layout"
android:visibility="gone" />
<com.android.launcher3.allapps.FloatingHeaderView
android:id="@+id/all_apps_header"
<com.android.launcher3.taskbar.TaskbarAllAppsContainerView
android:id="@+id/apps_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/search_container_all_apps"
android:layout_height="match_parent"
android:clipChildren="true"
android:clipToPadding="false"
android:paddingTop="@dimen/all_apps_header_top_padding"
android:orientation="vertical">
android:focusable="false"
android:saveEnabled="false"
android:theme="?attr/allAppsTheme">
<include layout="@layout/all_apps_personal_work_tabs" />
</com.android.launcher3.allapps.FloatingHeaderView>
<include
layout="@layout/all_apps_rv_layout"
android:visibility="gone" />
<include layout="@layout/all_apps_fast_scroller" />
</com.android.launcher3.taskbar.TaskbarAllAppsContainerView>
<com.android.launcher3.allapps.FloatingHeaderView
android:id="@+id/all_apps_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/search_container_all_apps"
android:clipToPadding="false"
android:paddingTop="@dimen/all_apps_header_top_padding"
android:orientation="vertical">
<include layout="@layout/all_apps_personal_work_tabs" />
</com.android.launcher3.allapps.FloatingHeaderView>
<include layout="@layout/all_apps_fast_scroller" />
</com.android.launcher3.taskbar.TaskbarAllAppsContainerView>
</com.android.launcher3.taskbar.TaskbarAllAppsSlideInView>
@@ -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) {
@@ -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<TaskbarActivityContext> 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);
}
}
@@ -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() { }
}
@@ -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
@@ -249,6 +249,10 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
* Returns whether the view itself will handle the touch event or not.
*/
public boolean shouldContainerScroll(MotionEvent ev) {
// Scroll if not within the container view (e.g. over large-screen scrim).
if (!mActivityContext.getDragLayer().isEventOverView(this, ev)) {
return true;
}
// TODO(b/216203409) Support dragging down from bottom sheet divider, if present.
AllAppsRecyclerView rv = getActiveRecyclerView();
if (rv == null) {
@@ -203,6 +203,7 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mOpenCloseAnimator.removeListener(this);
onCloseComplete();
}
});