Fixed resetting state on stop

This commit is contained in:
M66B 2016-02-19 09:25:01 +01:00
parent c58c4bacdf
commit bb2b9a9d44
2 changed files with 7 additions and 6 deletions

View File

@ -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);
}

View File

@ -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