diff --git a/changelog.d/4626.misc b/changelog.d/4626.misc
new file mode 100644
index 0000000000..9f2d979cbb
--- /dev/null
+++ b/changelog.d/4626.misc
@@ -0,0 +1 @@
+Introducing feature flagging to the login and notification settings flows
\ No newline at end of file
diff --git a/tools/check/forbidden_strings_in_code.txt b/tools/check/forbidden_strings_in_code.txt
index b135954f63..bbd6105b15 100644
--- a/tools/check/forbidden_strings_in_code.txt
+++ b/tools/check/forbidden_strings_in_code.txt
@@ -160,7 +160,7 @@ Formatter\.formatShortFileSize===1
# android\.text\.TextUtils
### This is not a rule, but a warning: the number of "enum class" has changed. For Json classes, it is mandatory that they have `@JsonClass(generateAdapter = false)`. If the enum is not used as a Json class, change the value in file forbidden_strings_in_code.txt
-enum class===108
+enum class===110
### Do not import temporary legacy classes
import org.matrix.android.sdk.internal.legacy.riot===3
diff --git a/vector/build.gradle b/vector/build.gradle
index ff81c4d721..d29f36c877 100644
--- a/vector/build.gradle
+++ b/vector/build.gradle
@@ -140,16 +140,8 @@ android {
buildConfigField "String", "BUILD_NUMBER", "\"${buildNumber}\""
resValue "string", "build_number", "\"${buildNumber}\""
- // The two booleans must not have the same value. We need two values for the manifest
- // LoginFlowV2 is disabled to be merged on develop (changelog: Improve login/register flow (#1410, #2585, #3172))
- resValue "bool", "useLoginV1", "true"
- resValue "bool", "useLoginV2", "false"
-
- // 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.LoginVersion", "LOGIN_VERSION", "im.vector.app.features.VectorFeatures.LoginVersion.V1"
+ 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/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml
index 5b56107ef7..6d3c6cdc51 100644
--- a/vector/src/main/AndroidManifest.xml
+++ b/vector/src/main/AndroidManifest.xml
@@ -113,45 +113,33 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+ android:windowSoftInputMode="adjustResize" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:windowSoftInputMode="adjustResize" />
(), UnlockedActivity
navigator.openLogin(this, null)
null
}
- args.isSoftLogout ->
+ args.isSoftLogout -> {
// The homeserver has invalidated the token, with a soft logout
- getSoftLogoutActivityIntent()
+ navigator.softLogout(this)
+ null
+ }
args.isUserLoggedOut ->
// the homeserver has invalidated the token (password changed, device deleted, other security reasons)
SignedOutActivity.newIntent(this)
@@ -236,7 +236,8 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity
HomeActivity.newIntent(this)
} else {
// The token is still invalid
- getSoftLogoutActivityIntent()
+ navigator.softLogout(this)
+ null
}
else -> {
// First start, or no active session
@@ -247,12 +248,4 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity
intent?.let { startActivity(it) }
finish()
}
-
- private fun getSoftLogoutActivityIntent(): Intent {
- return if (resources.getBoolean(R.bool.useLoginV2)) {
- SoftLogoutActivity2.newIntent(this)
- } else {
- SoftLogoutActivity.newIntent(this)
- }
- }
}
diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt
new file mode 100644
index 0000000000..b40d2d02f2
--- /dev/null
+++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021 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
+
+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..a2d10cf818 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
@@ -17,7 +17,6 @@ package im.vector.app.features.home.room.list.actions
import androidx.annotation.StringRes
import com.airbnb.epoxy.TypedEpoxyController
-import im.vector.app.BuildConfig
import im.vector.app.R
import im.vector.app.core.epoxy.bottomSheetDividerItem
import im.vector.app.core.epoxy.bottomsheet.bottomSheetActionItem
@@ -25,6 +24,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 +38,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 +48,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
@@ -73,14 +74,14 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
}
if (isV2) {
- notificationViewState.notificationOptions.forEach { notificationState ->
+ notificationViewState.notificationOptions.forEach { notificationState ->
val title = titleForNotificationState(notificationState)
radioButtonItem {
id(notificationState.name)
titleRes(title)
selected(notificationViewState.notificationStateMapped() == notificationState)
listener {
- host.listener?.didSelectRoomNotificationState(notificationState)
+ host.listener?.didSelectRoomNotificationState(notificationState)
}
}
}
@@ -102,8 +103,9 @@ class RoomListQuickActionsEpoxyController @Inject constructor(
RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages
RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only
RoomNotificationState.MUTE -> R.string.room_settings_none
- else -> null
+ else -> null
}
+
private fun RoomListQuickActionsSharedAction.toBottomSheetItem(index: Int, roomNotificationState: RoomNotificationState? = null) {
val host = this@RoomListQuickActionsEpoxyController
val selected = when (this) {
diff --git a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt
index a357caf8fa..bbad40ce78 100644
--- a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt
+++ b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt
@@ -18,6 +18,7 @@ package im.vector.app.features.login
import android.content.Context
import android.content.Intent
+import android.net.Uri
import android.view.View
import android.view.ViewGroup
import androidx.core.view.ViewCompat
@@ -363,5 +364,11 @@ open class LoginActivity : VectorBaseActivity(), ToolbarCo
putExtra(EXTRA_CONFIG, loginConfig)
}
}
+
+ fun redirectIntent(context: Context, data: Uri?): Intent {
+ return Intent(context, LoginActivity::class.java).apply {
+ setData(data)
+ }
+ }
}
}
diff --git a/vector/src/main/java/im/vector/app/features/login/SSORedirectRouterActivity.kt b/vector/src/main/java/im/vector/app/features/login/SSORedirectRouterActivity.kt
new file mode 100644
index 0000000000..29f8559362
--- /dev/null
+++ b/vector/src/main/java/im/vector/app/features/login/SSORedirectRouterActivity.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 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.login
+
+import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
+import dagger.hilt.android.AndroidEntryPoint
+import im.vector.app.features.navigation.Navigator
+import javax.inject.Inject
+
+@AndroidEntryPoint
+class SSORedirectRouterActivity : AppCompatActivity() {
+
+ @Inject lateinit var navigator: Navigator
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ navigator.loginSSORedirect(this, intent.data)
+ finish()
+ }
+}
diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt
index 8f1b20aa7f..eea480864a 100644
--- a/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt
+++ b/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt
@@ -18,6 +18,7 @@ package im.vector.app.features.login2
import android.content.Context
import android.content.Intent
+import android.net.Uri
import android.view.View
import android.view.ViewGroup
import androidx.core.view.ViewCompat
@@ -396,5 +397,11 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC
putExtra(EXTRA_CONFIG, loginConfig)
}
}
+
+ fun redirectIntent(context: Context, data: Uri?): Intent {
+ return Intent(context, LoginActivity2::class.java).apply {
+ setData(data)
+ }
+ }
}
}
diff --git a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt
index 89a05c88da..eacd8523cf 100644
--- a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt
+++ b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt
@@ -19,6 +19,7 @@ package im.vector.app.features.navigation
import android.app.Activity
import android.content.Context
import android.content.Intent
+import android.net.Uri
import android.os.Build
import android.view.View
import android.view.Window
@@ -36,6 +37,7 @@ import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.error.fatalError
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.utils.toast
+import im.vector.app.features.VectorFeatures
import im.vector.app.features.call.conference.JitsiCallViewModel
import im.vector.app.features.call.conference.VectorJitsiActivity
import im.vector.app.features.call.transfer.CallTransferActivity
@@ -77,6 +79,8 @@ import im.vector.app.features.roomprofile.RoomProfileActivity
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.settings.VectorSettingsActivity
import im.vector.app.features.share.SharedData
+import im.vector.app.features.signout.soft.SoftLogoutActivity
+import im.vector.app.features.signout.soft.SoftLogoutActivity2
import im.vector.app.features.spaces.InviteRoomSpaceChooserBottomSheet
import im.vector.app.features.spaces.SpaceExploreActivity
import im.vector.app.features.spaces.SpacePreviewActivity
@@ -102,19 +106,35 @@ class DefaultNavigator @Inject constructor(
private val vectorPreferences: VectorPreferences,
private val widgetArgsBuilder: WidgetArgsBuilder,
private val appStateHandler: AppStateHandler,
- private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider
+ private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider,
+ private val features: VectorFeatures
) : Navigator {
override fun openLogin(context: Context, loginConfig: LoginConfig?, flags: Int) {
- val intent = if (context.resources.getBoolean(R.bool.useLoginV2)) {
- LoginActivity2.newIntent(context, loginConfig)
- } else {
- LoginActivity.newIntent(context, loginConfig)
+ val intent = when (features.loginVersion()) {
+ VectorFeatures.LoginVersion.V1 -> LoginActivity.newIntent(context, loginConfig)
+ VectorFeatures.LoginVersion.V2 -> LoginActivity2.newIntent(context, loginConfig)
}
intent.addFlags(flags)
context.startActivity(intent)
}
+ override fun loginSSORedirect(context: Context, data: Uri?) {
+ val intent = when (features.loginVersion()) {
+ VectorFeatures.LoginVersion.V1 -> LoginActivity.redirectIntent(context, data)
+ VectorFeatures.LoginVersion.V2 -> LoginActivity2.redirectIntent(context, data)
+ }
+ context.startActivity(intent)
+ }
+
+ override fun softLogout(context: Context) {
+ val intent = when (features.loginVersion()) {
+ VectorFeatures.LoginVersion.V1 -> SoftLogoutActivity.newIntent(context)
+ VectorFeatures.LoginVersion.V2 -> SoftLogoutActivity2.newIntent(context)
+ }
+ context.startActivity(intent)
+ }
+
override fun openRoom(context: Context, roomId: String, eventId: String?, buildTask: Boolean) {
if (sessionHolder.getSafeActiveSession()?.getRoom(roomId) == null) {
fatalError("Trying to open an unknown room $roomId", vectorPreferences.failFast())
diff --git a/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt b/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt
index 264593fe18..a1f40f07c0 100644
--- a/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt
+++ b/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt
@@ -19,6 +19,7 @@ package im.vector.app.features.navigation
import android.app.Activity
import android.content.Context
import android.content.Intent
+import android.net.Uri
import android.view.View
import androidx.activity.result.ActivityResultLauncher
import androidx.core.util.Pair
@@ -41,6 +42,10 @@ interface Navigator {
fun openLogin(context: Context, loginConfig: LoginConfig? = null, flags: Int = 0)
+ fun loginSSORedirect(context: Context, data: Uri?)
+
+ fun softLogout(context: Context)
+
fun openRoom(context: Context, roomId: String, eventId: String? = null, buildTask: Boolean = false)
sealed class PostSwitchSpaceAction {
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)
+ }
}
}
diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt
index 07cd9d6dac..6eb8d7c195 100755
--- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt
+++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt
@@ -47,6 +47,9 @@ class VectorPreferences @Inject constructor(private val context: Context) {
const val SETTINGS_DISCOVERY_PREFERENCE_KEY = "SETTINGS_DISCOVERY_PREFERENCE_KEY"
const val SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY = "SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY"
+ const val SETTINGS_NOTIFICATION_DEFAULT_PREFERENCE_KEY = "SETTINGS_NOTIFICATION_DEFAULT_PREFERENCE_KEY"
+ const val SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY = "SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY"
+ const val SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY = "SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY"
const val SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY = "SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY"
const val SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY = "SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY"
const val SETTINGS_COPYRIGHT_PREFERENCE_KEY = "SETTINGS_COPYRIGHT_PREFERENCE_KEY"
diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt
index 4199bd1753..3004d30913 100644
--- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt
+++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt
@@ -40,6 +40,7 @@ import im.vector.app.core.pushers.PushersManager
import im.vector.app.core.services.GuardServiceStarter
import im.vector.app.core.utils.isIgnoringBatteryOptimizations
import im.vector.app.core.utils.requestDisablingBatteryOptimization
+import im.vector.app.features.VectorFeatures
import im.vector.app.features.notifications.NotificationUtils
import im.vector.app.features.settings.BackgroundSyncMode
import im.vector.app.features.settings.BackgroundSyncModeChooserDialog
@@ -63,7 +64,8 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
private val pushManager: PushersManager,
private val activeSessionHolder: ActiveSessionHolder,
private val vectorPreferences: VectorPreferences,
- private val guardServiceStarter: GuardServiceStarter
+ private val guardServiceStarter: GuardServiceStarter,
+ private val features: VectorFeatures
) : VectorSettingsBaseFragment(),
BackgroundSyncModeChooserDialog.InteractionListener {
@@ -145,6 +147,7 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
refreshBackgroundSyncPrefs()
handleSystemPreference()
+ handleVersionedSettings()
}
private fun bindEmailNotifications() {
@@ -309,6 +312,15 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
}
}
+ private fun handleVersionedSettings() {
+ val isNotificationSettingsV2Enabled = features.notificationSettingsVersion() == VectorFeatures.NotificationSettingsVersion.V2
+
+ findPreference(VectorPreferences.SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY)?.isVisible = !isNotificationSettingsV2Enabled
+ findPreference(VectorPreferences.SETTINGS_NOTIFICATION_DEFAULT_PREFERENCE_KEY)?.isVisible = isNotificationSettingsV2Enabled
+ findPreference(VectorPreferences.SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY)?.isVisible = isNotificationSettingsV2Enabled
+ findPreference(VectorPreferences.SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY)?.isVisible = isNotificationSettingsV2Enabled
+ }
+
override fun onResume() {
super.onResume()
activeSessionHolder.getSafeActiveSession()?.refreshPushers()
diff --git a/vector/src/main/res/xml/vector_settings_notifications.xml b/vector/src/main/res/xml/vector_settings_notifications.xml
index 7d41bdbd86..154e7cca0d 100644
--- a/vector/src/main/res/xml/vector_settings_notifications.xml
+++ b/vector/src/main/res/xml/vector_settings_notifications.xml
@@ -26,38 +26,34 @@
android:persistent="false"
android:summary="@string/settings_notification_advanced_summary"
android:title="@string/settings_notification_advanced"
- app:fragment="im.vector.app.features.settings.notifications.VectorSettingsAdvancedNotificationPreferenceFragment"
- app:isPreferenceVisible="@bool/useNotificationSettingsV1" />
+ app:fragment="im.vector.app.features.settings.notifications.VectorSettingsAdvancedNotificationPreferenceFragment" />
+ app:fragment="im.vector.app.features.settings.notifications.VectorSettingsDefaultNotificationPreferenceFragment" />
+ app:fragment="im.vector.app.features.settings.notifications.VectorSettingsKeywordAndMentionsNotificationPreferenceFragment" />
+ app:fragment="im.vector.app.features.settings.notifications.VectorSettingsOtherNotificationPreferenceFragment" />
+ android:title="@string/settings_notification_emails_category" />