From bb2b9a9d44558517728c9469b7ade8e6e5cf1719 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 19 Feb 2016 09:25:01 +0100 Subject: [PATCH] Fixed resetting state on stop --- app/src/main/java/eu/faircode/netguard/ActivityMain.java | 9 +++++---- .../main/java/eu/faircode/netguard/SinkholeService.java | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/ActivityMain.java b/app/src/main/java/eu/faircode/netguard/ActivityMain.java index 2ed0083e..03331d68 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivityMain.java +++ b/app/src/main/java/eu/faircode/netguard/ActivityMain.java @@ -496,15 +496,16 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences if (adapter != null) if (intent.hasExtra(EXTRA_CONNECTED) && intent.hasExtra(EXTRA_METERED)) { - ivMetered.setVisibility(Util.isMeteredNetwork(ActivityMain.this) ? View.VISIBLE : View.INVISIBLE); - - if (intent.getBooleanExtra(EXTRA_CONNECTED, false)) + if (intent.getBooleanExtra(EXTRA_CONNECTED, false)) { if (intent.getBooleanExtra(EXTRA_METERED, false)) adapter.setMobileActive(); else adapter.setWifiActive(); - else + ivMetered.setVisibility(Util.isMeteredNetwork(ActivityMain.this) ? View.VISIBLE : View.INVISIBLE); + } else { adapter.setDisconnected(); + ivMetered.setVisibility(View.INVISIBLE); + } } else updateApplicationList(null); } diff --git a/app/src/main/java/eu/faircode/netguard/SinkholeService.java b/app/src/main/java/eu/faircode/netguard/SinkholeService.java index 47f042d7..ec992a2b 100644 --- a/app/src/main/java/eu/faircode/netguard/SinkholeService.java +++ b/app/src/main/java/eu/faircode/netguard/SinkholeService.java @@ -318,8 +318,8 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS // Update main view Intent ruleset = new Intent(ActivityMain.ACTION_RULES_CHANGED); - ruleset.putExtra(ActivityMain.EXTRA_CONNECTED, last_connected); - ruleset.putExtra(ActivityMain.EXTRA_METERED, last_metered); + ruleset.putExtra(ActivityMain.EXTRA_CONNECTED, cmd == Command.stop ? false : last_connected); + ruleset.putExtra(ActivityMain.EXTRA_METERED, cmd == Command.stop ? false : last_metered); LocalBroadcastManager.getInstance(SinkholeService.this).sendBroadcast(ruleset); // Update widgets