diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-05-11 00:46:33 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-05-11 00:46:33 +0200 |
commit | bfb51aa744b09b248daacd3ada8f04e6c6f7d5a5 (patch) | |
tree | af278c4a7243807df6cf0e7774fd7cc810f7d1a9 /src/de/blinkt/openvpn/Settings_Authentication.java | |
parent | be5159289c41a525b718363e3f7ab78019928d42 (diff) |
Rework FIle selection dialog.
Include possibility to include file content in VPN Profile. Allows safer storage of Certifcates and keys. (closes issue #13)
--HG--
rename : src/com/lamerman/FileDialog.java => src/de/blinkt/openvpn/FileSelectionFragment.java
Diffstat (limited to 'src/de/blinkt/openvpn/Settings_Authentication.java')
-rw-r--r-- | src/de/blinkt/openvpn/Settings_Authentication.java | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/de/blinkt/openvpn/Settings_Authentication.java b/src/de/blinkt/openvpn/Settings_Authentication.java index 4124783b..003a26dd 100644 --- a/src/de/blinkt/openvpn/Settings_Authentication.java +++ b/src/de/blinkt/openvpn/Settings_Authentication.java @@ -12,8 +12,6 @@ import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceFragment; import android.preference.SwitchPreference; -import com.lamerman.FileDialog; -import com.lamerman.SelectionMode; public class Settings_Authentication extends PreferenceFragment implements OnPreferenceChangeListener, OnPreferenceClickListener { private static final int SELECT_TLS_FILE = 23223232; @@ -25,6 +23,7 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre private Preference mTLSAuthFile; private SwitchPreference mUseTLSAuth; private EditTextPreference mCipher; + private String mTlsAuthFileData; @Override public void onCreate(Bundle savedInstanceState) { @@ -61,7 +60,8 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre onPreferenceChange(mRemoteCN, mProfile.mRemoteCN); mUseTLSAuth.setChecked(mProfile.mUseTLSAuth); - mTLSAuthFile.setSummary(mProfile.mTLSAuthFilename); + mTlsAuthFileData= mProfile.mTLSAuthFilename; + setTlsAuthSummary(mTlsAuthFileData); mTLSAuthDirection.setValue(mProfile.mTLSAuthDirection); mCipher.setText(mProfile.mCipher); onPreferenceChange(mCipher, mProfile.mCipher); @@ -73,10 +73,7 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre mProfile.mRemoteCN=mRemoteCN.getText(); mProfile.mUseTLSAuth = mUseTLSAuth.isChecked(); - if(mTLSAuthFile.getSummary()==null) - mProfile.mTLSAuthFilename=null; - else - mProfile.mTLSAuthFilename = mTLSAuthFile.getSummary().toString(); + mProfile.mTLSAuthFilename = mTlsAuthFileData; if(mTLSAuthDirection.getValue()==null) mProfile.mTLSAuthDirection=null; @@ -109,9 +106,8 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre 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); + Intent startFC = new Intent(getActivity(),FileSelectionFragment.class); + startFC.putExtra(FileSelect.START_DATA, "/sdcard"); startActivityForResult(startFC,SELECT_TLS_FILE); } @@ -126,9 +122,17 @@ public class Settings_Authentication extends PreferenceFragment implements OnPre 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); + String result = data.getStringExtra(FileSelect.RESULT_DATA); + mTlsAuthFileData=result; + setTlsAuthSummary(result); } } + + private void setTlsAuthSummary(String result) { + if(result.startsWith(FileSelect.INLINE_TAG)) + mTLSAuthFile.setSummary(R.string.inline_file_data); + else + mTLSAuthFile.setSummary(result); + } }
\ No newline at end of file |