diff --git a/vector/src/main/java/im/vector/app/core/preference/KeywordPreference.kt b/vector/src/main/java/im/vector/app/core/preference/KeywordPreference.kt index 7355263897..a1a4fb5738 100644 --- a/vector/src/main/java/im/vector/app/core/preference/KeywordPreference.kt +++ b/vector/src/main/java/im/vector/app/core/preference/KeywordPreference.kt @@ -34,23 +34,24 @@ class KeywordPreference : VectorPreference { fun didRemoveKeyword(keyword: String) } + private var keywordsEnabled = true + + private var _keywords: LinkedHashSet = linkedSetOf() + var keywords: Set get() { return _keywords } set(value) { - val newLinkedSet:LinkedHashSet = linkedSetOf() - newLinkedSet.addAll(value.sorted()) - _keywords = newLinkedSet + // Updates existing `LinkedHashSet` vs assign a new set. + // This preserves the order added while on the screen (avoids keywords jumping around). + _keywords.removeAll(_keywords.filter { !value.contains(it) }) + _keywords.addAll(value.sorted()) notifyChanged() } var listener: Listener? = null - var keywordsEnabled = true - - private var _keywords: LinkedHashSet = linkedSetOf() - constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet) : super(context, attrs) diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsDefaultNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsDefaultNotificationPreferenceFragment.kt index 7d6b74b093..777cd0b2d1 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsDefaultNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsDefaultNotificationPreferenceFragment.kt @@ -16,7 +16,10 @@ package im.vector.app.features.settings.notifications +import androidx.preference.PreferenceCategory import im.vector.app.R +import im.vector.app.core.preference.VectorCheckboxPreference +import im.vector.app.core.preference.VectorPreferenceCategory import org.matrix.android.sdk.api.pushrules.RuleIds class VectorSettingsDefaultNotificationPreferenceFragment @@ -32,4 +35,10 @@ class VectorSettingsDefaultNotificationPreferenceFragment "SETTINGS_PUSH_RULE_MESSAGES_IN_E2E_ONE_ONE_CHAT_PREFERENCE_KEY" to RuleIds.RULE_ID_ONE_TO_ONE_ENCRYPTED_ROOM, "SETTINGS_PUSH_RULE_MESSAGES_IN_E2E_GROUP_CHAT_PREFERENCE_KEY" to RuleIds.RULE_ID_ENCRYPTED ) + + override fun bindPref() { + super.bindPref() + val category = findPreference("SETTINGS_DEFAULT")!! + category.isIconSpaceReserved = false + } } diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsKeywordAndMentionsNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsKeywordAndMentionsNotificationPreferenceFragment.kt index dfb99266eb..580c546293 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsKeywordAndMentionsNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsKeywordAndMentionsNotificationPreferenceFragment.kt @@ -24,6 +24,7 @@ import androidx.preference.Preference import im.vector.app.R import im.vector.app.core.preference.KeywordPreference import im.vector.app.core.preference.VectorCheckboxPreference +import im.vector.app.core.preference.VectorPreferenceCategory import im.vector.app.core.utils.toast import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -31,9 +32,7 @@ import kotlinx.coroutines.withContext import org.matrix.android.sdk.api.pushrules.RuleIds import org.matrix.android.sdk.api.pushrules.RuleKind import org.matrix.android.sdk.api.pushrules.rest.PushRule -import org.matrix.android.sdk.api.pushrules.rest.PushRuleAndKind import org.matrix.android.sdk.api.pushrules.toJson -import org.matrix.android.sdk.rx.rx class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment : VectorSettingsPushRuleNotificationPreferenceFragment() { @@ -49,10 +48,14 @@ class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment override fun bindPref() { super.bindPref() + val mentionCategory = findPreference("SETTINGS_KEYWORDS_AND_MENTIONS")!! + mentionCategory.isIconSpaceReserved = false + val yourKeywordsCategory = findPreference("SETTINGS_YOUR_KEYWORDS")!! + yourKeywordsCategory.isIconSpaceReserved = false val keywordRules = session.getPushRules().content?.filter { !it.ruleId.startsWith(".") }.orEmpty() val editKeywordPreference = findPreference("SETTINGS_KEYWORD_EDIT")!! val keywordPreference = findPreference("SETTINGS_PUSH_RULE_MESSAGES_CONTAINING_KEYWORDS_PREFERENCE_KEY")!! - + keywordPreference.isIconSpaceReserved = false val anyEnabledKeywords = keywordRules.any(PushRule::enabled) keywordPreference.isChecked = anyEnabledKeywords editKeywordPreference.isEnabled = anyEnabledKeywords diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsOtherNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsOtherNotificationPreferenceFragment.kt index 42203fb613..2e083a7d65 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsOtherNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsOtherNotificationPreferenceFragment.kt @@ -17,6 +17,7 @@ package im.vector.app.features.settings.notifications import im.vector.app.R +import im.vector.app.core.preference.VectorPreferenceCategory import org.matrix.android.sdk.api.pushrules.RuleIds class VectorSettingsOtherNotificationPreferenceFragment @@ -32,4 +33,10 @@ class VectorSettingsOtherNotificationPreferenceFragment "SETTINGS_PUSH_RULE_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY" to RuleIds.RULE_ID_SUPPRESS_BOTS_NOTIFICATIONS, "SETTINGS_PUSH_RULE_ROOMS_UPGRADED_KEY" to RuleIds.RULE_ID_TOMBSTONE ) + + override fun bindPref() { + super.bindPref() + val category = findPreference("SETTINGS_OTHER")!! + category.isIconSpaceReserved = false + } } diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsPushRuleNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsPushRuleNotificationPreferenceFragment.kt index 618c3ce06a..5d75250c09 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsPushRuleNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsPushRuleNotificationPreferenceFragment.kt @@ -96,6 +96,7 @@ abstract class VectorSettingsPushRuleNotificationPreferenceFragment override fun bindPref() { for (preferenceKey in prefKeyToPushRuleId.keys) { val preference = findPreference(preferenceKey)!! + preference.isIconSpaceReserved = false val ruleAndKind: PushRuleAndKind? = session.getPushRules().findDefaultRule(prefKeyToPushRuleId[preferenceKey]) if (ruleAndKind == null) { // The rule is not defined, hide the preference diff --git a/vector/src/main/res/layout/vector_preference_chip_group.xml b/vector/src/main/res/layout/vector_preference_chip_group.xml index 0c1d72e96c..7799d95f0a 100644 --- a/vector/src/main/res/layout/vector_preference_chip_group.xml +++ b/vector/src/main/res/layout/vector_preference_chip_group.xml @@ -14,12 +14,11 @@ android:layout_marginStart="@dimen/layout_horizontal_margin" android:layout_marginEnd="@dimen/layout_horizontal_margin" app:errorEnabled="false" - app:hintEnabled="true" + app:hintEnabled="false" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:placeholderText="@string/settings_notification_new_keyword"> + app:layout_constraintTop_toTopOf="parent"> + android:hint="@string/settings_notification_new_keyword" /> diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 12946dfde5..16dd1e5265 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1093,7 +1093,7 @@ Notify me for Your keywords - New keyword + Add new keyword Notification privacy Troubleshoot Notifications @@ -1212,15 +1212,16 @@ Msgs in group chats When I’m invited to a room Messages sent by bot + Messages containing @room - Messages containing my display name - Messages containing my username + My display name + My username Direct messages Encrypted direct messages Group messages Encrypted group messages - Messages containing @room - Messages containing keywords + \@room + Keywords Room invitations Call invitations Messages by bot diff --git a/vector/src/main/res/xml/vector_settings_notification_mentions_and_keywords.xml b/vector/src/main/res/xml/vector_settings_notification_mentions_and_keywords.xml index c5fb14d779..fd81d74755 100644 --- a/vector/src/main/res/xml/vector_settings_notification_mentions_and_keywords.xml +++ b/vector/src/main/res/xml/vector_settings_notification_mentions_and_keywords.xml @@ -14,12 +14,16 @@ + android:title="@string/settings_mentions_at_room" /> + +