diff options
Diffstat (limited to 'main/src/main/java/de/blinkt/openvpn/fragments')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/fragments/Settings_Basic.java | 6 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java | 37 |
2 files changed, 41 insertions, 2 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Basic.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Basic.java index ea8768d3..c85dc114 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Basic.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Basic.java @@ -61,9 +61,10 @@ public class Settings_Basic extends Settings_Fragment implements View.OnClickLis private EditText mKeyPassword; private SparseArray<FileSelectLayout> fileselects = new SparseArray<>(); + private Spinner mAuthRetry; - private void addFileSelectLayout (FileSelectLayout fsl, Utils.FileType type) { + private void addFileSelectLayout (FileSelectLayout fsl, Utils.FileType type) { int i = fileselects.size() + CHOOSE_FILE_OFFSET; fileselects.put(i, fsl); fsl.setCaller(this, i, type); @@ -136,6 +137,7 @@ public class Settings_Basic extends Settings_Fragment implements View.OnClickLis mUserName = (EditText) mView.findViewById(R.id.auth_username); mPassword = (EditText) mView.findViewById(R.id.auth_password); mKeyPassword = (EditText) mView.findViewById(R.id.key_password); + mAuthRetry = (Spinner) mView.findViewById(id.auth_retry); addFileSelectLayout(mCaCert, Utils.FileType.CA_CERTIFICATE); addFileSelectLayout(mClientCert, Utils.FileType.CLIENT_CERTIFICATE); @@ -145,6 +147,7 @@ public class Settings_Basic extends Settings_Fragment implements View.OnClickLis mCaCert.setShowClear(); mType.setOnItemSelectedListener(this); + mAuthRetry.setOnItemSelectedListener(this); mView.findViewById(R.id.select_keystore_button).setOnClickListener(this); @@ -276,6 +279,7 @@ public class Settings_Basic extends Settings_Fragment implements View.OnClickLis mProfile.mPassword = mPassword.getText().toString(); mProfile.mUsername = mUserName.getText().toString(); mProfile.mKeyPassword = mKeyPassword.getText().toString(); + mProfile.mAuthRetry = mAuthRetry.getSelectedItemPosition(); } diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java index 66e20822..5c70564e 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Obscure.java @@ -13,6 +13,8 @@ import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.widget.Toast; +import java.util.Locale; + import de.blinkt.openvpn.R; import de.blinkt.openvpn.VpnProfile; @@ -29,6 +31,7 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr private ListPreference mConnectRetrymax; private EditTextPreference mConnectRetry; private EditTextPreference mConnectRetryMaxTime; + private EditTextPreference mTunMtu; public void onCreateBehaviour(Bundle savedInstanceState) { @@ -115,6 +118,9 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr mMssFixCheckBox = (CheckBoxPreference) findPreference("mssFix"); mMssFixValue = (EditTextPreference) findPreference("mssFixValue"); mMssFixValue.setOnPreferenceChangeListener(this); + mTunMtu = (EditTextPreference) findPreference("tunmtu"); + mTunMtu.setOnPreferenceChangeListener(this);; + onCreateBehaviour(savedInstanceState); loadSettings(); @@ -135,12 +141,29 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr mMssFixCheckBox.setChecked(true); setMssSummary(mProfile.mMssFix); } + + + int tunmtu = mProfile.mTunMtu; + if (mProfile.mTunMtu < 48) + tunmtu = 1500; + + mTunMtu.setText(String.valueOf(tunmtu)); + setMtuSummary(tunmtu); + + loadSettingsBehaviour(); } private void setMssSummary(int value) { - mMssFixValue.setSummary(String.format("Configured MSS value: %d", value)); + mMssFixValue.setSummary(String.format(Locale.getDefault(),"Configured MSS value: %d", value)); + } + + private void setMtuSummary(int value) { + if (value == 1500) + mTunMtu.setSummary(String.format(Locale.getDefault(),"Using default (1500) MTU", value)); + else + mTunMtu.setSummary(String.format(Locale.getDefault(),"Configured MTU value: %d", value)); } protected void saveSettings() { @@ -153,6 +176,7 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr else mProfile.mMssFix=0; + mProfile.mTunMtu = Integer.parseInt(mTunMtu.getText()); saveSettingsBehaviour(); } @@ -170,6 +194,17 @@ public class Settings_Obscure extends OpenVpnPreferencesFragment implements OnPr Toast.makeText(getActivity(), R.string.mssfix_invalid_value, Toast.LENGTH_LONG).show(); return false; } + else if (preference.getKey().equals("tunmtu")) + try { + int v = Integer.parseInt((String) newValue); + if (v < 48 || v > 9000) + throw new NumberFormatException("mtu value"); + setMtuSummary(v); + + } catch(NumberFormatException e) { + Toast.makeText(getActivity(), R.string.mtu_invalid_value, Toast.LENGTH_LONG).show(); + return false; + } return onPreferenceChangeBehaviour(preference, newValue); } |