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

Commit c90df24e authored by Brian Isganitis's avatar Brian Isganitis
Browse files

Notify Taskbar search session of All Apps transitions.

Test: Manual
Bug: 290819902
Flag: ENABLE_ALL_APPS_SEARCH_IN_TASKBAR
Change-Id: I9ff5ec7d55c33f9987aec79ebae31c38c710a920
parent 62e0c886
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ public final class TaskbarAllAppsController {
            cleanUpOverlay();
        });
        TaskbarAllAppsViewController viewController = new TaskbarAllAppsViewController(
                mOverlayContext, mSlideInView, mControllers);
                mOverlayContext, mSlideInView, mControllers, mSearchSessionController);

        viewController.show(animate);
        mAppsView = mOverlayContext.getAppsView();
+20 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ package com.android.launcher3.taskbar.allapps;

import static com.android.app.animation.Interpolators.EMPHASIZED;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Canvas;
@@ -63,14 +65,23 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
        }
        mIsOpen = true;
        attachToContainer();
        mAllAppsCallbacks.onAllAppsTransitionStart(true);

        if (animate) {
            mOpenCloseAnimator.setValues(
                    PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED));
            mOpenCloseAnimator.setInterpolator(EMPHASIZED);
            mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mOpenCloseAnimator.removeListener(this);
                    mAllAppsCallbacks.onAllAppsTransitionEnd(true);
                }
            });
            mOpenCloseAnimator.setDuration(mAllAppsCallbacks.getOpenDuration()).start();
        } else {
            mTranslationShift = TRANSLATION_SHIFT_OPENED;
            mAllAppsCallbacks.onAllAppsTransitionEnd(true);
        }
    }

@@ -81,9 +92,18 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla

    @Override
    protected void handleClose(boolean animate) {
        if (mIsOpen) {
            mAllAppsCallbacks.onAllAppsTransitionStart(false);
        }
        handleClose(animate, mAllAppsCallbacks.getCloseDuration());
    }

    @Override
    protected void onCloseComplete() {
        mAllAppsCallbacks.onAllAppsTransitionEnd(false);
        super.onCloseComplete();
    }

    @Override
    protected Interpolator getIdleInterpolator() {
        return EMPHASIZED;
+21 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_
import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.allapps.AllAppsTransitionListener;
import com.android.launcher3.appprediction.AppsDividerView;
import com.android.launcher3.taskbar.NavbarButtonsViewController;
import com.android.launcher3.taskbar.TaskbarControllers;
@@ -43,7 +44,8 @@ final class TaskbarAllAppsViewController {
    TaskbarAllAppsViewController(
            TaskbarOverlayContext context,
            TaskbarAllAppsSlideInView slideInView,
            TaskbarControllers taskbarControllers) {
            TaskbarControllers taskbarControllers,
            TaskbarSearchSessionController searchSessionController) {

        mContext = context;
        mSlideInView = slideInView;
@@ -52,7 +54,7 @@ final class TaskbarAllAppsViewController {
        mNavbarButtonsViewController = taskbarControllers.navbarButtonsViewController;
        mOverlayController = taskbarControllers.taskbarOverlayController;

        mSlideInView.init(new TaskbarAllAppsCallbacks());
        mSlideInView.init(new TaskbarAllAppsCallbacks(searchSessionController));
        setUpAppDivider();
        setUpTaskbarStashing();
    }
@@ -94,7 +96,13 @@ final class TaskbarAllAppsViewController {
        });
    }

    class TaskbarAllAppsCallbacks {
    class TaskbarAllAppsCallbacks implements AllAppsTransitionListener {
        private final TaskbarSearchSessionController mSearchSessionController;

        private TaskbarAllAppsCallbacks(TaskbarSearchSessionController searchSessionController) {
            mSearchSessionController = searchSessionController;
        }

        int getOpenDuration() {
            return mOverlayController.getOpenDuration();
        }
@@ -102,5 +110,15 @@ final class TaskbarAllAppsViewController {
        int getCloseDuration() {
            return mOverlayController.getCloseDuration();
        }

        @Override
        public void onAllAppsTransitionStart(boolean toAllApps) {
            mSearchSessionController.onAllAppsTransitionStart(toAllApps);
        }

        @Override
        public void onAllAppsTransitionEnd(boolean toAllApps) {
            mSearchSessionController.onAllAppsTransitionEnd(toAllApps);
        }
    }
}
+10 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.launcher3.taskbar.allapps
import android.content.Context
import android.view.View
import com.android.launcher3.R
import com.android.launcher3.allapps.AllAppsTransitionListener
import com.android.launcher3.config.FeatureFlags
import com.android.launcher3.dragndrop.DragOptions.PreDragCondition
import com.android.launcher3.model.data.ItemInfo
@@ -26,19 +27,23 @@ import com.android.launcher3.util.ResourceBasedOverride
import com.android.launcher3.util.ResourceBasedOverride.Overrides

/** Stub for managing the Taskbar search session. */
open class TaskbarSearchSessionController : ResourceBasedOverride {
open class TaskbarSearchSessionController : ResourceBasedOverride, AllAppsTransitionListener {

    /** Start the search session lifecycle. */
    open fun startLifecycle() {}
    open fun startLifecycle() = Unit

    /** Destroy the search session. */
    open fun onDestroy() {}
    open fun onDestroy() = Unit

    /** Updates the predicted items shown in the zero-state. */
    open fun setZeroStatePredictedItems(items: List<ItemInfo>) {}
    open fun setZeroStatePredictedItems(items: List<ItemInfo>) = Unit

    /** Updates the search suggestions shown in the zero-state. */
    open fun setZeroStateSearchSuggestions(items: List<ItemInfo>) {}
    open fun setZeroStateSearchSuggestions(items: List<ItemInfo>) = Unit

    override fun onAllAppsTransitionStart(toAllApps: Boolean) = Unit

    override fun onAllAppsTransitionEnd(toAllApps: Boolean) = Unit

    /** Creates a [PreDragCondition] for [view], if it is a search result that requires one. */
    open fun createPreDragConditionForSearch(view: View): PreDragCondition? = null
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.allapps;

/**
 * An interface for listening to all-apps open-close transition
 */
public interface AllAppsTransitionListener {
    /**
     * Called when the transition starts
     * @param toAllApps {@code true} if this transition is supposed to end in the AppApps UI
     *
     * @see ActivityAllAppsContainerView
     */
    void onAllAppsTransitionStart(boolean toAllApps);

    /**
     * Called when the transition ends
     * @param toAllApps {@code true} if the final state is all-apps
     *
     * @see ActivityAllAppsContainerView
     */
    void onAllAppsTransitionEnd(boolean toAllApps);
}