-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/ons/delabs_voice_message
- Loading branch information
Showing
23 changed files
with
478 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Reorganise Advanced Notifications in to Default Notifications, Keywords and Mentions, Other (This feature is hidden in the release ui until a future release date.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Voice Message - UI Improvements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
vector/src/main/java/im/vector/app/core/preference/VectorCheckboxPreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2021 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.core.preference | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.widget.TextView | ||
import androidx.preference.CheckBoxPreference | ||
import androidx.preference.PreferenceViewHolder | ||
|
||
class VectorCheckboxPreference : CheckBoxPreference { | ||
// Note: @JvmOverload does not work here... | ||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) | ||
|
||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) | ||
|
||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) | ||
|
||
constructor(context: Context) : super(context) | ||
|
||
init { | ||
// Set to false to remove the space when there is no icon | ||
isIconSpaceReserved = true | ||
} | ||
|
||
override fun onBindViewHolder(holder: PreferenceViewHolder) { | ||
// display the title in multi-line to avoid ellipsis. | ||
(holder.findViewById(android.R.id.title) as? TextView)?.isSingleLine = false | ||
super.onBindViewHolder(holder) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
vector/src/main/java/im/vector/app/features/settings/notifications/NotificationIndex.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2021 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.settings.notifications | ||
|
||
import org.matrix.android.sdk.api.pushrules.rest.PushRule | ||
import org.matrix.android.sdk.api.pushrules.toJson | ||
|
||
enum class NotificationIndex { | ||
OFF, | ||
SILENT, | ||
NOISY; | ||
} | ||
|
||
/** | ||
* Given a push rule determine the NotificationIndex by comparing it to the static push rule definitions. | ||
* Used when determining the selected state of the PushRulePreference. | ||
*/ | ||
val PushRule.notificationIndex: NotificationIndex? get() = | ||
NotificationIndex.values().firstOrNull { | ||
// Get the actions for the index | ||
val standardAction = getStandardAction(this.ruleId, it) ?: return@firstOrNull false | ||
val indexActions = standardAction.actions ?: listOf() | ||
// Check if the input rule matches a rule generated from the static rule definitions | ||
val targetRule = this.copy(enabled = standardAction != StandardActions.Disabled, actions = indexActions.toJson()) | ||
ruleMatches(this, targetRule) | ||
} | ||
|
||
/** | ||
* A check to determine if two push rules should be considered a match. | ||
*/ | ||
private fun ruleMatches(rule: PushRule, targetRule: PushRule): Boolean { | ||
// Rules match if both are disabled, or if both are enabled and their highlight/sound/notify actions match up. | ||
return (!rule.enabled && !targetRule.enabled) | ||
|| (rule.enabled | ||
&& targetRule.enabled | ||
&& rule.getHighlight() == targetRule.getHighlight() | ||
&& rule.getNotificationSound() == targetRule.getNotificationSound() | ||
&& rule.shouldNotify() == targetRule.shouldNotify() | ||
&& rule.shouldNotNotify() == targetRule.shouldNotNotify()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.