Merge "Remove primaryUserOnly param from AppListPage" into udc-qpr-dev

This commit is contained in:
Chaohui Wang
2023-06-15 09:29:37 +00:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 11 deletions

View File

@@ -42,7 +42,6 @@ fun <T : AppRecord> AppListPage(
showInstantApps: Boolean = false,
noMoreOptions: Boolean = false,
matchAnyUserForAdmin: Boolean = false,
primaryUserOnly: Boolean = false,
noItemMessage: String? = null,
moreOptions: @Composable MoreOptionsScope.() -> Unit = {},
header: @Composable () -> Unit = {},
@@ -60,7 +59,7 @@ fun <T : AppRecord> AppListPage(
}
},
) { bottomPadding, searchQuery ->
UserProfilePager(primaryUserOnly) { userGroup ->
UserProfilePager { userGroup ->
val appListInput = AppListInput(
config = AppListConfig(
userIds = userGroup.userInfos.map { it.id },

View File

@@ -38,14 +38,9 @@ data class UserGroup(
)
@Composable
fun UserProfilePager(
primaryUserOnly: Boolean = false,
content: @Composable (userGroup: UserGroup) -> Unit,
) {
fun UserProfilePager(content: @Composable (userGroup: UserGroup) -> Unit) {
val context = LocalContext.current
val userGroups = remember {
context.userManager.getUserGroups(primaryUserOnly)
}
val userGroups = remember { context.userManager.getUserGroups() }
val titles = remember {
val enterpriseRepository = EnterpriseRepository(context)
userGroups.map { userGroup ->
@@ -60,10 +55,9 @@ fun UserProfilePager(
}
}
private fun UserManager.getUserGroups(primaryUserOnly: Boolean): List<UserGroup> {
private fun UserManager.getUserGroups(): List<UserGroup> {
val userGroupList = mutableListOf<UserGroup>()
val profileToShowInSettingsList = getProfiles(UserHandle.myUserId())
.filter { userInfo -> !primaryUserOnly || userInfo.isPrimary }
.map { userInfo -> userInfo to getUserProperties(userInfo.userHandle).showInSettings }
profileToShowInSettingsList.filter { it.second == UserProperties.SHOW_IN_SETTINGS_WITH_PARENT }