QuickTileService: show toast for longer and use right messages

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-01-08 20:30:25 +01:00
parent 7645ea15c4
commit 5944efc13c
2 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,8 @@ import com.wireguard.android.activity.MainActivity;
import com.wireguard.android.model.Tunnel; import com.wireguard.android.model.Tunnel;
import com.wireguard.android.model.Tunnel.State; import com.wireguard.android.model.Tunnel.State;
import com.wireguard.android.model.TunnelManager; import com.wireguard.android.model.TunnelManager;
import com.wireguard.android.util.ExceptionLoggers;
import com.wireguard.android.util.RootShell;
import java.util.Objects; import java.util.Objects;
@ -66,8 +68,10 @@ public class QuickTileService extends TileService {
if (throwable == null) if (throwable == null)
return null; return null;
Log.e(TAG, "Cannot toggle tunnel", throwable); Log.e(TAG, "Cannot toggle tunnel", throwable);
final String message = "Cannot toggle tunnel: " + throwable.getCause().getMessage(); final String message = throwable instanceof RootShell.NoRootException ?
Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); getApplicationContext().getString(R.string.error_rootshell) :
getApplicationContext().getString(R.string.error_toggle) + ": " + throwable.getMessage();
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
return null; return null;
} }

View File

@ -17,6 +17,7 @@
<string name="endpoint">Endpoint</string> <string name="endpoint">Endpoint</string>
<string name="error_down">Error bringing down WireGuard tunnel</string> <string name="error_down">Error bringing down WireGuard tunnel</string>
<string name="error_up">Error bringing up 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="error_rootshell">Please obtain root access and try again</string>
<string name="generate">Generate</string> <string name="generate">Generate</string>
<string name="hint_automatic">(auto)</string> <string name="hint_automatic">(auto)</string>