From d1642c928a484dcdc573fafe51e8032ef474d8dd Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 26 Jun 2019 14:07:53 +0200 Subject: [PATCH] Move specific classes for FDroid into FDroid variant source code --- vector/src/fdroid/AndroidManifest.xml | 8 ++++-- .../troubleshoot/TestAutoStartBoot.kt | 2 +- .../TestBackgroundRestrictions.kt | 2 +- .../troubleshoot/TestBatteryOptimization.kt | 2 +- .../riotredesign/fdroid/package-info.kt | 20 ++++++++++++++ .../receiver}/AlarmSyncBroadcastReceiver.kt | 27 ++++++++++++++----- .../OnApplicationUpgradeOrRebootReceiver.kt | 3 +-- .../fdroid/service}/VectorSyncService.kt | 8 +++--- .../vector/riotredesign/push/fcm/FcmHelper.kt | 20 +++++++++++++- ...ificationTroubleshootTestManagerFactory.kt | 4 +-- vector/src/gplay/AndroidManifest.xml | 2 +- .../troubleshoot/TestFirebaseToken.kt | 2 +- .../troubleshoot/TestPlayServices.kt | 2 +- .../troubleshoot/TestTokenRegistration.kt | 2 +- .../vector/riotredesign/gplay/package-info.kt | 21 +++++++++++++++ .../fcm/VectorFirebaseMessagingService.kt | 3 ++- .../vector/riotredesign/push/fcm/FcmHelper.kt | 8 ++++++ ...ificationTroubleshootTestManagerFactory.kt | 6 ++--- vector/src/main/AndroidManifest.xml | 9 ------- .../vector/riotredesign/VectorApplication.kt | 18 ++----------- 20 files changed, 116 insertions(+), 53 deletions(-) rename vector/src/fdroid/java/im/vector/riotredesign/{push/fcm => fdroid/features/settings}/troubleshoot/TestAutoStartBoot.kt (96%) rename vector/src/fdroid/java/im/vector/riotredesign/{push/fcm => fdroid/features/settings}/troubleshoot/TestBackgroundRestrictions.kt (98%) rename vector/src/fdroid/java/im/vector/riotredesign/{push/fcm => fdroid/features/settings}/troubleshoot/TestBatteryOptimization.kt (96%) create mode 100644 vector/src/fdroid/java/im/vector/riotredesign/fdroid/package-info.kt rename vector/src/{main/java/im/vector/riotredesign/core/services => fdroid/java/im/vector/riotredesign/fdroid/receiver}/AlarmSyncBroadcastReceiver.kt (70%) rename vector/src/fdroid/java/im/vector/riotredesign/{ => fdroid}/receiver/OnApplicationUpgradeOrRebootReceiver.kt (90%) rename vector/src/{main/java/im/vector/riotredesign/core/services => fdroid/java/im/vector/riotredesign/fdroid/service}/VectorSyncService.kt (92%) rename vector/src/gplay/java/im/vector/riotredesign/{push/fcm => gplay/features/settings}/troubleshoot/TestFirebaseToken.kt (98%) rename vector/src/gplay/java/im/vector/riotredesign/{push/fcm => gplay/features/settings}/troubleshoot/TestPlayServices.kt (97%) rename vector/src/gplay/java/im/vector/riotredesign/{push/fcm => gplay/features/settings}/troubleshoot/TestTokenRegistration.kt (96%) create mode 100644 vector/src/gplay/java/im/vector/riotredesign/gplay/package-info.kt rename vector/src/gplay/java/im/vector/riotredesign/{ => gplay}/push/fcm/VectorFirebaseMessagingService.kt (99%) diff --git a/vector/src/fdroid/AndroidManifest.xml b/vector/src/fdroid/AndroidManifest.xml index 042d9ef82f..11d116fef5 100644 --- a/vector/src/fdroid/AndroidManifest.xml +++ b/vector/src/fdroid/AndroidManifest.xml @@ -8,7 +8,7 @@ - + @@ -16,10 +16,14 @@ + + \ No newline at end of file diff --git a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestAutoStartBoot.kt b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt similarity index 96% rename from vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestAutoStartBoot.kt rename to vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt index bd266448d6..211f733741 100644 --- a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestAutoStartBoot.kt +++ b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.riotredesign.push.fcm.troubleshoot +package im.vector.riotredesign.fdroid.features.settings.troubleshoot import androidx.fragment.app.Fragment import im.vector.riotredesign.R diff --git a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestBackgroundRestrictions.kt b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt similarity index 98% rename from vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestBackgroundRestrictions.kt rename to vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt index d5903b92ff..72c0b4333c 100644 --- a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestBackgroundRestrictions.kt +++ b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.riotredesign.push.fcm.troubleshoot +package im.vector.riotredesign.fdroid.features.settings.troubleshoot import android.content.Context import android.net.ConnectivityManager diff --git a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestBatteryOptimization.kt b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestBatteryOptimization.kt similarity index 96% rename from vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestBatteryOptimization.kt rename to vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestBatteryOptimization.kt index ad1529e844..4cfd762feb 100644 --- a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/troubleshoot/TestBatteryOptimization.kt +++ b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/features/settings/troubleshoot/TestBatteryOptimization.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.riotredesign.push.fcm.troubleshoot +package im.vector.riotredesign.fdroid.features.settings.troubleshoot import androidx.fragment.app.Fragment import im.vector.riotredesign.R diff --git a/vector/src/fdroid/java/im/vector/riotredesign/fdroid/package-info.kt b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/package-info.kt new file mode 100644 index 0000000000..9873a2802d --- /dev/null +++ b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/package-info.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Code exclusively used by the FDroid build and not referenced on the main source code + */ +package im.vector.riotredesign.fdroid \ No newline at end of file diff --git a/vector/src/main/java/im/vector/riotredesign/core/services/AlarmSyncBroadcastReceiver.kt b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/receiver/AlarmSyncBroadcastReceiver.kt similarity index 70% rename from vector/src/main/java/im/vector/riotredesign/core/services/AlarmSyncBroadcastReceiver.kt rename to vector/src/fdroid/java/im/vector/riotredesign/fdroid/receiver/AlarmSyncBroadcastReceiver.kt index f89f39e3ab..ec37964fa0 100644 --- a/vector/src/main/java/im/vector/riotredesign/core/services/AlarmSyncBroadcastReceiver.kt +++ b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/receiver/AlarmSyncBroadcastReceiver.kt @@ -1,4 +1,20 @@ -package im.vector.riotredesign.core.services +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotredesign.fdroid.receiver import android.app.AlarmManager import android.app.PendingIntent @@ -8,6 +24,7 @@ import android.content.Intent import android.os.Build import android.os.PowerManager import androidx.core.content.ContextCompat +import im.vector.riotredesign.fdroid.service.VectorSyncService import timber.log.Timber class AlarmSyncBroadcastReceiver : BroadcastReceiver() { @@ -46,13 +63,12 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { } companion object { - const val REQUEST_CODE = 0 + private const val REQUEST_CODE = 0 fun scheduleAlarm(context: Context, delay: Long) { //Reschedule val intent = Intent(context, AlarmSyncBroadcastReceiver::class.java) - val pIntent = PendingIntent.getBroadcast(context, AlarmSyncBroadcastReceiver.REQUEST_CODE, - intent, PendingIntent.FLAG_UPDATE_CURRENT) + val pIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT) val firstMillis = System.currentTimeMillis() + delay val alarmMgr = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -64,8 +80,7 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { fun cancelAlarm(context: Context) { val intent = Intent(context, AlarmSyncBroadcastReceiver::class.java) - val pIntent = PendingIntent.getBroadcast(context, AlarmSyncBroadcastReceiver.REQUEST_CODE, - intent, PendingIntent.FLAG_UPDATE_CURRENT) + val pIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT) val alarmMgr = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager alarmMgr.cancel(pIntent) } diff --git a/vector/src/fdroid/java/im/vector/riotredesign/receiver/OnApplicationUpgradeOrRebootReceiver.kt b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/receiver/OnApplicationUpgradeOrRebootReceiver.kt similarity index 90% rename from vector/src/fdroid/java/im/vector/riotredesign/receiver/OnApplicationUpgradeOrRebootReceiver.kt rename to vector/src/fdroid/java/im/vector/riotredesign/fdroid/receiver/OnApplicationUpgradeOrRebootReceiver.kt index a13bc71ada..4ed793d793 100644 --- a/vector/src/fdroid/java/im/vector/riotredesign/receiver/OnApplicationUpgradeOrRebootReceiver.kt +++ b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/receiver/OnApplicationUpgradeOrRebootReceiver.kt @@ -15,12 +15,11 @@ * limitations under the License. */ -package im.vector.riotredesign.receiver +package im.vector.riotredesign.fdroid.receiver import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import im.vector.riotredesign.core.services.AlarmSyncBroadcastReceiver import timber.log.Timber class OnApplicationUpgradeOrRebootReceiver : BroadcastReceiver() { diff --git a/vector/src/main/java/im/vector/riotredesign/core/services/VectorSyncService.kt b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/service/VectorSyncService.kt similarity index 92% rename from vector/src/main/java/im/vector/riotredesign/core/services/VectorSyncService.kt rename to vector/src/fdroid/java/im/vector/riotredesign/fdroid/service/VectorSyncService.kt index 6f105c94fd..6b3cec1ae8 100644 --- a/vector/src/main/java/im/vector/riotredesign/core/services/VectorSyncService.kt +++ b/vector/src/fdroid/java/im/vector/riotredesign/fdroid/service/VectorSyncService.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.riotredesign.core.services +package im.vector.riotredesign.fdroid.service import android.app.NotificationManager import android.content.Context @@ -28,12 +28,12 @@ import timber.log.Timber class VectorSyncService : SyncService() { override fun onCreate() { - Timber.v("VectorSyncService - onCreate ") + Timber.v("VectorSyncService - onCreate") super.onCreate() } override fun onDestroy() { - Timber.v("VectorSyncService - onDestroy ") + Timber.v("VectorSyncService - onDestroy") removeForegroundNotif() super.onDestroy() } @@ -57,7 +57,7 @@ class VectorSyncService : SyncService() { } /** - * If the service is bounded and the service was previously started we can remove foreground notif + * If the service is bounded and the service was previously started we can remove foreground notification */ override fun onBind(intent: Intent?): IBinder { Timber.v("VectorSyncService - onBind ") diff --git a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/FcmHelper.kt b/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/FcmHelper.kt index 11826a7b35..6691f5ed2d 100755 --- a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/FcmHelper.kt +++ b/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/FcmHelper.kt @@ -18,9 +18,14 @@ package im.vector.riotredesign.push.fcm import android.app.Activity import android.content.Context - import im.vector.riotredesign.core.pushers.PushersManager +import im.vector.riotredesign.fdroid.receiver.AlarmSyncBroadcastReceiver +import im.vector.riotredesign.features.settings.PreferencesManager +import timber.log.Timber +/** + * This class has an alter ego in the gplay variant. + */ object FcmHelper { fun isPushSupported(): Boolean = false @@ -52,4 +57,17 @@ object FcmHelper { fun ensureFcmTokenIsRetrieved(activity: Activity, pushersManager: PushersManager) { // No op } + + fun onEnterForeground(context: Context) { + AlarmSyncBroadcastReceiver.cancelAlarm(context) + } + + fun onEnterBackground(context: Context, hasSession: Boolean) { + //We need to use alarm in this mode + if (PreferencesManager.areNotificationEnabledForDevice(context) + && hasSession) { + AlarmSyncBroadcastReceiver.scheduleAlarm(context, 4_000L) + Timber.i("Alarm scheduled to restart service") + } + } } diff --git a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/NotificationTroubleshootTestManagerFactory.kt b/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/NotificationTroubleshootTestManagerFactory.kt index 0a3fdd227d..9a5ada35af 100644 --- a/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/NotificationTroubleshootTestManagerFactory.kt +++ b/vector/src/fdroid/java/im/vector/riotredesign/push/fcm/NotificationTroubleshootTestManagerFactory.kt @@ -17,9 +17,9 @@ package im.vector.riotredesign.push.fcm import androidx.fragment.app.Fragment import im.vector.matrix.android.api.session.Session +import im.vector.riotredesign.fdroid.features.settings.troubleshoot.TestAutoStartBoot +import im.vector.riotredesign.fdroid.features.settings.troubleshoot.TestBackgroundRestrictions import im.vector.riotredesign.features.settings.troubleshoot.* -import im.vector.riotredesign.push.fcm.troubleshoot.TestAutoStartBoot -import im.vector.riotredesign.push.fcm.troubleshoot.TestBackgroundRestrictions class NotificationTroubleshootTestManagerFactory { diff --git a/vector/src/gplay/AndroidManifest.xml b/vector/src/gplay/AndroidManifest.xml index 145da025c7..8f6a1cef48 100755 --- a/vector/src/gplay/AndroidManifest.xml +++ b/vector/src/gplay/AndroidManifest.xml @@ -9,7 +9,7 @@ android:name="firebase_analytics_collection_deactivated" android:value="true" /> - + diff --git a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestFirebaseToken.kt b/vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestFirebaseToken.kt similarity index 98% rename from vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestFirebaseToken.kt rename to vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestFirebaseToken.kt index 6ab552dadf..56ee8062e4 100644 --- a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestFirebaseToken.kt +++ b/vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestFirebaseToken.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.riotredesign.push.fcm.troubleshoot +package im.vector.riotredesign.gplay.features.settings.troubleshoot import androidx.fragment.app.Fragment import com.google.firebase.iid.FirebaseInstanceId diff --git a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestPlayServices.kt b/vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestPlayServices.kt similarity index 97% rename from vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestPlayServices.kt rename to vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestPlayServices.kt index 5d56712b39..842f043d26 100644 --- a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestPlayServices.kt +++ b/vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestPlayServices.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.riotredesign.push.fcm.troubleshoot +package im.vector.riotredesign.gplay.features.settings.troubleshoot import androidx.fragment.app.Fragment import com.google.android.gms.common.ConnectionResult diff --git a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestTokenRegistration.kt b/vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestTokenRegistration.kt similarity index 96% rename from vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestTokenRegistration.kt rename to vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestTokenRegistration.kt index 912597ec40..8f96aaa821 100644 --- a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/troubleshoot/TestTokenRegistration.kt +++ b/vector/src/gplay/java/im/vector/riotredesign/gplay/features/settings/troubleshoot/TestTokenRegistration.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package im.vector.riotredesign.push.fcm.troubleshoot +package im.vector.riotredesign.gplay.features.settings.troubleshoot import androidx.fragment.app.Fragment import im.vector.riotredesign.R diff --git a/vector/src/gplay/java/im/vector/riotredesign/gplay/package-info.kt b/vector/src/gplay/java/im/vector/riotredesign/gplay/package-info.kt new file mode 100644 index 0000000000..6093852523 --- /dev/null +++ b/vector/src/gplay/java/im/vector/riotredesign/gplay/package-info.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Code exclusively used by the GPlay build and not referenced on the main source code + */ +package im.vector.riotredesign.gplay + diff --git a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/VectorFirebaseMessagingService.kt b/vector/src/gplay/java/im/vector/riotredesign/gplay/push/fcm/VectorFirebaseMessagingService.kt similarity index 99% rename from vector/src/gplay/java/im/vector/riotredesign/push/fcm/VectorFirebaseMessagingService.kt rename to vector/src/gplay/java/im/vector/riotredesign/gplay/push/fcm/VectorFirebaseMessagingService.kt index 99c95d891e..2d0ad013a3 100755 --- a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/VectorFirebaseMessagingService.kt +++ b/vector/src/gplay/java/im/vector/riotredesign/gplay/push/fcm/VectorFirebaseMessagingService.kt @@ -17,7 +17,7 @@ * limitations under the License. */ -package im.vector.riotredesign.push.fcm +package im.vector.riotredesign.gplay.push.fcm import android.os.Handler import android.os.Looper @@ -39,6 +39,7 @@ import im.vector.riotredesign.features.notifications.NotifiableMessageEvent import im.vector.riotredesign.features.notifications.NotificationDrawerManager import im.vector.riotredesign.features.notifications.SimpleNotifiableEvent import im.vector.riotredesign.features.settings.PreferencesManager +import im.vector.riotredesign.push.fcm.FcmHelper import org.koin.android.ext.android.inject import timber.log.Timber diff --git a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/FcmHelper.kt b/vector/src/gplay/java/im/vector/riotredesign/push/fcm/FcmHelper.kt index 25f380f42f..a0e2d8240d 100755 --- a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/FcmHelper.kt +++ b/vector/src/gplay/java/im/vector/riotredesign/push/fcm/FcmHelper.kt @@ -99,4 +99,12 @@ object FcmHelper { val resultCode = apiAvailability.isGooglePlayServicesAvailable(activity) return resultCode == ConnectionResult.SUCCESS } + + fun onEnterForeground(context: Context) { + // No op + } + + fun onEnterBackground(context: Context, hasSession: Boolean) { + // TODO FCM fallback + } } diff --git a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/NotificationTroubleshootTestManagerFactory.kt b/vector/src/gplay/java/im/vector/riotredesign/push/fcm/NotificationTroubleshootTestManagerFactory.kt index ee4e59e4ab..f2bb4007b7 100644 --- a/vector/src/gplay/java/im/vector/riotredesign/push/fcm/NotificationTroubleshootTestManagerFactory.kt +++ b/vector/src/gplay/java/im/vector/riotredesign/push/fcm/NotificationTroubleshootTestManagerFactory.kt @@ -18,9 +18,9 @@ package im.vector.riotredesign.push.fcm import androidx.fragment.app.Fragment import im.vector.matrix.android.api.session.Session import im.vector.riotredesign.features.settings.troubleshoot.* -import im.vector.riotredesign.push.fcm.troubleshoot.TestFirebaseToken -import im.vector.riotredesign.push.fcm.troubleshoot.TestPlayServices -import im.vector.riotredesign.push.fcm.troubleshoot.TestTokenRegistration +import im.vector.riotredesign.gplay.features.settings.troubleshoot.TestFirebaseToken +import im.vector.riotredesign.gplay.features.settings.troubleshoot.TestPlayServices +import im.vector.riotredesign.gplay.features.settings.troubleshoot.TestTokenRegistration class NotificationTroubleshootTestManagerFactory { diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index aaae3edb6b..8fa242175f 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -68,15 +68,6 @@ - - - - - - - diff --git a/vector/src/main/java/im/vector/riotredesign/VectorApplication.kt b/vector/src/main/java/im/vector/riotredesign/VectorApplication.kt index 9bef712e0c..90ec01c9c7 100644 --- a/vector/src/main/java/im/vector/riotredesign/VectorApplication.kt +++ b/vector/src/main/java/im/vector/riotredesign/VectorApplication.kt @@ -36,7 +36,6 @@ import com.github.piasy.biv.loader.glide.GlideImageLoader import com.jakewharton.threetenabp.AndroidThreeTen import im.vector.matrix.android.api.Matrix import im.vector.riotredesign.core.di.AppModule -import im.vector.riotredesign.core.services.AlarmSyncBroadcastReceiver import im.vector.riotredesign.features.configuration.VectorConfiguration import im.vector.riotredesign.features.crypto.keysbackup.KeysBackupModule import im.vector.riotredesign.features.home.HomeModule @@ -47,7 +46,6 @@ import im.vector.riotredesign.features.notifications.PushRuleTriggerListener import im.vector.riotredesign.features.rageshake.VectorFileLogger import im.vector.riotredesign.features.rageshake.VectorUncaughtExceptionHandler import im.vector.riotredesign.features.roomdirectory.RoomDirectoryModule -import im.vector.riotredesign.features.settings.PreferencesManager import im.vector.riotredesign.features.version.getVersion import im.vector.riotredesign.push.fcm.FcmHelper import org.koin.android.ext.android.get @@ -117,7 +115,7 @@ class VectorApplication : Application() { @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) fun entersForeground() { - AlarmSyncBroadcastReceiver.cancelAlarm(appContext) + FcmHelper.onEnterForeground(appContext) Matrix.getInstance().currentSession?.also { it.stopAnyBackgroundSync() } @@ -129,20 +127,8 @@ class VectorApplication : Application() { notificationDrawerManager.persistInfo() - if (FcmHelper.isPushSupported()) { - //TODO FCM fallback - } else { - //TODO check if notifications are enabled for this device - //We need to use alarm in this mode - if (PreferencesManager.areNotificationEnabledForDevice(applicationContext)) { - if (Matrix.getInstance().currentSession != null) { - AlarmSyncBroadcastReceiver.scheduleAlarm(applicationContext, 4_000L) - Timber.i("Alarm scheduled to restart service") - } - } - } + FcmHelper.onEnterBackground(appContext, Matrix.getInstance().currentSession != null) } - })