scrolling in all apps did not factor in additional top padding in the all apps list recycler. This made it so that apps could occasionally scroll and be obcured by that top padding, making them un-tappable. Added this padding to the scrolling logic to make scrolling less flaky. Test: TaplTestsTaskbar, TaplTestsLauncher3 and presubmit Fixes: 248064856 Change-Id: Id76b92b4bc354917f3688ac53673d0ed7a905f02
135 lines
4.8 KiB
Java
135 lines
4.8 KiB
Java
/*
|
|
* 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.allapps;
|
|
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.VisibleForTesting;
|
|
|
|
import com.android.launcher3.R;
|
|
import com.android.launcher3.appprediction.PredictionRowView;
|
|
import com.android.launcher3.config.FeatureFlags;
|
|
import com.android.launcher3.model.data.AppInfo;
|
|
import com.android.launcher3.model.data.ItemInfo;
|
|
import com.android.launcher3.taskbar.TaskbarControllers;
|
|
import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Handles the all apps overlay window initialization, updates, and its data.
|
|
* <p>
|
|
* All apps is in an application overlay window instead of taskbar's navigation bar panel window,
|
|
* because a navigation bar panel is higher than UI components that all apps should be below such as
|
|
* the notification tray.
|
|
* <p>
|
|
* The all apps window is created and destroyed upon opening and closing all apps, respectively.
|
|
* Application data may be bound while the window does not exist, so this controller will store
|
|
* the models for the next all apps session.
|
|
*/
|
|
public final class TaskbarAllAppsController {
|
|
|
|
private TaskbarControllers mControllers;
|
|
private @Nullable TaskbarAllAppsContainerView mAppsView;
|
|
|
|
// Application data models.
|
|
private AppInfo[] mApps;
|
|
private int mAppsModelFlags;
|
|
private List<ItemInfo> mPredictedApps;
|
|
|
|
/** Initialize the controller. */
|
|
public void init(TaskbarControllers controllers, boolean allAppsVisible) {
|
|
if (!FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
|
|
return;
|
|
}
|
|
mControllers = controllers;
|
|
|
|
/*
|
|
* Recreate All Apps if it was open in the previous Taskbar instance (e.g. the configuration
|
|
* changed).
|
|
*/
|
|
if (allAppsVisible) {
|
|
show(false);
|
|
}
|
|
}
|
|
|
|
/** Updates the current {@link AppInfo} instances. */
|
|
public void setApps(AppInfo[] apps, int flags) {
|
|
if (!FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
|
|
return;
|
|
}
|
|
|
|
mApps = apps;
|
|
mAppsModelFlags = flags;
|
|
if (mAppsView != null) {
|
|
mAppsView.getAppsStore().setApps(mApps, mAppsModelFlags);
|
|
}
|
|
}
|
|
|
|
/** Updates the current predictions. */
|
|
public void setPredictedApps(List<ItemInfo> predictedApps) {
|
|
if (!FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
|
|
return;
|
|
}
|
|
|
|
mPredictedApps = predictedApps;
|
|
if (mAppsView != null) {
|
|
mAppsView.getFloatingHeaderView()
|
|
.findFixedRowByType(PredictionRowView.class)
|
|
.setPredictedApps(mPredictedApps);
|
|
}
|
|
}
|
|
|
|
/** Opens the {@link TaskbarAllAppsContainerView} in a new window. */
|
|
public void show() {
|
|
show(true);
|
|
}
|
|
|
|
private void show(boolean animate) {
|
|
if (mAppsView != null) {
|
|
return;
|
|
}
|
|
// mControllers and getSharedState should never be null here. Do not handle null-pointer
|
|
// to catch invalid states.
|
|
mControllers.getSharedState().allAppsVisible = true;
|
|
|
|
TaskbarOverlayContext overlayContext =
|
|
mControllers.taskbarOverlayController.requestWindow();
|
|
TaskbarAllAppsSlideInView slideInView =
|
|
(TaskbarAllAppsSlideInView) overlayContext.getLayoutInflater().inflate(
|
|
R.layout.taskbar_all_apps, overlayContext.getDragLayer(), false);
|
|
slideInView.addOnCloseListener(() -> {
|
|
mControllers.getSharedState().allAppsVisible = false;
|
|
mAppsView = null;
|
|
});
|
|
TaskbarAllAppsViewController viewController = new TaskbarAllAppsViewController(
|
|
overlayContext, slideInView, mControllers);
|
|
|
|
viewController.show(animate);
|
|
mAppsView = overlayContext.getAppsView();
|
|
mAppsView.getAppsStore().setApps(mApps, mAppsModelFlags);
|
|
mAppsView.getFloatingHeaderView()
|
|
.findFixedRowByType(PredictionRowView.class)
|
|
.setPredictedApps(mPredictedApps);
|
|
}
|
|
|
|
|
|
@VisibleForTesting
|
|
public int getTaskbarAllAppsTopPadding() {
|
|
// Allow null-pointer since this should only be null if the apps view is not showing.
|
|
return mAppsView.getActiveRecyclerView().getClipBounds().top;
|
|
}
|
|
}
|