diff options
| author | 2024-01-30 15:54:03 -0500 | |
|---|---|---|
| committer | 2024-01-30 15:57:54 -0500 | |
| commit | 068c7147bd553869fca073fee25f62809c82fb3d (patch) | |
| tree | 3e74270b534164f238e76a84d319699e5d740340 /java/src | |
| parent | bd5caa0531d029d5215df0cab98d62c73b8f6d7e (diff) | |
Adds ProfilePagerResources
This consolidates resources for tabbed profile UI into a form
which can be accessed generically, via profile type, instead of
specific properties.
Bug: 309960444
Test: manual
Change-Id: If96d1a5956ee5c25a36ab5d7160289bb655c224b
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/com/android/intentresolver/v2/ui/ProfilePagerResources.kt | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/java/src/com/android/intentresolver/v2/ui/ProfilePagerResources.kt b/java/src/com/android/intentresolver/v2/ui/ProfilePagerResources.kt new file mode 100644 index 00000000..0d31b23e --- /dev/null +++ b/java/src/com/android/intentresolver/v2/ui/ProfilePagerResources.kt @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.intentresolver.v2.ui + +import android.content.res.Resources +import com.android.intentresolver.inject.ApplicationOwned +import com.android.intentresolver.v2.data.repository.DevicePolicyResources +import com.android.intentresolver.v2.domain.model.Profile +import javax.inject.Inject +import com.android.intentresolver.R + +class ProfilePagerResources +@Inject +constructor( + @ApplicationOwned private val resources: Resources, + private val devicePolicyResources: DevicePolicyResources +) { + private val privateTabLabel by lazy { resources.getString(R.string.resolver_private_tab) } + + private val privateTabAccessibilityLabel by lazy { + resources.getString(R.string.resolver_private_tab_accessibility) + } + + fun profileTabLabel(profile: Profile.Type): String { + return when (profile) { + Profile.Type.PERSONAL -> devicePolicyResources.personalTabLabel + Profile.Type.WORK -> devicePolicyResources.workTabLabel + Profile.Type.PRIVATE -> privateTabLabel + } + } + + fun profileTabAccessibilityLabel(type: Profile.Type): String { + return when (type) { + Profile.Type.PERSONAL -> devicePolicyResources.personalTabAccessibilityLabel + Profile.Type.WORK -> devicePolicyResources.workTabAccessibilityLabel + Profile.Type.PRIVATE -> privateTabAccessibilityLabel + } + } +}
\ No newline at end of file |