Cleanup and fix resValue

This commit is contained in:
David Langley 2021-08-24 16:49:18 +01:00
parent 238f772461
commit 3481fc70c7
4 changed files with 10 additions and 10 deletions

View File

@ -216,6 +216,7 @@ internal class DefaultPushRuleService @Inject constructor(
} }
override fun getKeywords(): LiveData<Set<String>> { override fun getKeywords(): LiveData<Set<String>> {
// Keywords are all content rules that don't start with '.'
val liveData = monarchy.findAllMappedWithChanges( val liveData = monarchy.findAllMappedWithChanges(
{ realm -> { realm ->
PushRulesEntity.where(realm, RuleScope.GLOBAL, RuleSetKey.CONTENT) PushRulesEntity.where(realm, RuleScope.GLOBAL, RuleSetKey.CONTENT)

View File

@ -143,8 +143,8 @@ android {
resValue "bool", "useLoginV2", "false" resValue "bool", "useLoginV2", "false"
// NotificationSettingsV2 is disabled. To be released in conjunction with iOS/Web // NotificationSettingsV2 is disabled. To be released in conjunction with iOS/Web
resValue "bool", "useNotificationSettingsV1", "false" resValue "bool", "useNotificationSettingsV1", "true"
resValue "bool", "useNotificationSettingsV2", "true" resValue "bool", "useNotificationSettingsV2", "false"
buildConfigField "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy", "outboundSessionKeySharingStrategy", "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy.WhenTyping" buildConfigField "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy", "outboundSessionKeySharingStrategy", "im.vector.app.features.crypto.keysrequest.OutboundSessionKeySharingStrategy.WhenTyping"

View File

@ -25,7 +25,6 @@ import androidx.preference.PreferenceViewHolder
import com.google.android.material.chip.Chip import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup import com.google.android.material.chip.ChipGroup
import im.vector.app.R import im.vector.app.R
import java.util.SortedSet
class KeywordPreference : VectorPreference { class KeywordPreference : VectorPreference {
@ -112,7 +111,6 @@ class KeywordPreference : VectorPreference {
chip.isClickable = true chip.isClickable = true
chip.isCheckable = false chip.isCheckable = false
chip.isCloseIconVisible = true chip.isCloseIconVisible = true
chip.clipBounds
chipGroup.addView(chip) chipGroup.addView(chip)
chip.setOnCloseIconClickListener { chip.setOnCloseIconClickListener {

View File

@ -19,7 +19,6 @@ package im.vector.app.features.settings.notifications
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.CheckBoxPreference
import androidx.preference.Preference import androidx.preference.Preference
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.preference.KeywordPreference import im.vector.app.core.preference.KeywordPreference
@ -50,20 +49,24 @@ class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
super.bindPref() super.bindPref()
val mentionCategory = findPreference<VectorPreferenceCategory>("SETTINGS_KEYWORDS_AND_MENTIONS")!! val mentionCategory = findPreference<VectorPreferenceCategory>("SETTINGS_KEYWORDS_AND_MENTIONS")!!
mentionCategory.isIconSpaceReserved = false mentionCategory.isIconSpaceReserved = false
val yourKeywordsCategory = findPreference<VectorPreferenceCategory>("SETTINGS_YOUR_KEYWORDS")!! val yourKeywordsCategory = findPreference<VectorPreferenceCategory>("SETTINGS_YOUR_KEYWORDS")!!
yourKeywordsCategory.isIconSpaceReserved = false yourKeywordsCategory.isIconSpaceReserved = false
val keywordRules = session.getPushRules().content?.filter { !it.ruleId.startsWith(".") }.orEmpty() val keywordRules = session.getPushRules().content?.filter { !it.ruleId.startsWith(".") }.orEmpty()
val anyEnabledKeywords = keywordRules.any(PushRule::enabled)
val editKeywordPreference = findPreference<KeywordPreference>("SETTINGS_KEYWORD_EDIT")!! val editKeywordPreference = findPreference<KeywordPreference>("SETTINGS_KEYWORD_EDIT")!!
editKeywordPreference.isEnabled = anyEnabledKeywords
val keywordPreference = findPreference<VectorCheckboxPreference>("SETTINGS_PUSH_RULE_MESSAGES_CONTAINING_KEYWORDS_PREFERENCE_KEY")!! val keywordPreference = findPreference<VectorCheckboxPreference>("SETTINGS_PUSH_RULE_MESSAGES_CONTAINING_KEYWORDS_PREFERENCE_KEY")!!
keywordPreference.isIconSpaceReserved = false keywordPreference.isIconSpaceReserved = false
val anyEnabledKeywords = keywordRules.any(PushRule::enabled)
keywordPreference.isChecked = anyEnabledKeywords keywordPreference.isChecked = anyEnabledKeywords
editKeywordPreference.isEnabled = anyEnabledKeywords
keywordPreference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> keywordPreference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
val keywords = editKeywordPreference.keywords val keywords = editKeywordPreference.keywords
val newChecked = newValue as Boolean val newChecked = newValue as Boolean
displayLoadingView() displayLoadingView()
session.getKeywords()
updateKeywordPushRules(keywords, newChecked){ result -> updateKeywordPushRules(keywords, newChecked){ result ->
hideLoadingView() hideLoadingView()
if (!isAdded) { if (!isAdded) {
@ -81,8 +84,6 @@ class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
false false
} }
editKeywordPreference.keywords = session.getKeywords().value.orEmpty()
editKeywordPreference.listener = object: KeywordPreference.Listener { editKeywordPreference.listener = object: KeywordPreference.Listener {
override fun didAddKeyword(keyword: String) { override fun didAddKeyword(keyword: String) {
addKeyword(keyword) addKeyword(keyword)