Add app name in appinfo page
Show the app's packageName at the bottom of the AppInfo page. Fix: 290884979 Test: Visual Test Change-Id: If74c9956ee617897c30a26b1fd0ab6bc91582e28
This commit is contained in:
@@ -27,14 +27,17 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.Divider
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler
|
||||
import com.android.settingslib.spa.framework.compose.rememberDrawablePainter
|
||||
import com.android.settingslib.spa.framework.theme.SettingsDimension
|
||||
import com.android.settingslib.spa.widget.ui.SettingsBody
|
||||
@@ -80,11 +83,22 @@ class AppInfoProvider(private val packageInfo: PackageInfo) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun FooterAppVersion() {
|
||||
fun FooterAppVersion(showPackageName: Boolean = rememberIsDevelopmentSettingsEnabled()) {
|
||||
if (packageInfo.versionName == null) return
|
||||
Divider()
|
||||
Box(modifier = Modifier.padding(SettingsDimension.itemPadding)) {
|
||||
HorizontalDivider()
|
||||
Column(modifier = Modifier.padding(SettingsDimension.itemPadding)) {
|
||||
SettingsBody(stringResource(R.string.version_text, packageInfo.versionNameBidiWrapped))
|
||||
if (showPackageName) {
|
||||
SettingsBody(packageInfo.packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun rememberIsDevelopmentSettingsEnabled(): Boolean {
|
||||
val context = LocalContext.current
|
||||
return remember {
|
||||
DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ class AppInfoTest {
|
||||
val packageInfo = PackageInfo().apply {
|
||||
applicationInfo = APP
|
||||
versionName = VERSION_NAME
|
||||
packageName = PACKAGE_NAME
|
||||
}
|
||||
val appInfoProvider = AppInfoProvider(packageInfo)
|
||||
|
||||
@@ -105,9 +106,45 @@ class AppInfoTest {
|
||||
composeTestRule.onNodeWithText("version $VERSION_NAME").assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun footerAppVersion_developmentEnabled_packageNameIsDisplayed() {
|
||||
val packageInfo = PackageInfo().apply {
|
||||
applicationInfo = APP
|
||||
versionName = VERSION_NAME
|
||||
packageName = PACKAGE_NAME
|
||||
}
|
||||
val appInfoProvider = AppInfoProvider(packageInfo)
|
||||
|
||||
composeTestRule.setContent {
|
||||
CompositionLocalProvider(LocalContext provides context) {
|
||||
appInfoProvider.FooterAppVersion(true)
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithText(PACKAGE_NAME).assertIsDisplayed()
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun footerAppVersion_developmentDisabled_packageNameDoesNotExist() {
|
||||
val packageInfo = PackageInfo().apply {
|
||||
applicationInfo = APP
|
||||
versionName = VERSION_NAME
|
||||
packageName = PACKAGE_NAME
|
||||
}
|
||||
val appInfoProvider = AppInfoProvider(packageInfo)
|
||||
|
||||
composeTestRule.setContent {
|
||||
CompositionLocalProvider(LocalContext provides context) {
|
||||
appInfoProvider.FooterAppVersion(false)
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithText(PACKAGE_NAME).assertDoesNotExist()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val LABEL = "Label"
|
||||
const val VERSION_NAME = "VersionName"
|
||||
const val PACKAGE_NAME = "package.name"
|
||||
val APP = object : ApplicationInfo() {
|
||||
override fun loadLabel(pm: PackageManager) = LABEL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user