From d9f3e382fe1b2f1c7d9de54cefa920b4f0502af6 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 25 Jun 2020 19:38:02 +0200 Subject: Android: Add a progress dialog for disc image conversion --- Source/Android/jni/MainAndroid.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Source/Android/jni/MainAndroid.cpp') diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index bef78a49b5..4bb72ff2f6 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -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(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(env->CallBooleanMethod( + jCallbackGlobal, IDCache::GetCompressCallbackRun(), ToJString(env, text), completion)); + }; bool success = false; -- cgit v1.2.3