From 1b9560b601b16c576a4295bfa5fb40167b5b504d Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Sat, 18 Jan 2025 07:16:12 -0500 Subject: [PATCH] fix: light mode text bugs --- .../config/SubmitConfigurationTextBox.kt | 6 +-- .../components/TrustNetworksTextBox.kt | 10 ++++- .../tunneloptions/config/ConfigScreen.kt | 39 ++++++++++++++++--- .../util/extensions/ContextExtensions.kt | 10 ++--- 4 files changed, 49 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/config/SubmitConfigurationTextBox.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/config/SubmitConfigurationTextBox.kt index afa4d25..3a36926 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/config/SubmitConfigurationTextBox.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/common/config/SubmitConfigurationTextBox.kt @@ -47,13 +47,13 @@ fun SubmitConfigurationTextBox( CustomTextField( isError = isErrorValue(stateValue), - textStyle = MaterialTheme.typography.bodySmall, + textStyle = MaterialTheme.typography.bodySmall.copy(color = MaterialTheme.colorScheme.onSurface), value = stateValue, onValueChange = { stateValue = it }, interactionSource = interactionSource, - label = { Text(label) }, + label = { Text(label, color = MaterialTheme.colorScheme.onSurface, style = MaterialTheme.typography.labelMedium) }, containerColor = MaterialTheme.colorScheme.surface, - placeholder = { Text(hint, style = MaterialTheme.typography.bodySmall) }, + placeholder = { Text(hint, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.outline) }, modifier = Modifier .padding( diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/autotunnel/components/TrustNetworksTextBox.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/autotunnel/components/TrustNetworksTextBox.kt index 81869af..d608de7 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/autotunnel/components/TrustNetworksTextBox.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/autotunnel/components/TrustNetworksTextBox.kt @@ -65,11 +65,17 @@ fun TrustedNetworkTextBox( } } CustomTextField( - textStyle = MaterialTheme.typography.bodySmall, + textStyle = MaterialTheme.typography.bodySmall.copy(color = MaterialTheme.colorScheme.onSurface), value = currentText, onValueChange = onValueChange, interactionSource = remember { MutableInteractionSource() }, - label = { Text(stringResource(R.string.add_wifi_name)) }, + label = { + Text( + stringResource(R.string.add_wifi_name), + color = MaterialTheme.colorScheme.onSurface, + style = MaterialTheme.typography.labelMedium, + ) + }, containerColor = MaterialTheme.colorScheme.surface, supportingText = supporting, modifier = diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/config/ConfigScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/config/ConfigScreen.kt index 3496f3d..0c44296 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/config/ConfigScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/tunneloptions/config/ConfigScreen.kt @@ -303,7 +303,13 @@ fun ConfigScreen(tunnelConfig: TunnelConfig?, appViewModel: AppViewModel) { ) } }, - label = { Text(stringResource(R.string.private_key)) }, + label = { + Text( + stringResource(R.string.private_key), + color = MaterialTheme.colorScheme.onSurface, + style = MaterialTheme.typography.labelMedium, + ) + }, singleLine = true, placeholder = { Text( @@ -342,7 +348,13 @@ fun ConfigScreen(tunnelConfig: TunnelConfig?, appViewModel: AppViewModel) { ) } }, - label = { Text(stringResource(R.string.public_key)) }, + label = { + Text( + stringResource(R.string.public_key), + color = MaterialTheme.colorScheme.onSurface, + style = MaterialTheme.typography.labelMedium, + ) + }, singleLine = true, placeholder = { Text( @@ -677,7 +689,8 @@ fun ConfigScreen(tunnelConfig: TunnelConfig?, appViewModel: AppViewModel) { hint = stringResource(R.string.base64_key), modifier = Modifier.fillMaxWidth(), ) - val presharedKeyEnabled = (tunnelConfig == null) || isAuthenticated || peer.preSharedKey.isBlank() + val presharedKeyEnabled = (tunnelConfig == null) || isAuthenticated || + with(configPair.second?.peers[index]?.preSharedKey) { this?.isEmpty == true || this?.isPresent == false } OutlinedTextField( textStyle = MaterialTheme.typography.labelLarge, modifier = @@ -693,7 +706,13 @@ fun ConfigScreen(tunnelConfig: TunnelConfig?, appViewModel: AppViewModel) { }, enabled = presharedKeyEnabled, onValueChange = { value -> peersState[index] = peersState[index].copy(preSharedKey = value) }, - label = { Text(stringResource(R.string.preshared_key)) }, + label = { + Text( + stringResource(R.string.preshared_key), + color = MaterialTheme.colorScheme.onSurface, + style = MaterialTheme.typography.labelMedium, + ) + }, singleLine = true, placeholder = { Text( @@ -720,7 +739,9 @@ fun ConfigScreen(tunnelConfig: TunnelConfig?, appViewModel: AppViewModel) { style = MaterialTheme.typography.labelMedium, ) }, - label = { Text(stringResource(R.string.persistent_keepalive), style = MaterialTheme.typography.labelMedium) }, + label = { + Text(stringResource(R.string.persistent_keepalive), color = MaterialTheme.colorScheme.onSurface, style = MaterialTheme.typography.labelMedium) + }, singleLine = true, placeholder = { Text(stringResource(R.string.optional_no_recommend), style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.outline) @@ -746,7 +767,13 @@ fun ConfigScreen(tunnelConfig: TunnelConfig?, appViewModel: AppViewModel) { onValueChange = { value -> peersState[index] = peersState[index].copy(allowedIps = value) }, - label = { Text(stringResource(R.string.allowed_ips)) }, + label = { + Text( + stringResource(R.string.allowed_ips), + color = MaterialTheme.colorScheme.onSurface, + style = MaterialTheme.typography.labelMedium, + ) + }, singleLine = true, placeholder = { Text(stringResource(R.string.comma_separated_list), style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.outline) diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/ContextExtensions.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/ContextExtensions.kt index 4ed8bd7..f52571f 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/ContextExtensions.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/util/extensions/ContextExtensions.kt @@ -87,8 +87,8 @@ fun Context.launchNotificationSettings() { fun Context.launchShareFile(file: Uri) { val shareIntent = Intent().apply { - setAction(Intent.ACTION_SEND) - setType("*/*") + action = Intent.ACTION_SEND + type = "*/*" putExtra(Intent.EXTRA_STREAM, file) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) } @@ -146,7 +146,7 @@ fun Context.launchVpnSettings(): Result { fun Context.launchLocationServicesSettings(): Result { return kotlin.runCatching { val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS).apply { - setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + flags = Intent.FLAG_ACTIVITY_NEW_TASK } startActivity(intent) } @@ -155,7 +155,7 @@ fun Context.launchLocationServicesSettings(): Result { fun Context.launchSettings(): Result { return kotlin.runCatching { val intent = Intent(Settings.ACTION_SETTINGS).apply { - setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + flags = Intent.FLAG_ACTIVITY_NEW_TASK } startActivity(intent) } @@ -165,7 +165,7 @@ fun Context.launchAppSettings() { kotlin.runCatching { val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { data = Uri.fromParts("package", packageName, null) - setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + flags = Intent.FLAG_ACTIVITY_NEW_TASK } startActivity(intent) }