-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add LMOFreeForm support #5100
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" /> | ||
|
||
<!-- 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
@@ -502,4 +548,4 @@ public List<SystemShortcut> getShortcuts(RecentsViewContainer container, | |
return createSingletonShortcutList(modalStateSystemShortcut); | ||
} | ||
}; | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please move it in lawnchair string resources : string.xml |
||
</resources> |
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; | ||
|
@@ -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<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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
There was a problem hiding this comment.
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!