diff --git a/lib_utils/src/main/res/values/string.xml b/lib_utils/src/main/res/values/string.xml new file mode 100644 index 00000000..508ae8e6 --- /dev/null +++ b/lib_utils/src/main/res/values/string.xml @@ -0,0 +1,13 @@ + + + Device Firmware Update + DFU + nRF Connect Device Manager + SMP + nRF Connect Device Manager + MDS + Legacy DFU + Legacy DFU + Buttonless DFU + Buttonless DFU + \ No newline at end of file diff --git a/profile/src/main/java/no/nordicsemi/android/toolbox/profile/view/dfu/DFUScreen.kt b/profile/src/main/java/no/nordicsemi/android/toolbox/profile/view/dfu/DFUScreen.kt index f81db6e9..c66c3a50 100644 --- a/profile/src/main/java/no/nordicsemi/android/toolbox/profile/view/dfu/DFUScreen.kt +++ b/profile/src/main/java/no/nordicsemi/android/toolbox/profile/view/dfu/DFUScreen.kt @@ -20,6 +20,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -33,9 +34,17 @@ internal fun DFUScreen() { val dfuServiceState by dfuViewModel.dfuServiceState.collectAsStateWithLifecycle() val context = LocalContext.current val uriHandler = LocalUriHandler.current + dfuServiceState.dfuAppName?.let { dfuApp -> val intent = context.packageManager.getLaunchIntentForPackage(dfuApp.packageName) - val description = intent?.let { "Open ${dfuApp.appName}" } ?: "Download from Play Store" + val description = + intent?.let { + stringResource( + R.string.dfu_description_open, + stringResource(dfuApp.appName) + ) + } + ?: stringResource(R.string.dfu_description_download) Column( modifier = Modifier @@ -52,20 +61,26 @@ internal fun DFUScreen() { horizontalAlignment = Alignment.CenterHorizontally, ) { Icon( - painter = painterResource(R.drawable.ic_dfu), + painter = painterResource(dfuApp.appIcon), contentDescription = null, tint = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.size(56.dp) ) Text( - text = "DFU is not supported", + text = stringResource( + R.string.dfu_not_supported_title, + stringResource(dfuApp.appShortName) + ), style = MaterialTheme.typography.titleMedium ) Text( - text = "DFU service is not available in the current version of the app. " + - "Please use the DFU app from Nordic Semiconductor to update your device’s firmware.", + text = stringResource( + R.string.dfu_not_supported_text, + stringResource(dfuApp.appShortName), + stringResource(dfuApp.appName) + ), textAlign = TextAlign.Center, style = MaterialTheme.typography.bodyMedium ) @@ -80,13 +95,12 @@ internal fun DFUScreen() { ) { Row(verticalAlignment = Alignment.CenterVertically) { val icon = intent?.let { dfuApp.appIcon } ?: R.drawable.google_play_2022_icon - val size = if (intent != null) 56.dp else 28.dp Icon( painter = painterResource(icon), contentDescription = null, modifier = Modifier - .size(size) + .size(40.dp) .padding(end = 8.dp), tint = if (intent == null) Color.Unspecified else MaterialTheme.colorScheme.onPrimary ) diff --git a/profile/src/main/res/values/dfuStrings.xml b/profile/src/main/res/values/dfuStrings.xml new file mode 100644 index 00000000..ae269ba4 --- /dev/null +++ b/profile/src/main/res/values/dfuStrings.xml @@ -0,0 +1,8 @@ + + + Open %s + Download from Play Store + %s is not supported + %1s service is not available in the current version of the app. Please use the %2s app from Nordic Semiconductor to update your device’s firmware. + + \ No newline at end of file diff --git a/profile_data/src/main/java/no/nordicsemi/android/toolbox/profile/data/DFUServiceData.kt b/profile_data/src/main/java/no/nordicsemi/android/toolbox/profile/data/DFUServiceData.kt index ff047fb6..ade594ef 100644 --- a/profile_data/src/main/java/no/nordicsemi/android/toolbox/profile/data/DFUServiceData.kt +++ b/profile_data/src/main/java/no/nordicsemi/android/toolbox/profile/data/DFUServiceData.kt @@ -1,6 +1,7 @@ package no.nordicsemi.android.toolbox.profile.data import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import no.nordicsemi.android.toolbox.lib.utils.Profile import no.nordicsemi.android.toolbox.lib.utils.R @@ -20,37 +21,43 @@ data class DFUServiceData( enum class DFUsAvailable( val packageName: String, val appLink: String, - val appName: String, - @DrawableRes val appIcon: Int + @param:StringRes val appName: Int, + @param:DrawableRes val appIcon: Int, + @param:StringRes val appShortName: Int, ) { DFU_SERVICE( packageName = DFU_PACKAGE_NAME, appLink = DFU_APP_LINK, - appName = "DFU", - appIcon = R.drawable.ic_dfu + appName = R.string.dfu_app_name, + appIcon = R.drawable.ic_dfu, + appShortName = R.string.dfu_short_name, ), SMP_SERVICE( packageName = SMP_PACKAGE_NAME, appLink = SMP_APP_LINK, - appName = "nRF Connect Device Manager", - appIcon = R.drawable.ic_device_manager + appName = R.string.smp_app_name, + appIcon = R.drawable.ic_device_manager, + appShortName = R.string.smp_short_name, ), MDS_SERVICE( packageName = SMP_PACKAGE_NAME, appLink = SMP_APP_LINK, - appName = "nRF Connect Device Manager", - appIcon = R.drawable.ic_device_manager + appName = R.string.mds_app_name, + appIcon = R.drawable.ic_device_manager, + appShortName = R.string.mds_app_name, ), LEGACY_DFU_SERVICE( packageName = DFU_PACKAGE_NAME, appLink = DFU_APP_LINK, - appName = "DFU", - appIcon = R.drawable.ic_dfu + appName = R.string.legacy_dfu_app_name, + appIcon = R.drawable.ic_dfu, + appShortName = R.string.legacy_dfu_short_name, ), EXPERIMENTAL_BUTTONLESS_DFU_SERVICE( packageName = DFU_PACKAGE_NAME, appLink = DFU_APP_LINK, - appName = "DFU", - appIcon = R.drawable.ic_dfu + appName = R.string.buttonless_dfu_app_name, + appIcon = R.drawable.ic_dfu, + appShortName = R.string.buttonless_dfu_short_name, ) } \ No newline at end of file