diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0e4798d..66b872e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -17,7 +17,7 @@ android { val versionMajor = 1 val versionMinor = 1 - val versionPatch = 2 + val versionPatch = 3 val versionBuild = 0 defaultConfig { diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardConnectivityWatcherService.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardConnectivityWatcherService.kt index e476fbe..381dfe4 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardConnectivityWatcherService.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardConnectivityWatcherService.kt @@ -29,6 +29,8 @@ import javax.inject.Inject @AndroidEntryPoint class WireGuardConnectivityWatcherService : ForegroundService() { + private val foregroundId = 122; + @Inject lateinit var wifiService : NetworkService @@ -66,7 +68,7 @@ class WireGuardConnectivityWatcherService : ForegroundService() { // we need this lock so our service gets not affected by Doze Mode initWakeLock() cancelWatcherJob() - startWatcherNotification() + launchWatcherNotification() if(this::tunnelId.isInitialized) { startWatcherJob() } else { @@ -86,13 +88,12 @@ class WireGuardConnectivityWatcherService : ForegroundService() { stopSelf() } - private fun startWatcherNotification() { + private fun launchWatcherNotification() { val notification = notificationService.createNotification( channelId = getString(R.string.watcher_channel_id), channelName = getString(R.string.watcher_channel_name), - title = getString(R.string.watcher_notification_title), description = getString(R.string.watcher_notification_text)) - super.startForeground(1, notification) + super.startForeground(foregroundId, notification) } //try to start task again if killed diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardTunnelService.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardTunnelService.kt index 513d98f..bd690da 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardTunnelService.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/foreground/WireGuardTunnelService.kt @@ -19,6 +19,8 @@ import javax.inject.Inject @AndroidEntryPoint class WireGuardTunnelService : ForegroundService() { + private val foregroundId = 123; + @Inject lateinit var vpnService : VpnService @@ -64,9 +66,11 @@ class WireGuardTunnelService : ForegroundService() { channelId = getString(R.string.vpn_channel_id), channelName = getString(R.string.vpn_channel_name), title = getString(R.string.tunnel_start_title), + onGoing = false, + showTimestamp = true, description = "${getString(R.string.tunnel_start_text)} $tunnelName" ) - super.startForeground(1, notification) + super.startForeground(foregroundId, notification) } private fun cancelJob() { if(this::job.isInitialized) { diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/notification/NotificationService.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/notification/NotificationService.kt index 6ae0082..cc8f0d9 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/notification/NotificationService.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/notification/NotificationService.kt @@ -7,10 +7,12 @@ interface NotificationService { fun createNotification( channelId: String, channelName: String, - title: String, + title: String = "", description: String, + showTimestamp : Boolean = false, importance: Int = NotificationManager.IMPORTANCE_HIGH, vibration: Boolean = true, + onGoing: Boolean = true, lights: Boolean = true ): Notification } \ No newline at end of file diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/notification/WireGuardNotification.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/notification/WireGuardNotification.kt index 8b62978..bc29647 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/notification/WireGuardNotification.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/notification/WireGuardNotification.kt @@ -21,8 +21,10 @@ class WireGuardNotification @Inject constructor(@ApplicationContext private val channelName: String, title: String, description: String, + showTimestamp: Boolean, importance: Int, vibration: Boolean, + onGoing: Boolean, lights: Boolean ) : Notification { val channel = NotificationChannel( @@ -53,7 +55,8 @@ class WireGuardNotification @Inject constructor(@ApplicationContext private val .setContentTitle(title) .setContentText(description) .setContentIntent(pendingIntent) - .setShowWhen(true) + .setOngoing(onGoing) + .setShowWhen(showTimestamp) .setSmallIcon(R.mipmap.ic_launcher_foreground) .build() } diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt index 9586fdd..0196a2e 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/ui/screens/settings/SettingsScreen.kt @@ -20,6 +20,10 @@ import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Close +import androidx.compose.material.icons.filled.Done +import androidx.compose.material.icons.outlined.Add +import androidx.compose.material.icons.outlined.AddCircleOutline +import androidx.compose.material.icons.outlined.Done import androidx.compose.material.icons.rounded.LocationOff import androidx.compose.material.icons.rounded.Map import androidx.compose.material3.Button @@ -28,6 +32,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExposedDropdownMenuBox import androidx.compose.material3.ExposedDropdownMenuDefaults import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.SnackbarDuration import androidx.compose.material3.SnackbarHostState @@ -44,6 +49,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontStyle @@ -100,13 +106,25 @@ fun SettingsScreen( } } } + + fun saveTrustedSSID() { + if (currentText.isNotEmpty()) { + scope.launch { + viewModel.onSaveTrustedSSID(currentText) + currentText = "" + } + } + } + if(!backgroundLocationState.status.isGranted) { Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Top, modifier = Modifier .fillMaxSize() .padding(padding)) { - Icon(Icons.Rounded.LocationOff, contentDescription = "Map", modifier = Modifier.padding(30.dp).size(128.dp)) + Icon(Icons.Rounded.LocationOff, contentDescription = "Map", modifier = Modifier + .padding(30.dp) + .size(128.dp)) Text(stringResource(R.string.prominent_background_location_title), textAlign = TextAlign.Center, modifier = Modifier.padding(30.dp), fontSize = 20.sp) Text(stringResource(R.string.prominent_background_location_message), textAlign = TextAlign.Center, modifier = Modifier.padding(30.dp), fontSize = 15.sp) //Spacer(modifier = Modifier.weight(1f)) @@ -257,14 +275,20 @@ fun SettingsScreen( ), keyboardActions = KeyboardActions( onDone = { - scope.launch { - if (currentText.isNotEmpty()) { - viewModel.onSaveTrustedSSID(currentText) - currentText = "" - } - } + saveTrustedSSID() } ), + trailingIcon = { + IconButton(onClick = { saveTrustedSSID() }) { + Icon( + imageVector = Icons.Outlined.Add, + contentDescription = if (currentText == "") stringResource(id = R.string.trusted_ssid_empty_description) else stringResource( + id = R.string.trusted_ssid_value_description + ), + tint = if(currentText == "") Color.Transparent else Color.Green + ) + } + }, ) Row( modifier = Modifier diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 33964d4..43a9ddb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,7 +14,7 @@ Tunnel name already exists https://discord.gg/Ad5fuEts Watcher Service - Now watching for Wi-Fi state changes + Monitoring network state changes VPN Connected Connected to tunnel - VPN permission is required for the app to work properly. @@ -35,4 +35,6 @@ This feature requires background location permission to enable Wi-Fi SSID monitoring even while the application is closed. For more details, please see the Privacy Policy linked on the Support screen. Background Location Disclosure Thank you for using WG Tunnel! If you are experiencing issues with the app, please reach out on Discord or create an issue on Github. I will try to address the issue as quickly as possible. Thank you! + Enter SSID + Submit SSID \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index ee73e07..84e9717 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,7 +13,7 @@ buildscript { } plugins { - id("com.android.application") version "8.2.0-alpha07" apply false + id("com.android.application") version "8.2.0-alpha08" apply false id("org.jetbrains.kotlin.android") version "1.8.21" apply false id("com.google.dagger.hilt.android") version "2.44" apply false kotlin("plugin.serialization") version "1.8.21" apply false