-
-
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
Conversation
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.
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); | ||
} | ||
} |
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.
Please move it here : TaskShortcutFactory.kt
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)); | ||
} | ||
}; |
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.
this one too : TaskShortcutFactory.kt
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
please move it in lawnchair string resources : string.xml
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); | ||
} | ||
} |
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.
Please move this to LawnchairShortcut.kt
the usage can be found here
@@ -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" /> | |||
|
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!
<!-- Floating window --> | ||
<uses-permission android:name="com.yaap.permission.START_FREEFORM" /> | ||
|
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.
please move this too in here Thanks!
Closing for now, as I have no way to test it because qickswitch doesn't work on my rom (A15 QPR2) at the moment. |
Description
#5096
Type of change
❌ General change (non-breaking change that doesn't fit the below categories like copyediting)
❌ Bug fix (non-breaking change which fixes an issue)
✅ New feature (non-breaking change which adds functionality)
❌ Breaking change (fix or feature that would cause existing functionality to not work as expected)