play-services-plugins
play-services-plugins copied to clipboard
Custom OssLicensesMenuActivity/component and/or full flexibility on display
Problem:
If the application theme in the manifest is, for example, a "no action bar theme", the title can't be displayed, since I can't override the theme for OssLicensesMenuActivity
.
Please let us subclass the activity or at least set a theme on it.
A better option is making the list a component (fragment?) that I can include in my own activity.
The best solution, however, is to have also a method that returns a data structure (list of licenses and dependency-license mapping) so I can display it in my own way. For example, I might want to group by license, i.e., list distinct licenses and, on each item's subtitle, list the packages using that same license. This would also solve #73, since we would be able to manually add licenses not related to gradle or maven. For example, resources like icons, etc, which may require a notice somewhere, could be added in my custom implementation of the activity. This is the best solution, since it gives us full flexibility on what info is shown and how.
You can actually override the theme for OssLicensesMenuActivity
and OssLicensesActivity
from the manifest:
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="[you theme with action bar]" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="[you theme with action bar]" />
Oh, I didn't know I could override external packages in my own manifest like that; thanks! @caller9 May I suggest putting this info in the README?
This is better than nothing, but I still recommend having a public method returning just the data. Like I said, this would allow, for example, grouping dependencies by license. When you have lots of dependencies, this is way more practical than having to open them one by one.
This isn't just for users of the app, it helps developers too. With this grouping, they can easily see if they accidentally bundle a GPL dependency in a non-GPL app, for example.
By the way (sorry if it's a dumb question), although the plugin is called "oss-licenses" it isn't guaranteed that all dependencies listed on it are actually open-source, right?
By the way (sorry if it's a dumb question), although the plugin is called "oss-licenses" it isn't guaranteed that all dependencies listed on it are actually open-source, right?
I can confirm that it's not guaranteed in theory but pretty much in practice. Here's a longer explanation: I was able to display a library with a proprietary license in an app using the OSS license plugin. These preconditions had to be met, however:
- Artifact is retrieved from a Maven2 repository (typically all public repos require uploaded artifacts to be open source, but you can host your own repo as I did) as the OSS plugin reads from metadata (pom.xml) files that are declared outside of the actual binary.
- License metadata, https://maven.apache.org/pom.html#Licenses, is defined for this artifact
To include license information that can be picked up by the OSS plugin you would need to explicitly define the pom.xml metadata when publishing to the Maven repository as the native Gradle metadata format, https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html, does not support license information (at least it's not clearly defined).
@geekley I worked around this by just parsing the generated license files manually and listing them in a RecyclerView, that was years ago.. this 1st party library isn't getting much attention :)
Why OssLicensesMenuActivity is final and can not be extended? That's so annoying and take my time! Android is open, so let make it open! Please!
OssLicensesMenuActivity and OssLicensesActivity are incompatible with splash screens from androidx core-splashscreen for the same reasons, which means that while the whole app can use a splashscreen theme, these 2 cannot. This is because there needs to be a call to installSplashScreen()
in onCreate() to transition away from the splash screen theme. Pretty crummy.