You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rnx #rb none #ROBOMERGE-OWNER: ryan.durand #ROBOMERGE-AUTHOR: ryan.durand #ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900 #ROBOMERGE-BOT: (v613-10869866) [CL 10870549 by ryan durand in Main branch]
65 lines
1.7 KiB
C++
65 lines
1.7 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AndroidWebBrowserDialog.h"
|
|
|
|
#if USE_ANDROID_JNI
|
|
|
|
#include "Android/AndroidApplication.h"
|
|
#include "Android/AndroidJava.h"
|
|
|
|
#include <jni.h>
|
|
|
|
namespace
|
|
{
|
|
FText GetFText(jstring InString)
|
|
{
|
|
if (InString == nullptr)
|
|
{
|
|
return FText::GetEmpty();
|
|
}
|
|
|
|
JNIEnv* JEnv = FAndroidApplication::GetJavaEnv();
|
|
FString Temp = FJavaHelper::FStringFromParam(JEnv, InString);
|
|
FText Retval = FText::FromString(Temp);
|
|
return Retval;
|
|
}
|
|
}
|
|
|
|
FAndroidWebBrowserDialog::FAndroidWebBrowserDialog(jstring InMessageText, jstring InDefaultPrompt, jobject InCallback)
|
|
: Type(EWebBrowserDialogType::Prompt)
|
|
, MessageText(GetFText(InMessageText))
|
|
, DefaultPrompt(GetFText(InDefaultPrompt))
|
|
, Callback(InCallback)
|
|
{
|
|
}
|
|
|
|
FAndroidWebBrowserDialog::FAndroidWebBrowserDialog(EWebBrowserDialogType InDialogType, jstring InMessageText, jobject InCallback)
|
|
: Type(InDialogType)
|
|
, MessageText(GetFText(InMessageText))
|
|
, DefaultPrompt()
|
|
, Callback(InCallback)
|
|
{
|
|
}
|
|
|
|
void FAndroidWebBrowserDialog::Continue(bool Success, const FText& UserResponse)
|
|
{
|
|
check(Callback != nullptr);
|
|
JNIEnv* JEnv = FAndroidApplication::GetJavaEnv();
|
|
const char* MethodName = Success?"confirm":"cancel";
|
|
const char* MethodSignature = (Success && Type==EWebBrowserDialogType::Prompt)?"(Ljava/lang/String;)V":"()V";
|
|
auto Class = NewScopedJavaObject(JEnv, JEnv->GetObjectClass(Callback));
|
|
jmethodID MethodId = JEnv->GetMethodID(*Class, MethodName, MethodSignature);
|
|
|
|
if (Success && Type==EWebBrowserDialogType::Prompt)
|
|
{
|
|
auto JUserResponse = FJavaClassObject::GetJString(UserResponse.ToString());
|
|
JEnv->CallVoidMethod(Callback, MethodId, *JUserResponse);
|
|
}
|
|
else
|
|
{
|
|
JEnv->CallVoidMethod(Callback, MethodId, nullptr);
|
|
}
|
|
}
|
|
|
|
#endif // USE_ANDROID_JNI
|