Browse Source

[android] build libi2pd staticly, add update strings, fix messages

pull/1288/head
R4SAS 6 years ago
parent
commit
d7609f119c
  1. 15
      android/build.gradle
  2. 7
      android/jni/Application.mk
  3. 17
      android/jni/i2pd_android.cpp
  4. 19
      android/res/values-ru/strings.xml
  5. 16
      android/res/values/strings.xml
  6. 2
      android/src/org/purplei2p/i2pd/DaemonSingleton.java
  7. 3
      android/src/org/purplei2p/i2pd/ForegroundService.java
  8. 6
      android/src/org/purplei2p/i2pd/I2PDActivity.java
  9. 4
      android/src/org/purplei2p/i2pd/I2PD_JNI.java

15
android/build.gradle

@ -28,15 +28,17 @@ android {
applicationId "org.purplei2p.i2pd" applicationId "org.purplei2p.i2pd"
targetSdkVersion 28 targetSdkVersion 28
minSdkVersion 14 minSdkVersion 14
versionCode 1 versionCode 2220
versionName "2.22.0" versionName "2.22.0"
ndk { ndk {
abiFilters 'armeabi-v7a' abiFilters 'armeabi-v7a'
abiFilters 'x86' abiFilters 'x86'
//abiFilters 'arm64-v8a'
//abiFilters 'x86_64'
} }
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
arguments "-j4" arguments "-j3"
} }
} }
} }
@ -49,6 +51,15 @@ android {
assets.srcDirs = ['assets'] assets.srcDirs = ['assets']
} }
} }
splits {
abi {
// change that to true if you need splitted apk
enable false
reset()
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
universalApk true
}
}
signingConfigs { signingConfigs {
orignal { orignal {
storeFile file("i2pdapk.jks") storeFile file("i2pdapk.jks")

7
android/jni/Application.mk

@ -1,12 +1,13 @@
APP_ABI := armeabi-v7a x86 #APP_ABI := armeabi-v7a x86
APP_PLATFORM := android-14 #APP_PLATFORM := android-14
# ABI arm64-v8a and x86_64 supported only from platform-21 # ABI arm64-v8a and x86_64 supported only from platform-21
#APP_ABI := arm64-v8a x86_64 #APP_ABI := arm64-v8a x86_64
#APP_PLATFORM := android-21 #APP_PLATFORM := android-21
NDK_TOOLCHAIN_VERSION := clang NDK_TOOLCHAIN_VERSION := clang
APP_STL := c++_shared #APP_STL := c++_shared
APP_STL := c++_static
# Enable c++11 extensions in source code # Enable c++11 extensions in source code
APP_CPPFLAGS += -std=c++11 -fexceptions -frtti APP_CPPFLAGS += -std=c++11 -fexceptions -frtti

17
android/jni/i2pd_android.cpp

@ -1,5 +1,3 @@
//#include <string.h>
#include <jni.h> #include <jni.h>
#include "org_purplei2p_i2pd_I2PD_JNI.h" #include "org_purplei2p_i2pd_I2PD_JNI.h"
#include "DaemonAndroid.h" #include "DaemonAndroid.h"
@ -26,17 +24,17 @@ JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
#else #else
#define ABI "armeabi" #define ABI "armeabi"
#endif #endif
#elif defined(__i386__) #elif defined(__i386__)
#define ABI "x86" #define ABI "x86"
#elif defined(__x86_64__) #elif defined(__x86_64__)
#define ABI "x86_64" #define ABI "x86_64"
#elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */ #elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */
#define ABI "mips64" #define ABI "mips64"
#elif defined(__mips__) #elif defined(__mips__)
#define ABI "mips" #define ABI "mips"
#elif defined(__aarch64__) #elif defined(__aarch64__)
#define ABI "arm64-v8a" #define ABI "arm64-v8a"
#else #else
#define ABI "unknown" #define ABI "unknown"
#endif #endif
@ -64,8 +62,7 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startAcceptingTunnels
} }
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
(JNIEnv * env, jclass clazz, jboolean isConnected) (JNIEnv * env, jclass clazz, jboolean isConnected) {
{
bool isConnectedBool = (bool) isConnected; bool isConnectedBool = (bool) isConnected;
i2p::transport::transports.SetOnline (isConnectedBool); i2p::transport::transports.SetOnline (isConnectedBool);
} }

19
android/res/values-ru/strings.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">i2pd</string>
<string name="action_stop">Остановить</string>
<string name="action_graceful_stop">Корректная остановка</string>
<string name="action_cancel_graceful_stop">Отменить мягкую остановку</string>
<string name="graceful_stop_is_already_in_progress">Мягкая остановка уже запущена</string>
<string name="graceful_stop_is_in_progress">Мягкая остановка запущена</string>
<string name="already_stopped">Уже остановлено</string>
<string name="uninitialized">Приложение инициализируется</string>
<string name="starting">Приложение запускается</string>
<string name="jniLibraryLoaded">Загружены JNI библиотеки</string>
<string name="startedOkay">Приложение запущено</string>
<string name="startFailed">Запуск не удался</string>
<string name="gracefulShutdownInProgress">Мягкая остановка запущена</string>
<string name="stopped">Приложение было остановлено</string>
<string name="remaining">осталось</string>
<string name="title_activity_i2_pdperms_asker_prompt">Запрос</string>
</resources>

16
android/res/values/strings.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
<string name="app_name">i2pd</string> <string name="app_name">i2pd</string>
<string name="action_stop">Stop</string> <string name="action_stop">Stop</string>
<string name="action_graceful_stop">Graceful Stop</string> <string name="action_graceful_stop">Graceful Stop</string>
@ -7,13 +7,13 @@
<string name="graceful_stop_is_already_in_progress">Graceful stop is already in progress</string> <string name="graceful_stop_is_already_in_progress">Graceful stop is already in progress</string>
<string name="graceful_stop_is_in_progress">Graceful stop is in progress</string> <string name="graceful_stop_is_in_progress">Graceful stop is in progress</string>
<string name="already_stopped">Already stopped</string> <string name="already_stopped">Already stopped</string>
<string name="uninitialized">i2pd initializing</string> <string name="uninitialized">Application initializing</string>
<string name="starting">i2pd is starting</string> <string name="starting">Application starting</string>
<string name="jniLibraryLoaded">i2pd: loaded JNI libraries</string> <string name="jniLibraryLoaded">Loaded JNI libraries</string>
<string name="startedOkay">i2pd started</string> <string name="startedOkay">Application Started</string>
<string name="startFailed">i2pd start failed</string> <string name="startFailed">Start failed</string>
<string name="gracefulShutdownInProgress">i2pd: graceful shutdown in progress</string> <string name="gracefulShutdownInProgress">Graceful shutdown in progress</string>
<string name="stopped">i2pd has stopped</string> <string name="stopped">Application stopped</string>
<string name="remaining">remaining</string> <string name="remaining">remaining</string>
<string name="title_activity_i2_pdperms_asker_prompt">Prompt</string> <string name="title_activity_i2_pdperms_asker_prompt">Prompt</string>
</resources> </resources>

2
android/src/org/purplei2p/i2pd/DaemonSingleton.java

@ -2,8 +2,8 @@ package org.purplei2p.i2pd;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import android.util.Log; import android.util.Log;
import org.purplei2p.i2pd.R;
public class DaemonSingleton { public class DaemonSingleton {
private static final String TAG="i2pd"; private static final String TAG="i2pd";

3
android/src/org/purplei2p/i2pd/ForegroundService.java

@ -85,7 +85,7 @@ public class ForegroundService extends Service {
stopForeground(true); stopForeground(true);
// Tell the user we stopped. // Tell the user we stopped.
// Toast.makeText(this, R.string.i2pd_service_stopped, Toast.LENGTH_SHORT).show(); //Toast.makeText(this, R.string.i2pd_service_stopped, Toast.LENGTH_SHORT).show();
shown=false; shown=false;
} }
@ -146,4 +146,3 @@ public class ForegroundService extends Service {
private static final DaemonSingleton daemon = DaemonSingleton.getInstance(); private static final DaemonSingleton daemon = DaemonSingleton.getInstance();
} }

6
android/src/org/purplei2p/i2pd/I2PDActivity.java

@ -66,9 +66,9 @@ public class I2PDActivity extends Activity {
} }
DaemonSingleton.State state = daemon.getState(); DaemonSingleton.State state = daemon.getState();
textView.setText( textView.setText(
String.valueOf(state)+ String.valueOf(getText(state.getStatusStringResourceId()))+
(DaemonSingleton.State.startFailed.equals(state)?": "+daemon.getDaemonStartResult():"")+ (DaemonSingleton.State.startFailed.equals(state) ? ": "+daemon.getDaemonStartResult() : "")+
(DaemonSingleton.State.gracefulShutdownInProgress.equals(state)?": "+formatGraceTimeRemaining()+" "+getText(R.string.remaining):"") (DaemonSingleton.State.gracefulShutdownInProgress.equals(state) ? ": "+formatGraceTimeRemaining()+" "+getText(R.string.remaining) : "")
); );
} catch (Throwable tr) { } catch (Throwable tr) {
Log.e(TAG,"error ignored",tr); Log.e(TAG,"error ignored",tr);

4
android/src/org/purplei2p/i2pd/I2PD_JNI.java

@ -2,11 +2,13 @@ package org.purplei2p.i2pd;
public class I2PD_JNI { public class I2PD_JNI {
public static native String getABICompiledWith(); public static native String getABICompiledWith();
/** /**
* returns error info if failed * returns error info if failed
* returns "ok" if daemon initialized and started okay * returns "ok" if daemon initialized and started okay
*/ */
public static native String startDaemon(); public static native String startDaemon();
//should only be called after startDaemon() success //should only be called after startDaemon() success
public static native void stopDaemon(); public static native void stopDaemon();
@ -17,7 +19,7 @@ public class I2PD_JNI {
public static native void onNetworkStateChanged(boolean isConnected); public static native void onNetworkStateChanged(boolean isConnected);
public static void loadLibraries() { public static void loadLibraries() {
System.loadLibrary("c++_shared"); //System.loadLibrary("c++_shared");
System.loadLibrary("i2pd"); System.loadLibrary("i2pd");
} }
} }

Loading…
Cancel
Save