Refactoring

This commit is contained in:
M66B 2015-11-01 07:44:48 +01:00
parent 77b495fd0f
commit 1de33fd3d9
1 changed files with 12 additions and 4 deletions

View File

@ -54,8 +54,7 @@ public class SinkholeService extends VpnService {
if (enabled && vpn == null) {
vpn = startVPN();
startDebug(vpn);
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(NOTIFY_DISABLED);
removeDisabledNotification();
}
break;
@ -298,7 +297,13 @@ public class SinkholeService extends VpnService {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.edit().putBoolean("enabled", false).apply();
// Display notification
// Display warning
showDisabledNotification();
super.onRevoke();
}
private void showDisabledNotification() {
Intent riMain = new Intent(this, ActivityMain.class);
PendingIntent piMain = PendingIntent.getActivity(this, 0, riMain, PendingIntent.FLAG_CANCEL_CURRENT);
@ -311,8 +316,11 @@ public class SinkholeService extends VpnService {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NOTIFY_DISABLED, notification.build());
}
super.onRevoke();
private void removeDisabledNotification() {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(NOTIFY_DISABLED);
}
public static void start(Context context) {