diff --git a/vector/build.gradle b/vector/build.gradle index 6f36358aa3..d29f36c877 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -141,12 +141,7 @@ android { resValue "string", "build_number", "\"${buildNumber}\"" buildConfigField "im.vector.app.features.VectorFeatures.LoginVersion", "LOGIN_VERSION", "im.vector.app.features.VectorFeatures.LoginVersion.V1" - - // NotificationSettingsV2 is disabled. To be released in conjunction with iOS/Web - def useNotificationSettingsV2 = true - buildConfigField "Boolean", "USE_NOTIFICATION_SETTINGS_V2", "${useNotificationSettingsV2}" - resValue "bool", "useNotificationSettingsV1", "${!useNotificationSettingsV2}" - resValue "bool", "useNotificationSettingsV2", "${useNotificationSettingsV2}" + buildConfigField "im.vector.app.features.VectorFeatures.NotificationSettingsVersion", "NOTIFICATION_SETTINGS_VERSION", "im.vector.app.features.VectorFeatures.NotificationSettingsVersion.V2" buildConfigField "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy", "outboundSessionKeySharingStrategy", "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy.WhenTyping" diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/settings/SettingsNotificationsRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/settings/SettingsNotificationsRobot.kt index 448552ba8e..4dddc4c9cc 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/settings/SettingsNotificationsRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/settings/SettingsNotificationsRobot.kt @@ -21,22 +21,27 @@ import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.espresso.tools.clickOnPreference +import im.vector.app.features.VectorFeatures class SettingsNotificationsRobot { fun crawl() { - if (BuildConfig.USE_NOTIFICATION_SETTINGS_V2) { - clickOn(R.string.settings_notification_default) - pressBack() - clickOn(R.string.settings_notification_mentions_and_keywords) - // TODO Test adding a keyword? - pressBack() - clickOn(R.string.settings_notification_other) - pressBack() - } else { - clickOn(R.string.settings_notification_advanced) - pressBack() + when (BuildConfig.NOTIFICATION_SETTINGS_VERSION!!) { + VectorFeatures.NotificationSettingsVersion.V1 -> { + clickOn(R.string.settings_notification_advanced) + pressBack() + } + VectorFeatures.NotificationSettingsVersion.V2 -> { + clickOn(R.string.settings_notification_default) + pressBack() + clickOn(R.string.settings_notification_mentions_and_keywords) + // TODO Test adding a keyword? + pressBack() + clickOn(R.string.settings_notification_other) + pressBack() + } } + /* clickOn(R.string.settings_noisy_notifications_preferences) TODO Cannot go back diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index ccc54b5d8e..b40d2d02f2 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -21,13 +21,20 @@ import im.vector.app.BuildConfig interface VectorFeatures { fun loginVersion(): LoginVersion + fun notificationSettingsVersion(): NotificationSettingsVersion enum class LoginVersion { V1, V2 } + + enum class NotificationSettingsVersion { + V1, + V2 + } } class DefaultVectorFeatures : VectorFeatures { override fun loginVersion(): VectorFeatures.LoginVersion = BuildConfig.LOGIN_VERSION + override fun notificationSettingsVersion(): VectorFeatures.NotificationSettingsVersion = BuildConfig.NOTIFICATION_SETTINGS_VERSION } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt index 7e39156b18..4e0f329738 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt @@ -25,6 +25,7 @@ import im.vector.app.core.epoxy.bottomsheet.bottomSheetRoomPreviewItem import im.vector.app.core.epoxy.profiles.notifications.radioButtonItem import im.vector.app.core.resources.ColorProvider import im.vector.app.core.resources.StringProvider +import im.vector.app.features.VectorFeatures import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.roomprofile.notifications.notificationOptions import im.vector.app.features.roomprofile.notifications.notificationStateMapped @@ -38,7 +39,8 @@ import javax.inject.Inject class RoomListQuickActionsEpoxyController @Inject constructor( private val avatarRenderer: AvatarRenderer, private val colorProvider: ColorProvider, - private val stringProvider: StringProvider + private val stringProvider: StringProvider, + private val features: VectorFeatures ) : TypedEpoxyController() { var listener: Listener? = null @@ -47,7 +49,7 @@ class RoomListQuickActionsEpoxyController @Inject constructor( val notificationViewState = state.notificationSettingsViewState val roomSummary = notificationViewState.roomSummary() ?: return val host = this - val isV2 = BuildConfig.USE_NOTIFICATION_SETTINGS_V2 + val isV2 = features.notificationSettingsVersion() == VectorFeatures.NotificationSettingsVersion.V2 // V2 always shows full details as we no longer display the sheet from RoomProfile > Notifications val showFull = state.roomListActionsArgs.mode == RoomListActionsArgs.Mode.FULL || isV2 diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt index e1a5cae907..4dac4be489 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt @@ -31,7 +31,6 @@ import com.airbnb.mvrx.args import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import com.google.android.material.dialog.MaterialAlertDialogBuilder -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.animations.AppBarStateChangeListener import im.vector.app.core.animations.MatrixItemAppBarStateChangeListener @@ -45,6 +44,7 @@ import im.vector.app.core.utils.copyToClipboard import im.vector.app.core.utils.startSharePlainTextIntent import im.vector.app.databinding.FragmentMatrixProfileBinding import im.vector.app.databinding.ViewStubRoomProfileHeaderBinding +import im.vector.app.features.VectorFeatures import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.room.detail.RoomDetailPendingAction import im.vector.app.features.home.room.detail.RoomDetailPendingActionStore @@ -70,6 +70,7 @@ class RoomProfileFragment @Inject constructor( private val roomProfileController: RoomProfileController, private val avatarRenderer: AvatarRenderer, private val roomDetailPendingActionStore: RoomDetailPendingActionStore, + private val features: VectorFeatures ) : VectorBaseFragment(), RoomProfileController.Callback { @@ -258,12 +259,15 @@ class RoomProfileFragment @Inject constructor( } override fun onNotificationsClicked() { - if (BuildConfig.USE_NOTIFICATION_SETTINGS_V2) { - roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomNotificationSettings) - } else { - RoomListQuickActionsBottomSheet - .newInstance(roomProfileArgs.roomId, RoomListActionsArgs.Mode.NOTIFICATIONS) - .show(childFragmentManager, "ROOM_PROFILE_NOTIFICATIONS") + when (features.notificationSettingsVersion()) { + VectorFeatures.NotificationSettingsVersion.V1 -> { + RoomListQuickActionsBottomSheet + .newInstance(roomProfileArgs.roomId, RoomListActionsArgs.Mode.NOTIFICATIONS) + .show(childFragmentManager, "ROOM_PROFILE_NOTIFICATIONS") + } + VectorFeatures.NotificationSettingsVersion.V2 -> { + roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomNotificationSettings) + } } }