summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt17
1 files changed, 8 insertions, 9 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt
index f216e69726..dfd3213811 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt
@@ -5,19 +5,18 @@ import android.graphics.drawable.Icon
import android.os.Build
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
+import kotlin.properties.Delegates.observable
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.model.TunnelState
import net.mullvad.mullvadvpn.service.tunnelstate.TunnelStateListener
import net.mullvad.talpid.tunnel.ActionAfterDisconnect
class MullvadTileService : TileService() {
- private var secured = false
- set(value) {
- if (field != value) {
- field = value
- updateTileState()
- }
+ private var secured by observable(false) { _, wasSecured, isSecured ->
+ if (wasSecured != isSecured) {
+ updateTileState()
}
+ }
private lateinit var listener: TunnelStateListener
private lateinit var securedIcon: Icon
@@ -70,13 +69,13 @@ class MullvadTileService : TileService() {
}
override fun onStopListening() {
- super.onStartListening()
-
listener.onStateChange = null
+
+ super.onStartListening()
}
private fun updateTileState() {
- qsTile.apply {
+ qsTile?.apply {
if (secured) {
state = Tile.STATE_ACTIVE
icon = securedIcon