From 39e94d54313cf140929339a9f2613d79cbf734b0 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 14 May 2012 23:06:36 +0200 Subject: - Rework saving state of preferences fragment - fix state of nobind not loaded (hopefully closes issue #19) Version 0.5.4 --- .../blinkt/openvpn/OpenVpnPreferencesFragment.java | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/de/blinkt/openvpn/OpenVpnPreferencesFragment.java (limited to 'src/de/blinkt/openvpn/OpenVpnPreferencesFragment.java') 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()); + } +} -- cgit v1.2.3