mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-24 01:44:23 +01:00
Modify DFU button
This commit is contained in:
@@ -29,6 +29,7 @@ fun FeatureButton(
|
||||
@StringRes nameCode: Int,
|
||||
@StringRes name: Int,
|
||||
isRunning: Boolean? = null,
|
||||
@StringRes description: Int? = null,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
ScreenSection(onClick = onClick) {
|
||||
@@ -57,12 +58,26 @@ fun FeatureButton(
|
||||
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = name),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = Modifier.weight(1f),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(id = name),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
description?.let {
|
||||
Spacer(modifier = Modifier.size(4.dp))
|
||||
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(id = it),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -19,6 +20,7 @@ import no.nordicsemi.android.nrftoolbox.R
|
||||
import no.nordicsemi.android.nrftoolbox.viewmodel.HomeViewModel
|
||||
import no.nordicsemi.android.theme.view.TitleAppBar
|
||||
|
||||
private const val DFU_PACKAGE_NAME = "no.nordicsemi.android.dfu"
|
||||
private const val DFU_LINK = "https://play.google.com/store/apps/details?id=no.nordicsemi.android.dfu"
|
||||
|
||||
@Composable
|
||||
@@ -120,8 +122,15 @@ fun HomeScreen() {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
val uriHandler = LocalUriHandler.current
|
||||
FeatureButton(R.drawable.ic_dfu, R.string.dfu_module, R.string.dfu_module_full) {
|
||||
uriHandler.openUri(DFU_LINK)
|
||||
val context = LocalContext.current
|
||||
val packageManger = context.packageManager
|
||||
FeatureButton(R.drawable.ic_dfu, R.string.dfu_module, R.string.dfu_module_full, null, R.string.dfu_module_info) {
|
||||
val intent = packageManger.getLaunchIntentForPackage(DFU_PACKAGE_NAME)
|
||||
if (intent != null) {
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
uriHandler.openUri(DFU_LINK)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
<string name="uart_module">UART</string>
|
||||
<string name="uart_module_full">Serial port over BLE</string>
|
||||
<string name="dfu_module">DFU</string>
|
||||
<string name="dfu_module_full">Available in separate application.</string>
|
||||
<string name="dfu_module_full">Device Firmware Update</string>
|
||||
<string name="dfu_module_info">Available in separate application.</string>
|
||||
|
||||
<string name="viewmodel_profiles">ViewModel profiles</string>
|
||||
<string name="service_profiles">Service profiles</string>
|
||||
|
||||
Reference in New Issue
Block a user