This commit is contained in:
LubuWest 2020-01-27 21:53:51 +01:00
commit c1bdcbf963
48 changed files with 1333 additions and 1229 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.5.1" android:versionCode="14" android:installLocation="auto">
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.5.2" android:versionCode="17" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:vmSafeMode="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Friendiqa" android:icon="@drawable/friendiqa" android:logo="@drawable/friendiqa" android:theme="@android:style/Theme.Holo.Light">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="androidnative.friendiqa.FriendiqaActivity" android:label="Friendiqa" android:screenOrientation="unspecified" android:launchMode="singleTask" android:taskAffinity="">
<intent-filter>
@ -88,7 +88,8 @@
</application>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- 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. -->
<!-- %%INSERT_PERMISSIONS -->

View file

@ -1,15 +1,17 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
@ -25,12 +27,16 @@ dependencies {
//apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:25.4.0'
}
//dependencies {
// compile 'com.android.support:support-v4:25.4.0'
//}
//dependencies {
// compile 'com.android.support:support-compat:25.4.0'
//}
dependencies {
compile 'com.android.support:support-compat:25.4.0'
compile 'androidx.appcompat:appcompat:1.1.0'
}
android {

View file

@ -1,4 +1,4 @@
androidBuildToolsVersion=25.0.3
androidCompileSdkVersion=27
buildDir=.build
qt5AndroidDir=/home/pankraz/Qt/5.11.1/android_armv7/src/android/java
android.useAndroidX=true
android.enableJetifier=true
android.enforceUniquePackageName=false

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip

0
source-android/android/gradlew vendored Normal file → Executable file
View file

View file

@ -7,8 +7,10 @@ import java.util.Map;
import android.content.pm.PackageManager;
import android.content.Context;
import android.Manifest.permission;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
//import android.support.v4.app.ActivityCompat;
//import android.support.v4.content.ContextCompat;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
/** An alternative Activity class for Qt applicaiton.

View file

@ -1,23 +1,69 @@
package androidnative;
import android.os.Build;
import android.content.Context;
import android.content.Intent;
import android.app.PendingIntent;
import android.content.Context;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.util.Log;
import android.app.Notification.Builder;
import android.app.Notification;
import android.app.job.JobScheduler;
import org.qtproject.qt5.android.bindings.QtService;
import org.qtproject.qt5.android.QtNative;
import org.qtproject.friendiqa.R;
import androidnative.friendiqa.FriendiqaActivity;
public class AndroidNativeService extends QtService
{
private static String TAG = "AndroidNative";
public void startQtService(Context ctx) {
Log.d(TAG,"Friendiqa QtService");
ctx.startService(new Intent(ctx, AndroidNativeService.class));
Log.d(TAG, "QtActivity active "+String.valueOf(QtNative.activity()!=null));
if (QtNative.activity()==null){
//Log.d(TAG,"Friendiqasync Stop existing QtService");
ctx.stopService(new Intent(ctx, AndroidNativeService.class));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//Log.d(TAG,"Friendiqasync startForegroundService");
ctx.startForegroundService(new Intent(ctx, AndroidNativeService.class));
} else {
ctx.startService(new Intent(ctx, AndroidNativeService.class));
}
}
public static void stopQtService(Context ctx) {
Log.d(TAG,"Friendiqa QtServiceStop");
//Log.d(TAG,"Friendiqasync QtServiceStop");
ctx.stopService(new Intent(ctx, AndroidNativeService.class));
}
@Override
public void onCreate()
{
Context context;
context = this.getApplicationContext();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent intent = new Intent(context,FriendiqaActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
String CHANNEL_ID = "channel_02";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
"Sync Channel",
NotificationManager.IMPORTANCE_DEFAULT);
channel.setSound(null,null);
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
//Log.d(TAG,"Friendiqa onCreate Notification");
Notification notification = new Notification.Builder(context,CHANNEL_ID)
.setSmallIcon(R.drawable.friendiqanotification)
.setContentTitle("Friendiqa")
.setContentText("Background Sync")
.setContentIntent(pendingIntent).build();
startForeground(1, notification);}
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.cancel(1);
super.onCreate();
}
}

View file

@ -11,8 +11,10 @@ import android.content.ComponentName;
import android.app.job.JobScheduler;
import android.app.job.JobInfo;
import android.app.PendingIntent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import org.qtproject.qt5.android.QtNative;
import androidnative.friendiqa.FriendiqaService;
import androidnative.friendiqa.FriendiqaStopService;
@ -120,32 +122,46 @@ public class Util {
final String textTitle = (String) message.get("title");
final String textContent = (String) message.get("message");
final int notificationId = (int) message.get("id");
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.friendiqanotification)
.setContentIntent(pendingIntent)
.setContentTitle(textTitle)
.setContentText(textContent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(textContent))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(notificationId, builder.build());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
final String CHANNEL_ID = "channel_01";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
"Channel for Friendiqa News",
NotificationManagerCompat.IMPORTANCE_LOW);
notificationManager.createNotificationChannel(channel);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context,CHANNEL_ID)
.setSmallIcon(R.drawable.friendiqanotification)
.setContentIntent(pendingIntent)
.setContentTitle(textTitle)
.setContentText(textContent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(textContent))
.setAutoCancel(true);
notificationManager.notify(notificationId, builder.build());
} else {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.friendiqanotification)
.setContentIntent(pendingIntent)
.setContentTitle(textTitle)
.setContentText(textContent)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(textContent))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true);
notificationManager.notify(notificationId, builder.build());
}
}
static void setSchedule(Map message) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return;
}
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
return;
}
//Log.d(TAG,"Friendiqa schedule Androidnative service");
final Integer value = (Integer) message.get("value");
//final Activity activity = QtNative.activity();
//final Service service = QtNative.service();
//final int JOB_ID = 1;
final int ONE_MIN = 60 * 1000;
Context context;
@ -155,34 +171,49 @@ public class Util {
} else {
context = QtNative.activity().getApplicationContext();
}
ComponentName component = new ComponentName(context, FriendiqaService.class);
JobInfo.Builder builder = new JobInfo.Builder(2, component)
// schedule it to run any time between 1 - 5 minutes
.setMinimumLatency(value * ONE_MIN)
.setOverrideDeadline((value + 5)*ONE_MIN)
//.setPeriodic(value * ONE_MIN)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(builder.build());
if (QtNative.service() != null){
//Log.d(TAG,"Schedule Stopping Friendiqa Androidnative service");
ComponentName componentStopper = new ComponentName(context, FriendiqaStopService.class);
JobInfo.Builder stopbuilder = new JobInfo.Builder(1, componentStopper)
.setMinimumLatency(50)
.setOverrideDeadline(100);
if (value==0){
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.cancelAll();
//Log.d(TAG,"Friendiqasync deleting Androidnative jobscheduler");
} else {
//Log.d(TAG,"Friendiqasync schedule Androidnative jobscheduler");
ComponentName component = new ComponentName(context, FriendiqaService.class);
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
//Log.d(TAG,"Jobinfolist size " + String.valueOf(jobScheduler.getAllPendingJobs().size()));
if (jobScheduler.getAllPendingJobs().size()==0){
JobInfo.Builder builder = new JobInfo.Builder(2, component)
.setPeriodic(value * ONE_MIN)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPersisted(true)
.setPrefetch(true);
//Log.d(TAG,"Friendiqa schedule Androidnative sync schedule"+ (value * ONE_MIN));
jobScheduler.schedule(builder.build());
} else {
for ( JobInfo jobInfo : jobScheduler.getAllPendingJobs() ) {
//Log.d(TAG,"Jobinfo current interval " + String.valueOf(jobInfo.getIntervalMillis ()));
if (jobInfo.getIntervalMillis ()!=(value * ONE_MIN)){
JobInfo.Builder builder = new JobInfo.Builder(2, component)
.setPeriodic(value * ONE_MIN)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPersisted(true)
.setPrefetch(true);
//Log.d(TAG,"Friendiqa schedule Androidnative sync schedule"+ (value * ONE_MIN));
jobScheduler.schedule(builder.build());
}
}
}
//Log.d(TAG,"Active service " + String.valueOf(QtNative.service()!=null));
if (QtNative.service() != null){
//Log.d(TAG,"Schedule Stopping Friendiqa Androidnative service");
ComponentName componentStopper = new ComponentName(context, FriendiqaStopService.class);
JobInfo.Builder stopbuilder = new JobInfo.Builder(1, componentStopper)
.setMinimumLatency(50)
.setOverrideDeadline(100);
JobScheduler jobStopScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobStopScheduler.schedule(stopbuilder.build());
//AndroidNativeService.stopQtService(context);
JobScheduler jobStopScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobStopScheduler.schedule(stopbuilder.build());
}
}
//context.stopService(new Intent(context, AndroidNativeService.class));
}
/**static void stopService(Map message){
this.stopService(new Intent(this, AndroidNativeService.class));
}
**/
}

