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

Android 15 Private Space Integration #2345

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

TSonono
Copy link

@TSonono TSonono commented Nov 24, 2024

#2338

Note that this is a draft and not ready for review/merge.

This has the basic functionality for a usable Private Space integration.

What is supported:

  • Unlock and lock the private space by pressing or long pressing the 3 dots in the KISS search bar and then press the applicable unlock/lock private space button.
  • Private space apps are shown and openable in the KISS app list/searchable/history.

What is missing (first two bullets as per https://developer.android.com/about/versions/15/behavior-changes-all#private-space-launcher-apps):

  • "separate launcher container for apps installed in the private space"
  • "Install Apps" button that launches an implicit intent to install apps into the user's private space".
  • After private space has been disabled, the apps must be removed from the app list, history and search view rather than being greyed out, which is currently the case.
  • Perhaps an option to disable shortcuts from apps in the private space in the KISS search view. It can be annoying if there's an app in both the standard user and the private space that has a lot of shortcuts with shortcuts from both apps showing.

I might work on this on and off for some weekends a head. If someone else is implementing this, let me know so that I don't work on this in vain. If someone wants to continue the work of this PR (in what I would assume a quicker pace than I have time for), I would be fine with that too, just let me know.

@TBog
Copy link
Collaborator

TBog commented Nov 24, 2024

Thank you for working on this!

return !manager.isQuietModeEnabled(user);
}

private void switchPrivateSpaceState() {
Copy link
Collaborator

@TBog TBog Nov 24, 2024

Choose a reason for hiding this comment

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

You could annotate the method switchPrivateSpaceState instead of asserting inside
@RequiresApi(35)

This has the basic functionality for a useable Private Space
interaction. What is missing is the "separate launcher container
for apps installed in the private space", as well as the "an "Install
Apps" button that launches an implicit intent to install apps into
the user's private space".
They are disabled by default.
Edge-to-edge is the default behavior in Android 15. It however breaks
the app currently.
@@ -66,6 +68,7 @@
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.APP_MARKET" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this category needed for? KISS should be launcher only

Comment on lines +223 to +227
} else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_PROFILE_AVAILABLE)
|| intent.getAction().equalsIgnoreCase(Intent.ACTION_PROFILE_UNAVAILABLE)) {
privateSpaceStateEvent(intent.getParcelableExtra(Intent.EXTRA_USER, UserHandle.class));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Private space is just another profile like e.g. any work profile. So if I read this correctly, these change here is not needed.
KISS is already reacting on these intents in ProfileChangedHandler

Comment on lines +243 to +248
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
IntentFilter intentFilterProfileAvailable = new IntentFilter(Intent.ACTION_PROFILE_AVAILABLE);
IntentFilter intentFilterProfileUnAvailable = new IntentFilter(Intent.ACTION_PROFILE_UNAVAILABLE);
this.registerReceiver(mReceiver, intentFilterProfileAvailable, Context.RECEIVER_EXPORTED);
this.registerReceiver(mReceiver, intentFilterProfileUnAvailable, Context.RECEIVER_EXPORTED);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, see ProfileChangedHandler

Comment on lines +766 to +782
@RequiresApi(35)
private void privateSpaceStateEvent(UserHandle handle) {
if (handle == null) {
return;
}

final LauncherApps launcher = (LauncherApps) this.getSystemService(Context.LAUNCHER_APPS_SERVICE);

LauncherUserInfo info = launcher.getLauncherUserInfo(handle);
if (info != null) {
if (info.getUserType().equalsIgnoreCase(UserManager.USER_TYPE_PROFILE_PRIVATE)) {
Log.d(TAG, "Private Space state changed");
// TODO: Check if private space state changed and change app view accordingly
}
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, see ProfileChangedHandler

Copy link
Collaborator

Choose a reason for hiding this comment

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

how are these theme changes related to private space? Is this fix for differet problem?

Comment on lines +429 to +432
} else if (isPrivateSpaceUnlocked()) {
privateSpaceItem.setTitle("Lock Private Space");
} else {
privateSpaceItem.setTitle("Unlock Private Space");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't forget about resources for titles here.

@@ -63,7 +68,18 @@ protected List<AppPojo> doInBackground(Void... params) {
ApplicationInfo appInfo = activityInfo.getApplicationInfo();
boolean disabled = PackageManagerUtils.isAppSuspended(appInfo) || isQuietModeEnabled(manager, profile);
final AppPojo app = createPojo(user, appInfo.packageName, activityInfo.getName(), activityInfo.getLabel(), disabled, excludedAppList, excludedFromHistoryAppList, excludedShortcutsAppList);
apps.add(app);
if ((android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you try to move code related to private space to separate class?

Code in MainActivity, in LoadShortcutsPojos class and in this class seems all pretty similar, this should be generalized somewhere instead of duplicated when possible.

@@ -71,10 +93,30 @@ protected List<ShortcutPojo> doInBackground(Void... params) {
return pojos;
}

@RequiresApi(35)
private boolean shouldAddShortcut(UserManager manager, LauncherUserInfo info,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Method to check if shortcuts should be hidden is already there, it's ShortcutUtil.isShortcutVisible some lines above.
Can you add the additional check there, as there is already some more logic depending on visibility of shortcuts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants