fix ordering of chips and align left for notification screens.
This commit is contained in:
parent
2598a67525
commit
be19f759f6
|
@ -34,23 +34,24 @@ class KeywordPreference : VectorPreference {
|
||||||
fun didRemoveKeyword(keyword: String)
|
fun didRemoveKeyword(keyword: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var keywordsEnabled = true
|
||||||
|
|
||||||
|
private var _keywords: LinkedHashSet<String> = linkedSetOf()
|
||||||
|
|
||||||
var keywords: Set<String>
|
var keywords: Set<String>
|
||||||
get() {
|
get() {
|
||||||
return _keywords
|
return _keywords
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
val newLinkedSet:LinkedHashSet<String> = linkedSetOf()
|
// Updates existing `LinkedHashSet` vs assign a new set.
|
||||||
newLinkedSet.addAll(value.sorted())
|
// This preserves the order added while on the screen (avoids keywords jumping around).
|
||||||
_keywords = newLinkedSet
|
_keywords.removeAll(_keywords.filter { !value.contains(it) })
|
||||||
|
_keywords.addAll(value.sorted())
|
||||||
notifyChanged()
|
notifyChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
var listener: Listener? = null
|
var listener: Listener? = null
|
||||||
|
|
||||||
var keywordsEnabled = true
|
|
||||||
|
|
||||||
private var _keywords: LinkedHashSet<String> = linkedSetOf()
|
|
||||||
|
|
||||||
constructor(context: Context) : super(context)
|
constructor(context: Context) : super(context)
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||||
|
|
|
@ -16,7 +16,10 @@
|
||||||
|
|
||||||
package im.vector.app.features.settings.notifications
|
package im.vector.app.features.settings.notifications
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceCategory
|
||||||
import im.vector.app.R
|
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
|
import org.matrix.android.sdk.api.pushrules.RuleIds
|
||||||
|
|
||||||
class VectorSettingsDefaultNotificationPreferenceFragment
|
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_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
|
"SETTINGS_PUSH_RULE_MESSAGES_IN_E2E_GROUP_CHAT_PREFERENCE_KEY" to RuleIds.RULE_ID_ENCRYPTED
|
||||||
)
|
)
|
||||||
|
|
||||||
|
override fun bindPref() {
|
||||||
|
super.bindPref()
|
||||||
|
val category = findPreference<VectorPreferenceCategory>("SETTINGS_DEFAULT")!!
|
||||||
|
category.isIconSpaceReserved = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ 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
|
||||||
import im.vector.app.core.preference.VectorCheckboxPreference
|
import im.vector.app.core.preference.VectorCheckboxPreference
|
||||||
|
import im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
import im.vector.app.core.utils.toast
|
import im.vector.app.core.utils.toast
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
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.RuleIds
|
||||||
import org.matrix.android.sdk.api.pushrules.RuleKind
|
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.PushRule
|
||||||
import org.matrix.android.sdk.api.pushrules.rest.PushRuleAndKind
|
|
||||||
import org.matrix.android.sdk.api.pushrules.toJson
|
import org.matrix.android.sdk.api.pushrules.toJson
|
||||||
import org.matrix.android.sdk.rx.rx
|
|
||||||
|
|
||||||
class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
|
class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
|
||||||
: VectorSettingsPushRuleNotificationPreferenceFragment() {
|
: VectorSettingsPushRuleNotificationPreferenceFragment() {
|
||||||
|
@ -49,10 +48,14 @@ class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
|
||||||
|
|
||||||
override fun bindPref() {
|
override fun bindPref() {
|
||||||
super.bindPref()
|
super.bindPref()
|
||||||
|
val mentionCategory = findPreference<VectorPreferenceCategory>("SETTINGS_KEYWORDS_AND_MENTIONS")!!
|
||||||
|
mentionCategory.isIconSpaceReserved = false
|
||||||
|
val yourKeywordsCategory = findPreference<VectorPreferenceCategory>("SETTINGS_YOUR_KEYWORDS")!!
|
||||||
|
yourKeywordsCategory.isIconSpaceReserved = false
|
||||||
val keywordRules = session.getPushRules().content?.filter { !it.ruleId.startsWith(".") }.orEmpty()
|
val keywordRules = session.getPushRules().content?.filter { !it.ruleId.startsWith(".") }.orEmpty()
|
||||||
val editKeywordPreference = findPreference<KeywordPreference>("SETTINGS_KEYWORD_EDIT")!!
|
val editKeywordPreference = findPreference<KeywordPreference>("SETTINGS_KEYWORD_EDIT")!!
|
||||||
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
|
||||||
val anyEnabledKeywords = keywordRules.any(PushRule::enabled)
|
val anyEnabledKeywords = keywordRules.any(PushRule::enabled)
|
||||||
keywordPreference.isChecked = anyEnabledKeywords
|
keywordPreference.isChecked = anyEnabledKeywords
|
||||||
editKeywordPreference.isEnabled = anyEnabledKeywords
|
editKeywordPreference.isEnabled = anyEnabledKeywords
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package im.vector.app.features.settings.notifications
|
package im.vector.app.features.settings.notifications
|
||||||
|
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
|
import im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
import org.matrix.android.sdk.api.pushrules.RuleIds
|
import org.matrix.android.sdk.api.pushrules.RuleIds
|
||||||
|
|
||||||
class VectorSettingsOtherNotificationPreferenceFragment
|
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_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY" to RuleIds.RULE_ID_SUPPRESS_BOTS_NOTIFICATIONS,
|
||||||
"SETTINGS_PUSH_RULE_ROOMS_UPGRADED_KEY" to RuleIds.RULE_ID_TOMBSTONE
|
"SETTINGS_PUSH_RULE_ROOMS_UPGRADED_KEY" to RuleIds.RULE_ID_TOMBSTONE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
override fun bindPref() {
|
||||||
|
super.bindPref()
|
||||||
|
val category = findPreference<VectorPreferenceCategory>("SETTINGS_OTHER")!!
|
||||||
|
category.isIconSpaceReserved = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ abstract class VectorSettingsPushRuleNotificationPreferenceFragment
|
||||||
override fun bindPref() {
|
override fun bindPref() {
|
||||||
for (preferenceKey in prefKeyToPushRuleId.keys) {
|
for (preferenceKey in prefKeyToPushRuleId.keys) {
|
||||||
val preference = findPreference<VectorCheckboxPreference>(preferenceKey)!!
|
val preference = findPreference<VectorCheckboxPreference>(preferenceKey)!!
|
||||||
|
preference.isIconSpaceReserved = false
|
||||||
val ruleAndKind: PushRuleAndKind? = session.getPushRules().findDefaultRule(prefKeyToPushRuleId[preferenceKey])
|
val ruleAndKind: PushRuleAndKind? = session.getPushRules().findDefaultRule(prefKeyToPushRuleId[preferenceKey])
|
||||||
if (ruleAndKind == null) {
|
if (ruleAndKind == null) {
|
||||||
// The rule is not defined, hide the preference
|
// The rule is not defined, hide the preference
|
||||||
|
|
|
@ -14,12 +14,11 @@
|
||||||
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||||
android:layout_marginEnd="@dimen/layout_horizontal_margin"
|
android:layout_marginEnd="@dimen/layout_horizontal_margin"
|
||||||
app:errorEnabled="false"
|
app:errorEnabled="false"
|
||||||
app:hintEnabled="true"
|
app:hintEnabled="false"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
app:placeholderText="@string/settings_notification_new_keyword">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/chipEditText"
|
android:id="@+id/chipEditText"
|
||||||
|
@ -28,7 +27,7 @@
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
android:hint="@string/settings_notification_your_keywords" />
|
android:hint="@string/settings_notification_new_keyword" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
|
|
@ -1093,7 +1093,7 @@
|
||||||
|
|
||||||
<string name="settings_notification_notify_me_for">Notify me for</string>
|
<string name="settings_notification_notify_me_for">Notify me for</string>
|
||||||
<string name="settings_notification_your_keywords">Your keywords</string>
|
<string name="settings_notification_your_keywords">Your keywords</string>
|
||||||
<string name="settings_notification_new_keyword">New keyword</string>
|
<string name="settings_notification_new_keyword">Add new keyword</string>
|
||||||
|
|
||||||
<string name="settings_notification_privacy">Notification privacy</string>
|
<string name="settings_notification_privacy">Notification privacy</string>
|
||||||
<string name="settings_notification_troubleshoot">Troubleshoot Notifications</string>
|
<string name="settings_notification_troubleshoot">Troubleshoot Notifications</string>
|
||||||
|
@ -1212,15 +1212,16 @@
|
||||||
<string name="settings_messages_in_group_chat">Msgs in group chats</string>
|
<string name="settings_messages_in_group_chat">Msgs in group chats</string>
|
||||||
<string name="settings_invited_to_room">When I’m invited to a room</string>
|
<string name="settings_invited_to_room">When I’m invited to a room</string>
|
||||||
<string name="settings_messages_sent_by_bot">Messages sent by bot</string>
|
<string name="settings_messages_sent_by_bot">Messages sent by bot</string>
|
||||||
|
<string name="settings_messages_at_room">Messages containing @room</string>
|
||||||
|
|
||||||
<string name="settings_messages_containing_display_name">Messages containing my display name</string>
|
<string name="settings_messages_containing_display_name">My display name</string>
|
||||||
<string name="settings_messages_containing_username">Messages containing my username</string>
|
<string name="settings_messages_containing_username">My username</string>
|
||||||
<string name="settings_messages_direct_messages">Direct messages</string>
|
<string name="settings_messages_direct_messages">Direct messages</string>
|
||||||
<string name="settings_encrypted_direct_messages">Encrypted direct messages</string>
|
<string name="settings_encrypted_direct_messages">Encrypted direct messages</string>
|
||||||
<string name="settings_group_messages">Group messages</string>
|
<string name="settings_group_messages">Group messages</string>
|
||||||
<string name="settings_encrypted_group_messages">Encrypted group messages</string>
|
<string name="settings_encrypted_group_messages">Encrypted group messages</string>
|
||||||
<string name="settings_messages_at_room">Messages containing @room</string>
|
<string name="settings_mentions_at_room">\@room</string>
|
||||||
<string name="settings_messages_containing_keywords">Messages containing keywords</string>
|
<string name="settings_messages_containing_keywords">Keywords</string>
|
||||||
<string name="settings_room_invitations">Room invitations</string>
|
<string name="settings_room_invitations">Room invitations</string>
|
||||||
<string name="settings_call_invitations">Call invitations</string>
|
<string name="settings_call_invitations">Call invitations</string>
|
||||||
<string name="settings_messages_by_bot">Messages by bot</string>
|
<string name="settings_messages_by_bot">Messages by bot</string>
|
||||||
|
|
|
@ -14,12 +14,16 @@
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorCheckboxPreference
|
<im.vector.app.core.preference.VectorCheckboxPreference
|
||||||
android:key="SETTINGS_PUSH_RULE_MESSAGES_CONTAINING_AT_ROOM_PREFERENCE_KEY"
|
android:key="SETTINGS_PUSH_RULE_MESSAGES_CONTAINING_AT_ROOM_PREFERENCE_KEY"
|
||||||
android:title="@string/settings_messages_at_room" />
|
android:title="@string/settings_mentions_at_room" />
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorCheckboxPreference
|
<im.vector.app.core.preference.VectorCheckboxPreference
|
||||||
android:key="SETTINGS_PUSH_RULE_MESSAGES_CONTAINING_KEYWORDS_PREFERENCE_KEY"
|
android:key="SETTINGS_PUSH_RULE_MESSAGES_CONTAINING_KEYWORDS_PREFERENCE_KEY"
|
||||||
android:title="@string/settings_messages_containing_keywords" />
|
android:title="@string/settings_messages_containing_keywords" />
|
||||||
|
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorPreferenceCategory
|
||||||
|
android:key="SETTINGS_YOUR_KEYWORDS"
|
||||||
|
android:title="@string/settings_notification_your_keywords">
|
||||||
<im.vector.app.core.preference.KeywordPreference
|
<im.vector.app.core.preference.KeywordPreference
|
||||||
android:key="SETTINGS_KEYWORD_EDIT"
|
android:key="SETTINGS_KEYWORD_EDIT"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue