Friendiqa v0.2.2
This commit is contained in:
parent
ca6ae19a88
commit
93f08e604f
22 changed files with 345 additions and 91 deletions
|
@ -21,14 +21,23 @@ public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.Qt
|
|||
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
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)) {
|
||||
|
||||
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) || (getIntent().getFlags() == (Intent.FLAG_ACTIVITY_NEW_TASK | 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);
|
||||
if ((data!=null) && (data.getType() != null) && !(data.getBooleanExtra("used",false))){
|
||||
String type = data.getType();
|
||||
String[] parts = type.split("/");
|
||||
String maintype= parts[0];
|
||||
if (maintype.equals("text")){
|
||||
SystemDispatcher.loadClass("androidnative.TextIntent");
|
||||
SystemDispatcher.onActivityResult(0x245285a4,Activity.RESULT_OK,data);
|
||||
|
||||
} else {
|
||||
SystemDispatcher.loadClass("androidnative.ImagePicker");
|
||||
SystemDispatcher.onActivityResult(0x245285a3,Activity.RESULT_OK,data);
|
||||
}
|
||||
getIntent().replaceExtras(new Bundle());
|
||||
getIntent().setAction("");
|
||||
getIntent().setData(null);
|
||||
|
@ -42,13 +51,25 @@ public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.Qt
|
|||
|
||||
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);
|
||||
if ((data!=null) && (data.getType() != null) && !(data.getBooleanExtra("used",false))){
|
||||
String type = data.getType();
|
||||
String[] parts = type.split("/");
|
||||
String maintype= parts[0];
|
||||
if (maintype.equals("text")){
|
||||
SystemDispatcher.loadClass("androidnative.TextIntent");
|
||||
SystemDispatcher.onActivityResult(0x245285a4,Activity.RESULT_OK,data);
|
||||
} else {
|
||||
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();
|
||||
}
|
||||
|
||||
} // onNewIntent
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ 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;
|
||||
|
@ -133,19 +131,21 @@ public class SystemDispatcher {
|
|||
*/
|
||||
public static void onActivityResult (int requestCode, int resultCode, Intent data) {
|
||||
Map message = new HashMap();
|
||||
|
||||
|
||||
message.put("requestCode",requestCode);
|
||||
message.put("resultCode",resultCode);
|
||||
message.put("data",data);
|
||||
|
||||
|
||||
if(isInitialized) {
|
||||
dispatch(ACTIVITY_RESULT_MESSAGE,message);
|
||||
waitingIntent=null;
|
||||
isIntentPending=false;
|
||||
} else { //onIntent start
|
||||
message.put("text",data.getStringExtra(Intent.EXTRA_TEXT));
|
||||
message.put("subject",data.getStringExtra(Intent.EXTRA_SUBJECT));
|
||||
waitingIntent = message;
|
||||
isIntentPending = true;
|
||||
|
||||
}
|
||||
//onIntent end
|
||||
|
||||
|
@ -216,7 +216,6 @@ public class SystemDispatcher {
|
|||
try {
|
||||
ClassLoader classLoader = SystemDispatcher.class.getClassLoader();
|
||||
Class aClass = Class.forName(className,true,classLoader);
|
||||
// Log.d(TAG,"Class Loaded: " + className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e(TAG,"Failed to load class: " + className);
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package androidnative;
|
||||
import org.qtproject.qt5.android.QtNative;
|
||||
import android.content.Intent;
|
||||
import android.app.Activity;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
public class TextIntent {
|
||||
|
||||
// Random
|
||||
public static final int TEXT_INTENT_ACTION = 0x245285a4;
|
||||
|
||||
public static final String CHOSEN_MESSAGE = "androidnative.TextIntent.chosen";
|
||||
|
||||
private static final String TAG = "androidnative.TextIntent";
|
||||
|
||||
private static Boolean broadcast = false;
|
||||
|
||||
static {
|
||||
SystemDispatcher.addListener(new SystemDispatcher.Listener() {
|
||||
public void onDispatched(String type , Map message) {
|
||||
if (type.equals(SystemDispatcher.ACTIVITY_RESULT_MESSAGE)) {
|
||||
onActivityResult(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static private void onActivityResult(Map message) {
|
||||
int resultCode = (Integer) message.get("resultCode");
|
||||
if (resultCode != Activity.RESULT_OK)
|
||||
return;
|
||||
int requestCode = (Integer) message.get("requestCode");
|
||||
Intent data = (Intent) message.get("data");
|
||||
|
||||
if (requestCode == TEXT_INTENT_ACTION) {
|
||||
String extrasubject = (String) message.get("subject");
|
||||
String extratext = (String) message.get("text");
|
||||
importText(data,extrasubject,extratext);
|
||||
}
|
||||
}
|
||||
|
||||
static private void importText(Intent data, String extrasubject, String extratext) {
|
||||
|
||||
String subject = data.getStringExtra(Intent.EXTRA_SUBJECT);
|
||||
String plaintext = data.getStringExtra(Intent.EXTRA_TEXT);
|
||||
String htmltext = data.getStringExtra(Intent.EXTRA_HTML_TEXT);
|
||||
if (subject==null){subject=extrasubject;};
|
||||
if (plaintext==null){plaintext=extratext;};
|
||||
Map reply = new HashMap();
|
||||
reply.put("subject",subject);
|
||||
reply.put("plaintext",plaintext);
|
||||
reply.put("htmltext",htmltext);
|
||||
SystemDispatcher.dispatch(CHOSEN_MESSAGE,reply);
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue