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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user