diff --git a/app/build.gradle b/app/build.gradle index 645bcfdbd..674ee827c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,16 +57,16 @@ android { sourceSets { playstore { - manifest.srcFile "src/main/AndroidManifest.xml" + manifest.srcFile "src/common/AndroidManifest.xml" java.srcDirs = ['src/main/java', 'src/playstore/java','src/common/java'] } fdroid { - manifest.srcFile "src/main/AndroidManifest.xml" + manifest.srcFile "src/common/AndroidManifest.xml" java.srcDirs = ['src/main/java', 'src/fdroid/java','src/common/java'] } lite { - manifest.srcFile "src/lite/AndroidManifest.xml" + manifest.srcFile "src/main/AndroidManifest.xml" java.srcDirs = ['src/main/java', 'src/lite/java'] } } @@ -134,7 +134,7 @@ dependencies { implementation "com.tonyodev.fetch2:fetch2:2.3.6" implementation 'jp.wasabeef:glide-transformations:4.0.0' - api 'com.theartofdev.edmodo:android-image-cropper:2.8.+' + implementation 'com.jaredrummler:cyanea:1.0.2' implementation "net.gotev:uploadservice:3.5.2" @@ -159,6 +159,7 @@ dependencies { //Flavors //Playstore + playstoreApi 'com.theartofdev.edmodo:android-image-cropper:2.8.+' playstoreImplementation "io.github.kobakei:ratethisapp:1.2.0" playstoreImplementation "org.conscrypt:conscrypt-android:2.4.0" playstoreImplementation 'com.github.stom79:country-picker-android:1.2.0' @@ -167,6 +168,7 @@ dependencies { //Fdroid + fdroidApi 'com.theartofdev.edmodo:android-image-cropper:2.8.+' fdroidImplementation "org.conscrypt:conscrypt-android:2.4.0" fdroidImplementation 'com.github.stom79:country-picker-android:1.2.0' fdroidImplementation 'com.vanniktech:emoji-one:0.6.0' diff --git a/app/src/common/AndroidManifest.xml b/app/src/common/AndroidManifest.xml index c3f41fc6d..bf557cc46 100644 --- a/app/src/common/AndroidManifest.xml +++ b/app/src/common/AndroidManifest.xml @@ -20,25 +20,6 @@ android:installLocation="auto"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/common/java/app/fedilab/android/activities/BaseActivity.java b/app/src/common/java/app/fedilab/android/activities/BaseActivity.java index f73443a17..fb356b3e3 100644 --- a/app/src/common/java/app/fedilab/android/activities/BaseActivity.java +++ b/app/src/common/java/app/fedilab/android/activities/BaseActivity.java @@ -21,4 +21,13 @@ public class BaseActivity extends AllBaseActivity { EmojiManager.install(new EmojiOneProvider()); } + protected void launchOwnerStatusesActivity(){ + Intent myIntent = new Intent(BaseMainActivity.this, OwnerStatusActivity.class); + startActivity(myIntent); + } + + protected void launchOwnerNotificationsActivity(){ + Intent myIntent = new Intent(BaseMainActivity.this, OwnerNotificationActivity.class); + startActivity(myIntent); + } } diff --git a/app/src/common/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java index 068ffc25d..bce76ece9 100644 --- a/app/src/common/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java +++ b/app/src/common/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java @@ -13,4 +13,8 @@ package app.fedilab.android.jobs; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class BackupNotificationsSyncJob extends BaseBackupNotificationsSyncJob {} +public class BackupNotificationsSyncJob extends BaseBackupNotificationsSyncJob { + static { + Helper.installProvider(); + } +} diff --git a/app/src/common/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java index ff2401b56..558de9423 100644 --- a/app/src/common/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java +++ b/app/src/common/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java @@ -13,4 +13,8 @@ package app.fedilab.android.jobs; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class BackupStatusesSyncJob extends BaseBackupStatusesSyncJob {} +public class BackupStatusesSyncJob extends BaseBackupStatusesSyncJob { + static { + Helper.installProvider(); + } +} diff --git a/app/src/common/java/app/fedilab/android/jobs/NotificationsSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/NotificationsSyncJob.java index 718e50c09..c45f21795 100644 --- a/app/src/common/java/app/fedilab/android/jobs/NotificationsSyncJob.java +++ b/app/src/common/java/app/fedilab/android/jobs/NotificationsSyncJob.java @@ -13,4 +13,8 @@ package app.fedilab.android.jobs; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class NotificationsSyncJob extends BaseNotificationsSyncJob {} +public class NotificationsSyncJob extends BaseNotificationsSyncJob { + static { + Helper.installProvider(); + } +} diff --git a/app/src/common/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java index 849e63154..d4b9cf058 100644 --- a/app/src/common/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java +++ b/app/src/common/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java @@ -13,4 +13,8 @@ package app.fedilab.android.jobs; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class ScheduledBoostsSyncJob extends BaseScheduledBoostsSyncJob {} +public class ScheduledBoostsSyncJob extends BaseScheduledBoostsSyncJob { + static { + Helper.installProvider(); + } +} diff --git a/app/src/common/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java index 45b7e8e0a..c54919396 100644 --- a/app/src/common/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java +++ b/app/src/common/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java @@ -13,4 +13,8 @@ package app.fedilab.android.jobs; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class ScheduledTootsSyncJob extends BaseScheduledTootsSyncJob {} +public class ScheduledTootsSyncJob extends BaseScheduledTootsSyncJob { + static { + Helper.installProvider(); + } +} diff --git a/app/src/common/java/app/fedilab/android/services/LiveNotificationService.java b/app/src/common/java/app/fedilab/android/services/LiveNotificationService.java index 4fc524195..1bd68ebd6 100644 --- a/app/src/common/java/app/fedilab/android/services/LiveNotificationService.java +++ b/app/src/common/java/app/fedilab/android/services/LiveNotificationService.java @@ -15,4 +15,7 @@ package app.fedilab.android.services; * see . */ public class LiveNotificationService extends BaseLiveNotificationService { + static { + Helper.installProvider(); + } } diff --git a/app/src/common/java/app/fedilab/android/services/StreamingHomeTimelineService.java b/app/src/common/java/app/fedilab/android/services/StreamingHomeTimelineService.java index 66b415edd..6246bc6f5 100644 --- a/app/src/common/java/app/fedilab/android/services/StreamingHomeTimelineService.java +++ b/app/src/common/java/app/fedilab/android/services/StreamingHomeTimelineService.java @@ -15,4 +15,7 @@ package app.fedilab.android.services; * see . */ public class StreamingHomeTimelineService extends BaseStreamingHomeTimelineService { + static { + Helper.installProvider(); + } } diff --git a/app/src/common/java/app/fedilab/android/services/StreamingLocalTimelineService.java b/app/src/common/java/app/fedilab/android/services/StreamingLocalTimelineService.java index 52845b910..103fa8890 100644 --- a/app/src/common/java/app/fedilab/android/services/StreamingLocalTimelineService.java +++ b/app/src/common/java/app/fedilab/android/services/StreamingLocalTimelineService.java @@ -14,4 +14,8 @@ package app.fedilab.android.services; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class StreamingLocalTimelineService extends BaseStreamingLocalTimelineService {} +public class StreamingLocalTimelineService extends BaseStreamingLocalTimelineService { + static { + Helper.installProvider(); + } +} diff --git a/app/src/lite/AndroidManifest.xml b/app/src/lite/AndroidManifest.xml index 5f15ba0d3..a38e2bc25 100644 --- a/app/src/lite/AndroidManifest.xml +++ b/app/src/lite/AndroidManifest.xml @@ -19,28 +19,7 @@ package="app.fedilab.android" android:installLocation="auto"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/lite/java/app/fedilab/android/activities/BaseActivity.java b/app/src/lite/java/app/fedilab/android/activities/BaseActivity.java index a4e116b2b..09afd52e3 100644 --- a/app/src/lite/java/app/fedilab/android/activities/BaseActivity.java +++ b/app/src/lite/java/app/fedilab/android/activities/BaseActivity.java @@ -14,10 +14,12 @@ package app.fedilab.android.activities; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ import android.annotation.SuppressLint; - +import android.content.Intent; @SuppressLint("Registered") public class BaseActivity extends AllBaseActivity { + protected void launchOwnerStatusesActivity(){} + protected void launchOwnerNotificationsActivity(){} } diff --git a/app/src/lite/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java index 22d73f0b9..068ffc25d 100644 --- a/app/src/lite/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java +++ b/app/src/lite/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java @@ -1,4 +1,16 @@ package app.fedilab.android.jobs; - -public class BackupNotificationsSyncJob { -} +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ +public class BackupNotificationsSyncJob extends BaseBackupNotificationsSyncJob {} diff --git a/app/src/lite/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java index 298f4f385..ff2401b56 100644 --- a/app/src/lite/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java +++ b/app/src/lite/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java @@ -1,4 +1,16 @@ package app.fedilab.android.jobs; - -public class BackupStatusesSyncJob { -} +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ +public class BackupStatusesSyncJob extends BaseBackupStatusesSyncJob {} diff --git a/app/src/lite/java/app/fedilab/android/jobs/NotificationsSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/NotificationsSyncJob.java index 11be25a83..718e50c09 100644 --- a/app/src/lite/java/app/fedilab/android/jobs/NotificationsSyncJob.java +++ b/app/src/lite/java/app/fedilab/android/jobs/NotificationsSyncJob.java @@ -1,4 +1,16 @@ package app.fedilab.android.jobs; - -public class NotificationsSyncJob { -} +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ +public class NotificationsSyncJob extends BaseNotificationsSyncJob {} diff --git a/app/src/lite/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java index f613daf26..849e63154 100644 --- a/app/src/lite/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java +++ b/app/src/lite/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java @@ -1,4 +1,16 @@ package app.fedilab.android.jobs; - -public class ScheduledBoostsSyncJob { -} +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ +public class ScheduledBoostsSyncJob extends BaseScheduledBoostsSyncJob {} diff --git a/app/src/lite/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java index 8984cb472..45b7e8e0a 100644 --- a/app/src/lite/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java +++ b/app/src/lite/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java @@ -1,4 +1,16 @@ package app.fedilab.android.jobs; - -public class ScheduledTootsSyncJob { -} +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ +public class ScheduledTootsSyncJob extends BaseScheduledTootsSyncJob {} diff --git a/app/src/lite/java/app/fedilab/android/services/LiveNotificationService.java b/app/src/lite/java/app/fedilab/android/services/LiveNotificationService.java index 6d6ae557d..4fc524195 100644 --- a/app/src/lite/java/app/fedilab/android/services/LiveNotificationService.java +++ b/app/src/lite/java/app/fedilab/android/services/LiveNotificationService.java @@ -1,4 +1,18 @@ package app.fedilab.android.services; +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ -public class LiveNotificationService { +public class LiveNotificationService extends BaseLiveNotificationService { } diff --git a/app/src/lite/java/app/fedilab/android/services/StreamingFederatedTimelineService.java b/app/src/lite/java/app/fedilab/android/services/StreamingFederatedTimelineService.java index 1a28a6d36..be3d5fc82 100644 --- a/app/src/lite/java/app/fedilab/android/services/StreamingFederatedTimelineService.java +++ b/app/src/lite/java/app/fedilab/android/services/StreamingFederatedTimelineService.java @@ -1,4 +1,18 @@ package app.fedilab.android.services; +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ -public class StreamingFederatedTimelineService { +public class StreamingFederatedTimelineService extends BaseStreamingFederatedTimelineService { } diff --git a/app/src/lite/java/app/fedilab/android/services/StreamingHomeTimelineService.java b/app/src/lite/java/app/fedilab/android/services/StreamingHomeTimelineService.java index 5e2fde267..66b415edd 100644 --- a/app/src/lite/java/app/fedilab/android/services/StreamingHomeTimelineService.java +++ b/app/src/lite/java/app/fedilab/android/services/StreamingHomeTimelineService.java @@ -1,4 +1,18 @@ package app.fedilab.android.services; +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ -public class StreamingHomeTimelineService { +public class StreamingHomeTimelineService extends BaseStreamingHomeTimelineService { } diff --git a/app/src/lite/java/app/fedilab/android/services/StreamingLocalTimelineService.java b/app/src/lite/java/app/fedilab/android/services/StreamingLocalTimelineService.java index 0ae8b3d6f..52845b910 100644 --- a/app/src/lite/java/app/fedilab/android/services/StreamingLocalTimelineService.java +++ b/app/src/lite/java/app/fedilab/android/services/StreamingLocalTimelineService.java @@ -1,4 +1,17 @@ package app.fedilab.android.services; +/* Copyright 2020 Thomas Schneider + * + * This file is a part of Fedilab + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Fedilab; if not, + * see . */ -public class StreamingLocalTimelineService { -} +public class StreamingLocalTimelineService extends BaseStreamingLocalTimelineService {} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ffec0e8d9..e922358cf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -328,10 +328,6 @@ android:configChanges="keyboardHidden|orientation|screenSize" android:label="@string/app_name" android:theme="@style/AppThemeDark_NoActionBar" /> - @@ -375,32 +371,6 @@ android:label="@string/app_name" android:theme="@style/AppThemeDark_NoActionBar" android:windowSoftInputMode="stateAlwaysHidden" /> - - - - jobRequests = JobManager.instance().getAllJobRequestsForTag(BACKUP_NOTIFICATIONS_SYNC); @@ -58,7 +54,7 @@ public class BackupNotificationsSyncJob extends Job { int jobRequestschedule = -1; try { - jobRequestschedule = new JobRequest.Builder(BackupNotificationsSyncJob.BACKUP_NOTIFICATIONS_SYNC) + jobRequestschedule = new JobRequest.Builder(BaseBackupNotificationsSyncJob.BACKUP_NOTIFICATIONS_SYNC) .setPeriodic(TimeUnit.MINUTES.toMillis(Helper.MINUTES_BETWEEN_BACKUP), TimeUnit.MINUTES.toMillis(5)) .setUpdateCurrent(updateCurrent) .setRequiredNetworkType(JobRequest.NetworkType.METERED) diff --git a/app/src/main/java/app/fedilab/android/jobs/BaseBackupStatusesSyncJob.java b/app/src/main/java/app/fedilab/android/jobs/BaseBackupStatusesSyncJob.java index 806ee7cbc..a103aacb7 100644 --- a/app/src/main/java/app/fedilab/android/jobs/BaseBackupStatusesSyncJob.java +++ b/app/src/main/java/app/fedilab/android/jobs/BaseBackupStatusesSyncJob.java @@ -40,13 +40,10 @@ import app.fedilab.android.sqlite.Sqlite; * backup statuses */ -public class BackupStatusesSyncJob extends Job { +public class BaseBackupStatusesSyncJob extends Job { public static final String BACKUP_SYNC = "job_backup"; - static { - Helper.installProvider(); - } public static int schedule(boolean updateCurrent) { @@ -57,7 +54,7 @@ public class BackupStatusesSyncJob extends Job { int jobRequestschedule = -1; try { - jobRequestschedule = new JobRequest.Builder(BackupStatusesSyncJob.BACKUP_SYNC) + jobRequestschedule = new JobRequest.Builder(BaseBackupStatusesSyncJob.BACKUP_SYNC) .setPeriodic(TimeUnit.MINUTES.toMillis(Helper.MINUTES_BETWEEN_BACKUP), TimeUnit.MINUTES.toMillis(5)) .setUpdateCurrent(updateCurrent) .setRequiredNetworkType(JobRequest.NetworkType.METERED) diff --git a/app/src/main/java/app/fedilab/android/jobs/BaseNotificationsSyncJob.java b/app/src/main/java/app/fedilab/android/jobs/BaseNotificationsSyncJob.java index 94be63c68..3d1e7b86e 100644 --- a/app/src/main/java/app/fedilab/android/jobs/BaseNotificationsSyncJob.java +++ b/app/src/main/java/app/fedilab/android/jobs/BaseNotificationsSyncJob.java @@ -70,14 +70,10 @@ import static app.fedilab.android.helper.Helper.notify_user; * Notifications refresh job */ -public class NotificationsSyncJob extends Job { +public class BaseNotificationsSyncJob extends Job { public static final String NOTIFICATION_REFRESH = "job_notification"; - static { - Helper.installProvider(); - } - public static int schedule(boolean updateCurrent) { Set jobRequests = JobManager.instance().getAllJobRequestsForTag(NOTIFICATION_REFRESH); @@ -87,7 +83,7 @@ public class NotificationsSyncJob extends Job { int jobRequestschedule = -1; try { - jobRequestschedule = new JobRequest.Builder(NotificationsSyncJob.NOTIFICATION_REFRESH) + jobRequestschedule = new JobRequest.Builder(BaseNotificationsSyncJob.NOTIFICATION_REFRESH) .setPeriodic(TimeUnit.MINUTES.toMillis(Helper.MINUTES_BETWEEN_NOTIFICATIONS_REFRESH), TimeUnit.MINUTES.toMillis(5)) .setUpdateCurrent(updateCurrent) .setRequiredNetworkType(JobRequest.NetworkType.METERED) diff --git a/app/src/main/java/app/fedilab/android/jobs/BaseScheduledBoostsSyncJob.java b/app/src/main/java/app/fedilab/android/jobs/BaseScheduledBoostsSyncJob.java index 0fd215127..0942d4c7b 100644 --- a/app/src/main/java/app/fedilab/android/jobs/BaseScheduledBoostsSyncJob.java +++ b/app/src/main/java/app/fedilab/android/jobs/BaseScheduledBoostsSyncJob.java @@ -40,13 +40,10 @@ import app.fedilab.android.sqlite.Sqlite; * Scheduled a boost a datetime */ -public class ScheduledBoostsSyncJob extends Job { +public class BaseScheduledBoostsSyncJob extends Job { public static final String SCHEDULED_BOOST = "job_scheduled_boost"; - static { - Helper.installProvider(); - } public static int schedule(Context context, Status status, long timestampScheduling) { @@ -54,7 +51,7 @@ public class ScheduledBoostsSyncJob extends Job { long endMs = startMs + TimeUnit.MINUTES.toMillis(5); SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - int jobId = new JobRequest.Builder(ScheduledBoostsSyncJob.SCHEDULED_BOOST) + int jobId = new JobRequest.Builder(BaseScheduledBoostsSyncJob.SCHEDULED_BOOST) .setExecutionWindow(startMs, endMs) .setUpdateCurrent(false) .setRequiredNetworkType(JobRequest.NetworkType.METERED) diff --git a/app/src/main/java/app/fedilab/android/jobs/BaseScheduledTootsSyncJob.java b/app/src/main/java/app/fedilab/android/jobs/BaseScheduledTootsSyncJob.java index d0c7bfb49..9a11490fc 100644 --- a/app/src/main/java/app/fedilab/android/jobs/BaseScheduledTootsSyncJob.java +++ b/app/src/main/java/app/fedilab/android/jobs/BaseScheduledTootsSyncJob.java @@ -40,13 +40,10 @@ import app.fedilab.android.sqlite.StatusStoredDAO; * Scheduled a toot a datetime */ -public class ScheduledTootsSyncJob extends Job { +public class BaseScheduledTootsSyncJob extends Job { public static final String SCHEDULED_TOOT = "job_scheduled_toot"; - static { - Helper.installProvider(); - } public static int schedule(Context context, long id, long timestampScheduling) { @@ -54,7 +51,7 @@ public class ScheduledTootsSyncJob extends Job { long endMs = startMs + TimeUnit.MINUTES.toMillis(5); SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - int jobId = new JobRequest.Builder(ScheduledTootsSyncJob.SCHEDULED_TOOT) + int jobId = new JobRequest.Builder(BaseScheduledTootsSyncJob.SCHEDULED_TOOT) .setExecutionWindow(startMs, endMs) .setUpdateCurrent(false) .setRequiredNetworkType(JobRequest.NetworkType.METERED) diff --git a/app/src/main/java/app/fedilab/android/services/BaseLiveNotificationService.java b/app/src/main/java/app/fedilab/android/services/BaseLiveNotificationService.java index d9c07e692..2e36cb76c 100644 --- a/app/src/main/java/app/fedilab/android/services/BaseLiveNotificationService.java +++ b/app/src/main/java/app/fedilab/android/services/BaseLiveNotificationService.java @@ -82,7 +82,7 @@ import static app.fedilab.android.helper.Helper.getNotificationIcon; * Manage service for streaming api and new notifications */ -public class LiveNotificationService extends Service implements NetworkStateReceiver.NetworkStateReceiverListener { +public abstract class BaseLiveNotificationService extends Service implements NetworkStateReceiver.NetworkStateReceiverListener { public static String CHANNEL_ID = "live_notifications"; public static int totalAccount = 0; @@ -90,9 +90,6 @@ public class LiveNotificationService extends Service implements NetworkStateRece private static HashMap lastNotification = new HashMap<>(); private static HashMap webSocketFutures = new HashMap<>(); - static { - Helper.installProvider(); - } protected Account account; private NetworkStateReceiver networkStateReceiver; @@ -115,7 +112,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel); } SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - List accountStreams = new AccountDAO(LiveNotificationService.this, db).getAllAccountCrossAction(); + List accountStreams = new AccountDAO(BaseLiveNotificationService.this, db).getAllAccountCrossAction(); totalAccount = 0; if (accountStreams != null) { for (Account account : accountStreams) { @@ -128,16 +125,16 @@ public class LiveNotificationService extends Service implements NetworkStateRece } } if (Build.VERSION.SDK_INT >= 26) { - Intent myIntent = new Intent(LiveNotificationService.this, MainActivity.class); + Intent myIntent = new Intent(BaseLiveNotificationService.this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity( - LiveNotificationService.this, + BaseLiveNotificationService.this, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT); android.app.Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID) .setContentTitle(getString(R.string.top_notification)) .setContentIntent(pendingIntent) - .setSmallIcon(getNotificationIcon(LiveNotificationService.this)) + .setSmallIcon(getNotificationIcon(BaseLiveNotificationService.this)) .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build(); if (notification != null) { @@ -161,7 +158,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); if (liveNotifications) { - List accountStreams = new AccountDAO(LiveNotificationService.this, db).getAllAccountCrossAction(); + List accountStreams = new AccountDAO(BaseLiveNotificationService.this, db).getAllAccountCrossAction(); if (accountStreams != null) { for (final Account accountStream : accountStreams) { if (accountStream.getSocial() == null || accountStream.getSocial().equals("MASTODON") || accountStream.getSocial().equals("PLEROMA")) { @@ -319,7 +316,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece ((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel); android.app.Notification notificationChannel = new NotificationCompat.Builder(this, CHANNEL_ID) .setContentTitle(getString(R.string.top_notification)) - .setSmallIcon(getNotificationIcon(LiveNotificationService.this)) + .setSmallIcon(getNotificationIcon(BaseLiveNotificationService.this)) .setContentText(getString(R.string.top_notification_message, String.valueOf(totalAccount), String.valueOf(eventsCount))).build(); if (notificationChannel != null) { startForeground(1, notificationChannel); @@ -329,10 +326,10 @@ public class LiveNotificationService extends Service implements NetworkStateRece } event = Helper.EventStreaming.NOTIFICATION; - notification = API.parseNotificationResponse(LiveNotificationService.this, new JSONObject(response.get("payload").toString())); + notification = API.parseNotificationResponse(BaseLiveNotificationService.this, new JSONObject(response.get("payload").toString())); b.putParcelable("data", notification); boolean liveNotifications = sharedpreferences.getBoolean(Helper.SET_LIVE_NOTIFICATIONS, true); - boolean canNotify = Helper.canNotify(LiveNotificationService.this); + boolean canNotify = Helper.canNotify(BaseLiveNotificationService.this); boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true); String targeted_account = null; Helper.NotifType notifType = Helper.NotifType.MENTION; @@ -445,7 +442,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece default: } //Some others notification - final Intent intent = new Intent(LiveNotificationService.this, MainActivity.class); + final Intent intent = new Intent(BaseLiveNotificationService.this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT); intent.putExtra(Helper.PREF_KEY_ID, account.getId()); @@ -458,7 +455,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece Helper.NotifType finalNotifType = notifType; Runnable myRunnable = () -> { if (finalMessage != null) { - Glide.with(LiveNotificationService.this) + Glide.with(BaseLiveNotificationService.this) .asBitmap() .load(notification.getAccount().getAvatar()) .listener(new RequestListener() { @@ -470,15 +467,15 @@ public class LiveNotificationService extends Service implements NetworkStateRece @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { assert e != null; - Helper.notify_user(LiveNotificationService.this, account, intent, BitmapFactory.decodeResource(getResources(), - getMainLogo(LiveNotificationService.this)), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage); + Helper.notify_user(BaseLiveNotificationService.this, account, intent, BitmapFactory.decodeResource(getResources(), + getMainLogo(BaseLiveNotificationService.this)), finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage); return false; } }) .into(new CustomTarget() { @Override public void onResourceReady(@NonNull Bitmap resource, Transition transition) { - Helper.notify_user(LiveNotificationService.this, account, intent, resource, finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage); + Helper.notify_user(BaseLiveNotificationService.this, account, intent, resource, finalNotifType, "@" + notification.getAccount().getAcct(), finalMessage); } @Override @@ -498,7 +495,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece intentBC.putExtra("eventStreaming", event); intentBC.putExtras(b); b.putParcelable("data", notification); - LocalBroadcastManager.getInstance(LiveNotificationService.this).sendBroadcast(intentBC); + LocalBroadcastManager.getInstance(BaseLiveNotificationService.this).sendBroadcast(intentBC); SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + account.getId() + account.getInstance(), notification.getId()); editor.apply(); diff --git a/app/src/main/java/app/fedilab/android/services/BaseStreamingFederatedTimelineService.java b/app/src/main/java/app/fedilab/android/services/BaseStreamingFederatedTimelineService.java index 2ff960735..fa7c57031 100644 --- a/app/src/main/java/app/fedilab/android/services/BaseStreamingFederatedTimelineService.java +++ b/app/src/main/java/app/fedilab/android/services/BaseStreamingFederatedTimelineService.java @@ -50,13 +50,9 @@ import app.fedilab.android.sqlite.Sqlite; * Manage service for streaming api for federated timeline */ -public class StreamingFederatedTimelineService extends IntentService { +public abstract class BaseStreamingFederatedTimelineService extends IntentService { - static { - Helper.installProvider(); - } - protected Account account; /** @@ -65,12 +61,12 @@ public class StreamingFederatedTimelineService extends IntentService { * @param name Used to name the worker thread, important only for debugging. */ @SuppressWarnings("unused") - public StreamingFederatedTimelineService(String name) { + public BaseStreamingFederatedTimelineService(String name) { super(name); } @SuppressWarnings("unused") - public StreamingFederatedTimelineService() { + public BaseStreamingFederatedTimelineService() { super("StreamingFederatedTimelineService"); } @@ -83,7 +79,7 @@ public class StreamingFederatedTimelineService extends IntentService { } SharedPreferences.Editor editor = sharedpreferences.edit(); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); - String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(StreamingFederatedTimelineService.this)); + String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseStreamingFederatedTimelineService.this)); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true); editor.apply(); } @@ -97,7 +93,7 @@ public class StreamingFederatedTimelineService extends IntentService { Account accountStream = null; if (userId != null) { SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - accountStream = new AccountDAO(StreamingFederatedTimelineService.this, db).getUniqAccount(userId, instance); + accountStream = new AccountDAO(BaseStreamingFederatedTimelineService.this, db).getUniqAccount(userId, instance); } if (accountStream != null) { Headers headers = new Headers(); @@ -144,14 +140,14 @@ public class StreamingFederatedTimelineService extends IntentService { Bundle b = new Bundle(); try { if (response.get("event").toString().equals("update")) { - status = API.parseStatuses(StreamingFederatedTimelineService.this, new JSONObject(response.get("payload").toString())); + status = API.parseStatuses(BaseStreamingFederatedTimelineService.this, new JSONObject(response.get("payload").toString())); status.setNew(true); b.putParcelable("data", status); if (account != null) b.putString("userIdService", account.getId()); Intent intentBC = new Intent(Helper.RECEIVE_FEDERATED_DATA); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(StreamingFederatedTimelineService.this).sendBroadcast(intentBC); + LocalBroadcastManager.getInstance(BaseStreamingFederatedTimelineService.this).sendBroadcast(intentBC); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/app/fedilab/android/services/BaseStreamingHomeTimelineService.java b/app/src/main/java/app/fedilab/android/services/BaseStreamingHomeTimelineService.java index 858727ffa..f77d90f33 100644 --- a/app/src/main/java/app/fedilab/android/services/BaseStreamingHomeTimelineService.java +++ b/app/src/main/java/app/fedilab/android/services/BaseStreamingHomeTimelineService.java @@ -50,13 +50,9 @@ import app.fedilab.android.sqlite.Sqlite; * Manage service for streaming api for home and notifications */ -public class StreamingHomeTimelineService extends IntentService { +public abstract class BaseStreamingHomeTimelineService extends IntentService { - static { - Helper.installProvider(); - } - protected Account account; /** @@ -65,12 +61,12 @@ public class StreamingHomeTimelineService extends IntentService { * @param name Used to name the worker thread, important only for debugging. */ @SuppressWarnings("unused") - public StreamingHomeTimelineService(String name) { + public BaseStreamingHomeTimelineService(String name) { super(name); } @SuppressWarnings("unused") - public StreamingHomeTimelineService() { + public BaseStreamingHomeTimelineService() { super("StreamingHomeTimelineService"); } @@ -83,7 +79,7 @@ public class StreamingHomeTimelineService extends IntentService { } SharedPreferences.Editor editor = sharedpreferences.edit(); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); - String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(StreamingHomeTimelineService.this)); + String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseStreamingHomeTimelineService.this)); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_HOME + userId + instance, true); editor.apply(); } @@ -97,7 +93,7 @@ public class StreamingHomeTimelineService extends IntentService { Account accountStream = null; if (userId != null) { SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - accountStream = new AccountDAO(StreamingHomeTimelineService.this, db).getUniqAccount(userId, instance); + accountStream = new AccountDAO(BaseStreamingHomeTimelineService.this, db).getUniqAccount(userId, instance); } if (accountStream != null) { Headers headers = new Headers(); @@ -144,14 +140,14 @@ public class StreamingHomeTimelineService extends IntentService { Bundle b = new Bundle(); try { if (response.get("event").toString().equals("update")) { - status = API.parseStatuses(StreamingHomeTimelineService.this, new JSONObject(response.get("payload").toString())); + status = API.parseStatuses(BaseStreamingHomeTimelineService.this, new JSONObject(response.get("payload").toString())); status.setNew(true); b.putParcelable("data", status); if (account != null) b.putString("userIdService", account.getId()); Intent intentBC = new Intent(Helper.RECEIVE_HOME_DATA); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(StreamingHomeTimelineService.this).sendBroadcast(intentBC); + LocalBroadcastManager.getInstance(BaseStreamingHomeTimelineService.this).sendBroadcast(intentBC); } } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/app/fedilab/android/services/BaseStreamingLocalTimelineService.java b/app/src/main/java/app/fedilab/android/services/BaseStreamingLocalTimelineService.java index ae9a2f7ea..c61f2db17 100644 --- a/app/src/main/java/app/fedilab/android/services/BaseStreamingLocalTimelineService.java +++ b/app/src/main/java/app/fedilab/android/services/BaseStreamingLocalTimelineService.java @@ -50,12 +50,7 @@ import app.fedilab.android.sqlite.Sqlite; * Manage service for streaming api for local timeline */ -public class StreamingLocalTimelineService extends IntentService { - - - static { - Helper.installProvider(); - } +public abstract class BaseStreamingLocalTimelineService extends IntentService { protected Account account; @@ -65,12 +60,12 @@ public class StreamingLocalTimelineService extends IntentService { * @param name Used to name the worker thread, important only for debugging. */ @SuppressWarnings("unused") - public StreamingLocalTimelineService(String name) { + public BaseStreamingLocalTimelineService(String name) { super(name); } @SuppressWarnings("unused") - public StreamingLocalTimelineService() { + public BaseStreamingLocalTimelineService() { super("StreamingLocalTimelineService"); } @@ -83,7 +78,7 @@ public class StreamingLocalTimelineService extends IntentService { } SharedPreferences.Editor editor = sharedpreferences.edit(); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); - String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(StreamingLocalTimelineService.this)); + String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseStreamingLocalTimelineService.this)); editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true); editor.apply(); } @@ -97,7 +92,7 @@ public class StreamingLocalTimelineService extends IntentService { Account accountStream = null; if (userId != null) { SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - accountStream = new AccountDAO(StreamingLocalTimelineService.this, db).getUniqAccount(userId, instance); + accountStream = new AccountDAO(BaseStreamingLocalTimelineService.this, db).getUniqAccount(userId, instance); } if (accountStream != null) { @@ -144,14 +139,14 @@ public class StreamingLocalTimelineService extends IntentService { Bundle b = new Bundle(); try { if (response.get("event").toString().equals("update")) { - status = API.parseStatuses(StreamingLocalTimelineService.this, new JSONObject(response.get("payload").toString())); + status = API.parseStatuses(BaseStreamingLocalTimelineService.this, new JSONObject(response.get("payload").toString())); status.setNew(true); b.putParcelable("data", status); if (account != null) b.putString("userIdService", account.getId()); Intent intentBC = new Intent(Helper.RECEIVE_LOCAL_DATA); intentBC.putExtras(b); - LocalBroadcastManager.getInstance(StreamingLocalTimelineService.this).sendBroadcast(intentBC); + LocalBroadcastManager.getInstance(BaseStreamingLocalTimelineService.this).sendBroadcast(intentBC); } } catch (Exception e) { e.printStackTrace();