From addfde6142bf06e77f96b88a5e7c4116f6add060 Mon Sep 17 00:00:00 2001 From: elisenlebkuch Date: Wed, 18 Dec 2024 15:16:54 +0100 Subject: [PATCH] Add LMOFreeForm support --- AndroidManifest-common.xml | 5 +- .../uioverrides/QuickstepLauncher.java | 2 + .../android/quickstep/TaskOverlayFactory.java | 1 + .../quickstep/TaskShortcutFactory.java | 48 ++++++++++++++++++- res/drawable/float_portrait_2_24px.xml | 10 ++++ res/values/strings.xml | 3 ++ .../launcher3/popup/SystemShortcut.java | 33 +++++++++++++ 7 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 res/drawable/float_portrait_2_24px.xml diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index e8fa644e1fd..e804414de6b 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -43,13 +43,16 @@ - + + + + Install apps to Private Space + + + Floating diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 9d49ca4aa60..19b3a60791c 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -1,5 +1,7 @@ package com.android.launcher3.popup; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; + import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_INSTALL_SYSTEM_SHORTCUT_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_APP_INFO_TAP; @@ -15,6 +17,7 @@ import android.os.Process; import android.os.UserHandle; import android.view.View; +import android.view.WindowInsets; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ImageView; import android.widget.TextView; @@ -379,6 +382,36 @@ public void onClick(View view) { .log(LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP); } } + + public static final Factory FREE_FORM = (activity, itemInfo, originalView) -> + new FreeForm(activity, itemInfo, originalView); + public static class FreeForm extends SystemShortcut { + private final String mPackageName; + private final ComponentName mComponentName; + private final int mUserId; + + public FreeForm(T target, ItemInfo itemInfo, View originalView) { + super(R.drawable.ic_caption_desktop_button_foreground, R.string.recent_task_option_freeform, target, itemInfo, originalView); + mPackageName = itemInfo.getTargetComponent().getPackageName(); + mComponentName = itemInfo.getTargetComponent(); + mUserId = originalView.getContext().getUserId(); + } + @Override + public void onClick(View view) { + if (mPackageName != null) { + startLmoFreeform(view.getContext()); + AbstractFloatingView.closeAllOpenViews(((ActivityContext) mTarget)); + } + } + private void startLmoFreeform(Context context) { + final Intent intent = new Intent("com.libremobileos.freeform.START_FREEFORM") + .setPackage("com.libremobileos.freeform") + .putExtra("packageName", mPackageName) + .putExtra("activityName", mComponentName.getClassName()) + .putExtra("userId", mUserId); + context.sendBroadcast(intent); + } + } protected void dismissTaskMenuView() { mAbstractFloatingViewHelper.closeOpenViews(mTarget, true,