diff options
author | schwabe <devnull@localhost> | 2012-04-28 19:58:02 +0200 |
---|---|---|
committer | schwabe <devnull@localhost> | 2012-04-28 19:58:02 +0200 |
commit | 63e466054c2f1d66e4618ac4d73208751f1e5bd1 (patch) | |
tree | 84a00021ec486093b406ec050087ee486f6e6958 /src/de/blinkt/openvpn/Settings_Authentication.java | |
parent | 031186e74c9f174d05a09c4059def7bcbc558ac6 (diff) |
Almost ready for version 0.4
Diffstat (limited to 'src/de/blinkt/openvpn/Settings_Authentication.java')
-rw-r--r-- | src/de/blinkt/openvpn/Settings_Authentication.java | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/src/de/blinkt/openvpn/Settings_Authentication.java b/src/de/blinkt/openvpn/Settings_Authentication.java index 1f96c6ca..f3ebb36d 100644 --- a/src/de/blinkt/openvpn/Settings_Authentication.java +++ b/src/de/blinkt/openvpn/Settings_Authentication.java @@ -1,17 +1,29 @@ package de.blinkt.openvpn; +import com.lamerman.FileDialog; +import com.lamerman.SelectionMode; + +import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; +import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceFragment; +import android.preference.SwitchPreference; -public class Settings_Authentication extends PreferenceFragment implements OnPreferenceChangeListener { +public class Settings_Authentication extends PreferenceFragment implements OnPreferenceChangeListener, OnPreferenceClickListener { + private static final int SELECT_TLS_FILE = 23223232; private CheckBoxPreference mExpectTLSCert; private CheckBoxPreference mCheckRemoteCN; private EditTextPreference mRemoteCN; private VpnProfile mProfile; + private ListPreference mTLSAuthDirection; + private Preference mTLSAuthFile; + private SwitchPreference mUseTLSAuth; @Override public void onCreate(Bundle savedInstanceState) { @@ -24,9 +36,15 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre mCheckRemoteCN = (CheckBoxPreference) findPreference("checkRemoteCN"); mRemoteCN = (EditTextPreference) findPreference("remotecn"); mRemoteCN.setOnPreferenceChangeListener(this); + + mUseTLSAuth = (SwitchPreference) findPreference("useTLSAuth" ); + mTLSAuthFile = findPreference("tlsAuthFile"); + mTLSAuthDirection = (ListPreference) findPreference("tls_direction"); + String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID"); mProfile = ProfileManager.get(profileUUID); - + mTLSAuthFile.setOnPreferenceClickListener(this); + loadSettings(); } @@ -38,12 +56,26 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre mRemoteCN.setText(mProfile.mRemoteCN); onPreferenceChange(mRemoteCN, mProfile.mRemoteCN); + mUseTLSAuth.setChecked(mProfile.mUseTLSAuth); + mTLSAuthFile.setSummary(mProfile.mTLSAuthFilename); + //mTLSAuthDirection.setValue(mProfile.mTLSAuthDirection); } private void saveSettings() { mProfile.mExpectTLSCert=mExpectTLSCert.isChecked(); mProfile.mCheckRemoteCN=mCheckRemoteCN.isChecked(); mProfile.mRemoteCN=mRemoteCN.getText(); + + mProfile.mUseTLSAuth = mUseTLSAuth.isChecked(); + if(mTLSAuthFile.getSummary()==null) + mProfile.mTLSAuthFilename=null; + else + mProfile.mTLSAuthFilename = mTLSAuthFile.getSummary().toString(); + + if(mTLSAuthDirection.getEntry()==null) + mProfile.mTLSAuthDirection=null; + else + mProfile.mTLSAuthDirection = mTLSAuthDirection.getEntry().toString(); } @Override @@ -60,7 +92,29 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre else preference.setSummary((String)newValue); } - saveSettings(); return true; } + void startFileDialog() { + Intent startFC = new Intent(getActivity(),FileDialog.class); + startFC.putExtra(FileDialog.START_PATH, "/sdcard"); + startFC.putExtra(FileDialog.SELECTION_MODE, SelectionMode.MODE_OPEN); + + startActivityForResult(startFC,SELECT_TLS_FILE); + } + @Override + public boolean onPreferenceClick(Preference preference) { + startFileDialog(); + return true; + + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if(requestCode==SELECT_TLS_FILE && resultCode == Activity.RESULT_OK){ + String filepath = data.getStringExtra(FileDialog.RESULT_PATH); + mTLSAuthFile.setSummary(filepath); + + } + } }
\ No newline at end of file |