Merge changes from topics "taskbar-search-back", "taskbar-search-transition" into udc-qpr-dev

* changes:
  Support system back in Taskbar search session.
  Notify Taskbar search session of All Apps transitions.
This commit is contained in:
Brian Isganitis
2023-07-21 00:14:04 +00:00
committed by Android (Google) Code Review
5 changed files with 103 additions and 9 deletions
@@ -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();
@@ -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;
@@ -194,4 +214,11 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
protected boolean isEventOverContent(MotionEvent ev) {
return getPopupContainer().isEventOverView(mAppsView.getVisibleContainerView(), ev);
}
@Override
public void onBackInvoked() {
if (!mAllAppsCallbacks.handleSearchBackInvoked()) {
super.onBackInvoked();
}
}
}
@@ -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,20 @@ 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);
}
/** Invoked on back press, returning {@code true} if the search session handled it. */
boolean handleSearchBackInvoked() {
return mSearchSessionController.handleBackInvoked();
}
}
}
@@ -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,23 +27,29 @@ 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
open fun handleBackInvoked(): Boolean = false
companion object {
@JvmStatic
fun newInstance(context: Context): TaskbarSearchSessionController {
@@ -0,0 +1,37 @@
/*
* 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);
}