Files
UnrealEngineUWP/Engine/Source/Runtime/WebBrowser/Private/Android/AndroidWebBrowserDialog.cpp
Josh Adams d0bf843c9c - Merging Dev-Kairos/Engine/... to Main/Engine/...
- Brings over the necessary engine changes for embedding UE4 mobile as a dylib/so in native mobile app
- Various changes for facial animation, screen recording, others
- ARKit and ARCore plugins were removed, as deemed "not ready"
#rb many people


#ROBOMERGE-OWNER: josh.adams
#ROBOMERGE-AUTHOR: josh.adams
#ROBOMERGE-SOURCE: CL 5201138 via CL 5203024

[CL 5226277 by Josh Adams in Main branch]
2019-02-27 11:57:17 -05:00

65 lines
1.7 KiB
C++

// Copyright 1998-2019 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