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

Push provider switch #2873

Merged
merged 20 commits into from
May 21, 2024
Merged

Push provider switch #2873

merged 20 commits into from
May 21, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented May 17, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Add an advanced setting entry to switch between available push providers: Firebase, and available UnifiedPush distributors.
Also properly unregister existing pushers and update the codebase for everything to work as expected.

Please note that matrix.org user may have issue getting push from UnifiedPush since there is some rate limiting. This will be handled separately.

Motivation and context

Screenshots / GIFs

PushProviderSelector2

Tests

  • Install the application
  • Install the application ntfy from https://f-droid.org/fr/packages/io.heckel.ntfy/ for instance
  • Use the application and ensure that push is received
  • Go to settings / advanced settings and switch the push provider to ntfy.
  • The push should still be received (with the limitation on matrix.org)
  • You can also check on the notification troubleshoot screen that Push are received (even for matrix.org users)
  • It's also possible to check the registered pushers by using Element Android on the same account: go to setting / advanced settings / Notification targets to see the list of active pushers.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty requested a review from a team as a code owner May 17, 2024 16:22
@bmarty bmarty requested review from ganfra and removed request for a team May 17, 2024 16:22
@ElementBot
Copy link
Collaborator

ElementBot commented May 17, 2024

Warnings
⚠️

gradle/libs.versions.toml#L6 - A newer version of com.android.tools.build:gradle than 8.4.0 is available: 8.4.1

⚠️

gradle/libs.versions.toml#L12 - A newer version of androidx.core:core-ktx than 1.13.0 is available: 1.13.1

⚠️

gradle/libs.versions.toml#L18 - A newer version of androidx.datastore:datastore-preferences than 1.0.0 is available: 1.1.1

⚠️

gradle/libs.versions.toml#L21 - A newer version of androidx.lifecycle:lifecycle-runtime-ktx than 2.7.0 is available: 2.8.0

⚠️

gradle/libs.versions.toml#L22 - A newer version of androidx.activity:activity-compose than 1.8.2 is available: 1.9.0

Messages
📖

gradle/libs.versions.toml#L136 - There are multiple dependencies junit:junit but with different version

📖

gradle/libs.versions.toml#L138 - There are multiple dependencies androidx.test.ext:junit but with different version

📖

gradle/libs.versions.toml#L207 - There are multiple dependencies junit:junit but with different version

📖

gradle/libs.versions.toml#L208 - There are multiple dependencies androidx.test.ext:junit but with different version

Generated by 🚫 dangerJS against 4ab0202

@bmarty bmarty changed the title Feature/bma/push provider switch Push provider switch May 17, 2024
Copy link
Contributor

github-actions bot commented May 17, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/ZpaH9f

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 17, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 17, 2024
Copy link
Contributor

@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.

Some minor remarks, otherwise LGTM

@@ -78,6 +147,9 @@ class AdvancedSettingsPresenter @Inject constructor(
isSharePresenceEnabled = isSharePresenceEnabled,
theme = theme,
showChangeThemeDialog = showChangeThemeDialog,
pushDistributor = currentDistributorName,
Copy link
Contributor

Choose a reason for hiding this comment

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

rename currentPushDistributor to be clear?

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -78,6 +147,9 @@ class AdvancedSettingsPresenter @Inject constructor(
isSharePresenceEnabled = isSharePresenceEnabled,
theme = theme,
showChangeThemeDialog = showChangeThemeDialog,
pushDistributor = currentDistributorName,
pushDistributors = distributorNames.toImmutableList(),
Copy link
Contributor

Choose a reason for hiding this comment

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

availablePushDistributors ?

Copy link
Member Author

Choose a reason for hiding this comment

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


// List of PushProvider -> Distributor
var distributors by remember { mutableStateOf<List<Pair<PushProvider, Distributor>>>(emptyList()) }
var distributorNames by remember { mutableStateOf<List<String>>(emptyList()) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use derivedStateOf instead of changing both field in the LaunchedEffect

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, both calls are sync and initialized once so I don't see why we need to make these values mutable states, just calculating them inside the remember for distributors one and derivedStateOf for distributorNames should be simpler.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, thanks. 97aa57b should be OK, just initialize data in remember (no need to use derivedStateOf). OK for you both?

@frebib
Copy link
Contributor

frebib commented May 20, 2024

Is there a specific reason to add the toggle to the "Advanced Settings" menu and not the "Notifications" menu? The latter would make more sense to me

@bmarty
Copy link
Member Author

bmarty commented May 21, 2024

Is there a specific reason to add the toggle to the "Advanced Settings" menu and not the "Notifications" menu? The latter would make more sense to me

We discussed internally about it, and concluded that this feature is quite an advanced feature and we do not want to confuse users when they want to change their notification settings.

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 21, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 21, 2024
Copy link

codecov bot commented May 21, 2024

Codecov Report

Attention: Patch coverage is 29.26829% with 145 lines in your changes are missing coverage. Please review.

Project coverage is 74.24%. Comparing base (15e7a9d) to head (4ab0202).
Report is 5 commits behind head on develop.

Files Patch % Lines
.../unifiedpush/VectorUnifiedPushMessagingReceiver.kt 0.00% 20 Missing ⚠️
...ies/pushproviders/firebase/FirebasePushProvider.kt 0.00% 16 Missing ⚠️
...ment/android/libraries/push/impl/PushersManager.kt 0.00% 15 Missing ⚠️
...roviders/unifiedpush/RegisterUnifiedPushUseCase.kt 0.00% 14 Missing ⚠️
.../pushproviders/firebase/FirebaseNewTokenHandler.kt 0.00% 13 Missing ⚠️
.../android/libraries/push/impl/DefaultPushService.kt 0.00% 11 Missing ⚠️
...viders/unifiedpush/UnifiedPushNewGatewayHandler.kt 0.00% 10 Missing ⚠️
...viders/unifiedpush/UnregisterUnifiedPushUseCase.kt 0.00% 10 Missing ⚠️
.../preferences/impl/advanced/AdvancedSettingsView.kt 65.21% 0 Missing and 8 partials ⚠️
...edpush/registration/EndpointRegistrationHandler.kt 0.00% 7 Missing ⚠️
... and 9 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2873      +/-   ##
===========================================
- Coverage    74.34%   74.24%   -0.10%     
===========================================
  Files         1536     1538       +2     
  Lines        36731    36866     +135     
  Branches      7123     7145      +22     
===========================================
+ Hits         27306    27371      +65     
- Misses        5700     5763      +63     
- Partials      3725     3732       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 21, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 21, 2024
@bmarty bmarty added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label May 21, 2024
@bmarty bmarty enabled auto-merge May 21, 2024 10:27
@bmarty bmarty force-pushed the feature/bma/pushProviderSwitch branch from d73ae65 to 06d80ee Compare May 21, 2024 12:47
@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 21, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 21, 2024
Copy link

sonarcloud bot commented May 21, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@ganfra ganfra added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 21, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 21, 2024
@bmarty bmarty merged commit 71763e3 into develop May 21, 2024
23 of 25 checks passed
@bmarty bmarty deleted the feature/bma/pushProviderSwitch branch May 21, 2024 14:52
@bmarty
Copy link
Member Author

bmarty commented May 27, 2024

@frebib FTR we have changed our mind and will move the setting to the Notifications settings screen. Tracked by #2912.

The switch will be displayed only if several providers are detected, to not confuse regular users about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants