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

Commit a3db6887 authored by Chaohui Wang's avatar Chaohui Wang Committed by Android (Google) Code Review
Browse files

Merge "Fix references to resources for Spa" into main

parents 56e7b532 20f1083d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ android_library {
    name: "SpaLib",

    srcs: ["src/**/*.kt"],

    use_resource_processor: true,
    static_libs: [
        "androidx.slice_slice-builders",
        "androidx.slice_slice-core",
@@ -50,5 +50,6 @@ android_library {
// Expose the srcs to tests, so the tests can access the internal classes.
filegroup {
    name: "SpaLib_srcs",
    visibility: ["//frameworks/base/packages/SettingsLib/Spa/tests"],
    srcs: ["src/**/*.kt"],
}
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ android_library {
    name: "SpaLibTestUtils",

    srcs: ["src/**/*.kt"],

    use_resource_processor: true,
    static_libs: [
        "SpaLib",
        "androidx.arch.core_core-testing",
+2 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ android_library {
    name: "SpaPrivilegedLib",

    srcs: ["src/**/*.kt"],

    use_resource_processor: true,
    static_libs: [
        "SpaLib",
        "SettingsLib",
@@ -45,5 +45,6 @@ java_defaults {
// Expose the srcs to tests, so the tests can access the internal classes.
filegroup {
    name: "SpaPrivilegedLib_srcs",
    visibility: [":__subpackages__"],
    srcs: ["src/**/*.kt"],
}
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.settingslib.spaprivileged.framework.compose

import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.android.settingslib.R

/** An empty placer holder string. */
@Composable
fun placeholder() = stringResource(R.string.summary_placeholder)

/** Gets an empty placer holder string. */
fun Context.getPlaceholder(): String = getString(R.string.summary_placeholder)
+3 −3
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.produceState
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.android.settingslib.Utils
import com.android.settingslib.spa.framework.compose.rememberContext
import com.android.settingslib.spaprivileged.R
import com.android.settingslib.spaprivileged.framework.common.userManager
import com.android.settingslib.spaprivileged.framework.compose.placeholder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

@@ -40,7 +40,7 @@ interface AppRepository {
    @Composable
    fun produceLabel(app: ApplicationInfo, isClonedAppPage: Boolean = false): State<String> {
        val context = LocalContext.current
        return produceState(initialValue = stringResource(R.string.summary_placeholder), app) {
        return produceState(initialValue = placeholder(), app) {
            withContext(Dispatchers.IO) {
                value = if (isClonedAppPage || isCloneApp(context, app)) {
                    context.getString(R.string.cloned_app_info_label, loadLabel(app))
@@ -82,7 +82,7 @@ internal class AppRepositoryImpl(private val context: Context) : AppRepository {
            withContext(Dispatchers.IO) {
                value = when {
                    context.userManager.isManagedProfile(app.userId) -> {
                        context.getString(R.string.category_work)
                        context.getString(com.android.settingslib.R.string.category_work)
                    }

                    else -> null
Loading