Friendiqa v0.2.1

This commit is contained in:
LubuWest 2018-04-11 21:50:43 +02:00
commit ee50729e0d
45 changed files with 580 additions and 146 deletions

View file

@ -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
}

View file

@ -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();
}
}
});