You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
add a media ContentProvider
Every time the ContentProvider is accessed, a file chooser opens and the selected file is then provided as media file.
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
package android.provider;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
public class MediaStore {
|
||||
|
||||
@@ -9,6 +16,43 @@ public class MediaStore {
|
||||
public static class Media {
|
||||
|
||||
public static final Uri EXTERNAL_CONTENT_URI = Uri.parse("content://media/external/images/media");
|
||||
public static final Uri INTERNAL_CONTENT_URI = Uri.parse("content://media/internal/images/media");
|
||||
}
|
||||
|
||||
public static class Thumbnails {
|
||||
|
||||
public static Cursor queryMiniThumbnail(ContentResolver contentResolver, long id, int kind, String[] projection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Bitmap getThumbnail(ContentResolver contentResolver, long imageId, long groupId, int kind, BitmapFactory.Options options) throws FileNotFoundException {
|
||||
ParcelFileDescriptor fd = contentResolver.openFileDescriptor(Media.EXTERNAL_CONTENT_URI.buildUpon().appendPath(String.valueOf(imageId)).build(), "r");
|
||||
return BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor(), null, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Video {
|
||||
|
||||
public static class Media {
|
||||
|
||||
public static final Uri EXTERNAL_CONTENT_URI = Uri.parse("content://media/external/video/media");
|
||||
public static final Uri INTERNAL_CONTENT_URI = Uri.parse("content://media/internal/video/media");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Audio {
|
||||
|
||||
public static class Media {
|
||||
|
||||
public static final Uri EXTERNAL_CONTENT_URI = Uri.parse("content://media/external/audio/media");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Files {
|
||||
|
||||
public static Uri getContentUri(String type) {
|
||||
return Uri.parse("content://media/files/" + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user