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

Commit 9e80fb35 authored by Brian Isganitis's avatar Brian Isganitis
Browse files

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
parent 4edf1da6
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -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>
 No newline at end of file
+29 −23
Original line number Diff line number Diff line
@@ -14,7 +14,12 @@
     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"
<com.android.launcher3.taskbar.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
        android:id="@+id/apps_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
@@ -42,3 +47,4 @@

        <include layout="@layout/all_apps_fast_scroller" />
    </com.android.launcher3.taskbar.TaskbarAllAppsContainerView>
</com.android.launcher3.taskbar.TaskbarAllAppsSlideInView>
+6 −3
Original line number Diff line number Diff line
@@ -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) {
+101 −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 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);
    }
}
+9 −50
Original line number Diff line number Diff line
@@ -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);
        }
    }

    /** Hides the {@link TaskbarAllAppsContainerView}. */
    public void hide() {
        if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
            mIsOpen = false;
            mContext.setTaskbarWindowFullscreen(false);
            mAppsView.setVisibility(View.GONE);
            mSlideInView.show();
        }
    }

    @Override
    public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
        mControllers.taskbarDragController.removeDragListener(this);
        mIsOpen = false;
        mAppsView.setVisibility(View.GONE);
    }

    @Override
    public void onDragEnd() { }
}
Loading