mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 13:49:53 -06:00
Android: Add a progress dialog for disc image conversion
This commit is contained in:
@ -36,6 +36,9 @@ static jclass s_ini_file_section_class;
|
||||
static jfieldID s_ini_file_section_pointer;
|
||||
static jmethodID s_ini_file_section_constructor;
|
||||
|
||||
static jclass s_compress_cb_class;
|
||||
static jmethodID s_compress_cb_run;
|
||||
|
||||
namespace IDCache
|
||||
{
|
||||
JNIEnv* GetEnvForThread()
|
||||
@ -161,6 +164,16 @@ jmethodID GetIniFileSectionConstructor()
|
||||
return s_ini_file_section_constructor;
|
||||
}
|
||||
|
||||
jclass GetCompressCallbackClass()
|
||||
{
|
||||
return s_compress_cb_class;
|
||||
}
|
||||
|
||||
jmethodID GetCompressCallbackRun()
|
||||
{
|
||||
return s_compress_cb_run;
|
||||
}
|
||||
|
||||
} // namespace IDCache
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -223,6 +236,11 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
s_linked_hash_map_put = env->GetMethodID(
|
||||
s_linked_hash_map_class, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
|
||||
const jclass compress_cb_class =
|
||||
env->FindClass("org/dolphinemu/dolphinemu/utils/CompressCallback");
|
||||
s_compress_cb_class = reinterpret_cast<jclass>(env->NewGlobalRef(compress_cb_class));
|
||||
s_compress_cb_run = env->GetMethodID(s_compress_cb_class, "run", "(Ljava/lang/String;F)Z");
|
||||
|
||||
return JNI_VERSION;
|
||||
}
|
||||
|
||||
@ -239,6 +257,7 @@ void JNI_OnUnload(JavaVM* vm, void* reserved)
|
||||
env->DeleteGlobalRef(s_linked_hash_map_class);
|
||||
env->DeleteGlobalRef(s_ini_file_class);
|
||||
env->DeleteGlobalRef(s_ini_file_section_class);
|
||||
env->DeleteGlobalRef(s_compress_cb_class);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -38,4 +38,7 @@ jclass GetIniFileSectionClass();
|
||||
jfieldID GetIniFileSectionPointer();
|
||||
jmethodID GetIniFileSectionConstructor();
|
||||
|
||||
jclass GetCompressCallbackClass();
|
||||
jmethodID GetCompressCallbackRun();
|
||||
|
||||
} // namespace IDCache
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/Logging/LogManager.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/ScopeGuard.h"
|
||||
#include "Common/Version.h"
|
||||
#include "Common/WindowSystemInfo.h"
|
||||
|
||||
@ -668,7 +669,7 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_InstallW
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ConvertDiscImage(
|
||||
JNIEnv* env, jobject obj, jstring jInPath, jstring jOutPath, jint jPlatform, jint jFormat,
|
||||
jint jBlockSize, jint jCompression, jint jCompressionLevel, jboolean jScrub)
|
||||
jint jBlockSize, jint jCompression, jint jCompressionLevel, jboolean jScrub, jobject jCallback)
|
||||
{
|
||||
const std::string in_path = GetJString(env, jInPath);
|
||||
const std::string out_path = GetJString(env, jOutPath);
|
||||
@ -687,7 +688,14 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ConvertD
|
||||
if (!blob_reader)
|
||||
return static_cast<jboolean>(false);
|
||||
|
||||
const auto callback = [](const std::string& text, float percent) { return true; };
|
||||
jobject jCallbackGlobal = env->NewGlobalRef(jCallback);
|
||||
Common::ScopeGuard scope_guard([jCallbackGlobal, env] { env->DeleteGlobalRef(jCallbackGlobal); });
|
||||
|
||||
const auto callback = [&jCallbackGlobal](const std::string& text, float completion) {
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
return static_cast<bool>(env->CallBooleanMethod(
|
||||
jCallbackGlobal, IDCache::GetCompressCallbackRun(), ToJString(env, text), completion));
|
||||
};
|
||||
|
||||
bool success = false;
|
||||
|
||||
|
Reference in New Issue
Block a user