mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Initial TaskbarUnitTestRule with example overlay controller tests.
Flag: TEST_ONLY Bug: 230027385 Test: TaskbarOverlayControllerTest Change-Id: I858906ece7e67677962ec8b4432bfcca5ec30283
This commit is contained in:
@@ -1605,4 +1605,9 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
boolean canToggleHomeAllApps() {
|
||||
return mControllers.uiController.canToggleHomeAllApps();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public TaskbarControllers getControllers() {
|
||||
return mControllers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,7 +611,8 @@ public class TaskbarManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void addTaskbarRootViewToWindow() {
|
||||
@VisibleForTesting
|
||||
void addTaskbarRootViewToWindow() {
|
||||
if (enableTaskbarNoRecreate() && !mAddedWindow && mTaskbarActivityContext != null) {
|
||||
mWindowManager.addView(mTaskbarRootLayout,
|
||||
mTaskbarActivityContext.getWindowLayoutParams());
|
||||
@@ -619,7 +620,8 @@ public class TaskbarManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeTaskbarRootViewFromWindow() {
|
||||
@VisibleForTesting
|
||||
void removeTaskbarRootViewFromWindow() {
|
||||
if (enableTaskbarNoRecreate() && mAddedWindow) {
|
||||
mWindowManager.removeViewImmediate(mTaskbarRootLayout);
|
||||
mAddedWindow = false;
|
||||
|
||||
@@ -133,16 +133,19 @@ public final class TaskbarOverlayController {
|
||||
* <p>
|
||||
* This method should be called after an exit animation finishes, if applicable.
|
||||
*/
|
||||
@SuppressLint("WrongConstant")
|
||||
void maybeCloseWindow() {
|
||||
if (mOverlayContext != null && (AbstractFloatingView.hasOpenView(mOverlayContext, TYPE_ALL)
|
||||
|| mOverlayContext.getDragController().isSystemDragInProgress())) {
|
||||
return;
|
||||
}
|
||||
if (!canCloseWindow()) return;
|
||||
mProxyView.close(false);
|
||||
onDestroy();
|
||||
}
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
private boolean canCloseWindow() {
|
||||
if (mOverlayContext == null) return true;
|
||||
if (AbstractFloatingView.hasOpenView(mOverlayContext, TYPE_ALL)) return false;
|
||||
return !mOverlayContext.getDragController().isSystemDragInProgress();
|
||||
}
|
||||
|
||||
/** Destroys the controller and any overlay window if present. */
|
||||
public void onDestroy() {
|
||||
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
|
||||
@@ -212,10 +215,17 @@ public final class TaskbarOverlayController {
|
||||
|
||||
@Override
|
||||
protected void handleClose(boolean animate) {
|
||||
if (mIsOpen) {
|
||||
mTaskbarContext.getDragLayer().removeView(this);
|
||||
Optional.ofNullable(mOverlayContext).ifPresent(c -> closeAllOpenViews(c, animate));
|
||||
}
|
||||
if (!mIsOpen) return;
|
||||
mTaskbarContext.getDragLayer().removeView(this);
|
||||
Optional.ofNullable(mOverlayContext).ifPresent(c -> {
|
||||
if (canCloseWindow()) {
|
||||
onDestroy(); // Window is already ready to be destroyed.
|
||||
} else {
|
||||
// Close window's AFVs before destroying it. Its drag layer will attempt to
|
||||
// close the proxy view again once its children are removed.
|
||||
closeAllOpenViews(c, animate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user