blob: 1f96c6ca0a544bb22efdcf8efa708bf350b938e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
package de.blinkt.openvpn;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceFragment;
public class Settings_Authentication extends PreferenceFragment implements OnPreferenceChangeListener {
private CheckBoxPreference mExpectTLSCert;
private CheckBoxPreference mCheckRemoteCN;
private EditTextPreference mRemoteCN;
private VpnProfile mProfile;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.vpn_authentification);
mExpectTLSCert = (CheckBoxPreference) findPreference("remoteServerTLS");
mCheckRemoteCN = (CheckBoxPreference) findPreference("checkRemoteCN");
mRemoteCN = (EditTextPreference) findPreference("remotecn");
mRemoteCN.setOnPreferenceChangeListener(this);
String profileUUID = getArguments().getString(getActivity().getPackageName() + ".profileUUID");
mProfile = ProfileManager.get(profileUUID);
loadSettings();
}
private void loadSettings() {
mExpectTLSCert.setChecked(mProfile.mExpectTLSCert);
mCheckRemoteCN.setChecked(mProfile.mCheckRemoteCN);
mRemoteCN.setText(mProfile.mRemoteCN);
onPreferenceChange(mRemoteCN, mProfile.mRemoteCN);
}
private void saveSettings() {
mProfile.mExpectTLSCert=mExpectTLSCert.isChecked();
mProfile.mCheckRemoteCN=mCheckRemoteCN.isChecked();
mProfile.mRemoteCN=mRemoteCN.getText();
}
@Override
public void onPause() {
super.onPause();
saveSettings();
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if(preference==mRemoteCN) {
if ("".equals(newValue))
preference.setSummary(mProfile.mServerName);
else
preference.setSummary((String)newValue);
}
saveSettings();
return true;
}
}
|