summaryrefslogtreecommitdiffhomepage
path: root/ui
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2023-04-02 15:35:39 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2023-04-04 15:31:52 +0200
commit5e844bed5e06cc8eed990848da720f5ff96859f8 (patch)
tree0d931c77ff1f3f3f2cb4d063d137d0dcbc08273e /ui
parent46bf98d7f67c443d393cde056f7f6e79ae32f320 (diff)
ui: do not return to detail page when restoring state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt18
1 files changed, 14 insertions, 4 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
index 8f0855ea..c89bc5aa 100644
--- a/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/BaseActivity.kt
@@ -17,13 +17,16 @@ import kotlinx.coroutines.launch
*/
abstract class BaseActivity : ThemeChangeAwareActivity() {
private val selectionChangeRegistry = SelectionChangeRegistry()
+ private var created = false
var selectedTunnel: ObservableTunnel? = null
set(value) {
val oldTunnel = field
if (oldTunnel == value) return
field = value
- onSelectedTunnelChanged(oldTunnel, value)
- selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, value)
+ if (created) {
+ onSelectedTunnelChanged(oldTunnel, value)
+ selectionChangeRegistry.notifyCallbacks(oldTunnel, 0, value)
+ }
}
fun addOnSelectedTunnelChangedListener(listener: OnSelectedTunnelChangedListener) {
@@ -39,10 +42,17 @@ abstract class BaseActivity : ThemeChangeAwareActivity() {
intent != null -> intent.getStringExtra(KEY_SELECTED_TUNNEL)
else -> null
}
- if (savedTunnelName != null)
+ if (savedTunnelName != null) {
lifecycleScope.launch {
- selectedTunnel = Application.getTunnelManager().getTunnels()[savedTunnelName]
+ val tunnel = Application.getTunnelManager().getTunnels()[savedTunnelName]
+ if (tunnel == null)
+ created = true
+ selectedTunnel = tunnel
+ created = true
}
+ } else {
+ created = true
+ }
}
override fun onSaveInstanceState(outState: Bundle) {