lint
This commit is contained in:
parent
3481fc70c7
commit
fb8c7f6be0
|
@ -16,7 +16,6 @@
|
|||
package org.matrix.android.sdk.internal.session.pushers
|
||||
|
||||
import org.matrix.android.sdk.api.pushrules.RuleKind
|
||||
import org.matrix.android.sdk.api.pushrules.rest.PushRule
|
||||
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
||||
import org.matrix.android.sdk.internal.network.executeRequest
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
|
|
|
@ -92,7 +92,7 @@ class KeywordPreference : VectorPreference {
|
|||
return@setOnEditorActionListener false
|
||||
}
|
||||
val keyword = chipEditText.text.toString().trim()
|
||||
if (keyword.isEmpty()){
|
||||
if (keyword.isEmpty()) {
|
||||
return@setOnEditorActionListener false
|
||||
}
|
||||
_keywords.add(keyword)
|
||||
|
@ -102,7 +102,6 @@ class KeywordPreference : VectorPreference {
|
|||
chipEditText.text = null
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun addChipToGroup(keyword: String, chipGroup: ChipGroup) {
|
||||
|
@ -114,8 +113,9 @@ class KeywordPreference : VectorPreference {
|
|||
chipGroup.addView(chip)
|
||||
|
||||
chip.setOnCloseIconClickListener {
|
||||
if (!keywordsEnabled)
|
||||
if (!keywordsEnabled) {
|
||||
return@setOnCloseIconClickListener
|
||||
}
|
||||
_keywords.remove(keyword)
|
||||
listener?.didRemoveKeyword(keyword)
|
||||
onPreferenceChangeListener?.onPreferenceChange(this, _keywords)
|
||||
|
|
|
@ -87,7 +87,7 @@ fun getStandardAction(ruleId: String, index: NotificationIndex): StandardActions
|
|||
NotificationIndex.NOISY -> StandardActions.Highlight
|
||||
}
|
||||
RuleIds.RULE_ID_KEYWORDS ->
|
||||
when(index) {
|
||||
when (index) {
|
||||
NotificationIndex.OFF -> StandardActions.Disabled
|
||||
NotificationIndex.SILENT -> StandardActions.Notify
|
||||
NotificationIndex.NOISY -> StandardActions.HighlightDefaultSound
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
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
|
||||
|
||||
|
|
|
@ -23,6 +23,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.VectorPreference
|
||||
import im.vector.app.core.preference.VectorPreferenceCategory
|
||||
import im.vector.app.core.utils.toast
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -63,11 +64,14 @@ class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
|
|||
keywordPreference.isIconSpaceReserved = false
|
||||
keywordPreference.isChecked = anyEnabledKeywords
|
||||
|
||||
val footerPreference = findPreference<VectorPreference>("SETTINGS_KEYWORDS_FOOTER")!!
|
||||
footerPreference.isIconSpaceReserved = false
|
||||
|
||||
keywordPreference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
val keywords = editKeywordPreference.keywords
|
||||
val newChecked = newValue as Boolean
|
||||
displayLoadingView()
|
||||
updateKeywordPushRules(keywords, newChecked){ result ->
|
||||
updateKeywordPushRules(keywords, newChecked) { result ->
|
||||
hideLoadingView()
|
||||
if (!isAdded) {
|
||||
return@updateKeywordPushRules
|
||||
|
@ -95,7 +99,6 @@ class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
|
|||
scrollToPreference(editKeywordPreference)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun updateKeywordPushRules(keywords: Set<String>, checked: Boolean, completion: (Result<Unit>) -> Unit) {
|
||||
|
@ -116,7 +119,7 @@ class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
|
|||
}
|
||||
}
|
||||
val firstError = results.firstNotNullOfOrNull(Result<Unit>::exceptionOrNull)
|
||||
if (firstError == null){
|
||||
if (firstError == null) {
|
||||
completion(Result.success(Unit))
|
||||
} else {
|
||||
completion(Result.failure(firstError))
|
||||
|
@ -124,7 +127,7 @@ class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment
|
|||
}
|
||||
}
|
||||
|
||||
fun updateWithKeywords (keywords: Set<String>) {
|
||||
fun updateWithKeywords(keywords: Set<String>) {
|
||||
val editKeywordPreference = findPreference<KeywordPreference>("SETTINGS_KEYWORD_EDIT") ?: return
|
||||
editKeywordPreference.keywords = keywords
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ abstract class VectorSettingsPushRuleNotificationPreferenceFragment
|
|||
val initialIndex = ruleAndKind.pushRule.notificationIndex
|
||||
preference.isChecked = initialIndex != NotificationIndex.OFF
|
||||
preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
updatePushRule(ruleAndKind.pushRule.ruleId, ruleAndKind.kind,newValue as Boolean, preference)
|
||||
updatePushRule(ruleAndKind.pushRule.ruleId, ruleAndKind.kind, newValue as Boolean, preference)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||
android:layout_marginEnd="@dimen/layout_horizontal_margin"
|
||||
app:chipSpacing="12dp"
|
||||
app:lineSpacing="2dp"/>
|
||||
android:paddingTop="16dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -1227,6 +1227,7 @@
|
|||
<string name="settings_call_invitations">Call invitations</string>
|
||||
<string name="settings_messages_by_bot">Messages by bot</string>
|
||||
<string name="settings_room_upgrades">Room upgrades</string>
|
||||
<string name="settings_mentions_and_keywords_encryption_notice">You won’t get notifications for mentions & keywords in encrypted rooms on mobile.</string>
|
||||
|
||||
<string name="settings_background_sync">Background synchronization</string>
|
||||
<string name="settings_background_fdroid_sync_mode">Background Sync Mode</string>
|
||||
|
|
|
@ -28,5 +28,10 @@
|
|||
android:key="SETTINGS_KEYWORD_EDIT"
|
||||
/>
|
||||
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:key="SETTINGS_KEYWORDS_FOOTER"
|
||||
android:focusable="false"
|
||||
android:summary="@string/settings_mentions_and_keywords_encryption_notice" />
|
||||
|
||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue