|
|
|
@ -1002,23 +1002,23 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
// DocumentProvider
|
|
|
|
|
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
|
|
|
|
|
// ExternalStorageProvider
|
|
|
|
|
// if (isExternalStorageDocument(uri)) {
|
|
|
|
|
// final String docId = DocumentsContract.getDocumentId(uri);
|
|
|
|
|
// final String[] split = docId.split(":");
|
|
|
|
|
// final String type = split[0];
|
|
|
|
|
//
|
|
|
|
|
// if ("primary".equalsIgnoreCase(type)) {
|
|
|
|
|
// return Environment.getExternalStorageDirectory() + "/" + split[1];
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // DownloadsProvider
|
|
|
|
|
// else if (isDownloadsDocument(uri)) {
|
|
|
|
|
// final String id = DocumentsContract.getDocumentId(uri);
|
|
|
|
|
// final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
|
|
|
|
// return getDataColumn(context, contentUri, null, null);
|
|
|
|
|
// }
|
|
|
|
|
if (isExternalStorageDocument(uri)) {
|
|
|
|
|
final String docId = DocumentsContract.getDocumentId(uri);
|
|
|
|
|
final String[] split = docId.split(":");
|
|
|
|
|
final String type = split[0];
|
|
|
|
|
|
|
|
|
|
if ("primary".equalsIgnoreCase(type)) {
|
|
|
|
|
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// DownloadsProvider
|
|
|
|
|
else if (isDownloadsDocument(uri)) {
|
|
|
|
|
final String id = DocumentsContract.getDocumentId(uri);
|
|
|
|
|
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
|
|
|
|
return getDataColumn(context, contentUri, null, null);
|
|
|
|
|
}
|
|
|
|
|
// MediaProvider
|
|
|
|
|
// else
|
|
|
|
|
else
|
|
|
|
|
if (isMediaDocument(uri)) {
|
|
|
|
|
final String docId = DocumentsContract.getDocumentId(uri);
|
|
|
|
|
final String[] split = docId.split(":");
|
|
|
|
@ -1069,14 +1069,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//是否为外部存储文件
|
|
|
|
|
// public boolean isExternalStorageDocument(Uri uri) {
|
|
|
|
|
// return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //是否为下载文件
|
|
|
|
|
// public boolean isDownloadsDocument(Uri uri) {
|
|
|
|
|
// return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
|
|
|
|
// }
|
|
|
|
|
public boolean isExternalStorageDocument(Uri uri) {
|
|
|
|
|
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//是否为下载文件
|
|
|
|
|
public boolean isDownloadsDocument(Uri uri) {
|
|
|
|
|
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//是否为媒体文件
|
|
|
|
|
public boolean isMediaDocument(Uri uri) {
|
|
|
|
|