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/OpenVpnPreferencesFragment.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/OpenVpnPreferencesFragment.java')
-rw-r--r-- | src/de/blinkt/openvpn/OpenVpnPreferencesFragment.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/OpenVpnPreferencesFragment.java b/src/de/blinkt/openvpn/OpenVpnPreferencesFragment.java new file mode 100644 index 00000000..10378a80 --- /dev/null +++ b/src/de/blinkt/openvpn/OpenVpnPreferencesFragment.java @@ -0,0 +1,52 @@ +package de.blinkt.openvpn;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+public abstract class OpenVpnPreferencesFragment extends PreferenceFragment {
+
+ protected VpnProfile mProfile;
+
+ protected abstract void loadSettings();
+ protected abstract void saveSettings();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // Make sure there is an instance of the profile manager
+ ProfileManager.getInstance(getActivity());
+
+ String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID");
+ mProfile = ProfileManager.get(profileUUID);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ saveSettings();
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ if(savedInstanceState!=null) {
+ String profileUUID=savedInstanceState.getString(VpnProfile.EXTRA_PROFILEUUID);
+ ProfileManager.getInstance(getActivity());
+ mProfile = ProfileManager.get(profileUUID);
+ loadSettings();
+ }
+ }
+
+ @Override
+ public void onStop() {
+ // TODO Auto-generated method stub
+ super.onStop();
+ }
+
+ @Override
+ public void onSaveInstanceState (Bundle outState) {
+ super.onSaveInstanceState(outState);
+ saveSettings();
+ outState.putString(VpnProfile.EXTRA_PROFILEUUID, mProfile.getUUIDString());
+ }
+}
|