View file

@ -77,3 +77,9 @@ contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
$$PWD/android/libcrypto_1_1.so \
$$PWD/android/libssl_1_1.so
}
contains(ANDROID_TARGET_ARCH,arm64-v8a) {
ANDROID_EXTRA_LIBS = \
/home/pankraz/ownCloud/clientsync/Friendiqa/v0.5.2/source-android/../../../../../git/android_openssl/arm64/libcrypto_1_1.so \
$$PWD/../../../../../git/android_openssl/arm64/libssl_1_1.so
}

View file

@ -1 +1 @@
./../source-linux/images/
../source-linux/images

View file

@ -1 +1 @@
./../source-linux/js/
../source-linux/js

View file

@ -1 +1 @@
./../../source-linux/qml/calendarqml/
../../source-linux/qml/calendarqml

View file

@ -1 +1 @@
./../../source-linux/qml/configqml/
../../source-linux/qml/configqml

View file

@ -1 +1 @@
./../../source-linux/qml/contactqml/
../../source-linux/qml/contactqml

View file

@ -31,14 +31,14 @@
import QtQuick 2.5
import QtQuick.LocalStorage 2.0
import QtQuick.Window 2.13
import QtQuick.Window 2.0
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
import "qrc:/js/news.js" as Newsjs
import "qrc:/js/service.js" as Service
StackView{
StackView{
id:root
property QtObject osSettings: {var tmp=Qt.createComponent("qrc:/qml/configqml/OSSettingsAndroid.qml");return tmp.createObject(root)}
width: osSettings.appWidth
@ -107,7 +107,6 @@ StackView{
Keys.onReleased: {
if (event.key === osSettings.backKey) {
if (rootstack.currentIndex==0){
newstab.active=true;
if (newstab.newstabstatus!=login.newsViewType){
@ -120,6 +119,7 @@ StackView{
newsSignal(dbnews)
})}
}
else if (newstab.conversation.length>0){newstab.conversation=[]}
else if (root.depth>1){root.pop()}
else{Service.cleanNews(root.db,function(){
@ -161,10 +161,10 @@ StackView{
anchors.fill: parent
onClicked:{
leftDrawer.close();
newstypeSignal("refresh")
// updatenews.setDatabase();
// updatenews.login();
// updatenews.startsync();
// newstypeSignal("refresh")
updatenews.setDatabase();
updatenews.login();
updatenews.startsync();
}
}
}
@ -308,6 +308,8 @@ StackView{
Item{
id:rootStackItem
width:parent.width
height: parent.height
//anchors.fill:parent
states: State {
name: "fullscreen";
@ -389,10 +391,10 @@ StackView{
}
}
Component.onCompleted: {
forceActiveFocus();
Component.onCompleted: {
forceActiveFocus();
Service.readGlobaloptions(db,function(go){globaloptions=go})
//print(xhr.networktype());
if(osSettings.osType=="Android"){
var component = Qt.createComponent("qrc:/qml/genericqml/IntentReceiver.qml");
var IntentReceiverQml = component.createObject(root);

View file

@ -1 +1 @@
./../../source-linux/qml/genericqml/
../../source-linux/qml/genericqml

View file

@ -1 +1 @@
./../../source-linux/qml/newsqml/
../../source-linux/qml/newsqml

View file

@ -1 +1 @@
./../../source-linux/qml/photoqml/
../../source-linux/qml/photoqml

1
source-android/translations Symbolic link
View file

@ -0,0 +1 @@
../source-linux/translations