diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-05-14 23:06:36 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-05-14 23:06:36 +0200 |
commit | e445ab7fdc6c3912291eaad7aac209b511bcd245 (patch) | |
tree | b925a150868fb635ab928a2e5e618f5e0bd46f85 /src/de/blinkt/openvpn/Settings_IP.java | |
parent | 320e9a6d8f9c5329a163db370c988db4bde011bf (diff) |
- Rework saving state of preferences fragment
- fix state of nobind not loaded (hopefully closes issue #19)
Version 0.5.4
Diffstat (limited to 'src/de/blinkt/openvpn/Settings_IP.java')
-rw-r--r-- | src/de/blinkt/openvpn/Settings_IP.java | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/de/blinkt/openvpn/Settings_IP.java b/src/de/blinkt/openvpn/Settings_IP.java index 52dcc5dc..dcdc10c0 100644 --- a/src/de/blinkt/openvpn/Settings_IP.java +++ b/src/de/blinkt/openvpn/Settings_IP.java @@ -8,7 +8,7 @@ import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.preference.SwitchPreference; -public class Settings_IP extends PreferenceFragment implements OnPreferenceChangeListener { +public class Settings_IP extends OpenVpnPreferencesFragment implements OnPreferenceChangeListener { private EditTextPreference mIPv4; private EditTextPreference mIPv6; private SwitchPreference mUsePull; @@ -18,7 +18,6 @@ public class Settings_IP extends PreferenceFragment implements OnPreferenceChang private EditTextPreference mDNS2; private EditTextPreference mCustomRoutes; private CheckBoxPreference mUseDefaultRoute; - private VpnProfile mProfile; private CheckBoxPreference mRouteNoPull; private CheckBoxPreference mNobind; @@ -26,10 +25,7 @@ public class Settings_IP extends PreferenceFragment implements OnPreferenceChang public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID"); - mProfile = ProfileManager.get(profileUUID); - - + // Make sure default values are applied. In a real app, you would // want this in a shared function that is used to retrieve the // SharedPreferences wherever they are needed. @@ -62,7 +58,8 @@ public class Settings_IP extends PreferenceFragment implements OnPreferenceChang loadSettings(); } - private void loadSettings() { + @Override + protected void loadSettings() { mUsePull.setChecked(mProfile.mUsePull); mIPv4.setText(mProfile.mIPv4Address); @@ -74,6 +71,7 @@ public class Settings_IP extends PreferenceFragment implements OnPreferenceChang mUseDefaultRoute.setChecked(mProfile.mUseDefaultRoute); mCustomRoutes.setText(mProfile.mCustomRoutes); mRouteNoPull.setChecked(mProfile.mRoutenopull); + mNobind.setChecked(mProfile.mNobind); // Sets Summary onPreferenceChange(mIPv4, mIPv4.getText()); @@ -86,18 +84,9 @@ public class Settings_IP extends PreferenceFragment implements OnPreferenceChang setDNSState(); } - public void onSaveInstanceState (Bundle outState) { - saveSettings(); - } @Override - public void onStop() { - saveSettings(); - super.onStop(); - - } - - private void saveSettings() { + protected void saveSettings() { mProfile.mUsePull = mUsePull.isChecked(); mProfile.mIPv4Address = mIPv4.getText(); mProfile.mIPv6Address = mIPv6.getText(); |