revamp the way the plugin requests permisions on Android by showing a pop-up to the user rather than silently crashing if those permisions were not already given
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "SenseGloveAndroidModule.h"
|
||||
|
||||
#include "SGAndroid/SGAndroidPermissions.h"
|
||||
#include "SGAndroid/SGConnectJNI.h"
|
||||
#include "SGAndroid/SGCoreJNI.h"
|
||||
#include "SGLog/SGLog.h"
|
||||
@@ -45,16 +46,8 @@ void FSenseGloveAndroidModule::StartupModule()
|
||||
{
|
||||
SGLOG("Starting up the SenseGloveAndroid module...");
|
||||
|
||||
#if PLATFORM_ANDROID
|
||||
const int32 R1 = FSGConnectJNI::Initialize();
|
||||
const int32 R2 = FSGCoreJNI::Initialize();
|
||||
|
||||
ensureAlwaysMsgf(R1 == 0,
|
||||
TEXT("Failed to initialize the SGConnect JNI bridge to SGConnect for Android! Status Code: %d"), R1);
|
||||
|
||||
ensureAlwaysMsgf(R2 == 0,
|
||||
TEXT("Failed to initialize the SGCore JNI bridge to SGConnect for Android! Status Code: %d"), R2);
|
||||
#endif /* PLATFORM_ANDROID */
|
||||
OnPostEngineInitHandle = FCoreDelegates::OnPostEngineInit.AddRaw(
|
||||
this, &FSenseGloveAndroidModule::OnPostEngineInit);
|
||||
}
|
||||
|
||||
void FSenseGloveAndroidModule::PreUnloadCallback()
|
||||
@@ -72,4 +65,26 @@ void FSenseGloveAndroidModule::ShutdownModule()
|
||||
SGLOG("Shutting down the SenseGloveAndroid module...");
|
||||
}
|
||||
|
||||
void FSenseGloveAndroidModule::OnPostEngineInit() const
|
||||
{
|
||||
#if PLATFORM_ANDROID
|
||||
USGAndroidPermissions::GetInstance()->Request(
|
||||
[](const TArray<FString>& Permissions, const TArray<bool>& GrantResults)
|
||||
{
|
||||
const int32 R1 = FSGConnectJNI::Initialize();
|
||||
const int32 R2 = FSGCoreJNI::Initialize();
|
||||
|
||||
ensureAlwaysMsgf(R1 == 0,
|
||||
TEXT(
|
||||
"Failed to initialize the SGConnect JNI bridge to SGConnect for Android! Status Code: %d"
|
||||
), R1);
|
||||
|
||||
ensureAlwaysMsgf(R2 == 0,
|
||||
TEXT("Failed to initialize the SGCore JNI bridge to SGConnect for Android! Status Code: %d"
|
||||
), R2);
|
||||
|
||||
});
|
||||
#endif /* PLATFORM_ANDROID */
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -35,17 +35,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Delegates/IDelegateInstance.h"
|
||||
#include "Modules/ModuleInterface.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "SenseGloveAndroid"
|
||||
|
||||
class FSenseGloveAndroidModule : public IModuleInterface
|
||||
{
|
||||
private:
|
||||
FDelegateHandle OnPostEngineInitHandle;
|
||||
|
||||
public:
|
||||
virtual void StartupModule() override;
|
||||
virtual void PreUnloadCallback() override;
|
||||
virtual void PostLoadCallback() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
private:
|
||||
void OnPostEngineInit() const;
|
||||
};
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -46,6 +46,7 @@ public class SenseGloveAndroid : ModuleRules
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"AndroidPermission",
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
|
||||
Reference in New Issue
Block a user