mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[ion/simulator/android] Get the language directly
Without using the "--language" command-line option
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
ion_src += $(addprefix ion/src/simulator/android/src/cpp/, \
|
||||
haptics_enabled.cpp \
|
||||
platform_images.cpp \
|
||||
platform_language.cpp \
|
||||
)
|
||||
|
||||
ion_src += $(addprefix ion/src/simulator/shared/, \
|
||||
dummy/journal.cpp \
|
||||
dummy/keyboard_callback.cpp \
|
||||
dummy/language.cpp \
|
||||
dummy/window_callback.cpp \
|
||||
clipboard_helper.cpp \
|
||||
haptics.cpp \
|
||||
|
||||
32
ion/src/simulator/android/src/cpp/platform_language.cpp
Normal file
32
ion/src/simulator/android/src/cpp/platform_language.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "../../../shared/platform.h"
|
||||
#include <jni.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Simulator {
|
||||
namespace Platform {
|
||||
|
||||
const char * languageCode() {
|
||||
static char buffer[4] = {0};
|
||||
if (buffer[0] == 0) {
|
||||
JNIEnv * env = static_cast<JNIEnv *>(SDL_AndroidGetJNIEnv());
|
||||
jobject activity = static_cast<jobject>(SDL_AndroidGetActivity());
|
||||
|
||||
jclass j_class = env->FindClass("com/numworks/calculator/EpsilonActivity");
|
||||
jmethodID j_methodId = env->GetMethodID(
|
||||
j_class,
|
||||
"retrieveLanguage",
|
||||
"(V)Ljava/lang/String;"
|
||||
);
|
||||
|
||||
jstring j_language = static_cast<jstring>(env->CallObjectMethod(activity, j_methodId));
|
||||
const char * language = env->GetStringUTFChars(j_language, nullptr);
|
||||
memcpy(buffer, language, 4);
|
||||
buffer[3] = 0;
|
||||
env->ReleaseStringUTFChars(j_language, language);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,13 +28,6 @@ public class EpsilonActivity extends SDLActivity {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getArguments() {
|
||||
Locale currentLocale = getResources().getConfiguration().locale;
|
||||
String[] arguments = {"--language", currentLocale.getLanguage()};
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public Bitmap retrieveBitmapAsset(String identifier) {
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
@@ -47,6 +40,10 @@ public class EpsilonActivity extends SDLActivity {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public String retrieveLanguage() {
|
||||
return getResources().getConfiguration().locale.getLanguage();
|
||||
}
|
||||
|
||||
public void telemetryInit() {
|
||||
sAnalytics = GoogleAnalytics.getInstance(this);
|
||||
sTracker = sAnalytics.newTracker("UA-93775823-3");
|
||||
|
||||
Reference in New Issue
Block a user