Closed StefMa closed 7 years ago
Merging #100 into master will not change coverage. The diff coverage is
100%
.
@@ Coverage Diff @@
## master #100 +/- ##
=======================================
Coverage 100% 100%
- Complexity 271 274 +3
=======================================
Files 22 22
Lines 659 670 +11
Branches 57 60 +3
=======================================
+ Hits 659 670 +11
Impacted Files | Coverage Δ | Complexity Δ | |
---|---|---|---|
...randcentrix/tray/provider/TrayContentProvider.java | 100% <100%> (ø) |
35 <1> (+1) |
:arrow_up: |
...a/net/grandcentrix/tray/provider/TrayContract.java | 100% <100%> (ø) |
11 <7> (+2) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 4ece993...a73f3b4. Read the comment docs.
Don't know if it a good idea to move the info to the wiki. Because ... no one read a github wiki 😄
Rest is working fine with your changes 👍
But what happen if someone have overridden TrayContentProvider
? 🤔
Is that anyhow possible?
The content provider is an internal component. Extending it will not work. Also using tray to share data between apps could be harder. But that's ok, tray was never designed for this.
This build on top of #81 but add the ability to override the default authority of
applicatonId.tray
. You can check each commit of me. Hopefully I have separated in a good and readable way.In case you miss something: We will now use always the
applicaitonId.tray
as authority. This will be set inside the TrayContentProvider inattachInfo()
. SinceContentProvider
s lifecycle is as long as the process lives, it is a clean solution to cache the authority info inside the class.You have the ability to override the default authority inside the
AndroidManifest
. I've added the instructions part how to do it inside theAndroidManifest
.I've also changed the "behaviour" if the
TrayContentProvider#mAuthority
is empty. We will now throw aRuntimeException
here. It is a "safety" feature, in my option. Since theContentProvider
starts as a "first part" of you App it should never happen. Otherwise we implemented something wrong....How to test
Push that PR to your mavenLocal (or something like that). (Note: Change the library version. Otherwise you will get in trouble and/or you have maybe version conflicts.) Create a new project and include tray like any other app. Attach the debugger in
TrayContract#getAuthority
and take a look what they return. The first run: Without any specific setup(!) will return your defaultapplicationId
+.tray
. Now create some build flavors and addapplicationIdSuffix
and run. The second run:TrayContract#getAuthority
should returnapplicationId
+applicationIdSuffix
+.tray
.For legacy testing: Add
resValue "string", "tray__authority", "my.custom.authority"
into yourbuild.gradle
. The third run: You will notice that we will use the sameauthority
like above. But inform the user viaLogcat
that they use a legacy method to override the default authority.Overriding: To override just add the following code to your
AndoridManifest
:The fourth run:
getAuthority
will now returnyour.custom.authoity
. Overriding in build-flavors: Create a newAndroidManifest
insideapp/src/flavorName/
and put the following inside:Run the two different flavors you have created. The fifhst run (build falvor without the specific
AndroidManifest
: Should return the "default" overriding value. Which meansyour.custom.authority
(from thesrc/main/AndroidManifest
) The second (and last) run (flavor with the specificAndroidManifest
: Shouldanother.custom.provider
(from thesrc/buildFlavor/AndroidManifest
).Hope I haven't miss something. Otherwise: Feel free to merge 👍