Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LMOFreeForm support #5100

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion AndroidManifest-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.ACCESS_RESTRICTED_SETTINGS" />

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also avoid white space changing if possible Thanks!

<!-- for rotating surface by arbitrary degree -->
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ROTATE_SURFACE_FLINGER" />
<uses-permission android:name="android.permission.WAKEUP_SURFACE_FLINGER" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<!-- Floating window -->
<uses-permission android:name="com.yaap.permission.START_FREEFORM" />

Comment on lines +53 to +55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move this too in here Thanks!

<!--
Permissions required for read/write access to the workspace data. These permission name
should not conflict with that defined in other apps, as such an app should embed its package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SPLIT_SELECTION_EXIT_INTERRUPTED;
import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition;
import static com.android.launcher3.popup.SystemShortcut.APP_INFO;
import static com.android.launcher3.popup.SystemShortcut.FREE_FORM;
import static com.android.launcher3.popup.SystemShortcut.DONT_SUGGEST_APP;
import static com.android.launcher3.popup.SystemShortcut.INSTALL;
import static com.android.launcher3.popup.SystemShortcut.PRIVATE_PROFILE_INSTALL;
Expand Down Expand Up @@ -448,6 +449,7 @@ public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
List<SystemShortcut.Factory> shortcuts = new ArrayList(Arrays.asList(
APP_INFO, WellbeingModel.SHORTCUT_FACTORY, mHotseatPredictionController));
shortcuts.addAll(getSplitShortcuts());
shortcuts.add(FREE_FORM);
shortcuts.add(WIDGETS);
shortcuts.add(INSTALL);
if (Flags.enablePrivateSpaceInstallShortcut()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public void clearAllActiveState() {
private static final TaskShortcutFactory[] MENU_OPTIONS = new TaskShortcutFactory[] {
TaskShortcutFactory.APP_INFO,
TaskShortcutFactory.SPLIT_SELECT,
TaskShortcutFactory.FLOATING,
TaskShortcutFactory.PIN,
TaskShortcutFactory.INSTALL,
TaskShortcutFactory.FREE_FORM,
Expand Down
48 changes: 47 additions & 1 deletion quickstep/src/com/android/quickstep/TaskShortcutFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static com.android.window.flags2.Flags.enableDesktopWindowingMode;

import android.app.ActivityOptions;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
Expand Down Expand Up @@ -282,6 +283,39 @@ private ActivityOptions makeLaunchOptions(RecentsViewContainer container) {
return activityOptions;
}
}

class FloatingSystemShortcut extends SystemShortcut<RecentsViewContainer> {
private static final String FREEFORM_PACKAGE = "com.libremobileos.freeform";
private static final String FREEFORM_INTENT = "com.libremobileos.freeform.START_FREEFORM";
private final TaskView mTaskView;
public FloatingSystemShortcut(RecentsViewContainer container, TaskContainer taskContainer) {
// TODO new icon?
super(R.drawable.float_portrait_2_24px, R.string.floating_window,
container, taskContainer.getItemInfo(), taskContainer.getTaskView());
mTaskView = taskContainer.getTaskView();
}
@Override
public void onClick(View view) {
dismissTaskMenuView();
RecentsView rv = mTarget.getOverviewPanel();
rv.switchToScreenshot(() -> {
rv.finishRecentsAnimation(true /* toRecents */, false /* shouldPip */, () -> {
mTarget.returnToHomescreen();
rv.getHandler().post(this::startLmoFreeform);
});
});
}
private void startLmoFreeform() {
final Task task = mTaskView.getFirstTask();
final Intent intent = new Intent(FREEFORM_INTENT)
.setPackage(FREEFORM_PACKAGE)
.putExtra("packageName", task.key.getPackageName())
.putExtra("activityName", task.getTopComponent().getClassName())
.putExtra("userId", task.key.userId)
.putExtra("taskId", task.key.id);
mTarget.asContext().sendBroadcast(intent);
}
}
Comment on lines +287 to +318
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move it here : TaskShortcutFactory.kt


/**
* Does NOT add split options in the following scenarios:
Expand Down Expand Up @@ -392,6 +426,18 @@ private boolean isAvailable(RecentsViewContainer container) {
}
};

TaskShortcutFactory FLOATING = new TaskShortcutFactory() {
@Override
public List<SystemShortcut> getShortcuts(RecentsViewContainer container,
TaskContainer taskContainer) {
final Task task = taskContainer.getTask();
if (!task.isDockable) {
return null;
}
return Collections.singletonList(new FloatingSystemShortcut(container, taskContainer));
}
};
Comment on lines +429 to +439
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one too : TaskShortcutFactory.kt


TaskShortcutFactory PIN = new TaskShortcutFactory() {
@Override
public List<SystemShortcut> getShortcuts(RecentsViewContainer container,
Expand Down Expand Up @@ -502,4 +548,4 @@ public List<SystemShortcut> getShortcuts(RecentsViewContainer container,
return createSingletonShortcutList(modalStateSystemShortcut);
}
};
}
}
10 changes: 10 additions & 0 deletions res/drawable/float_portrait_2_24px.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:autoMirrored="true">
<path
android:fillColor="@android:color/black"
android:pathData="M320,440L560,440L560,240L320,240L320,440ZM800,800Q800,833 776.5,856.5Q753,880 720,880L240,880Q207,880 183.5,856.5Q160,833 160,800L160,160Q160,127 183.5,103.5Q207,80 240,80L720,80Q753,80 776.5,103.5Q800,127 800,160L800,800ZM720,800L720,160Q720,160 720,160Q720,160 720,160L240,160Q240,160 240,160Q240,160 240,160L240,800Q240,800 240,800Q240,800 240,800L720,800Q720,800 720,800Q720,800 720,800ZM720,160Q720,160 720,160Q720,160 720,160L240,160Q240,160 240,160Q240,160 240,160L240,160Q240,160 240,160Q240,160 240,160L720,160Q720,160 720,160Q720,160 720,160Z"/>
</vector>
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -500,4 +500,7 @@
<string name="ps_add_button_label">Install</string>
<!-- Content description for install app icon -->
<string name="ps_add_button_content_description">Install apps to Private Space</string>

<!-- Floating window -->
<string name="floating_window">Floating</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move it in lawnchair string resources : string.xml

</resources>
33 changes: 33 additions & 0 deletions src/com/android/launcher3/popup/SystemShortcut.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -379,6 +382,36 @@ public void onClick(View view) {
.log(LAUNCHER_PRIVATE_SPACE_UNINSTALL_SYSTEM_SHORTCUT_TAP);
}
}

public static final Factory<ActivityContext> FREE_FORM = (activity, itemInfo, originalView) ->
new FreeForm(activity, itemInfo, originalView);
public static class FreeForm<T extends ActivityContext> extends SystemShortcut<T> {
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);
}
}
Comment on lines +386 to +414
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to LawnchairShortcut.kt

the usage can be found here


protected void dismissTaskMenuView() {
mAbstractFloatingViewHelper.closeOpenViews(mTarget, true,
Expand Down
Loading