android: Only show disconnect button if actually connected
This commit is contained in:
+11
-5
@@ -326,6 +326,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
State state = mService.getState();
|
State state = mService.getState();
|
||||||
ErrorState error = mService.getErrorState();
|
ErrorState error = mService.getErrorState();
|
||||||
String name = "";
|
String name = "";
|
||||||
|
boolean add_action = false;
|
||||||
|
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
{
|
{
|
||||||
@@ -351,11 +352,13 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
s = R.string.state_connecting;
|
s = R.string.state_connecting;
|
||||||
builder.setSmallIcon(R.drawable.ic_notification_warning);
|
builder.setSmallIcon(R.drawable.ic_notification_warning);
|
||||||
builder.setColor(ContextCompat.getColor(this, R.color.warning_text));
|
builder.setColor(ContextCompat.getColor(this, R.color.warning_text));
|
||||||
|
add_action = true;
|
||||||
break;
|
break;
|
||||||
case CONNECTED:
|
case CONNECTED:
|
||||||
s = R.string.state_connected;
|
s = R.string.state_connected;
|
||||||
builder.setColor(ContextCompat.getColor(this, R.color.success_text));
|
builder.setColor(ContextCompat.getColor(this, R.color.success_text));
|
||||||
builder.setUsesChronometer(true);
|
builder.setUsesChronometer(true);
|
||||||
|
add_action = true;
|
||||||
break;
|
break;
|
||||||
case DISCONNECTING:
|
case DISCONNECTING:
|
||||||
s = R.string.state_disconnecting;
|
s = R.string.state_disconnecting;
|
||||||
@@ -365,11 +368,14 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
builder.setContentTitle(getString(s));
|
builder.setContentTitle(getString(s));
|
||||||
if (!publicVersion)
|
if (!publicVersion)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
if (add_action)
|
||||||
intent.setAction(MainActivity.DISCONNECT);
|
{
|
||||||
PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, intent,
|
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
intent.setAction(MainActivity.DISCONNECT);
|
||||||
builder.addAction(R.drawable.ic_notification_disconnect, getString(R.string.disconnect), pending);
|
PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, intent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
builder.addAction(R.drawable.ic_notification_disconnect, getString(R.string.disconnect), pending);
|
||||||
|
}
|
||||||
builder.setContentText(name);
|
builder.setContentText(name);
|
||||||
builder.setPublicVersion(buildNotification(true));
|
builder.setPublicVersion(buildNotification(true));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user