removing boolean notification version usage

This commit is contained in:
Adam Brown 2021-12-03 15:58:18 +00:00
parent 8a0fe41b80
commit db406704c9
3 changed files with 23 additions and 12 deletions

View File

@ -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_DISCOVERY_PREFERENCE_KEY = "SETTINGS_DISCOVERY_PREFERENCE_KEY"
const val SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY = "SETTINGS_NOTIFICATION_ADVANCED_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_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_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY = "SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY"
const val SETTINGS_COPYRIGHT_PREFERENCE_KEY = "SETTINGS_COPYRIGHT_PREFERENCE_KEY" const val SETTINGS_COPYRIGHT_PREFERENCE_KEY = "SETTINGS_COPYRIGHT_PREFERENCE_KEY"

View File

@ -40,6 +40,7 @@ import im.vector.app.core.pushers.PushersManager
import im.vector.app.core.services.GuardServiceStarter import im.vector.app.core.services.GuardServiceStarter
import im.vector.app.core.utils.isIgnoringBatteryOptimizations import im.vector.app.core.utils.isIgnoringBatteryOptimizations
import im.vector.app.core.utils.requestDisablingBatteryOptimization 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.notifications.NotificationUtils
import im.vector.app.features.settings.BackgroundSyncMode import im.vector.app.features.settings.BackgroundSyncMode
import im.vector.app.features.settings.BackgroundSyncModeChooserDialog import im.vector.app.features.settings.BackgroundSyncModeChooserDialog
@ -63,7 +64,8 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
private val pushManager: PushersManager, private val pushManager: PushersManager,
private val activeSessionHolder: ActiveSessionHolder, private val activeSessionHolder: ActiveSessionHolder,
private val vectorPreferences: VectorPreferences, private val vectorPreferences: VectorPreferences,
private val guardServiceStarter: GuardServiceStarter private val guardServiceStarter: GuardServiceStarter,
private val features: VectorFeatures
) : VectorSettingsBaseFragment(), ) : VectorSettingsBaseFragment(),
BackgroundSyncModeChooserDialog.InteractionListener { BackgroundSyncModeChooserDialog.InteractionListener {
@ -145,6 +147,7 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
refreshBackgroundSyncPrefs() refreshBackgroundSyncPrefs()
handleSystemPreference() handleSystemPreference()
handleVersionedSettings()
} }
private fun bindEmailNotifications() { private fun bindEmailNotifications() {
@ -309,6 +312,15 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
} }
} }
private fun handleVersionedSettings() {
val isNotificationSettingsV2Enabled = features.notificationSettingsVersion() == VectorFeatures.NotificationSettingsVersion.V2
findPreference<Preference>(VectorPreferences.SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY)?.isVisible = !isNotificationSettingsV2Enabled
findPreference<Preference>(VectorPreferences.SETTINGS_NOTIFICATION_DEFAULT_PREFERENCE_KEY)?.isVisible = isNotificationSettingsV2Enabled
findPreference<Preference>(VectorPreferences.SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY)?.isVisible = isNotificationSettingsV2Enabled
findPreference<Preference>(VectorPreferences.SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY)?.isVisible = isNotificationSettingsV2Enabled
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
activeSessionHolder.getSafeActiveSession()?.refreshPushers() activeSessionHolder.getSafeActiveSession()?.refreshPushers()

View File

@ -26,38 +26,34 @@
android:persistent="false" android:persistent="false"
android:summary="@string/settings_notification_advanced_summary" android:summary="@string/settings_notification_advanced_summary"
android:title="@string/settings_notification_advanced" android:title="@string/settings_notification_advanced"
app:fragment="im.vector.app.features.settings.notifications.VectorSettingsAdvancedNotificationPreferenceFragment" app:fragment="im.vector.app.features.settings.notifications.VectorSettingsAdvancedNotificationPreferenceFragment" />
app:isPreferenceVisible="@bool/useNotificationSettingsV1" />
<im.vector.app.core.preference.VectorPreference <im.vector.app.core.preference.VectorPreference
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY" android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
android:key="SETTINGS_NOTIFICATION_DEFAULT_PREFERENCE_KEY" android:key="SETTINGS_NOTIFICATION_DEFAULT_PREFERENCE_KEY"
android:persistent="false" android:persistent="false"
android:title="@string/settings_notification_default" android:title="@string/settings_notification_default"
app:fragment="im.vector.app.features.settings.notifications.VectorSettingsDefaultNotificationPreferenceFragment" app:fragment="im.vector.app.features.settings.notifications.VectorSettingsDefaultNotificationPreferenceFragment" />
app:isPreferenceVisible="@bool/useNotificationSettingsV2"/>
<im.vector.app.core.preference.VectorPreference <im.vector.app.core.preference.VectorPreference
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY" android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
android:key="SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY" android:key="SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY"
android:persistent="false" android:persistent="false"
android:title="@string/settings_notification_mentions_and_keywords" android:title="@string/settings_notification_mentions_and_keywords"
app:fragment="im.vector.app.features.settings.notifications.VectorSettingsKeywordAndMentionsNotificationPreferenceFragment" app:fragment="im.vector.app.features.settings.notifications.VectorSettingsKeywordAndMentionsNotificationPreferenceFragment" />
app:isPreferenceVisible="@bool/useNotificationSettingsV2"/>
<im.vector.app.core.preference.VectorPreference <im.vector.app.core.preference.VectorPreference
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY" android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
android:key="SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY" android:key="SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY"
android:persistent="false" android:persistent="false"
android:title="@string/settings_notification_other" android:title="@string/settings_notification_other"
app:fragment="im.vector.app.features.settings.notifications.VectorSettingsOtherNotificationPreferenceFragment" app:fragment="im.vector.app.features.settings.notifications.VectorSettingsOtherNotificationPreferenceFragment" />
app:isPreferenceVisible="@bool/useNotificationSettingsV2"/>
</im.vector.app.core.preference.VectorPreferenceCategory> </im.vector.app.core.preference.VectorPreferenceCategory>
<im.vector.app.core.preference.VectorPreferenceCategory <im.vector.app.core.preference.VectorPreferenceCategory
android:key="SETTINGS_EMAIL_NOTIFICATION_CATEGORY_PREFERENCE_KEY" android:key="SETTINGS_EMAIL_NOTIFICATION_CATEGORY_PREFERENCE_KEY"
android:title="@string/settings_notification_emails_category"/> android:title="@string/settings_notification_emails_category" />
<im.vector.app.core.preference.VectorPreferenceCategory <im.vector.app.core.preference.VectorPreferenceCategory
android:persistent="false" android:persistent="false"
@ -103,14 +99,14 @@
<im.vector.app.core.preference.VectorEditTextPreference <im.vector.app.core.preference.VectorEditTextPreference
android:inputType="numberDecimal" android:inputType="numberDecimal"
android:persistent="false"
android:key="SETTINGS_SET_SYNC_DELAY_PREFERENCE_KEY" android:key="SETTINGS_SET_SYNC_DELAY_PREFERENCE_KEY"
android:persistent="false"
android:title="@string/settings_set_sync_delay" /> android:title="@string/settings_set_sync_delay" />
<im.vector.app.core.preference.VectorEditTextPreference <im.vector.app.core.preference.VectorEditTextPreference
android:inputType="numberDecimal" android:inputType="numberDecimal"
android:persistent="false"
android:key="SETTINGS_SET_SYNC_TIMEOUT_PREFERENCE_KEY" android:key="SETTINGS_SET_SYNC_TIMEOUT_PREFERENCE_KEY"
android:persistent="false"
android:title="@string/settings_set_sync_timeout" /> android:title="@string/settings_set_sync_timeout" />
<im.vector.app.core.preference.VectorSwitchPreference <im.vector.app.core.preference.VectorSwitchPreference