Skip to content

Commit 12b8290

Browse files
Android and indentation
1 parent d2779c7 commit 12b8290

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

include/nbl/system/CApplicationAndroid.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
#ifndef _NBL_SYSTEM_C_APPLICATION_FRAMEWORK_ANDROID_H_INCLUDED_
22
#define _NBL_SYSTEM_C_APPLICATION_FRAMEWORK_ANDROID_H_INCLUDED_
33

4-
#ifdef _NBL_PLATFORM_ANDROID_
5-
64
#include "nbl/core/declarations.h"
7-
#include "nbl/system/CStdoutLoggerAndroid.h"
5+
86
#include "nbl/system/IApplicationFramework.h"
7+
#include "nbl/system/CStdoutLoggerAndroid.h"
8+
9+
10+
namespace nbl::system
11+
{
12+
#ifdef _NBL_PLATFORM_ANDROID_
913
#include <android_native_app_glue.h>
1014
#include <android/sensor.h>
1115
#include <android/log.h>
12-
namespace nbl::system
13-
{
1416

1517
class CApplicationAndroid : public IApplicationFramework
16-
{
18+
{
1719
public:
1820
void onStateSaved(android_app* params)
1921
{
@@ -132,10 +134,9 @@ namespace nbl::system
132134
};
133135
CEventPoller eventPoller;
134136
bool keepPolling() const { return eventPoller.continuePredicate(); }
135-
};
136-
137-
}
137+
};
138138

139139
#endif
140+
}
140141

141142
#endif

include/nbl/system/IApplicationFramework.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define _NBL_SYSTEM_I_APPLICATION_FRAMEWORK_H_INCLUDED_
33

44
#include "nbl/core/declarations.h"
5-
#include "nbl/system/declarations.h"
65

6+
#include "nbl/system/declarations.h"
77
#include "nbl/system/definitions.h"
88

99
namespace nbl::system

src/nbl/system/CAPKResourcesArchive.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ CAPKResourcesArchive::CAPKResourcesArchive(const path& _path, system::logger_opt
1515
core::vector<IFileArchive::SListEntry> CAPKResourcesArchive::computeItems(const std::string& asset_path, ANativeActivity* activity, JNIEnv* jniEnv)
1616
{
1717
auto context_object = activity->clazz;
18-
auto getAssets_method = env->GetMethodID(env->GetObjectClass(context_object), "getAssets", "()Landroid/content/res/AssetManager;");
19-
auto assetManager_object = env->CallObjectMethod(context_object,getAssets_method);
20-
auto list_method = env->GetMethodID(env->GetObjectClass(assetManager_object), "list", "(Ljava/lang/String;)[Ljava/lang/String;");
18+
auto getAssets_method = jniEnv->GetMethodID(jniEnv->GetObjectClass(context_object), "getAssets", "()Landroid/content/res/AssetManager;");
19+
auto assetManager_object = jniEnv->CallObjectMethod(context_object,getAssets_method);
20+
auto list_method = jniEnv->GetMethodID(jniEnv->GetObjectClass(assetManager_object), "list", "(Ljava/lang/String;)[Ljava/lang/String;");
2121

22-
jstring path_object = env->NewStringUTF(asset_path.c_str());
22+
jstring path_object = jniEnv->NewStringUTF(asset_path.c_str());
2323

24-
auto files_object = (jobjectArray)env->CallObjectMethod(assetManager_object, list_method, path_object);
24+
auto files_object = (jobjectArray)jniEnv->CallObjectMethod(assetManager_object, list_method, path_object);
2525

26-
env->DeleteLocalRef(path_object);
26+
jniEnv->DeleteLocalRef(path_object);
2727

28-
auto length = env->GetArrayLength(files_object);
28+
auto length = jniEnv->GetArrayLength(files_object);
2929

3030
core::vector<IFileArchive::SListEntry> result;
3131
for (decltype(length) i=0; i<length; i++)
3232
{
33-
jstring jstr = (jstring)env->GetObjectArrayElement(files_object,i);
33+
jstring jstr = (jstring)jniEnv->GetObjectArrayElement(files_object,i);
3434

35-
const char* filename = env->GetStringUTFChars(jstr,nullptr);
35+
const char* filename = jniEnv->GetStringUTFChars(jstr,nullptr);
3636
if (filename != nullptr)
3737
{
3838
auto& item = result.emplace_back();
@@ -46,10 +46,10 @@ core::vector<IFileArchive::SListEntry> CAPKResourcesArchive::computeItems(const
4646
item.ID = i;
4747
item.allocatorType = EAT_APK_ALLOCATOR;
4848

49-
env->ReleaseStringUTFChars(jstr,filename);
49+
jniEnv->ReleaseStringUTFChars(jstr,filename);
5050
}
5151

52-
env->DeleteLocalRef(jstr);
52+
jniEnv->DeleteLocalRef(jstr);
5353
}
5454
}
5555

src/nbl/ui/CGraphicalApplicationAndroid.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44

55
namespace nbl::ui
66
{
7-
system::path CGraphicalApplicationAndroid::getSharedResourcesPath(JNIEnv* env)
8-
{
9-
// Get File object for the external storage directory.
10-
jclass classEnvironment = env->FindClass("android/os/Environment");
11-
jmethodID methodIDgetExternalStorageDirectory = env->GetStaticMethodID(classEnvironment, "getExternalStorageDirectory", "()Ljava/io/File;"); // public static File getExternalStorageDirectory ()
12-
jobject objectFile = env->CallStaticObjectMethod(classEnvironment, methodIDgetExternalStorageDirectory);
137

14-
// Call method on File object to retrieve String object.
15-
jclass classFile = env->GetObjectClass(objectFile);
16-
jmethodID methodIDgetAbsolutePath = env->GetMethodID(classFile, "getAbsolutePath", "()Ljava/lang/String;");
17-
jstring stringPath = (jstring)env->CallObjectMethod(objectFile, methodIDgetAbsolutePath);
8+
system::path CGraphicalApplicationAndroid::getSharedResourcesPath(JNIEnv* env)
9+
{
10+
// Get File object for the external storage directory.
11+
jclass classEnvironment = env->FindClass("android/os/Environment");
12+
jmethodID methodIDgetExternalStorageDirectory = env->GetStaticMethodID(classEnvironment, "getExternalStorageDirectory", "()Ljava/io/File;"); // public static File getExternalStorageDirectory ()
13+
jobject objectFile = env->CallStaticObjectMethod(classEnvironment, methodIDgetExternalStorageDirectory);
14+
15+
// Call method on File object to retrieve String object.
16+
jclass classFile = env->GetObjectClass(objectFile);
17+
jmethodID methodIDgetAbsolutePath = env->GetMethodID(classFile, "getAbsolutePath", "()Ljava/lang/String;");
18+
jstring stringPath = (jstring)env->CallObjectMethod(objectFile, methodIDgetAbsolutePath);
19+
20+
// Extract a C string from the String object, and chdir() to it.
21+
const char* sharedPath = env->GetStringUTFChars(stringPath, NULL);
22+
return system::path(sharedPath);
23+
}
1824

19-
// Extract a C string from the String object, and chdir() to it.
20-
const char* sharedPath = env->GetStringUTFChars(stringPath, NULL);
21-
return system::path(sharedPath);
22-
}
2325
}
2426

2527
#endif

0 commit comments

Comments
 (0)