summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java50
-rw-r--r--main/src/main/res/layout/config_converter.xml10
-rwxr-xr-xmain/src/main/res/values-in/strings.xml2
-rwxr-xr-xmain/src/main/res/values/strings.xml1
4 files changed, 53 insertions, 10 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java
index f316eeaa..f2329366 100644
--- a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java
+++ b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java
@@ -6,12 +6,16 @@
package de.blinkt.openvpn.activities;
+import android.Manifest;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.ActivityNotFoundException;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.database.Cursor;
+import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.OpenableColumns;
@@ -61,6 +65,7 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie
private static final int RESULT_INSTALLPKCS12 = 7;
private static final int CHOOSE_FILE_OFFSET = 1000;
public static final String VPNPROFILE = "vpnProfile";
+ private static final int PERMISSION_REQUEST = 37231;
private VpnProfile mResult;
@@ -78,6 +83,20 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie
public void onClick(View v) {
if (v.getId() == R.id.fab_save)
userActionSaveProfile();
+ if (v.getId() == R.id.permssion_hint && Build.VERSION.SDK_INT == Build.VERSION_CODES.M)
+ doRequestSDCardPermission();
+
+ }
+
+ @TargetApi(Build.VERSION_CODES.M)
+ private void doRequestSDCardPermission() {
+ requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
+ if (requestCode == PERMISSION_REQUEST)
+ embedFiles(null);
}
@Override
@@ -377,12 +396,23 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie
((LinearLayout) findViewById(R.id.config_convert_root)).addView(fl, 2);
findViewById(R.id.files_missing_hint).setVisibility(View.VISIBLE);
+ if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M)
+ checkPermission();
+
fl.setData(value, this);
int i = getFileLayoutOffset(type);
fl.setCaller(this, i, type);
}
+ @TargetApi(Build.VERSION_CODES.M)
+ private void checkPermission() {
+ if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
+ findViewById(R.id.permssion_hint).setVisibility(View.VISIBLE);
+ findViewById(R.id.permssion_hint).setOnClickListener(this);
+ }
+ }
+
private int getFileLayoutOffset(Utils.FileType type) {
return CHOOSE_FILE_OFFSET + type.getValue();
}
@@ -507,17 +537,19 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie
mResult.mClientKeyFilename = embedFile(mResult.mClientKeyFilename, Utils.FileType.KEYFILE, false);
mResult.mTLSAuthFilename = embedFile(mResult.mTLSAuthFilename, Utils.FileType.TLS_AUTH_FILE, false);
mResult.mPKCS12Filename = embedFile(mResult.mPKCS12Filename, Utils.FileType.PKCS12, false);
- mEmbeddedPwFile = cp.getAuthUserPassFile();
- mEmbeddedPwFile = embedFile(cp.getAuthUserPassFile(), Utils.FileType.USERPW_FILE, false);
- mCrlFileName = embedFile(cp.getCrlVerifyFile(), Utils.FileType.CRL_FILE, true);
+ if (cp != null) {
+ mEmbeddedPwFile = cp.getAuthUserPassFile();
+ mEmbeddedPwFile = embedFile(cp.getAuthUserPassFile(), Utils.FileType.USERPW_FILE, false);
+ mCrlFileName = embedFile(cp.getCrlVerifyFile(), Utils.FileType.CRL_FILE, true);
- ConfigParser.removeCRLCustomOption(mResult);
- if (!TextUtils.isEmpty(mCrlFileName)) {
- // TODO: Convert this to a real config option that is parsed
ConfigParser.removeCRLCustomOption(mResult);
- mResult.mCustomConfigOptions += "\ncrl-verify " + VpnProfile.openVpnEscape(mCrlFileName);
- } else if (!TextUtils.isEmpty(cp.getCrlVerifyFile())) {
- mResult.mCustomConfigOptions += "\n#crl-verify " + VpnProfile.openVpnEscape(cp.getCrlVerifyFile());
+ if (!TextUtils.isEmpty(mCrlFileName)) {
+ // TODO: Convert this to a real config option that is parsed
+ ConfigParser.removeCRLCustomOption(mResult);
+ mResult.mCustomConfigOptions += "\ncrl-verify " + VpnProfile.openVpnEscape(mCrlFileName);
+ } else if (!TextUtils.isEmpty(cp.getCrlVerifyFile())) {
+ mResult.mCustomConfigOptions += "\n#crl-verify " + VpnProfile.openVpnEscape(cp.getCrlVerifyFile());
+ }
}
}
diff --git a/main/src/main/res/layout/config_converter.xml b/main/src/main/res/layout/config_converter.xml
index 763ab051..739dbf72 100644
--- a/main/src/main/res/layout/config_converter.xml
+++ b/main/src/main/res/layout/config_converter.xml
@@ -27,6 +27,16 @@
android:id="@+id/files_missing_hint"
tools:visibilty="visible"/>
+ <TextView
+ android:text="@string/query_permissions_sdcard"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ tools:visibility="visible"
+ android:visibility="gone"
+ android:id="@+id/permssion_hint"
+ android:padding="5dp"
+ android:textStyle="bold" />
+
<CheckBox
android:id="@+id/importpkcs12"
android:layout_width="fill_parent"
diff --git a/main/src/main/res/values-in/strings.xml b/main/src/main/res/values-in/strings.xml
index beb32d52..b287756b 100755
--- a/main/src/main/res/values-in/strings.xml
+++ b/main/src/main/res/values-in/strings.xml
@@ -296,7 +296,7 @@
<string name="allow_vpn_changes">Memungkinkan perubahan Profil VPN</string>
<string name="hwkeychain">Hardware Keystore:</string>
<string name="permission_icon_app">Ikon aplikasi mencoba menggunakan OpenVPN untuk Android</string>
- <string name="faq_vpndialog43">"Dimulai dengan Android 4.3 konfirmasi VPN dijaga terhadap\" overlay aplikasi \". Hal ini menyebabkan dialog tidak bereaksi menyentuh masukan. Jika Anda memiliki sebuah aplikasi yang menggunakan lapisan itu dapat menyebabkan perilaku ini. Jika Anda menemukan kontak aplikasi menyinggung penulis app. Masalah ini mempengaruhi semua aplikasi VPN di Android 4.3 dan kemudian. Lihat juga <a href="http://code.google.com/p/ics-openvpn/issues/detail?id=185"> Issue 185 <a> untuk rincian tambahan "</string>
+ <string name="faq_vpndialog43">"Dimulai dengan Android 4.3 konfirmasi VPN dijaga terhadap\" overlay aplikasi \". Hal ini menyebabkan dialog tidak bereaksi menyentuh masukan. Jika Anda memiliki sebuah aplikasi yang menggunakan lapisan itu dapat menyebabkan perilaku ini. Jika Anda menemukan kontak aplikasi menyinggung penulis app. Masalah ini mempengaruhi semua aplikasi VPN di Android 4.3 dan kemudian. Lihat juga <a href="http://code.google.com/p/ics-openvpn/issues/detail?id=185"> Issue 185 </a> untuk rincian tambahan "</string>
<string name="faq_vpndialog43_title">VPN Konfirmasi Dialog</string>
<string name="donatePlayStore">Atau Anda dapat mengirimkan saya donasi dengan Play Store:</string>
<string name="thanks_for_donation">Terima kasih untuk menyumbangkan %s!</string>
diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml
index 3978c4d1..c1c3a638 100755
--- a/main/src/main/res/values/strings.xml
+++ b/main/src/main/res/values/strings.xml
@@ -387,5 +387,6 @@
<string name="clear_log_on_connect">Clear log on new connection</string>
<string name="connect_timeout">Connect Timeout</string>
<string name="no_allowed_app">No allowed app app added. Addding ourselves (%s) to have at least one app in the allowed app list to not allow all apps</string>
+ <string name="query_permissions_sdcard">OpenVPN for Android can try to discover the missing file(s) on the sdcard automatically. Tap this message start the permission request.</string>
</resources>