mirror of
https://github.com/home-assistant/android
synced 2024-07-22 10:54:12 +00:00
Remove NFC tag sample YAML for 'scanned by this device' on 2022.12+ (#3114)
This commit is contained in:
parent
11e8d5a8e8
commit
4ec5fbf1f0
|
@ -30,6 +30,8 @@ class NfcViewModel @Inject constructor(
|
|||
|
||||
var isNfcEnabled by mutableStateOf(false)
|
||||
private set
|
||||
var usesAndroidDeviceId by mutableStateOf(false)
|
||||
private set
|
||||
var nfcTagIdentifier by mutableStateOf<String?>(null)
|
||||
private set
|
||||
var nfcIdentifierIsEditable by mutableStateOf(true)
|
||||
|
@ -42,6 +44,12 @@ class NfcViewModel @Inject constructor(
|
|||
private val _nfcResultSnackbar = MutableSharedFlow<Int>()
|
||||
var nfcResultSnackbar = _nfcResultSnackbar.asSharedFlow()
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
usesAndroidDeviceId = !integrationUseCase.isHomeAssistantVersionAtLeast(2022, 12, 0)
|
||||
}
|
||||
}
|
||||
|
||||
fun setDestination(destination: String?) {
|
||||
nfcEventShouldWrite = nfcTagIdentifier != null && destination == NfcSetupActivity.NAV_WRITE
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import io.homeassistant.companion.android.common.R as commonR
|
|||
@Composable
|
||||
fun NfcEditView(
|
||||
identifier: String?,
|
||||
showDeviceSample: Boolean,
|
||||
onDuplicateClicked: () -> Unit,
|
||||
onFireEventClicked: () -> Unit
|
||||
) {
|
||||
|
@ -79,15 +80,17 @@ fun NfcEditView(
|
|||
item {
|
||||
NfcTriggerExample(
|
||||
modifier = Modifier.padding(bottom = 8.dp),
|
||||
description = stringResource(commonR.string.nfc_trigger_any),
|
||||
description = if (showDeviceSample) stringResource(commonR.string.nfc_trigger_any) else "",
|
||||
example = tagTriggerExample
|
||||
)
|
||||
}
|
||||
item {
|
||||
NfcTriggerExample(
|
||||
description = stringResource(commonR.string.nfc_trigger_device),
|
||||
example = deviceTriggerExample
|
||||
)
|
||||
if (showDeviceSample) {
|
||||
item {
|
||||
NfcTriggerExample(
|
||||
description = stringResource(commonR.string.nfc_trigger_device),
|
||||
example = deviceTriggerExample
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.homeassistant.companion.android.nfc.views
|
|||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.IconButton
|
||||
import androidx.compose.material.Scaffold
|
||||
|
@ -93,11 +94,11 @@ fun LoadNfcView(
|
|||
contentColor = colorResource(commonR.color.colorOnBackground)
|
||||
)
|
||||
}
|
||||
) {
|
||||
) { contentPadding ->
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = startDestination,
|
||||
modifier = Modifier
|
||||
modifier = Modifier.padding(contentPadding)
|
||||
) {
|
||||
composable(NfcSetupActivity.NAV_WELCOME) {
|
||||
NfcWelcomeView(
|
||||
|
@ -121,6 +122,7 @@ fun LoadNfcView(
|
|||
composable(NfcSetupActivity.NAV_EDIT) {
|
||||
NfcEditView(
|
||||
identifier = viewModel.nfcTagIdentifier,
|
||||
showDeviceSample = viewModel.usesAndroidDeviceId,
|
||||
onDuplicateClicked = { viewModel.duplicateNfcTag() },
|
||||
onFireEventClicked = { viewModel.fireNfcTagEvent() }
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue