Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganise Account Notification Settings #3673

Merged
merged 15 commits into from
Aug 11, 2021

Conversation

langleyd
Copy link
Member

@langleyd langleyd commented Jul 14, 2021

Implements feature #3646

screenshots

Account Settings > Notifications
image
Default Notifications
image
Mentions and Keywords
image
Other
image

notes

  • Kept the existing settings architecture (VectorSettingsBaseFragment, VectorPreference VectorPreferenceCategory, etc). Changing the architecture to ViewModels etc I think would be out of the scope of this PR.
  • Introduced VectorSwitchPreference to replace PushRulePreference and moved all business logic to the fragment level.
  • Removing an option (Silent) allowed us to simplify the business logic somewhat but kept implementation functionally equivalent to previous.
  • Found some bugs/discrepancies with web(not regressions, they occur in develop), that I will fix as a part of Changing Account Settings > Notifications > Advanced Notifications on android causes discrepancies with web #3672.
  • Introduced build time resVal to hide V2 until we are ready to introduce this new UI.
  • Ran contributing steps/checks
  • Update Global Notifications to Default Notifications on design's advice

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, IDK why vector/src/main/java/im/vector/app/core/preference/PushRulePreference.kt was executable :/

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT, some small remarks, but nothing terrific. Thanks!

import androidx.preference.CheckBoxPreference
import androidx.preference.PreferenceViewHolder

open class VectorCheckboxPreference : CheckBoxPreference {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class does not have to be open. It does not have to be sealed as well, but let's keep the default Kotlin behavior (so seal) unless we have to extend the class.

override val preferenceXmlRes = R.xml.vector_settings_notification_global

override val prefKeyToPushRuleId: Map<String, String>
get() = mapOf(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be simplified with override val prefKeyToPushRuleId = mapOf(

get() = mapOf(
"SETTINGS_PUSH_RULE_INVITED_TO_ROOM_PREFERENCE_KEY" to RuleIds.RULE_ID_INVITE_ME,
"SETTINGS_PUSH_RULE_CALL_INVITATIONS_PREFERENCE_KEY" to RuleIds.RULE_ID_CALL,
"SETTINGS_PUSH_RULE_MESSAGES_SENT_BY_BOT_PREFERENCE_KEY" to RuleIds.RULE_ID_SUPPRESS_BOTS_NOTIFICATIONS,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm scared about the suppress wording here. So it mean that the check box has the opposite behavior? I know it's in the spec... EDIT: the UI seems to uncheck the box by default, so I guess it's working correctly.

/**
* @return the bing rule status boolean
*/
fun ruleStatusIndexFor(ruleAndKind: PushRuleAndKind): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make all the fun private where it's possible, default visibility is public in Kotlin

<string name="settings_messages_at_room">Messages containing @room</string>
<string name="settings_messages_in_e2e_one_to_one">Encrypted messages in one-to-one chats</string>
<string name="settings_messages_in_e2e_group_chat">Encrypted messages in group chats</string>
<string name="settings_when_rooms_are_upgraded">When rooms are upgraded</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint will complain that we have translation but not original string. So either remove all the existing translations or keep the original string and we do the cleanup in the strings from time to time.
I would go for the first option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, actually those strings has just been moved above. Please ignore my comment

<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<im.vector.app.core.preference.VectorPreferenceCategory
android:key="SETTINGS_OTHER"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is never used, but this is not the correct key (copy/paste error).

import org.matrix.android.sdk.api.pushrules.toJson

enum class NotificationIndex(val index: Int) {
OFF(0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum already have indexes by default starting from 0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus I didn't actually end up using the index value 🥴. Removed, thanks.

Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small remark otherwise LGTM

@langleyd langleyd merged commit a538014 into develop Aug 11, 2021
@langleyd langleyd deleted the feature/dla/reorg_account_notification_settings branch August 11, 2021 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reorganise Advanced Notifications in to Global Notifications, Keywords and Mentions, Other
4 participants