From f605e0c4791318e3f8b103004b7cd4fa1fa4c223 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 8 Aug 2022 17:51:08 +0100 Subject: [PATCH] decoupling the notification test factory from the vector module --- .../vector/app/di/NotificationTestModule.kt | 31 +++++++++++++++++++ ...ficationTroubleshootTestManagerFactory.kt} | 7 +++-- .../vector/app/di/NotificationTestModule.kt | 31 +++++++++++++++++++ ...ficationTroubleshootTestManagerFactory.kt} | 7 +++-- ...ificationTroubleshootTestManagerFactory.kt | 24 ++++++++++++++ ...ttingsNotificationsTroubleshootFragment.kt | 2 +- 6 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 vector/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt rename vector/src/fdroid/java/im/vector/app/push/fcm/{NotificationTroubleshootTestManagerFactory.kt => FdroidNotificationTroubleshootTestManagerFactory.kt} (93%) create mode 100644 vector/src/gplay/java/im/vector/app/di/NotificationTestModule.kt rename vector/src/gplay/java/im/vector/app/push/fcm/{NotificationTroubleshootTestManagerFactory.kt => GoogleNotificationTroubleshootTestManagerFactory.kt} (93%) create mode 100644 vector/src/main/java/im/vector/app/features/push/NotificationTroubleshootTestManagerFactory.kt diff --git a/vector/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt b/vector/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt new file mode 100644 index 0000000000..a171126168 --- /dev/null +++ b/vector/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 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.app.di + +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ActivityComponent +import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory +import im.vector.app.push.fcm.FdroidNotificationTroubleshootTestManagerFactory + +@InstallIn(ActivityComponent::class) +@Module +abstract class NotificationTestModule { + @Binds + abstract fun bindsNotificationTestFactory(factory: FdroidNotificationTroubleshootTestManagerFactory): NotificationTroubleshootTestManagerFactory +} diff --git a/vector/src/fdroid/java/im/vector/app/push/fcm/NotificationTroubleshootTestManagerFactory.kt b/vector/src/fdroid/java/im/vector/app/push/fcm/FdroidNotificationTroubleshootTestManagerFactory.kt similarity index 93% rename from vector/src/fdroid/java/im/vector/app/push/fcm/NotificationTroubleshootTestManagerFactory.kt rename to vector/src/fdroid/java/im/vector/app/push/fcm/FdroidNotificationTroubleshootTestManagerFactory.kt index 5873b4308f..86843f0e6f 100644 --- a/vector/src/fdroid/java/im/vector/app/push/fcm/NotificationTroubleshootTestManagerFactory.kt +++ b/vector/src/fdroid/java/im/vector/app/push/fcm/FdroidNotificationTroubleshootTestManagerFactory.kt @@ -21,6 +21,7 @@ import im.vector.app.fdroid.features.settings.troubleshoot.TestAutoStartBoot import im.vector.app.fdroid.features.settings.troubleshoot.TestBackgroundRestrictions import im.vector.app.fdroid.features.settings.troubleshoot.TestBatteryOptimization import im.vector.app.features.VectorFeatures +import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager import im.vector.app.features.settings.troubleshoot.TestAccountSettings import im.vector.app.features.settings.troubleshoot.TestAvailableUnifiedPushDistributors @@ -35,7 +36,7 @@ import im.vector.app.features.settings.troubleshoot.TestUnifiedPushEndpoint import im.vector.app.features.settings.troubleshoot.TestUnifiedPushGateway import javax.inject.Inject -class NotificationTroubleshootTestManagerFactory @Inject constructor( +class FdroidNotificationTroubleshootTestManagerFactory @Inject constructor( private val unifiedPushHelper: UnifiedPushHelper, private val testSystemSettings: TestSystemSettings, private val testAccountSettings: TestAccountSettings, @@ -52,9 +53,9 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor( private val testBatteryOptimization: TestBatteryOptimization, private val testNotification: TestNotification, private val vectorFeatures: VectorFeatures, -) { +): NotificationTroubleshootTestManagerFactory { - fun create(fragment: Fragment): NotificationTroubleshootTestManager { + override fun create(fragment: Fragment): NotificationTroubleshootTestManager { val mgr = NotificationTroubleshootTestManager(fragment) mgr.addTest(testSystemSettings) mgr.addTest(testAccountSettings) diff --git a/vector/src/gplay/java/im/vector/app/di/NotificationTestModule.kt b/vector/src/gplay/java/im/vector/app/di/NotificationTestModule.kt new file mode 100644 index 0000000000..f3dfbccfc1 --- /dev/null +++ b/vector/src/gplay/java/im/vector/app/di/NotificationTestModule.kt @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 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.app.di + +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ActivityComponent +import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory +import im.vector.app.push.fcm.GoogleNotificationTroubleshootTestManagerFactory + +@InstallIn(ActivityComponent::class) +@Module +abstract class NotificationTestModule { + @Binds + abstract fun bindsNotificationTestFactory(factory: GoogleNotificationTroubleshootTestManagerFactory): NotificationTroubleshootTestManagerFactory +} diff --git a/vector/src/gplay/java/im/vector/app/push/fcm/NotificationTroubleshootTestManagerFactory.kt b/vector/src/gplay/java/im/vector/app/push/fcm/GoogleNotificationTroubleshootTestManagerFactory.kt similarity index 93% rename from vector/src/gplay/java/im/vector/app/push/fcm/NotificationTroubleshootTestManagerFactory.kt rename to vector/src/gplay/java/im/vector/app/push/fcm/GoogleNotificationTroubleshootTestManagerFactory.kt index b3425c778b..154e127fb6 100644 --- a/vector/src/gplay/java/im/vector/app/push/fcm/NotificationTroubleshootTestManagerFactory.kt +++ b/vector/src/gplay/java/im/vector/app/push/fcm/GoogleNotificationTroubleshootTestManagerFactory.kt @@ -18,6 +18,7 @@ package im.vector.app.push.fcm import androidx.fragment.app.Fragment import im.vector.app.core.pushers.UnifiedPushHelper import im.vector.app.features.VectorFeatures +import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager import im.vector.app.features.settings.troubleshoot.TestAccountSettings import im.vector.app.features.settings.troubleshoot.TestAvailableUnifiedPushDistributors @@ -35,7 +36,7 @@ import im.vector.app.gplay.features.settings.troubleshoot.TestPlayServices import im.vector.app.gplay.features.settings.troubleshoot.TestTokenRegistration import javax.inject.Inject -class NotificationTroubleshootTestManagerFactory @Inject constructor( +class GoogleNotificationTroubleshootTestManagerFactory @Inject constructor( private val unifiedPushHelper: UnifiedPushHelper, private val testSystemSettings: TestSystemSettings, private val testAccountSettings: TestAccountSettings, @@ -52,9 +53,9 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor( private val testPushFromPushGateway: TestPushFromPushGateway, private val testNotification: TestNotification, private val vectorFeatures: VectorFeatures, -) { +) : NotificationTroubleshootTestManagerFactory { - fun create(fragment: Fragment): NotificationTroubleshootTestManager { + override fun create(fragment: Fragment): NotificationTroubleshootTestManager { val mgr = NotificationTroubleshootTestManager(fragment) mgr.addTest(testSystemSettings) mgr.addTest(testAccountSettings) diff --git a/vector/src/main/java/im/vector/app/features/push/NotificationTroubleshootTestManagerFactory.kt b/vector/src/main/java/im/vector/app/features/push/NotificationTroubleshootTestManagerFactory.kt new file mode 100644 index 0000000000..6a3ce04c1a --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/push/NotificationTroubleshootTestManagerFactory.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 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.app.features.push + +import androidx.fragment.app.Fragment +import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager + +interface NotificationTroubleshootTestManagerFactory { + fun create(fragment: Fragment): NotificationTroubleshootTestManager +} diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt index 8a3407b428..e75824195e 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationsTroubleshootFragment.kt @@ -35,11 +35,11 @@ import im.vector.app.core.extensions.registerStartForActivityResult import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentSettingsNotificationsTroubleshootBinding import im.vector.app.features.notifications.NotificationActionIds +import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory import im.vector.app.features.rageshake.BugReporter import im.vector.app.features.settings.VectorSettingsFragmentInteractionListener import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager import im.vector.app.features.settings.troubleshoot.TroubleshootTest -import im.vector.app.push.fcm.NotificationTroubleshootTestManagerFactory import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.tryOrNull import javax.inject.Inject