Skip to content

Commit

Permalink
fix(config): respect enabled parameter for Send button
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Nov 11, 2024
1 parent 683b354 commit 5480174
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fun AmbientLightingConfigItemList(

item {
PreferenceFooter(
enabled = ambientLightingInput != ambientLightingConfig,
enabled = enabled && ambientLightingInput != ambientLightingConfig,
onCancelClicked = {
focusManager.clearFocus()
ambientLightingInput = ambientLightingConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fun AudioConfigItemList(

item {
PreferenceFooter(
enabled = audioInput != audioConfig,
enabled = enabled && audioInput != audioConfig,
onCancelClicked = {
focusManager.clearFocus()
audioInput = audioConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fun BluetoothConfigItemList(

item {
PreferenceFooter(
enabled = bluetoothInput != bluetoothConfig,
enabled = enabled && bluetoothInput != bluetoothConfig,
onCancelClicked = {
focusManager.clearFocus()
bluetoothInput = bluetoothConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fun CannedMessageConfigItemList(

item {
PreferenceFooter(
enabled = cannedMessageInput != cannedMessageConfig || messagesInput != messages,
enabled = enabled && cannedMessageInput != cannedMessageConfig || messagesInput != messages,
onCancelClicked = {
focusManager.clearFocus()
messagesInput = messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fun ChannelSettingsItemList(

item {
PreferenceFooter(
enabled = isEditing,
enabled = enabled && isEditing,
negativeText = R.string.cancel,
onNegativeClicked = {
focusManager.clearFocus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fun DetectionSensorConfigItemList(

item {
PreferenceFooter(
enabled = detectionSensorInput != detectionSensorConfig,
enabled = enabled && detectionSensorInput != detectionSensorConfig,
onCancelClicked = {
focusManager.clearFocus()
detectionSensorInput = detectionSensorConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fun DisplayConfigItemList(

item {
PreferenceFooter(
enabled = displayInput != displayConfig,
enabled = enabled && displayInput != displayConfig,
onCancelClicked = {
focusManager.clearFocus()
displayInput = displayConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fun ExternalNotificationConfigItemList(

item {
PreferenceFooter(
enabled = externalNotificationInput != extNotificationConfig || ringtoneInput != ringtone,
enabled = enabled && externalNotificationInput != extNotificationConfig || ringtoneInput != ringtone,
onCancelClicked = {
focusManager.clearFocus()
ringtoneInput = ringtone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fun LoRaConfigItemList(

item {
PreferenceFooter(
enabled = loraInput != loraConfig,
enabled = enabled && loraInput != loraConfig,
onCancelClicked = {
focusManager.clearFocus()
loraInput = loraConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fun MQTTConfigItemList(

item {
PreferenceFooter(
enabled = mqttInput != mqttConfig,
enabled = enabled && mqttInput != mqttConfig,
onCancelClicked = {
focusManager.clearFocus()
mqttInput = mqttConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fun NeighborInfoConfigItemList(

item {
PreferenceFooter(
enabled = neighborInfoInput != neighborInfoConfig,
enabled = enabled && neighborInfoInput != neighborInfoConfig,
onCancelClicked = {
focusManager.clearFocus()
neighborInfoInput = neighborInfoConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ fun NetworkConfigScreen(
)
}

private fun extractWifiCredentials(qrCode: String) = Regex("""WIFI:S:(.*?);.*?P:(.*?);""")
.find(qrCode)?.destructured
?.let { (ssid, password) -> ssid to password } ?: (null to null)

@Composable
fun NetworkConfigItemList(
networkConfig: NetworkConfig,
Expand All @@ -87,11 +91,6 @@ fun NetworkConfigItemList(
ScanErrorDialog { showScanErrorDialog = false }
}

fun extractWifiCredentials(qrCode: String) = Regex("""WIFI:S:(.*?);.*?P:(.*?);""")
.find(qrCode)?.destructured
?.let { (ssid, password) -> ssid to password }
?: (null to null)

val barcodeLauncher = rememberLauncherForActivityResult(ScanContract()) { result ->
if (result.contents != null) {
val (ssid, psk) = extractWifiCredentials(result.contents)
Expand Down Expand Up @@ -258,7 +257,7 @@ fun NetworkConfigItemList(

item {
PreferenceFooter(
enabled = networkInput != networkConfig,
enabled = enabled && networkInput != networkConfig,
onCancelClicked = {
focusManager.clearFocus()
networkInput = networkConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fun PaxcounterConfigItemList(

item {
PreferenceFooter(
enabled = paxcounterInput != paxcounterConfig,
enabled = enabled && paxcounterInput != paxcounterConfig,
onCancelClicked = {
focusManager.clearFocus()
paxcounterInput = paxcounterConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ fun PositionConfigItemList(

item {
PreferenceFooter(
enabled = positionInput != positionConfig || locationInput != location,
enabled = enabled && positionInput != positionConfig || locationInput != location,
onCancelClicked = {
focusManager.clearFocus()
locationInput = location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fun PowerConfigItemList(

item {
PreferenceFooter(
enabled = powerInput != powerConfig,
enabled = enabled && powerInput != powerConfig,
onCancelClicked = {
focusManager.clearFocus()
powerInput = powerConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun RangeTestConfigItemList(

item {
PreferenceFooter(
enabled = rangeTestInput != rangeTestConfig,
enabled = enabled && rangeTestInput != rangeTestConfig,
onCancelClicked = {
focusManager.clearFocus()
rangeTestInput = rangeTestConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fun RemoteHardwareConfigItemList(

item {
PreferenceFooter(
enabled = remoteHardwareInput != remoteHardwareConfig,
enabled = enabled && remoteHardwareInput != remoteHardwareConfig,
onCancelClicked = {
focusManager.clearFocus()
remoteHardwareInput = remoteHardwareConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fun SecurityConfigItemList(

item {
PreferenceFooter(
enabled = securityInput != securityConfig,
enabled = enabled && securityInput != securityConfig,
onCancelClicked = {
focusManager.clearFocus()
securityInput = securityConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fun SerialConfigItemList(

item {
PreferenceFooter(
enabled = serialInput != serialConfig,
enabled = enabled && serialInput != serialConfig,
onCancelClicked = {
focusManager.clearFocus()
serialInput = serialConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fun StoreForwardConfigItemList(

item {
PreferenceFooter(
enabled = storeForwardInput != storeForwardConfig,
enabled = enabled && storeForwardInput != storeForwardConfig,
onCancelClicked = {
focusManager.clearFocus()
storeForwardInput = storeForwardConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fun TelemetryConfigItemList(

item {
PreferenceFooter(
enabled = telemetryInput != telemetryConfig,
enabled = enabled && telemetryInput != telemetryConfig,
onCancelClicked = {
focusManager.clearFocus()
telemetryInput = telemetryConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fun UserConfigItemList(

item {
PreferenceFooter(
enabled = userInput != userConfig,
enabled = enabled && userInput != userConfig,
onCancelClicked = {
focusManager.clearFocus()
userInput = userConfig
Expand Down

0 comments on commit 5480174

Please sign in to comment.