mirror of
https://github.com/PurpleI2P/i2pd-android.git
synced 2025-02-02 18:04:28 +00:00
add i2pd multilingual support
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
80830ac712
commit
eef59d9052
@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)
|
|||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
LOCAL_MODULE := i2pd
|
LOCAL_MODULE := i2pd
|
||||||
LOCAL_CPP_FEATURES := rtti exceptions
|
LOCAL_CPP_FEATURES := rtti exceptions
|
||||||
LOCAL_C_INCLUDES += $(IFADDRS_PATH) $(LIB_SRC_PATH) $(LIB_CLIENT_SRC_PATH) $(DAEMON_SRC_PATH)
|
LOCAL_C_INCLUDES += $(IFADDRS_PATH) $(LIB_SRC_PATH) $(LIB_CLIENT_SRC_PATH) $(LANG_SRC_PATH) $(DAEMON_SRC_PATH)
|
||||||
LOCAL_STATIC_LIBRARIES := \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
boost_system \
|
boost_system \
|
||||||
boost_date_time \
|
boost_date_time \
|
||||||
@ -19,6 +19,7 @@ LOCAL_SRC_FILES := \
|
|||||||
$(IFADDRS_PATH)/ifaddrs.c \
|
$(IFADDRS_PATH)/ifaddrs.c \
|
||||||
$(wildcard $(LIB_SRC_PATH)/*.cpp) \
|
$(wildcard $(LIB_SRC_PATH)/*.cpp) \
|
||||||
$(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp) \
|
$(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp) \
|
||||||
|
$(wildcard $(LANG_SRC_PATH)/*.cpp) \
|
||||||
$(DAEMON_SRC_PATH)/Daemon.cpp \
|
$(DAEMON_SRC_PATH)/Daemon.cpp \
|
||||||
$(DAEMON_SRC_PATH)/UPnP.cpp \
|
$(DAEMON_SRC_PATH)/UPnP.cpp \
|
||||||
$(DAEMON_SRC_PATH)/HTTPServer.cpp \
|
$(DAEMON_SRC_PATH)/HTTPServer.cpp \
|
||||||
|
@ -19,4 +19,5 @@ I2PD_SRC_PATH = $(NDK_MODULE_PATH)/i2pd
|
|||||||
|
|
||||||
LIB_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd
|
LIB_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd
|
||||||
LIB_CLIENT_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd_client
|
LIB_CLIENT_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd_client
|
||||||
|
LANG_SRC_PATH = $(I2PD_SRC_PATH)/i18n
|
||||||
DAEMON_SRC_PATH = $(I2PD_SRC_PATH)/daemon
|
DAEMON_SRC_PATH = $(I2PD_SRC_PATH)/daemon
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
#include "DaemonAndroid.h"
|
#include "DaemonAndroid.h"
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
|
#include "I18N.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
@ -74,6 +75,7 @@ namespace android
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
std::string dataDir = "";
|
std::string dataDir = "";
|
||||||
|
std::string language = "";
|
||||||
|
|
||||||
DaemonAndroidImpl::DaemonAndroidImpl ()
|
DaemonAndroidImpl::DaemonAndroidImpl ()
|
||||||
//:
|
//:
|
||||||
@ -104,7 +106,7 @@ namespace android
|
|||||||
std::this_thread::sleep_for (std::chrono::seconds(1)); // otherwise wait for 1 more second
|
std::this_thread::sleep_for (std::chrono::seconds(1)); // otherwise wait for 1 more second
|
||||||
}
|
}
|
||||||
while (numAttempts <= 10); // 10 seconds max
|
while (numAttempts <= 10); // 10 seconds max
|
||||||
return Daemon.init(argc,argv);
|
return Daemon.init(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DaemonAndroidImpl::start()
|
void DaemonAndroidImpl::start()
|
||||||
@ -163,12 +165,16 @@ namespace android
|
|||||||
|
|
||||||
{
|
{
|
||||||
//Log.d(TAG"Initialising the daemon...");
|
//Log.d(TAG"Initialising the daemon...");
|
||||||
bool daemonInitSuccess = daemon.init(1,argv);
|
bool daemonInitSuccess = daemon.init(1, argv);
|
||||||
if(!daemonInitSuccess)
|
if(!daemonInitSuccess)
|
||||||
{
|
{
|
||||||
//QMessageBox::critical(0, "Error", "Daemon init failed");
|
//QMessageBox::critical(0, "Error", "Daemon init failed");
|
||||||
return "Daemon init failed";
|
return "Daemon init failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set webconsole language from application
|
||||||
|
i2p::i18n::SetLanguage(language);
|
||||||
|
|
||||||
//Log.d(TAG"Initialised, creating the main window...");
|
//Log.d(TAG"Initialised, creating the main window...");
|
||||||
//MainWindow w;
|
//MainWindow w;
|
||||||
//Log.d(TAG"Before main window.show()...");
|
//Log.d(TAG"Before main window.show()...");
|
||||||
@ -219,10 +225,14 @@ namespace android
|
|||||||
dataDir = jdataDir;
|
dataDir = jdataDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string GetDataDir(void)
|
||||||
GetDataDir(void)
|
|
||||||
{
|
{
|
||||||
return dataDir;
|
return dataDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetLanguage(std::string jlanguage)
|
||||||
|
{
|
||||||
|
language = jlanguage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,8 @@ namespace android
|
|||||||
void SetDataDir(std::string jdataDir);
|
void SetDataDir(std::string jdataDir);
|
||||||
// get datadir
|
// get datadir
|
||||||
std::string GetDataDir(void);
|
std::string GetDataDir(void);
|
||||||
|
// set webconsole language
|
||||||
|
void SetLanguage(std::string jlanguage);
|
||||||
/*
|
/*
|
||||||
class Worker : public QObject
|
class Worker : public QObject
|
||||||
{
|
{
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit f22eaa6db51e36d0a064c56907589164752035c5
|
Subproject commit 3a53e049bd4fbb085af75810e13970e4471c8a64
|
@ -56,6 +56,7 @@ JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon
|
|||||||
(JNIEnv *env, jclass clazz) {
|
(JNIEnv *env, jclass clazz) {
|
||||||
return env->NewStringUTF(i2p::android::start().c_str());
|
return env->NewStringUTF(i2p::android::start().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getDataDir
|
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getDataDir
|
||||||
(JNIEnv *env, jclass clazz) {
|
(JNIEnv *env, jclass clazz) {
|
||||||
return env->NewStringUTF( i2p::android::GetDataDir().c_str() );
|
return env->NewStringUTF( i2p::android::GetDataDir().c_str() );
|
||||||
@ -125,3 +126,10 @@ JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr
|
|||||||
std::string result = "http://" + httpAddr + ":" + std::to_string(httpPort) + "/";
|
std::string result = "http://" + httpAddr + ":" + std::to_string(httpPort) + "/";
|
||||||
return env->NewStringUTF(result.c_str());
|
return env->NewStringUTF(result.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setLanguage
|
||||||
|
(JNIEnv *env, jclass clazz, jstring jlanguage) {
|
||||||
|
auto language = env->GetStringUTFChars(jlanguage, NULL);
|
||||||
|
env->ReleaseStringUTFChars(jlanguage, language);
|
||||||
|
i2p::android::SetLanguage(language);
|
||||||
|
}
|
||||||
|
@ -53,6 +53,9 @@ JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
|
|||||||
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr
|
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr
|
||||||
(JNIEnv *, jclass);
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setLanguage
|
||||||
|
(JNIEnv *env, jclass clazz, jstring jlanguage);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,6 +10,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
@ -31,6 +32,8 @@ public class DaemonWrapper {
|
|||||||
private String i2pdpath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/i2pd/";
|
private String i2pdpath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/i2pd/";
|
||||||
private boolean assetsCopied;
|
private boolean assetsCopied;
|
||||||
|
|
||||||
|
private static final String appLocale = Locale.getDefault().getDisplayLanguage(Locale.ENGLISH).toLowerCase(); // lower-case system language (like "english")
|
||||||
|
|
||||||
public interface StateUpdateListener {
|
public interface StateUpdateListener {
|
||||||
void daemonStateUpdate(State oldValue, State newValue);
|
void daemonStateUpdate(State oldValue, State newValue);
|
||||||
}
|
}
|
||||||
@ -184,7 +187,11 @@ public class DaemonWrapper {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
synchronized (DaemonWrapper.this) {
|
synchronized (DaemonWrapper.this) {
|
||||||
I2PD_JNI.setDataDir(i2pdpath);//(Environment.getExternalStorageDirectory().getAbsolutePath() + "/i2pd");
|
I2PD_JNI.setDataDir(i2pdpath); // (Environment.getExternalStorageDirectory().getAbsolutePath() + "/i2pd");
|
||||||
|
|
||||||
|
Log.d(TAG, "setting webconsole language to " + appLocale);
|
||||||
|
I2PD_JNI.setLanguage(appLocale);
|
||||||
|
|
||||||
daemonStartResult = I2PD_JNI.startDaemon();
|
daemonStartResult = I2PD_JNI.startDaemon();
|
||||||
if ("ok".equals(daemonStartResult)) {
|
if ("ok".equals(daemonStartResult)) {
|
||||||
setState(State.startedOkay);
|
setState(State.startedOkay);
|
||||||
|
@ -26,6 +26,8 @@ public class I2PD_JNI {
|
|||||||
|
|
||||||
public static native String getWebConsAddr();
|
public static native String getWebConsAddr();
|
||||||
|
|
||||||
|
public static native void setLanguage(String jlanguage);
|
||||||
|
|
||||||
public static void loadLibraries() {
|
public static void loadLibraries() {
|
||||||
//System.loadLibrary("c++_shared");
|
//System.loadLibrary("c++_shared");
|
||||||
System.loadLibrary("i2pd");
|
System.loadLibrary("i2pd");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user