diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-01-08 20:30:25 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-01-08 20:30:25 +0100 |
commit | 5944efc13cd3b63d3a6c38b583116cb06c22d439 (patch) | |
tree | c6fa33c098045f521922e43cccb4b714b07b4e9e /app | |
parent | 7645ea15c408251cacafb03ea70426ad577f32a3 (diff) |
QuickTileService: show toast for longer and use right messages
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/wireguard/android/QuickTileService.java | 8 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/app/src/main/java/com/wireguard/android/QuickTileService.java b/app/src/main/java/com/wireguard/android/QuickTileService.java index 98c3b3d3..0468f83f 100644 --- a/app/src/main/java/com/wireguard/android/QuickTileService.java +++ b/app/src/main/java/com/wireguard/android/QuickTileService.java @@ -15,6 +15,8 @@ import com.wireguard.android.activity.MainActivity; import com.wireguard.android.model.Tunnel; import com.wireguard.android.model.Tunnel.State; import com.wireguard.android.model.TunnelManager; +import com.wireguard.android.util.ExceptionLoggers; +import com.wireguard.android.util.RootShell; import java.util.Objects; @@ -66,8 +68,10 @@ public class QuickTileService extends TileService { if (throwable == null) return null; Log.e(TAG, "Cannot toggle tunnel", throwable); - final String message = "Cannot toggle tunnel: " + throwable.getCause().getMessage(); - Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); + final String message = throwable instanceof RootShell.NoRootException ? + getApplicationContext().getString(R.string.error_rootshell) : + getApplicationContext().getString(R.string.error_toggle) + ": " + throwable.getMessage(); + Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show(); return null; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0a873679..7d129454 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,6 +17,7 @@ <string name="endpoint">Endpoint</string> <string name="error_down">Error bringing down WireGuard tunnel</string> <string name="error_up">Error bringing up WireGuard tunnel</string> + <string name="error_toggle">Error toggling WireGuard tunnel</string> <string name="error_rootshell">Please obtain root access and try again</string> <string name="generate">Generate</string> <string name="hint_automatic">(auto)</string> |