Feature: Respect hidden private space option (#1923)

* Hide private profile space apps from search when hide private space option is enabled, and add a search action for locking and unlocking the private space.

* Filter private space apps from favorites while hidden
This commit is contained in:
Alex Alwardt
2026-07-04 09:57:54 -04:00
committed by GitHub
parent 031359197c
commit db051292be
16 changed files with 167 additions and 17 deletions

View File

@@ -41,6 +41,7 @@ data class Profile(
data class State(
val locked: Boolean = false,
val hidden: Boolean = false,
)
companion object {

View File

@@ -762,6 +762,9 @@
<string name="search_action_contact">Add to contacts</string>
<string name="search_action_open_url">View website</string>
<string name="search_action_event">Schedule event</string>
<string name="search_action_private_space">Private space</string>
<string name="search_action_private_space_lock">Lock private space</string>
<string name="search_action_private_space_unlock">Unlock private space</string>
<string name="create_search_action_title">New quick action</string>
<string name="edit_search_action_title">Edit quick action</string>
<string name="create_search_action_type">What type of action do you want to create?</string>

View File

@@ -5,6 +5,7 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.LauncherApps
import android.content.pm.LauncherUserInfo
import android.os.Process
import android.os.UserHandle
import android.os.UserManager
@@ -71,6 +72,11 @@ class ProfileManager(
it.mapNotNull { it?.profile }
}.shareIn(scope, SharingStarted.WhileSubscribed(), replay = 1)
val hiddenPrivateSpaceUser: Flow<UserHandle?> = profileStates.map { profiles ->
val private = profiles[2]
if (private?.state?.hidden == true) private.profile.userHandle else null
}.shareIn(scope, SharingStarted.WhileSubscribed(), replay = 1)
init {
val receiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
@@ -164,9 +170,16 @@ class ProfileManager(
}
private fun getProfileState(userHandle: UserHandle): Profile.State {
return Profile.State(
locked = !userManager.isUserUnlocked(userHandle),
)
val locked = !userManager.isUserUnlocked(userHandle)
val hidden = if (isAtLeastApiLevel(36) && locked) {
launcherApps.getLauncherUserInfo(userHandle)
?.getUserConfig()
?.getBoolean(LauncherUserInfo.PRIVATE_SPACE_ENTRYPOINT_HIDDEN, false)
?: false
} else {
false
}
return Profile.State(locked = locked, hidden = hidden)
}
@RequiresApi(28)