forked from lubuwest/Friendiqa
Friendiqa v0.2.1
This commit is contained in:
parent
c85f857afe
commit
ee50729e0d
45 changed files with 580 additions and 146 deletions
0
source-android/androidnative.pri/ci/qt-android
Executable file → Normal file
0
source-android/androidnative.pri/ci/qt-android
Executable file → Normal file
|
@ -23,3 +23,8 @@ void AndroidNative::SystemDispatcherProxy::loadClass(QString className)
|
|||
{
|
||||
SystemDispatcher::instance()->loadClass(className);
|
||||
}
|
||||
|
||||
void AndroidNative::SystemDispatcherProxy::setInitialized()
|
||||
{
|
||||
SystemDispatcher::instance()->setInitialized();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace AndroidNative {
|
|||
|
||||
Q_INVOKABLE void loadClass(QString className);
|
||||
|
||||
Q_INVOKABLE void setInitialized();
|
||||
|
||||
signals:
|
||||
void dispatched(QString type , QVariantMap message);
|
||||
|
||||
|
|
|
@ -332,6 +332,16 @@ void AndroidNative::SystemDispatcher::loadClass(QString javaClassName)
|
|||
dispatch("androidnative.SystemDispatcher.loadClass",message);
|
||||
}
|
||||
|
||||
|
||||
void AndroidNative::SystemDispatcher::setInitialized()
|
||||
{
|
||||
QVariantMap message;
|
||||
message["Initialized"] = true;
|
||||
|
||||
dispatch("androidnative.SystemDispatcher.setInitialized",message);
|
||||
}
|
||||
|
||||
|
||||
void AndroidNative::SystemDispatcher::registerNatives()
|
||||
{
|
||||
Q_UNUSED(registerNativesCalled);
|
||||
|
|
|
@ -29,6 +29,9 @@ namespace AndroidNative {
|
|||
*/
|
||||
Q_INVOKABLE void loadClass(QString javaClassName);
|
||||
|
||||
//inform Dispatcher about loaded Environment, Intents can be processed
|
||||
Q_INVOKABLE void setInitialized();
|
||||
|
||||
/// Register JNI native methods. This function must be called in JNI_OnLoad. Otherwise, the messenger will not be working
|
||||
static void registerNatives();
|
||||
|
||||
|
|
0
source-android/androidnative.pri/examples/androidnativeexample/android-sources/gradlew
vendored
Executable file → Normal file
0
source-android/androidnative.pri/examples/androidnativeexample/android-sources/gradlew
vendored
Executable file → Normal file
0
source-android/androidnative.pri/examples/androidnativeexample/res/drawable-xxhdpi/ic_menu.png
Executable file → Normal file
0
source-android/androidnative.pri/examples/androidnativeexample/res/drawable-xxhdpi/ic_menu.png
Executable file → Normal file
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 127 B |
|
@ -1,5 +1,9 @@
|
|||
package androidnative;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.app.Activity;
|
||||
import android.os.*;
|
||||
import java.util.Map;
|
||||
|
||||
/** An alternative Activity class for Qt applicaiton.
|
||||
|
||||
|
@ -14,10 +18,38 @@ public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.Qt
|
|||
SystemDispatcher.onActivityResult(requestCode,resultCode,data);
|
||||
}
|
||||
|
||||
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
SystemDispatcher.onActivityResume();
|
||||
|
||||
if((getIntent().getFlags() == (Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)) {
|
||||
SystemDispatcher.onActivityResume();
|
||||
} else {
|
||||
Intent data = getIntent();
|
||||
if ((data != null) && !(data.getBooleanExtra("used",false))){
|
||||
SystemDispatcher.loadClass("androidnative.ImagePicker");
|
||||
SystemDispatcher.onActivityResult(0x245285a3,Activity.RESULT_OK,data);
|
||||
getIntent().replaceExtras(new Bundle());
|
||||
getIntent().setAction("");
|
||||
getIntent().setData(null);
|
||||
getIntent().setFlags(0);
|
||||
getIntent().putExtra("used", true);
|
||||
|
||||
} else {
|
||||
SystemDispatcher.onActivityResume();
|
||||
}}
|
||||
}
|
||||
|
||||
protected void onNewIntent(Intent data) {
|
||||
super.onNewIntent(data);
|
||||
SystemDispatcher.loadClass("androidnative.ImagePicker");
|
||||
SystemDispatcher.onActivityResult(0x245285a3,Activity.RESULT_OK,data);
|
||||
getIntent().replaceExtras(new Bundle());
|
||||
getIntent().setAction("");
|
||||
getIntent().setData(null);
|
||||
getIntent().setFlags(0);
|
||||
getIntent().putExtra("used", true);
|
||||
|
||||
} // onNewIntent
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ import android.util.Log;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.content.Intent;
|
||||
//import android.content.*;
|
||||
//import android.app.*;
|
||||
import android.os.*;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.io.StringWriter;
|
||||
import java.io.PrintWriter;
|
||||
|
@ -110,6 +113,14 @@ public class SystemDispatcher {
|
|||
|
||||
public static String SYSTEM_DISPATCHER_LOAD_CLASS_MESSAGE = "androidnative.SystemDispatcher.loadClass";
|
||||
|
||||
public static String SYSTEM_DISPATCHER_SET_INITIALIZED_MESSAGE = "androidnative.SystemDispatcher.setInitialized";
|
||||
|
||||
public static boolean isIntentPending=false;
|
||||
|
||||
public static boolean isInitialized=false;
|
||||
|
||||
private static Map waitingIntent;
|
||||
|
||||
/** A helper function to dispatch a massage when onResume is invoked in the Activity class
|
||||
*/
|
||||
|
||||
|
@ -117,6 +128,7 @@ public class SystemDispatcher {
|
|||
dispatch(ACTIVITY_RESUME_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
/** A helper function to dispatch a message based on the input argument fron Activity.onActivityResult
|
||||
*/
|
||||
public static void onActivityResult (int requestCode, int resultCode, Intent data) {
|
||||
|
@ -126,7 +138,17 @@ public class SystemDispatcher {
|
|||
message.put("resultCode",resultCode);
|
||||
message.put("data",data);
|
||||
|
||||
|
||||
if(isInitialized) {
|
||||
dispatch(ACTIVITY_RESULT_MESSAGE,message);
|
||||
waitingIntent=null;
|
||||
isIntentPending=false;
|
||||
} else { //onIntent start
|
||||
waitingIntent = message;
|
||||
isIntentPending = true;
|
||||
}
|
||||
//onIntent end
|
||||
|
||||
}
|
||||
|
||||
private static class Payload {
|
||||
|
@ -201,6 +223,18 @@ public class SystemDispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void setInitialized() {
|
||||
isInitialized = true;
|
||||
if(isIntentPending) {
|
||||
isIntentPending = false;
|
||||
dispatch(ACTIVITY_RESULT_MESSAGE,waitingIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void init() {
|
||||
SystemDispatcher.addListener(new SystemDispatcher.Listener() {
|
||||
public void onDispatched(String type , Map message) {
|
||||
|
@ -210,6 +244,9 @@ public class SystemDispatcher {
|
|||
String className = (String) message.get("className");
|
||||
loadClass(className);
|
||||
}
|
||||
if (type.equals(SYSTEM_DISPATCHER_SET_INITIALIZED_MESSAGE)) {
|
||||
setInitialized();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
0
source-android/androidnative.pri/tests/instrument/activity/android-sources/gradlew
vendored
Executable file → Normal file
0
source-android/androidnative.pri/tests/instrument/activity/android-sources/gradlew
vendored
Executable file → Normal file
0
source-android/androidnative.pri/tests/instrument/runner/gradlew
vendored
Executable file → Normal file
0
source-android/androidnative.pri/tests/instrument/runner/gradlew
vendored
Executable file → Normal file
Loading…
Add table
Add a link
Reference in a new issue