-
Notifications
You must be signed in to change notification settings - Fork 741
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
UnifiedPush #6228
Merged
Merged
UnifiedPush #6228
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
04b297b
Add UnifiedPush support
p1gp1g 848adc4
Add UnifiedPush settings
p1gp1g f00257f
Add UnifiedPush troubleshoot
p1gp1g 1069f77
Lint
p1gp1g f774f46
Check custom unifiedpush gateway
p1gp1g 7eca405
Update UnifiedPush libs
p1gp1g ee7fccf
Fix compilation issues after rebase
bmarty d88d279
Sort alphabetically.
bmarty 4281175
Move `ALLOW_EXTERNAL_UNIFIEDPUSH_DISTRIB` to `defaultConfig` and docu…
bmarty 09a918b
Cleanup
bmarty 96acb61
Add `unifiedpush` to the project dict.
bmarty 674e3a7
Make `UnifiedPushHelper` a regular class and inject the context in th…
bmarty 5e10449
Use the RawService to do network request.
bmarty f1e57d2
Use `.orEmpty()` instead of `?: ""`
bmarty 9216d8b
Small cleanup
bmarty 74de9c8
Small rework
bmarty 12d969b
Prefer using `toString()`
bmarty cc80bf9
Use plurals
bmarty 399e95a
`setOnDismissListener` should cover all the cases.
bmarty ddf6a69
Small cleanup
bmarty ad8cb22
We need an Activity to display the dialog
bmarty ff6aa11
VectorPreferences can be injected.
bmarty 77601f6
typo
bmarty 4018113
Better usage of Timber.
bmarty fb8408c
Small cleanup
bmarty 76bc6a5
Move the setting at the beginning of the section
bmarty 3f6b529
Add summary to the notification with the current value.
bmarty bdb2d29
Catch 404
bmarty bbbeb4b
Extract storage to its own class.
bmarty 45768c5
Small cleanup
bmarty cdfb728
Clarify the data classes for the Json parsing
bmarty 6cc2a36
Add explicit Json names
bmarty 35e0a0a
Detekt
bmarty 80d42f0
Remove unused methods / clarify API
bmarty 18b4906
Change BuildConfig field to a VectorFeature.
bmarty 110c17e
No need to have a mutable list here.
bmarty 420144d
Fix back issue on the dialog.
bmarty fb7df5b
Ignore if no change is done.
bmarty a5378d6
avoid runBlocking
bmarty fc66e5f
Ignore if no change is done - bugfix
bmarty 639c570
Create extension to get app names
bmarty 8708719
shorter code
bmarty a139756
Fix an issue with empty endpoint. It can happen if the endpoint is ma…
bmarty 905934b
Rename method for clarity
bmarty 3c72ee6
Unregister UP when signing out
bmarty 5846ad5
Inject constructor of `BackgroundSyncStarter` and `FcmHelper`
bmarty 3560ac9
Create a Kotlin Config object in vector-config module, for easy confi…
bmarty 2b8d1dd
Write documentation about UnifiedPush.
bmarty c43122a
Explain why the data are different when received from Firebase and fr…
bmarty 2f2ee1b
Format project (only modified files, there are other fomatting issues).
bmarty 4a54674
This module now have Kotlin code.
bmarty 33911c8
Update documentation after @p1gp1g review.
bmarty b1e062a
Fix small issue on the settings.
bmarty c7d021e
Extract parser to its own file and add unit test.
bmarty 55bac9b
Give time to the tests to perform
bmarty d1e2a90
Add test for the notification settings.
bmarty 56e6f51
Rename setting key for clarity
bmarty 279b9b5
Be lenient on the Json format for received data in a Push.
bmarty 2174b11
Move companion at the bottom of the class.
bmarty 0147eb4
Fix test
bmarty 4968198
I have done some manual test, this should be fine.
bmarty d978d0a
Delete obsolete comment.
bmarty 90f16c6
Remove unused dep.
bmarty e0fe91f
Remove alias.
bmarty 7bd2184
Rename fun.
bmarty 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
Use UnifiedPush and allows user to have push without FCM. |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# UnifiedPush | ||
|
||
<!--- TOC --> | ||
|
||
* [Introduction](#introduction) | ||
* [Configuration in Element-Android and their forks](#configuration-in-element-android-and-their-forks) | ||
* [Enabling and disabling the feature](#enabling-and-disabling-the-feature) | ||
* [Override the configuration at runtime](#override-the-configuration-at-runtime) | ||
* [Enabling the feature](#enabling-the-feature) | ||
* [Disabling the feature](#disabling-the-feature) | ||
* [Useful links](#useful-links) | ||
|
||
<!--- END --> | ||
|
||
## Introduction | ||
|
||
The recently started UnifiedPush project is an Android protocol and library for apps to be able to receive distributor-agnostic push notifications. | ||
|
||
The *F-Droid* and *Gplay* flavors of Element Android support UnifiedPush, so the user can use any distributor installed on their devices. This would make it possible to have push notifications without depending on Google services or libraries. Currently, the main distributors are [ntfy](https://ntfy.sh) which does not require any setup (like manual registration) to use the public server and [NextPush](https://github.com/UP-NextPush/android), available as a nextcloud application. | ||
|
||
The *Gplay* variant uses a UnifiedPush library which basically embed a FCM distributor built into the application (so a user doesn't need to do anything other than install the app to get FCM notifications). This variant uses Google Services to receive notifications if the user has not installed any distributor. | ||
|
||
The *F-Droid* variant does not use this library to avoid any proprietary blob. It will use a polling service if the user has not installed any distributor. | ||
|
||
In all cases, if there are other distributors available, the user will have to opt-in to one of them in the preferences. | ||
|
||
## Configuration in Element-Android and their forks | ||
|
||
### Enabling and disabling the feature | ||
|
||
Allowing the user to use an alternative distributor can be changed in [Config](../vector-config/src/main/java/im/vector/app/config/Config.kt). The flag is named `ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS`. Default value is `true`. | ||
|
||
#### Override the configuration at runtime | ||
|
||
On debug version, it is possible to override this configuration at runtime, using the `Feature` screen. The Feature is named `Allow external UnifiedPush distributors`. | ||
|
||
#### Enabling the feature | ||
|
||
This is the default behavior of Element Android. | ||
|
||
If `ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS` is set to true, it allows any available external UnifiedPush distributor to be chosen by the user. | ||
- For Gplay variant it means that FCM will be used by default, but user can choose another UnifiedPush distributor; | ||
- For F-Droid variant, it means that background polling will be used by default, but user can choose another UnifiedPush distributor. | ||
- On the UI, the setting to choose an alternative distributor will be visible to the user, and some tests in the notification troubleshoot screen will shown. | ||
- For F-Droid, if the user has chosen a distributor, the settings to configure the background polling will be hidden. | ||
|
||
#### Disabling the feature | ||
|
||
If `ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS` is set to false, it prevents the usage of external UnifiedPush distributors. | ||
- For Gplay variant it means that only FCM will be used; | ||
- For F-Droid variant, it means that only background polling will be used. | ||
- On the UI, the setting to choose an alternative distributor will be hidden to the user, and some tests in the notification troubleshoot screen will be hidden. | ||
|
||
### Useful links | ||
|
||
- UnifiedPush official website: [https://unifiedpush.org/](https://unifiedpush.org/) | ||
- List of available distributors can be retrieved here: [https://unifiedpush.org/users/distributors/](https://unifiedpush.org/users/distributors/) | ||
- UnifiedPush project discussion can occurs here: [#unifiedpush:matrix.org](https://matrix.to/#/#unifiedpush:matrix.org) |
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
39 changes: 39 additions & 0 deletions
39
vector-config/src/main/java/im/vector/app/config/Config.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,39 @@ | ||
/* | ||
* Copyright (c) 2022 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.config | ||
|
||
/** | ||
* Set of flags to configure the application. | ||
*/ | ||
object Config { | ||
/** | ||
* Flag to allow external UnifiedPush distributors to be chosen by the user. | ||
* | ||
* Set to true to allow any available external UnifiedPush distributor to be chosen by the user. | ||
* - For Gplay variant it means that FCM will be used by default, but user can choose another UnifiedPush distributor; | ||
* - For F-Droid variant, it means that background polling will be used by default, but user can choose another UnifiedPush distributor. | ||
* | ||
* Set to false to prevent usage of external UnifiedPush distributors. | ||
* - For Gplay variant it means that only FCM will be used; | ||
* - For F-Droid variant, it means that only background polling will be available to the user. | ||
* | ||
* *Note*: When the app is already installed on users' phone: | ||
* - Changing the value from `false` to `true` will let the user be able to select an external UnifiedPush distributor; | ||
* - Changing the value from `true` to `false` will force the app to return to the background sync / Firebase Push. | ||
*/ | ||
const val ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS = true | ||
} |
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
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
30 changes: 30 additions & 0 deletions
30
vector/src/fdroid/java/im/vector/app/fdroid/receiver/KeepInternalDistributor.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,30 @@ | ||
/* | ||
* Copyright (c) 2022 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.fdroid.receiver | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
|
||
/** | ||
* UnifiedPush lib tracks an action to check installed and uninstalled distributors. | ||
* We declare it to keep the background sync as an internal unifiedpush distributor. | ||
* This class is used to declare this action. | ||
*/ | ||
class KeepInternalDistributor : BroadcastReceiver() { | ||
override fun onReceive(context: Context, intent: Intent) {} | ||
} |
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.
💯 is the plan for this to become our source of truth?
(with some values being pulled in via the
BuildConfig
)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.
Yes, this is what I have in mind. At the end they will be no
BuildConfig
fields anymore. (Also note that this class does not have access tovector
module'sBuildConfig
class.So we have:
Config
here, in this dedicated super simple configuration module;VectorFeatures
to be able to override values at runtime.