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:
@@ -0,0 +1,25 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../generated_headers/android_content_ATLMediaContentProvider.h"
|
||||
#include "../defines.h"
|
||||
#include "../util.h"
|
||||
|
||||
extern GtkWindow *window;
|
||||
|
||||
static void file_dialog_callback(GObject *dialog, GAsyncResult *res, gpointer user_data) {
|
||||
GFile *file = gtk_file_dialog_open_finish(GTK_FILE_DIALOG(dialog), res, NULL);
|
||||
JNIEnv *env = get_jni_env();
|
||||
jobject this = (jobject) user_data;
|
||||
(*env)->CallVoidMethod(env, this, _METHOD(_CLASS(this), "setSelectedFile", "(Ljava/lang/String;)V"), _JSTRING(g_file_get_path(file)));
|
||||
g_object_unref(file);
|
||||
_UNREF(this);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_content_ATLMediaContentProvider_native_1open_1media_1folder(JNIEnv *env, jobject this)
|
||||
{
|
||||
GtkFileDialog *dialog = gtk_file_dialog_new();
|
||||
gtk_file_dialog_set_title(GTK_FILE_DIALOG(dialog), "Open Media Folder");
|
||||
gtk_file_dialog_set_modal(GTK_FILE_DIALOG(dialog), TRUE);
|
||||
gtk_file_dialog_open(dialog, window, NULL, file_dialog_callback, _REF(this));
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class android_content_ATLMediaContentProvider */
|
||||
|
||||
#ifndef _Included_android_content_ATLMediaContentProvider
|
||||
#define _Included_android_content_ATLMediaContentProvider
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: android_content_ATLMediaContentProvider
|
||||
* Method: native_open_media_folder
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_content_ATLMediaContentProvider_native_1open_1media_1folder
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user