mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
Merge pull request #526 from hypnosis-i2p/openssl
Android setForeground fix + notific.icon + fs crash fix + backg.thread restored
This commit is contained in:
commit
db0dfa1bf1
6
FS.cpp
6
FS.cpp
@ -54,9 +54,9 @@ namespace fs {
|
|||||||
dataDir = (home != NULL && strlen(home) > 0) ? home : "";
|
dataDir = (home != NULL && strlen(home) > 0) ? home : "";
|
||||||
dataDir += "/Library/Application Support/" + appName;
|
dataDir += "/Library/Application Support/" + appName;
|
||||||
return;
|
return;
|
||||||
#elif defined(ANDROID)
|
//#elif defined(ANDROID)
|
||||||
dataDir = "/sdcard/" + appName; // TODO: might not work for some devices
|
// dataDir = "/sdcard/" + appName; // TODO: might not work for some devices //does throw & terminate on Android 6.0 (?) in i2p::fs::Init()+164
|
||||||
return;
|
// return;
|
||||||
#else /* other unix */
|
#else /* other unix */
|
||||||
char *home = getenv("HOME");
|
char *home = getenv("HOME");
|
||||||
if (isService) {
|
if (isService) {
|
||||||
|
@ -78,11 +78,6 @@ namespace qt
|
|||||||
setRunningCallback(0);
|
setRunningCallback(0);
|
||||||
m_IsRunning=false;
|
m_IsRunning=false;
|
||||||
return Daemon.init(argc,argv);
|
return Daemon.init(argc,argv);
|
||||||
|
|
||||||
}
|
|
||||||
void DaemonQTImpl::deinit()
|
|
||||||
{
|
|
||||||
delete mutex; mutex = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DaemonQTImpl::start()
|
void DaemonQTImpl::start()
|
||||||
@ -129,34 +124,35 @@ namespace qt
|
|||||||
|
|
||||||
int RunQT (int argc, char* argv[])
|
int RunQT (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
//int result = runGUI(argc, argv);
|
QApplication app(argc, argv);
|
||||||
//QMessageBox::information(0,"Debug","runGUI completed");
|
int result;
|
||||||
QApplication app(argc, argv);
|
|
||||||
DaemonQTImpl daemon;
|
{
|
||||||
qDebug("Initialising the daemon...");
|
DaemonQTImpl daemon;
|
||||||
bool daemonInitSuccess = daemon.init(argc, argv);
|
qDebug("Initialising the daemon...");
|
||||||
if(!daemonInitSuccess)
|
bool daemonInitSuccess = daemon.init(argc, argv);
|
||||||
{
|
if(!daemonInitSuccess)
|
||||||
QMessageBox::critical(0, "Error", "Daemon init failed");
|
{
|
||||||
return 1;
|
QMessageBox::critical(0, "Error", "Daemon init failed");
|
||||||
}
|
return 1;
|
||||||
qDebug("Initialised, creating the main window...");
|
}
|
||||||
MainWindow w;
|
qDebug("Initialised, creating the main window...");
|
||||||
qDebug("Before main window.show()...");
|
MainWindow w;
|
||||||
w.show ();
|
qDebug("Before main window.show()...");
|
||||||
int result;
|
w.show ();
|
||||||
{
|
|
||||||
/* i2p::qt::Controller daemonQtController(daemon);
|
{
|
||||||
qDebug("Starting the daemon...");
|
i2p::qt::Controller daemonQtController(daemon);
|
||||||
emit daemonQtController.startDaemon();
|
qDebug("Starting the daemon...");
|
||||||
qDebug("Starting gui event loop...");*/
|
emit daemonQtController.startDaemon();
|
||||||
daemon.start ();
|
//daemon.start ();
|
||||||
result = app.exec();
|
qDebug("Starting GUI event loop...");
|
||||||
daemon.stop ();
|
result = app.exec();
|
||||||
}
|
//daemon.stop ();
|
||||||
daemon.deinit();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//QMessageBox::information(&w, "Debug", "demon stopped");
|
//QMessageBox::information(&w, "Debug", "demon stopped");
|
||||||
//exit(result); //return from main() causes intermittent sigsegv bugs in some Androids. exit() is a workaround for this
|
|
||||||
qDebug("Exiting the application");
|
qDebug("Exiting the application");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ namespace qt
|
|||||||
* @return success
|
* @return success
|
||||||
*/
|
*/
|
||||||
bool init(int argc, char* argv[]);
|
bool init(int argc, char* argv[]);
|
||||||
void deinit();
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void restart();
|
void restart();
|
||||||
|
1
qt/i2pd_qt/android/.gitignore
vendored
Normal file
1
qt/i2pd_qt/android/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/gen/
|
@ -1,7 +1,22 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<manifest package="org.purplei2p.i2pd" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.8.0" android:versionCode="1" android:installLocation="auto">
|
<manifest
|
||||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="i2pd">
|
package="org.purplei2p.i2pd"
|
||||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:versionName="2.8.0" android:versionCode="1" android:installLocation="auto">
|
||||||
|
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="24"/>
|
||||||
|
<supports-screens
|
||||||
|
android:largeScreens="true"
|
||||||
|
android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||||
|
<!-- <application android:hardwareAccelerated="true" -->
|
||||||
|
<application
|
||||||
|
android:name="org.qtproject.qt5.android.bindings.QtApplication"
|
||||||
|
android:label="i2pd">
|
||||||
|
<!-- android:configChanges="screenSize|smallestScreenSize" are since api 13, "layoutDirection" since api 17 -->
|
||||||
|
<activity
|
||||||
|
android:configChanges="orientation|uiMode|screenLayout|locale|fontScale|keyboard|keyboardHidden|navigation"
|
||||||
|
android:name="org.purplei2p.i2pd.I2PDMainActivity"
|
||||||
|
android:label="-- %%INSERT_APP_NAME%% --"
|
||||||
|
android:screenOrientation="unspecified" android:launchMode="singleTop">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
@ -45,9 +60,8 @@
|
|||||||
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
|
||||||
<!-- auto screen scale factor -->
|
<!-- auto screen scale factor -->
|
||||||
</activity>
|
</activity>
|
||||||
|
<service android:enabled="true" android:name=".LocalService" />
|
||||||
</application>
|
</application>
|
||||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="23"/>
|
|
||||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
|
||||||
|
|
||||||
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
|
||||||
Remove the comment if you do not require these default permissions. -->
|
Remove the comment if you do not require these default permissions. -->
|
||||||
|
57
qt/i2pd_qt/android/build.gradle
Normal file
57
qt/i2pd_qt/android/build.gradle
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:1.1.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
/*******************************************************
|
||||||
|
* The following variables:
|
||||||
|
* - androidBuildToolsVersion,
|
||||||
|
* - androidCompileSdkVersion
|
||||||
|
* - qt5AndroidDir - holds the path to qt android files
|
||||||
|
* needed to build any Qt application
|
||||||
|
* on Android.
|
||||||
|
*
|
||||||
|
* are defined in gradle.properties file. This file is
|
||||||
|
* updated by QtCreator and androiddeployqt tools.
|
||||||
|
* Changing them manually might break the compilation!
|
||||||
|
*******************************************************/
|
||||||
|
|
||||||
|
compileSdkVersion androidCompileSdkVersion.toInteger()
|
||||||
|
|
||||||
|
buildToolsVersion androidBuildToolsVersion
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
|
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
|
||||||
|
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
|
||||||
|
res.srcDirs = [qt5AndroidDir + '/res', 'res']
|
||||||
|
resources.srcDirs = ['src']
|
||||||
|
renderscript.srcDirs = ['src']
|
||||||
|
assets.srcDirs = ['assets']
|
||||||
|
jniLibs.srcDirs = ['libs']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
}
|
BIN
qt/i2pd_qt/android/libs/android-support-v4.jar
Normal file
BIN
qt/i2pd_qt/android/libs/android-support-v4.jar
Normal file
Binary file not shown.
14
qt/i2pd_qt/android/project.properties
Normal file
14
qt/i2pd_qt/android/project.properties
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# This file is automatically generated by Android Tools.
|
||||||
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
|
#
|
||||||
|
# This file must be checked in Version Control Systems.
|
||||||
|
#
|
||||||
|
# To customize properties used by the Ant build system edit
|
||||||
|
# "ant.properties", and override values to adapt the script to your
|
||||||
|
# project structure.
|
||||||
|
#
|
||||||
|
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||||
|
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||||
|
|
||||||
|
# Project target.
|
||||||
|
target=android-11
|
BIN
qt/i2pd_qt/android/res/drawable/itoopie_notification_icon.png
Normal file
BIN
qt/i2pd_qt/android/res/drawable/itoopie_notification_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
4
qt/i2pd_qt/android/res/layout/splash.xml
Normal file
4
qt/i2pd_qt/android/res/layout/splash.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent" />
|
6
qt/i2pd_qt/android/res/values-de/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-de/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Ministro-Dienst wurde nicht gefunden.\nAnwendung kann nicht gestartet werden</string>
|
||||||
|
<string name="ministro_needed_msg">Diese Anwendung benötigt den Ministro-Dienst. Möchten Sie ihn installieren?</string>
|
||||||
|
<string name="fatal_error_msg">In Ihrer Anwendung ist ein schwerwiegender Fehler aufgetreten, sie kann nicht fortgesetzt werden</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-el/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-el/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Δεν ήταν δυνατή η εύρεση της υπηρεσίας Ministro. Δεν είναι δυνατή η εκκίνηση της εφαρμογής.</string>
|
||||||
|
<string name="ministro_needed_msg">Η εφαρμογή απαιτεί την υπηρεσία Ministro. Να εγκατασταθεί η υπηρεσία?</string>
|
||||||
|
<string name="fatal_error_msg">Παρουσιάστηκε ένα κρίσιμο σφάλμα και η εφαρμογή δεν μπορεί να συνεχίσει.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-es/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-es/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Servicio Ministro inesistente. Imposible ejecutar la aplicación.</string>
|
||||||
|
<string name="ministro_needed_msg">Esta aplicación requiere el servicio Ministro. Instalarlo?</string>
|
||||||
|
<string name="fatal_error_msg">La aplicación ha causado un error grave y no es posible continuar.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-et/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-et/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Ei suuda leida Ministro teenust.\nProgrammi ei saa käivitada.</string>
|
||||||
|
<string name="ministro_needed_msg">See programm vajab Ministro teenust.\nKas soovite paigaldada?</string>
|
||||||
|
<string name="fatal_error_msg">Programmiga juhtus fataalne viga.\nKahjuks ei saa jätkata.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-fa/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-fa/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">سرویس Ministro را پیدا نمیکند. برنامه نمیتواند آغاز شود.</string>
|
||||||
|
<string name="ministro_needed_msg">این نرمافزار به سرویس Ministro احتیاج دارد. آیا دوست دارید آن را نصب کنید؟</string>
|
||||||
|
<string name="fatal_error_msg">خطایی اساسی در برنامهتان رخ داد و اجرای برنامه نمیتواند ادامه یابد.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-fr/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-fr/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Le service Ministro est introuvable.\nL\'application ne peut pas démarrer.</string>
|
||||||
|
<string name="ministro_needed_msg">Cette application requiert le service Ministro. Voulez-vous l\'installer?</string>
|
||||||
|
<string name="fatal_error_msg">Votre application a rencontré une erreur fatale et ne peut pas continuer.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-id/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-id/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Layanan Ministro tidak bisa ditemukan.\nAplikasi tidak bisa dimulai.</string>
|
||||||
|
<string name="ministro_needed_msg">Aplikasi ini membutuhkan layanan Ministro. Apakah Anda ingin menginstalnya?</string>
|
||||||
|
<string name="fatal_error_msg">Aplikasi Anda mengalami kesalahan fatal dan tidak dapat melanjutkan.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-it/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-it/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Servizio Ministro inesistente. Impossibile eseguire \nl\'applicazione.</string>
|
||||||
|
<string name="ministro_needed_msg">Questa applicazione richiede il servizio Ministro.Installarlo?</string>
|
||||||
|
<string name="fatal_error_msg">L\'applicazione ha provocato un errore grave e non puo\' continuare.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-ja/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-ja/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Ministroサービスが見つかりません。\nアプリケーションが起動できません。</string>
|
||||||
|
<string name="ministro_needed_msg">このアプリケーションにはMinistroサービスが必要です。 インストールしてもよろしいですか?</string>
|
||||||
|
<string name="fatal_error_msg">アプリケーションで致命的なエラーが発生したため続行できません。</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-ms/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-ms/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Tidak jumpa servis Ministro.\nAplikasi tidak boleh dimulakan.</string>
|
||||||
|
<string name="ministro_needed_msg">Aplikasi ini memerlukan servis Ministro. Adakah anda ingin pasang servis itu?</string>
|
||||||
|
<string name="fatal_error_msg">Aplikasi anda menemui ralat muat dan tidak boleh diteruskan.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-nb/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-nb/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Kan ikke finne tjenesten Ministro. Applikasjonen kan ikke starte.</string>
|
||||||
|
<string name="ministro_needed_msg">Denne applikasjonen krever tjenesten Ministro. Vil du installere denne?</string>
|
||||||
|
<string name="fatal_error_msg">Applikasjonen fikk en kritisk feil og kan ikke fortsette</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-nl/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-nl/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">De Ministro service is niet gevonden.\nDe applicatie kan niet starten.</string>
|
||||||
|
<string name="ministro_needed_msg">Deze applicatie maakt gebruik van de Ministro service. Wilt u deze installeren?</string>
|
||||||
|
<string name="fatal_error_msg">Er is een fatale fout in de applicatie opgetreden. De applicatie kan niet verder gaan.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-pl/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-pl/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Usługa Ministro nie została znaleziona.\nAplikacja nie może zostać uruchomiona.</string>
|
||||||
|
<string name="ministro_needed_msg">Aplikacja wymaga usługi Ministro. Czy chcesz ją zainstalować?</string>
|
||||||
|
<string name="fatal_error_msg">Wystąpił błąd krytyczny. Aplikacja zostanie zamknięta.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-pt-rBR/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-pt-rBR/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Não foi possível encontrar o serviço Ministro.\nA aplicação não pode iniciar.</string>
|
||||||
|
<string name="ministro_needed_msg">Essa aplicação requer o serviço Ministro. Gostaria de instalá-lo?</string>
|
||||||
|
<string name="fatal_error_msg">Sua aplicação encontrou um erro fatal e não pode continuar.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-ro/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-ro/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Serviciul Ministro nu poate fi găsit.\nAplicaţia nu poate porni.</string>
|
||||||
|
<string name="ministro_needed_msg">Această aplicaţie necesită serviciul Ministro.\nDoriţi să-l instalaţi?</string>
|
||||||
|
<string name="fatal_error_msg">Aplicaţia dumneavoastră a întâmpinat o eroare fatală şi nu poate continua.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-rs/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-rs/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Ministro servise nije pronađen. Aplikacija ne može biti pokrenuta.</string>
|
||||||
|
<string name="ministro_needed_msg">Ova aplikacija zahteva Ministro servis. Želite li da ga instalirate?</string>
|
||||||
|
<string name="fatal_error_msg">Vaša aplikacija je naišla na fatalnu grešku i ne može nastaviti sa radom.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-ru/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-ru/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">Сервис Ministro не найден.\nПриложение нельзя запустить.</string>
|
||||||
|
<string name="ministro_needed_msg">Этому приложению необходим сервис Ministro. Вы хотите его установить?</string>
|
||||||
|
<string name="fatal_error_msg">Ваше приложение столкнулось с фатальной ошибкой и не может более работать.</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-zh-rCN/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-zh-rCN/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">无法找到Ministro服务。\n应用程序无法启动。</string>
|
||||||
|
<string name="ministro_needed_msg">此应用程序需要Ministro服务。您想安装它吗?</string>
|
||||||
|
<string name="fatal_error_msg">您的应用程序遇到一个致命错误导致它无法继续。</string>
|
||||||
|
</resources>
|
6
qt/i2pd_qt/android/res/values-zh-rTW/strings.xml
Normal file
6
qt/i2pd_qt/android/res/values-zh-rTW/strings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<string name="ministro_not_found_msg">無法找到Ministro服務。\n應用程序無法啟動。</string>
|
||||||
|
<string name="ministro_needed_msg">此應用程序需要Ministro服務。您想安裝它嗎?</string>
|
||||||
|
<string name="fatal_error_msg">您的應用程序遇到一個致命錯誤導致它無法繼續。</string>
|
||||||
|
</resources>
|
25
qt/i2pd_qt/android/res/values/libs.xml
Normal file
25
qt/i2pd_qt/android/res/values/libs.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<array name="qt_sources">
|
||||||
|
<item>https://download.qt-project.org/ministro/android/qt5/qt-5.4</item>
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<!-- The following is handled automatically by the deployment tool. It should
|
||||||
|
not be edited manually. -->
|
||||||
|
|
||||||
|
<array name="bundled_libs">
|
||||||
|
<!-- %%INSERT_EXTRA_LIBS%% -->
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<array name="qt_libs">
|
||||||
|
<!-- %%INSERT_QT_LIBS%% -->
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<array name="bundled_in_lib">
|
||||||
|
<!-- %%INSERT_BUNDLED_IN_LIB%% -->
|
||||||
|
</array>
|
||||||
|
<array name="bundled_in_assets">
|
||||||
|
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
|
||||||
|
</array>
|
||||||
|
|
||||||
|
</resources>
|
10
qt/i2pd_qt/android/res/values/strings.xml
Normal file
10
qt/i2pd_qt/android/res/values/strings.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<resources>
|
||||||
|
<!-- %%INSERT_STRINGS -->
|
||||||
|
<string name="ministro_not_found_msg">Can\'t find Ministro service.\nThe application can\'t start.</string>
|
||||||
|
<string name="ministro_needed_msg">This application requires Ministro service. Would you like to install it?</string>
|
||||||
|
<string name="fatal_error_msg">Your application encountered a fatal error and cannot continue.</string>
|
||||||
|
<string name="local_service_started">i2pd started</string>
|
||||||
|
<string name="local_service_stopped">i2pd stopped</string>
|
||||||
|
<string name="local_service_label">i2pd</string>
|
||||||
|
</resources>
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2011-2013, BogDan Vatra <bogdan@kde.org>
|
||||||
|
Contact: http://www.qt.io/licensing/
|
||||||
|
|
||||||
|
Commercial License Usage
|
||||||
|
Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
accordance with the commercial license agreement provided with the
|
||||||
|
Software or, alternatively, in accordance with the terms contained in
|
||||||
|
a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
|
||||||
|
BSD License Usage
|
||||||
|
Alternatively, this file may be used under the BSD license as follows:
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.kde.necessitas.ministro;
|
||||||
|
|
||||||
|
import org.kde.necessitas.ministro.IMinistroCallback;
|
||||||
|
|
||||||
|
interface IMinistro
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Check/download required libs to run the application
|
||||||
|
*
|
||||||
|
* param callback - interface used by Minsitro service to notify the client when the loader is ready
|
||||||
|
* param parameters
|
||||||
|
* parameters fields:
|
||||||
|
* * Key Name Key type Explanations
|
||||||
|
* "sources" StringArray Sources list from where Ministro will download the libs. Make sure you are using ONLY secure locations.
|
||||||
|
* "repository" String Overwrites the default Ministro repository. Possible values: default, stable, testing and unstable
|
||||||
|
* "required.modules" StringArray Required modules by your application
|
||||||
|
* "application.title" String Application name, used to show more informations to user
|
||||||
|
* "qt.provider" String Qt libs provider, currently only "necessitas" is supported.
|
||||||
|
* "minimum.ministro.api" Integer Minimum Ministro API level, used to check if Ministro service compatible with your application. Current API Level is 3 !
|
||||||
|
* "minimum.qt.version" Integer Minimim Qt version (e.g. 0x040800, which means Qt 4.8.0, check http://qt-project.org/doc/qt-4.8/qtglobal.html#QT_VERSION)!
|
||||||
|
*/
|
||||||
|
void requestLoader(in IMinistroCallback callback, in Bundle parameters);
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2011-2013, BogDan Vatra <bogdan@kde.org>
|
||||||
|
Contact: http://www.qt.io/licensing/
|
||||||
|
|
||||||
|
Commercial License Usage
|
||||||
|
Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
accordance with the commercial license agreement provided with the
|
||||||
|
Software or, alternatively, in accordance with the terms contained in
|
||||||
|
a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
|
||||||
|
BSD License Usage
|
||||||
|
Alternatively, this file may be used under the BSD license as follows:
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.kde.necessitas.ministro;
|
||||||
|
|
||||||
|
oneway interface IMinistroCallback {
|
||||||
|
/**
|
||||||
|
* This method is called by the Ministro service back into the application which
|
||||||
|
* implements this interface.
|
||||||
|
*
|
||||||
|
* param in - loaderParams
|
||||||
|
* loaderParams fields:
|
||||||
|
* * Key Name Key type Explanations
|
||||||
|
* * "error.code" Integer See below
|
||||||
|
* * "error.message" String Missing if no error, otherwise will contain the error message translated into phone language where available.
|
||||||
|
* * "dex.path" String The list of jar/apk files containing classes and resources, needed to be passed to application DexClassLoader
|
||||||
|
* * "lib.path" String The list of directories containing native libraries; may be missing, needed to be passed to application DexClassLoader
|
||||||
|
* * "loader.class.name" String Loader class name.
|
||||||
|
*
|
||||||
|
* "error.code" field possible errors:
|
||||||
|
* - 0 no error.
|
||||||
|
* - 1 incompatible Ministro version. Ministro needs to be upgraded.
|
||||||
|
* - 2 not all modules could be satisfy.
|
||||||
|
* - 3 invalid parameters
|
||||||
|
* - 4 invalid qt version
|
||||||
|
* - 5 download canceled
|
||||||
|
*
|
||||||
|
* The parameter contains additional fields which are used by the loader to start your application, so it must be passed to the loader.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void loaderReady(in Bundle loaderParams);
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package org.purplei2p.i2pd;
|
||||||
|
|
||||||
|
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.IBinder;
|
||||||
|
|
||||||
|
public class I2PDMainActivity extends QtActivity
|
||||||
|
{
|
||||||
|
|
||||||
|
private static I2PDMainActivity instance;
|
||||||
|
|
||||||
|
public I2PDMainActivity() {}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.qtproject.qt5.android.bindings.QtActivity#onCreate(android.os.Bundle)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
I2PDMainActivity.setInstance(this);
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
//set the app be foreground (do not unload when RAM needed)
|
||||||
|
doBindService();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.qtproject.qt5.android.bindings.QtActivity#onDestroy()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
I2PDMainActivity.setInstance(null);
|
||||||
|
doUnbindService();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static I2PDMainActivity getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setInstance(I2PDMainActivity instance) {
|
||||||
|
I2PDMainActivity.instance = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// private LocalService mBoundService;
|
||||||
|
|
||||||
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
|
// This is called when the connection with the service has been
|
||||||
|
// established, giving us the service object we can use to
|
||||||
|
// interact with the service. Because we have bound to a explicit
|
||||||
|
// service that we know is running in our own process, we can
|
||||||
|
// cast its IBinder to a concrete class and directly access it.
|
||||||
|
// mBoundService = ((LocalService.LocalBinder)service).getService();
|
||||||
|
|
||||||
|
// Tell the user about this for our demo.
|
||||||
|
// Toast.makeText(Binding.this, R.string.local_service_connected,
|
||||||
|
// Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onServiceDisconnected(ComponentName className) {
|
||||||
|
// This is called when the connection with the service has been
|
||||||
|
// unexpectedly disconnected -- that is, its process crashed.
|
||||||
|
// Because it is running in our same process, we should never
|
||||||
|
// see this happen.
|
||||||
|
// mBoundService = null;
|
||||||
|
// Toast.makeText(Binding.this, R.string.local_service_disconnected,
|
||||||
|
// Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private boolean mIsBound;
|
||||||
|
|
||||||
|
private void doBindService() {
|
||||||
|
// Establish a connection with the service. We use an explicit
|
||||||
|
// class name because we want a specific service implementation that
|
||||||
|
// we know will be running in our own process (and thus won't be
|
||||||
|
// supporting component replacement by other applications).
|
||||||
|
bindService(new Intent(this,
|
||||||
|
LocalService.class), mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
mIsBound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void doUnbindService() {
|
||||||
|
if (mIsBound) {
|
||||||
|
// Detach our existing connection.
|
||||||
|
unbindService(mConnection);
|
||||||
|
mIsBound = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
92
qt/i2pd_qt/android/src/org/purplei2p/i2pd/LocalService.java
Normal file
92
qt/i2pd_qt/android/src/org/purplei2p/i2pd/LocalService.java
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package org.purplei2p.i2pd;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Binder;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class LocalService extends Service {
|
||||||
|
// private NotificationManager mNM;
|
||||||
|
|
||||||
|
// Unique Identification Number for the Notification.
|
||||||
|
// We use it on Notification start, and to cancel it.
|
||||||
|
private int NOTIFICATION = R.string.local_service_started;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for clients to access. Because we know this service always
|
||||||
|
* runs in the same process as its clients, we don't need to deal with
|
||||||
|
* IPC.
|
||||||
|
*/
|
||||||
|
public class LocalBinder extends Binder {
|
||||||
|
LocalService getService() {
|
||||||
|
return LocalService.this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
// mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
// Display a notification about us starting. We put an icon in the status bar.
|
||||||
|
showNotification();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
Log.i("LocalService", "Received start id " + startId + ": " + intent);
|
||||||
|
return START_NOT_STICKY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
// Cancel the persistent notification.
|
||||||
|
//mNM.cancel(NOTIFICATION);
|
||||||
|
stopForeground(true);
|
||||||
|
|
||||||
|
// Tell the user we stopped.
|
||||||
|
Toast.makeText(this, R.string.local_service_stopped, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return mBinder;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is the object that receives interactions from clients. See
|
||||||
|
// RemoteService for a more complete example.
|
||||||
|
private final IBinder mBinder = new LocalBinder();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a notification while this service is running.
|
||||||
|
*/
|
||||||
|
private void showNotification() {
|
||||||
|
// In this sample, we'll use the same text for the ticker and the expanded notification
|
||||||
|
CharSequence text = getText(R.string.local_service_started);
|
||||||
|
|
||||||
|
// The PendingIntent to launch our activity if the user selects this notification
|
||||||
|
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
|
||||||
|
new Intent(this, I2PDMainActivity.class), 0);
|
||||||
|
|
||||||
|
// Set the info for the views that show in the notification panel.
|
||||||
|
Notification notification = new NotificationCompat.Builder(this)
|
||||||
|
.setSmallIcon(R.drawable.itoopie_notification_icon) // the status icon
|
||||||
|
.setTicker(text) // the status text
|
||||||
|
.setWhen(System.currentTimeMillis()) // the time stamp
|
||||||
|
.setContentTitle(getText(R.string.local_service_label)) // the label of the entry
|
||||||
|
.setContentText(text) // the contents of the entry
|
||||||
|
.setContentIntent(contentIntent) // The intent to send when the entry is clicked
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Send the notification.
|
||||||
|
//mNM.notify(NOTIFICATION, notification);
|
||||||
|
startForeground(NOTIFICATION, notification);
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2012-2013, BogDan Vatra <bogdan@kde.org>
|
||||||
|
Contact: http://www.qt.io/licensing/
|
||||||
|
|
||||||
|
Commercial License Usage
|
||||||
|
Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
accordance with the commercial license agreement provided with the
|
||||||
|
Software or, alternatively, in accordance with the terms contained in
|
||||||
|
a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
|
||||||
|
BSD License Usage
|
||||||
|
Alternatively, this file may be used under the BSD license as follows:
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.qtproject.qt5.android.bindings;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
public class QtApplication extends Application
|
||||||
|
{
|
||||||
|
public final static String QtTAG = "Qt";
|
||||||
|
public static Object m_delegateObject = null;
|
||||||
|
public static HashMap<String, ArrayList<Method>> m_delegateMethods= new HashMap<String, ArrayList<Method>>();
|
||||||
|
public static Method dispatchKeyEvent = null;
|
||||||
|
public static Method dispatchPopulateAccessibilityEvent = null;
|
||||||
|
public static Method dispatchTouchEvent = null;
|
||||||
|
public static Method dispatchTrackballEvent = null;
|
||||||
|
public static Method onKeyDown = null;
|
||||||
|
public static Method onKeyMultiple = null;
|
||||||
|
public static Method onKeyUp = null;
|
||||||
|
public static Method onTouchEvent = null;
|
||||||
|
public static Method onTrackballEvent = null;
|
||||||
|
public static Method onActivityResult = null;
|
||||||
|
public static Method onCreate = null;
|
||||||
|
public static Method onKeyLongPress = null;
|
||||||
|
public static Method dispatchKeyShortcutEvent = null;
|
||||||
|
public static Method onKeyShortcut = null;
|
||||||
|
public static Method dispatchGenericMotionEvent = null;
|
||||||
|
public static Method onGenericMotionEvent = null;
|
||||||
|
|
||||||
|
public static void setQtActivityDelegate(Object listener)
|
||||||
|
{
|
||||||
|
QtApplication.m_delegateObject = listener;
|
||||||
|
|
||||||
|
ArrayList<Method> delegateMethods = new ArrayList<Method>();
|
||||||
|
for (Method m : listener.getClass().getMethods()) {
|
||||||
|
if (m.getDeclaringClass().getName().startsWith("org.qtproject.qt5.android"))
|
||||||
|
delegateMethods.add(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<Field> applicationFields = new ArrayList<Field>();
|
||||||
|
for (Field f : QtApplication.class.getFields()) {
|
||||||
|
if (f.getDeclaringClass().getName().equals(QtApplication.class.getName()))
|
||||||
|
applicationFields.add(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Method delegateMethod : delegateMethods) {
|
||||||
|
try {
|
||||||
|
QtActivity.class.getDeclaredMethod(delegateMethod.getName(), delegateMethod.getParameterTypes());
|
||||||
|
if (QtApplication.m_delegateMethods.containsKey(delegateMethod.getName())) {
|
||||||
|
QtApplication.m_delegateMethods.get(delegateMethod.getName()).add(delegateMethod);
|
||||||
|
} else {
|
||||||
|
ArrayList<Method> delegateSet = new ArrayList<Method>();
|
||||||
|
delegateSet.add(delegateMethod);
|
||||||
|
QtApplication.m_delegateMethods.put(delegateMethod.getName(), delegateSet);
|
||||||
|
}
|
||||||
|
for (Field applicationField:applicationFields) {
|
||||||
|
if (applicationField.getName().equals(delegateMethod.getName())) {
|
||||||
|
try {
|
||||||
|
applicationField.set(null, delegateMethod);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTerminate() {
|
||||||
|
if (m_delegateObject != null && m_delegateMethods.containsKey("onTerminate"))
|
||||||
|
invokeDelegateMethod(m_delegateMethods.get("onTerminate").get(0));
|
||||||
|
super.onTerminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class InvokeResult
|
||||||
|
{
|
||||||
|
public boolean invoked = false;
|
||||||
|
public Object methodReturns = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int stackDeep=-1;
|
||||||
|
public static InvokeResult invokeDelegate(Object... args)
|
||||||
|
{
|
||||||
|
InvokeResult result = new InvokeResult();
|
||||||
|
if (m_delegateObject == null)
|
||||||
|
return result;
|
||||||
|
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
||||||
|
if (-1 == stackDeep) {
|
||||||
|
String activityClassName = QtActivity.class.getCanonicalName();
|
||||||
|
for (int it=0;it<elements.length;it++)
|
||||||
|
if (elements[it].getClassName().equals(activityClassName)) {
|
||||||
|
stackDeep = it;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final String methodName=elements[stackDeep].getMethodName();
|
||||||
|
if (-1 == stackDeep || !m_delegateMethods.containsKey(methodName))
|
||||||
|
return result;
|
||||||
|
|
||||||
|
for (Method m : m_delegateMethods.get(methodName)) {
|
||||||
|
if (m.getParameterTypes().length == args.length) {
|
||||||
|
result.methodReturns = invokeDelegateMethod(m, args);
|
||||||
|
result.invoked = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object invokeDelegateMethod(Method m, Object... args)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return m.invoke(m_delegateObject, args);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -13,13 +13,18 @@ TEMPLATE = app
|
|||||||
QMAKE_CXXFLAGS *= -std=c++11
|
QMAKE_CXXFLAGS *= -std=c++11
|
||||||
|
|
||||||
# git clone https://github.com/PurpleI2P/Boost-for-Android-Prebuilt.git
|
# git clone https://github.com/PurpleI2P/Boost-for-Android-Prebuilt.git
|
||||||
# git clone https://github.com/PurpleI2P/OpenSSL-for-Android-Prebuilt
|
# git clone https://github.com/PurpleI2P/OpenSSL-for-Android-Prebuilt.git
|
||||||
# git clone https://github.com/PurpleI2P/android-ifaddrs.git
|
# git clone https://github.com/PurpleI2P/android-ifaddrs.git
|
||||||
# change to your own
|
# change to your own
|
||||||
BOOST_PATH = /mnt/media/android/Boost-for-Android-Prebuilt
|
BOOST_PATH = /mnt/media/android/Boost-for-Android-Prebuilt
|
||||||
OPENSSL_PATH = /mnt/media/android/OpenSSL-for-Android-Prebuilt
|
OPENSSL_PATH = /mnt/media/android/OpenSSL-for-Android-Prebuilt
|
||||||
IFADDRS_PATH = /mnt/media/android/android-ifaddrs
|
IFADDRS_PATH = /mnt/media/android/android-ifaddrs
|
||||||
|
|
||||||
|
# Steps in Android SDK manager:
|
||||||
|
# 1) Check Extras/Google Support Library https://developer.android.com/topic/libraries/support-library/setup.html
|
||||||
|
# 2) Check API 11
|
||||||
|
# Finally, click Install.
|
||||||
|
|
||||||
SOURCES += DaemonQT.cpp\
|
SOURCES += DaemonQT.cpp\
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
../../HTTPServer.cpp ../../I2PControl.cpp ../../UPnP.cpp ../../Daemon.cpp ../../Config.cpp \
|
../../HTTPServer.cpp ../../I2PControl.cpp ../../UPnP.cpp ../../Daemon.cpp ../../Config.cpp \
|
||||||
|
Loading…
Reference in New Issue
Block a user