From 938399d881aa6b365be131ffb3a517d64be427bb Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 26 Sep 2020 13:34:20 +0200 Subject: ui: queue up tunnel mutating on activity scope instead of fragment scope Fragment scopes get cancelled when the fragment goes away, but we don't actually want to cancel an in-flight transition in that case. Also, before when the fragment would cancel, there'd be an exception, and the exception handler would call Fragment::getString, which in turn called requireContext, which caused an exception. Work around this by using the `activity ?: Application.get()` idiom to always have a context for strings and toasts. Signed-off-by: Jason A. Donenfeld --- ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt') diff --git a/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt b/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt index d8ac94d9..1ee0dafc 100644 --- a/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt +++ b/ui/src/main/java/com/wireguard/android/util/ErrorMessages.kt @@ -6,7 +6,7 @@ package com.wireguard.android.util import android.content.res.Resources import android.os.RemoteException -import com.wireguard.android.Application.Companion.get +import com.wireguard.android.Application import com.wireguard.android.R import com.wireguard.android.backend.BackendException import com.wireguard.android.util.RootShell.RootShellException @@ -63,7 +63,7 @@ object ErrorMessages { ) operator fun get(throwable: Throwable?): String { - val resources = get().resources + val resources = Application.get().resources if (throwable == null) return resources.getString(R.string.unknown_error) val rootCause = rootCause(throwable) return when { -- cgit v1.2.3-59-g8ed1b