Recreate All Apps when Taskbar is recreated.

Test: Manual
Fix: 222039500
Fix: 222037737
Fix: 222034811
Change-Id: I53aa3ae77d03ae2a1d500d906ad2ed90efda6f4a
This commit is contained in:
Brian Isganitis
2022-03-07 18:30:29 -08:00
parent 3c8277d161
commit 464209c535
6 changed files with 42 additions and 12 deletions

View File

@@ -38,6 +38,7 @@ import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.taskbar.TaskbarActivityContext;
import com.android.launcher3.taskbar.TaskbarControllers;
import com.android.launcher3.taskbar.TaskbarSharedState;
import java.util.List;
import java.util.Optional;
@@ -62,6 +63,7 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
private final LayoutParams mLayoutParams;
private TaskbarControllers mControllers;
private TaskbarSharedState mSharedState;
/** Window context for all apps if it is open. */
private @Nullable TaskbarAllAppsContext mAllAppsContext;
@@ -77,9 +79,19 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
}
/** Initialize the controller. */
public void init(TaskbarControllers controllers) {
if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
mControllers = controllers;
public void init(TaskbarControllers controllers, TaskbarSharedState sharedState) {
if (!FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
return;
}
mControllers = controllers;
mSharedState = sharedState;
/*
* Recreate All Apps if it was open in the previous Taskbar instance (e.g. the configuration
* changed).
*/
if (mSharedState.allAppsVisible) {
show(false);
}
}
@@ -112,10 +124,15 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
/** Opens the {@link TaskbarAllAppsContainerView} in a new window. */
public void show() {
show(true);
}
private void show(boolean animate) {
if (mProxyView.isOpen()) {
return;
}
mProxyView.show();
mSharedState.allAppsVisible = true;
mAllAppsContext = new TaskbarAllAppsContext(mTaskbarContext,
this,
@@ -129,6 +146,7 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
mAllAppsContext.getAppsView().getFloatingHeaderView()
.findFixedRowByType(PredictionRowView.class)
.setPredictedApps(mPredictedApps);
mAllAppsContext.getAllAppsViewController().show(animate);
}
/** Closes the {@link TaskbarAllAppsContainerView}. */
@@ -148,6 +166,12 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
return;
}
mProxyView.close(false);
mSharedState.allAppsVisible = false;
onDestroy();
}
/** Destroys the controller and any All Apps window if present. */
public void onDestroy() {
mTaskbarContext.removeOnDeviceProfileChangeListener(this);
Optional.ofNullable(mAllAppsContext)
.map(c -> c.getSystemService(WindowManager.class))