From 6f80050a3951e4c45244f610e8aa9a669945dcd4 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 10 Dec 2015 13:40:33 +0100 Subject: [PATCH] Small improvement --- .../faircode/netguard/ActivitySettings.java | 19 ++++++++++++------- app/src/main/res/values/strings.xml | 1 - 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java index 36c1ca11..255e05ff 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivitySettings.java +++ b/app/src/main/java/eu/faircode/netguard/ActivitySettings.java @@ -61,7 +61,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -108,9 +107,12 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere pref_stats_base.setTitle(getString(R.string.setting_stats_base, prefs.getString("stats_base", "5"))); // Wi-Fi home - MultiSelectListPreference wifi_homes_pref = (MultiSelectListPreference) screen.findPreference("wifi_homes"); + MultiSelectListPreference pref_wifi_homes = (MultiSelectListPreference) screen.findPreference("wifi_homes"); Set ssid = prefs.getStringSet("wifi_homes", new HashSet()); - wifi_homes_pref.setTitle(getString(R.string.setting_wifi_home, TextUtils.join(", ", ssid))); + if (ssid.size() > 0) + pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, TextUtils.join(", ", ssid))); + else + pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, "-")); WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); List listSSID = new ArrayList<>(); @@ -118,8 +120,8 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere if (configs != null) for (WifiConfiguration config : configs) listSSID.add(config.SSID); - wifi_homes_pref.setEntries(listSSID.toArray(new CharSequence[0])); - wifi_homes_pref.setEntryValues(listSSID.toArray(new CharSequence[0])); + pref_wifi_homes.setEntries(listSSID.toArray(new CharSequence[0])); + pref_wifi_homes.setEntryValues(listSSID.toArray(new CharSequence[0])); // Handle auto enable Preference pref_auto_enable = screen.findPreference("auto_enable"); @@ -295,7 +297,10 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere else if ("wifi_homes".equals(name)) { MultiSelectListPreference pref_wifi_homes = (MultiSelectListPreference) getPreferenceScreen().findPreference(name); Set ssid = prefs.getStringSet(name, new HashSet()); - pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, TextUtils.join(", ", ssid))); + if (ssid.size() > 0) + pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, TextUtils.join(", ", ssid))); + else + pref_wifi_homes.setTitle(getString(R.string.setting_wifi_home, "-")); SinkholeService.reload(null, "setting changed", this); } else if ("unmetered_2g".equals(name) || @@ -683,7 +688,7 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere current.put(key, value); else if ("set".equals(type)) { Set set = new HashSet<>(); - for (String s : ((String) value).split("\n")) + for (String s : value.split("\n")) set.add(s); current.put(key, set); } else diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 91dccd81..72d9d6e8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -70,7 +70,6 @@ Since NetGuard has no internet permission, you know your internet traffic is not %7.3f KB/s %7.3f MB/s - All Allow Wi-Fi when screen is on Allow mobile when screen is on Block when roaming