From d00382a09d9fde915388bc1aff3687e65ff3a8a8 Mon Sep 17 00:00:00 2001 From: minch Date: Mon, 27 Jan 2025 21:35:35 +0000 Subject: [PATCH] Hook up `mAddDesktopButton` with the API `createDesktop` Add the `setOnClickListener` for the `mAddDesktopButton`, it will call the `createDesktop` API inside SystemUiProxy to create a new Desk inside the display that the button resides in. Flag: com.android.window.flags.enable_multiple_desktops_frontend com.android.window.flags.enable_multiple_desktops_backend Fix: 391917345 Test: Manual, make sure the callback function `createDesk` is called after clicking the button. No real desk will be created for now, as the backend hasn't been implemented yet. Change-Id: I70417a1ce0963b9b3c109c3f3dffaab808212d23 --- quickstep/src/com/android/quickstep/views/RecentsView.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index c0b026bd66..7f79e1ecf5 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -907,6 +907,7 @@ public abstract class RecentsView< if (DesktopModeStatus.enableMultipleDesktops(mContext)) { mAddDesktopButton = (AddDesktopButton) LayoutInflater.from(context).inflate( R.layout.overview_add_desktop_button, this, false); + mAddDesktopButton.setOnClickListener(this::createDesk); } mTaskViewPool = new ViewPool<>(context, this, R.layout.task, 20 /* max size */, @@ -4605,6 +4606,12 @@ public abstract class RecentsView< } } + private void createDesk(View view) { + SystemUiProxy.INSTANCE + .get(getContext()) + .createDesktop(mContainer.getDisplay().getDisplayId()); + } + @Override public boolean dispatchKeyEvent(KeyEvent event) { if (isHandlingTouch() || event.getAction() != KeyEvent.ACTION_DOWN) {