v.0.4
This commit is contained in:
parent
aca94a5393
commit
63dfb9b197
70 changed files with 2829 additions and 1056 deletions
|
@ -2,10 +2,6 @@ package androidnative.friendiqa;
|
|||
|
||||
import androidnative.AndroidNativeActivity;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class FriendiqaActivity extends AndroidNativeActivity {
|
||||
public FriendiqaActivity() {
|
||||
super();
|
||||
|
@ -13,8 +9,4 @@ public class FriendiqaActivity extends AndroidNativeActivity {
|
|||
QT_ANDROID_THEMES = new String[] {""};
|
||||
QT_ANDROID_DEFAULT_THEME = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
96
source-android/android/src/FriendiqaNotifierService.java
Normal file
96
source-android/android/src/FriendiqaNotifierService.java
Normal file
|
@ -0,0 +1,96 @@
|
|||
package androidnative.friendiqa;
|
||||
import androidnative.SystemDispatcher;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.util.Log;
|
||||
import android.os.Handler;
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
import android.content.Context;
|
||||
import java.util.Map;
|
||||
import org.qtproject.qt5.android.QtNative;
|
||||
|
||||
public class FriendiqaNotifierService {
|
||||
|
||||
static {
|
||||
|
||||
SystemDispatcher.addListener(new SystemDispatcher.Listener() {
|
||||
|
||||
NotificationManager m_notificationManager;
|
||||
Notification.Builder m_builder;
|
||||
|
||||
private void notificationManagerNotify(Map data) {
|
||||
|
||||
final Activity activity = QtNative.activity();
|
||||
final Map messageData = data;
|
||||
|
||||
Runnable runnable = new Runnable () {
|
||||
public void run() {
|
||||
try {
|
||||
String title = (String) messageData.get("title");
|
||||
|
||||
String message = (String) messageData.get("message");
|
||||
|
||||
if (m_notificationManager == null) {
|
||||
m_notificationManager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
m_builder = new Notification.Builder(activity);
|
||||
|
||||
// Small Icon is a must to make notification works.
|
||||
// And that is why you need to inherit QtActivity
|
||||
//m_builder.setSmallIcon(drawable.icon);
|
||||
}
|
||||
|
||||
m_builder.setContentTitle(title);
|
||||
m_builder.setContentText(message);
|
||||
m_notificationManager.notify(1, m_builder.build());
|
||||
|
||||
// Test function. Remove it later.
|
||||
SystemDispatcher.dispatch("Notifier.notifyFinished");
|
||||
} catch (Exception e) {
|
||||
Log.d("",e.getMessage());
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
}
|
||||
|
||||
private void hapticFeedbackPerform(Map data) {
|
||||
|
||||
final Activity activity = QtNative.activity();
|
||||
final Map messageData = data;
|
||||
Runnable runnable = new Runnable () {
|
||||
public void run() {
|
||||
int feedbackConstant = (Integer) messageData.get("feedbackConstant");
|
||||
int flags = (Integer) messageData.get("flags");
|
||||
|
||||
Log.d("",String.format("hapticFeedbackPerform(%d,%d)",feedbackConstant,flags));
|
||||
|
||||
View rootView = activity.getWindow().getDecorView().getRootView();
|
||||
rootView.performHapticFeedback(feedbackConstant, flags);
|
||||
|
||||
// Test function. Remove it later.
|
||||
SystemDispatcher.dispatch("hapticFeedbackPerformFinished");
|
||||
};
|
||||
};
|
||||
activity.runOnUiThread(runnable);
|
||||
}
|
||||
|
||||
public void onDispatched(String name , Map data) {
|
||||
|
||||
if (name.equals("Notifier.notify")) {
|
||||
notificationManagerNotify(data);
|
||||
return;
|
||||
} else if (name.equals("hapticFeedbackPerform")) {
|
||||
hapticFeedbackPerform(data);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
35
source-android/android/src/FriendiqaService.java
Normal file
35
source-android/android/src/FriendiqaService.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package androidnative.friendiqa;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.app.job.JobService;
|
||||
import android.app.job.JobParameters;
|
||||
import androidnative.AndroidNativeService;
|
||||
import org.qtproject.qt5.android.bindings.QtService;
|
||||
import org.qtproject.qt5.android.QtNative;
|
||||
//import androidnative.friendiqa.FriendiqaQtService;
|
||||
|
||||
public class FriendiqaService extends JobService{
|
||||
private static String TAG = "AndroidNative";
|
||||
//Log.e(TAG,"Service");
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onStartJob(JobParameters params) {
|
||||
//Log.d(TAG,"Friendiqa JobService");
|
||||
Context context = this.getApplicationContext();
|
||||
AndroidNativeService fs = new AndroidNativeService();
|
||||
fs.startQtService(context);
|
||||
jobFinished(params,false);
|
||||
//Intent serviceIntent = new Intent(this, AndroidNativeService.class);
|
||||
//startService(serviceIntent);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStopJob(JobParameters params) {
|
||||
// whether or not you would like JobScheduler to automatically retry your failed job.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
40
source-android/android/src/FriendiqaStopService.java
Normal file
40
source-android/android/src/FriendiqaStopService.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package androidnative.friendiqa;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.app.job.JobService;
|
||||
import android.app.job.JobParameters;
|
||||
import androidnative.AndroidNativeService;
|
||||
import org.qtproject.qt5.android.bindings.QtService;
|
||||
import org.qtproject.qt5.android.QtNative;
|
||||
//import androidnative.friendiqa.FriendiqaQtService;
|
||||
|
||||
public class FriendiqaStopService extends JobService{
|
||||
private static String TAG = "AndroidNative";
|
||||
//Log.e(TAG,"Service");
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onStartJob(JobParameters params) {
|
||||
//Log.d(TAG,"Friendiqa JobServiceStop");
|
||||
Context context = this.getApplicationContext();
|
||||
AndroidNativeService fs = new AndroidNativeService();
|
||||
fs.stopQtService(context);
|
||||
jobFinished(params,false);
|
||||
//Intent serviceIntent = new Intent(this, AndroidNativeService.class);
|
||||
//startService(serviceIntent);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStopJob(JobParameters params) {
|
||||
// whether or not you would like JobScheduler to automatically retry your failed job.
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onUnbind(Intent intent) {
|
||||
stopSelf();
|
||||
return super.onUnbind(intent);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue