-
Notifications
You must be signed in to change notification settings - Fork 731
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
Local Notification Settings Event #7300
Merged
ericdecanini
merged 66 commits into
develop
from
feature/eric/local_notification_settings
Oct 13, 2022
Merged
Changes from 60 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
5ced831
Adds push notifications switch
ericdecanini e1b78b9
Adds functionality to Push notification toggle
ericdecanini 233d07e
Adds DefaultPushersServiceTest for togglePusher
ericdecanini da80c08
Adds DefaultTogglePusherTaskTest
ericdecanini 670cceb
Adds SessionOverviewViewModelTest for toggling pusher
ericdecanini 71558ed
Hides pusher toggle if there are no pushers of the device
ericdecanini 3cc22c5
Adds changelog file
ericdecanini 66b8ebd
Edits changelog file
ericdecanini ae2a02c
Fixes copyrights
ericdecanini 47e5491
Unregisters checkedChangelistener in onDetachedFromWindow for switch …
ericdecanini d91bbfd
Links notification settings toggle to pusher service
ericdecanini ac33ac1
Adds changelog file
ericdecanini 757ee1a
Adds error handling to VectorSettingsNotificationPreferenceFragment
ericdecanini 121415d
Removes comment in FakePushersService
ericdecanini 826efc0
Adds parsing for LocalNotificationSettings event
ericdecanini 3cfb6a9
Adds changelog file
ericdecanini 225050d
Merge branch 'feature/eric/msc3881' into feature/eric/push-toggle-not…
ericdecanini c038540
Fixes post merge errors
ericdecanini 2289fde
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini 1639b71
Merge branch 'feature/eric/msc3881' into feature/eric/push-toggle-not…
ericdecanini a1908b0
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini 3398646
Fixes imports and improves string name
ericdecanini 008ea66
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini 9c533bc
Merge branch 'feature/eric/msc3881' into feature/eric/push-toggle-not…
ericdecanini 4f65d5d
Merge branch 'feature/eric/msc3881' into feature/eric/push-toggle-not…
ericdecanini c3a70b5
Fixes legal copies
ericdecanini a951a80
Fixes kdoc punctuation
ericdecanini a9dd794
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini e999aab
Fixes string error
ericdecanini b4c15d3
Removes unused imports
ericdecanini c356b8c
Merge branch 'feature/eric/msc3881' into feature/eric/push-toggle-not…
ericdecanini ddc0021
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini e5ce394
Moves LocalNotificationSettingsContent
ericdecanini 126f048
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini 4a8eb51
Merge branch 'feature/eric/msc3881' into feature/eric/push-toggle-not…
ericdecanini 91e902f
Fixes lint errors
ericdecanini a996c8c
Fixes test errors
ericdecanini 3ecd04f
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini be16bad
Fixes test errors
ericdecanini f397a62
Fixes error
ericdecanini 6895e14
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini 04a0da9
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini 971fe8e
Fixes error
ericdecanini 476aab3
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini e44bca3
Fixes error
ericdecanini 7523556
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini dee1f88
Fixes error
ericdecanini d656000
Fixes error
ericdecanini 1e3dbba
Fixes error
ericdecanini 49c6240
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini dfe17cd
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini 9de170a
Fixes error
ericdecanini f93674d
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini 6457e45
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini 110600c
Merge branch 'feature/eric/msc3881' into feature/eric/push-toggle-not…
ericdecanini 2f2dc4e
Merge branch 'feature/eric/push-toggle-notifications' into feature/er…
ericdecanini fc61d09
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini cb81451
Merge remote-tracking branch 'origin/develop' into feature/eric/notif…
ericdecanini b02b4a3
Adds lost tests
ericdecanini 8f9b315
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini c6224b1
Adds PusherEntity migration
ericdecanini d1562d3
Fixes session overview layout overlap
ericdecanini 992d7d3
Fixes switch being enabled by default
ericdecanini b693c93
Merge branch 'feature/eric/notificaton-settings-enabled' into feature…
ericdecanini c0441ad
Adds device id and unstable prefix
ericdecanini c38bbd8
Merge remote-tracking branch 'origin/develop' into feature/eric/local…
ericdecanini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ | ||
Links "Enable Notifications for this session" setting to enabled value in pusher |
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 @@ | ||
Implements client-side of local notification settings event |
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
25 changes: 25 additions & 0 deletions
25
...roid/src/main/java/org/matrix/android/sdk/api/account/LocalNotificationSettingsContent.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,25 @@ | ||
/* | ||
* Copyright 2022 The Matrix.org Foundation C.I.C. | ||
* | ||
* 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 org.matrix.android.sdk.api.account | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
data class LocalNotificationSettingsContent( | ||
@Json(name = "is_silenced") val isSilenced: Boolean = false | ||
) |
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
package im.vector.app.features.home | ||
|
||
import androidx.lifecycle.asFlow | ||
import com.airbnb.mvrx.Mavericks | ||
import com.airbnb.mvrx.MavericksViewModelFactory | ||
import com.airbnb.mvrx.ViewModelContext | ||
|
@@ -45,10 +46,12 @@ import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.flow.collect | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.map | ||
import kotlinx.coroutines.flow.onCompletion | ||
import kotlinx.coroutines.flow.onEach | ||
import kotlinx.coroutines.flow.takeWhile | ||
import kotlinx.coroutines.launch | ||
import org.matrix.android.sdk.api.account.LocalNotificationSettingsContent | ||
import org.matrix.android.sdk.api.auth.UIABaseAuth | ||
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor | ||
import org.matrix.android.sdk.api.auth.UserPasswordAuth | ||
|
@@ -57,9 +60,11 @@ import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse | |
import org.matrix.android.sdk.api.auth.registration.nextUncompletedStage | ||
import org.matrix.android.sdk.api.extensions.tryOrNull | ||
import org.matrix.android.sdk.api.raw.RawService | ||
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes | ||
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService | ||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo | ||
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap | ||
import org.matrix.android.sdk.api.session.events.model.toModel | ||
import org.matrix.android.sdk.api.session.getUserOrDefault | ||
import org.matrix.android.sdk.api.session.pushrules.RuleIds | ||
import org.matrix.android.sdk.api.session.room.model.Membership | ||
|
@@ -115,6 +120,7 @@ class HomeActivityViewModel @AssistedInject constructor( | |
observeCrossSigningReset() | ||
observeAnalytics() | ||
observeReleaseNotes() | ||
observeLocalNotificationsSilenced() | ||
initThreadsMigration() | ||
} | ||
|
||
|
@@ -136,6 +142,17 @@ class HomeActivityViewModel @AssistedInject constructor( | |
} | ||
} | ||
|
||
fun observeLocalNotificationsSilenced() { | ||
val currentSession = activeSessionHolder.getActiveSession() | ||
viewModelScope.launch { | ||
currentSession.accountDataService() | ||
.getLiveUserAccountDataEvent(UserAccountDataTypes.TYPE_LOCAL_NOTIFICATION_SETTINGS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to add |
||
.asFlow() | ||
.map { it.getOrNull()?.content?.toModel<LocalNotificationSettingsContent>()?.isSilenced ?: false } | ||
.onEach { setState { copy(areNotificationsSilenced = it) } } | ||
} | ||
} | ||
|
||
private fun observeAnalytics() { | ||
if (analyticsConfig.isEnabled) { | ||
analyticsStore.didAskUserConsentFlow | ||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This need to unstable prefix. Please see the bottom of the MSC-3890