|
@@ -10,6 +10,7 @@ import android.os.Environment;
|
|
|
import android.os.storage.StorageManager;
|
|
|
import android.provider.DocumentsContract;
|
|
|
import android.provider.MediaStore;
|
|
|
+import android.provider.OpenableColumns;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
|
|
@@ -228,7 +229,7 @@ public final class UriUtils {
|
|
|
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
|
|
} else if ("audio".equals(type)) {
|
|
|
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
|
|
- } else if("document".equals(type)){
|
|
|
+ } else if ("document".equals(type)) {
|
|
|
contentUri = MediaStore.Files.getContentUri("external");
|
|
|
} else {
|
|
|
Log.d("UriUtils", uri.toString() + " parse failed. -> 1_2");
|
|
@@ -312,7 +313,13 @@ public final class UriUtils {
|
|
|
InputStream is = null;
|
|
|
try {
|
|
|
is = Utils.getApp().getContentResolver().openInputStream(uri);
|
|
|
- File file = new File(Utils.getApp().getCacheDir(), "" + System.currentTimeMillis());
|
|
|
+ Cursor cursor = Utils.getApp().getContentResolver().query(uri, null, null, null, null);
|
|
|
+ String displayName = "" + System.currentTimeMillis();
|
|
|
+ if (cursor.moveToFirst()) {
|
|
|
+ displayName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
|
|
|
+ }
|
|
|
+ Log.i("UriUtils", "displayName:" + displayName);
|
|
|
+ File file = new File(Utils.getApp().getCacheDir(), displayName);
|
|
|
UtilsBridge.writeFileFromIS(file.getAbsolutePath(), is);
|
|
|
return file;
|
|
|
} catch (FileNotFoundException e) {
|