From 05a92d143b21af734d0826ab862e8be030686e09 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Fri, 13 Jun 2014 15:25:45 +0200 Subject: Use GET_CONTENT on every device but not on Samsung where the documentsui seems to unable to handle GET_CONTENT. Also always show SD cards --- .../java/de/blinkt/openvpn/fragments/Utils.java | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'main') diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java b/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java index f7038877..6784af93 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Utils.java @@ -10,16 +10,17 @@ import android.net.Uri; import android.os.Build; import android.provider.OpenableColumns; import android.util.Base64; -import android.util.Log; import android.webkit.MimeTypeMap; -import de.blinkt.openvpn.VpnProfile; -import junit.framework.Assert; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.List; import java.util.TreeSet; import java.util.Vector; +import de.blinkt.openvpn.VpnProfile; + public class Utils { @@ -99,17 +100,30 @@ public class Utils { i.putExtra(Intent.EXTRA_MIME_TYPES, supportedMimeTypes.toArray(new String[supportedMimeTypes.size()])); + // People don't know that this is actually a system setting. Override it ... + // DocumentsContract.EXTRA_SHOW_ADVANCED is hidden + i.putExtra("android.content.extra.SHOW_ADVANCED", true); + /* Samsung has decided to do something strange, on stock Android GET_CONTENT opens the document UI */ /* fist try with documentsui */ i.setPackage("com.android.documentsui"); + + //noinspection ConstantConditions - if (true || !isIntentAvailable(c,i)) { + if (!isIntentAvailable(c,i)) { i.setAction(Intent.ACTION_OPEN_DOCUMENT); i.setPackage(null); } + /* + final PackageManager packageManager = c.getPackageManager(); + ResolveInfo list = packageManager.resolveActivity(i, 0); + + Toast.makeText(c, "Starting package: "+ list.activityInfo.packageName + + "with ACTION " + i.getAction(), Toast.LENGTH_LONG).show(); + */ return i; } -- cgit v1.2.3