Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1eaa4688 authored by Manish Singh's avatar Manish Singh
Browse files

Allow the title to be updated for any profile type

Currently it supports only the work profile / personal profile
distinction. So, any profile other than the managed profile gets the
Personal profile title.

Bug: 302278487
Test: manual
Change-Id: I2498d89e9c68c55a819e6285691b946b3498f8b7
parent a60a9eb5
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -18,8 +18,10 @@ package com.android.settingslib.spaprivileged.model.enterprise


import android.app.admin.DevicePolicyManager
import android.app.admin.DevicePolicyManager
import android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_CATEGORY_HEADER
import android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_CATEGORY_HEADER
import android.app.admin.DevicePolicyResources.Strings.Settings.PRIVATE_CATEGORY_HEADER
import android.app.admin.DevicePolicyResources.Strings.Settings.WORK_CATEGORY_HEADER
import android.app.admin.DevicePolicyResources.Strings.Settings.WORK_CATEGORY_HEADER
import android.content.Context
import android.content.Context
import android.content.pm.UserInfo
import com.android.settingslib.R
import com.android.settingslib.R


class EnterpriseRepository(private val context: Context) {
class EnterpriseRepository(private val context: Context) {
@@ -30,8 +32,10 @@ class EnterpriseRepository(private val context: Context) {
    fun getEnterpriseString(updatableStringId: String, resId: Int): String =
    fun getEnterpriseString(updatableStringId: String, resId: Int): String =
        checkNotNull(resources.getString(updatableStringId) { context.getString(resId) })
        checkNotNull(resources.getString(updatableStringId) { context.getString(resId) })


    fun getProfileTitle(isManagedProfile: Boolean): String = if (isManagedProfile) {
    fun getProfileTitle(userInfo: UserInfo): String = if (userInfo.isManagedProfile) {
        getEnterpriseString(WORK_CATEGORY_HEADER, R.string.category_work)
        getEnterpriseString(WORK_CATEGORY_HEADER, R.string.category_work)
    } else if (userInfo.isPrivateProfile) {
        getEnterpriseString(PRIVATE_CATEGORY_HEADER, R.string.category_private)
    } else {
    } else {
        getEnterpriseString(PERSONAL_CATEGORY_HEADER, R.string.category_personal)
        getEnterpriseString(PERSONAL_CATEGORY_HEADER, R.string.category_personal)
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -45,7 +45,7 @@ fun UserProfilePager(content: @Composable (userGroup: UserGroup) -> Unit) {
        val enterpriseRepository = EnterpriseRepository(context)
        val enterpriseRepository = EnterpriseRepository(context)
        userGroups.map { userGroup ->
        userGroups.map { userGroup ->
            enterpriseRepository.getProfileTitle(
            enterpriseRepository.getProfileTitle(
                isManagedProfile = userGroup.userInfos.first().isManagedProfile,
                userGroup.userInfos.first(),
            )
            )
        }
        }
    }
    }