-
Notifications
You must be signed in to change notification settings - Fork 12
The Configuration File
The great File of Configuration is truly a mighty hurdle to overcome when implementing this library. It contains many confusing and difficult concepts such as "tags" and "attributes". However, when it comes down to it, it is really just a weird form of layout file that specifies the information to display instead of how to display it.
For no specific reason, each configuration file must have an <about>
tag as its root element. Inside of that tag, any amount of children can be defined in any order. When the about screen is opened, these tags will be parsed and their corresponding objects will be created, much like inflating a layout file. The objects are then added to a list to be displayed in a RecyclerView. In order to simplify things, these tags, their corresponding objects, and the views created for them in the RecyclerView will be referred to as "wedges".
Because wedge classes are instantiated from the configuration file, the wedge's tag in the file must be the class name of the wedge that should be instantiated (optionally including the package name, if using a custom wedge - similarly to how Views are added to a layout file).
With this information, we can now create a simple configuration file using the App
, Contributors
, and Licenses
wedges as follows.
<about>
<AppWedge/>
<ContributorsWedge/>
<LicensesWedge/>
</about>
This will create a screen that displays information about your app, followed by its contributors and finally the open source licenses that you have used. However, the only information that is currently displayed is what Attribouter knows how to find by itself; the AppWedge
displays your app's icon, name, and a link to rate your app on the Play Store, the ContributorsWedge
displays the people that have contributed to Attribouter, and the LicensesWedge
displays the licenses that Attribouter uses. In order to add information to these wedges, you can use one of the following options:
As stated in their documentation, both the AppWedge
and the ContributorsWedge
have an attribute titled repo
that accepts the full name of a GitHub repository. Let's say that the repository for your app is fennifith/Pasta-for-Spotify. In that case, you can modify the file as follows:
<about>
<AppWedge
repo="fennifith/Pasta-for-Spotify" />
<ContributorsWedge
repo="fennifith/Pasta-for-Spotify" />
<LicensesWedge/>
</about>
The AppWedge
now displays the repository's description, a link to the Pasta-for-Spotify repository on GitHub, and a link to the project's homepage (https://jfenn.me/apps/pasta), and the ContributorsWedge
includes all of the people that have contributed to it.
If your project does not have a GitHub repository or you want some information to be available without an internet connection, you should define that information in the configuration file. Using the documentation pages for AppWedge
and ContributorsWedge
, the equivalent of Option 1 (without the GitHub link in the AppWedge
) would be as follows:
<about>
<AppWedge
title="Pasta for Spotify"
description="A material design Spotify client for Android"
websiteUrl="https://jfenn.me/apps/pasta/" />
<ContributorsWedge>
<ContributorWedge
name="James Fenn"
avatar="https://avatars3.githubusercontent.com/u/13000407"
task="Developer"
blog="https://jfenn.me/"
email="me@jfenn.me" />
<ContributorWedge
name="Jan-Lukas Else"
avatar="https://avatars3.githubusercontent.com/u/8822316"
task="Contributor"
blog="https://about.jlelse.de" />
<ContributorWedge
name="Alexandre Piveteau"
avatar="https://avatars1.githubusercontent.com/u/6318990"
task="Contributor"
blog="https://alexandrepiveteau.ch" />
</ContributorsWedge>
<LicensesWedge/>
</about>
"This should be fairly easy. All that you need to do is combine the two previous options, right?"
Actually, there is one extra step - if you do not define the login
attribute on all of the ContributorWedge
s, you will end up with two sets of contributors - one from the configuration file and one from the GitHub API. Similar attributes are used to merge duplicate wedges like LinkWedge
s and LicenseWedge
s, so you should check out "Overriding Resources and Providing Translations" if the results of this option confuse you. When you are done, the end result should look something like this:
<about>
<AppWedge
repo="fennifith/Pasta-for-Spotify"
title="Pasta for Spotify"
description="A material design Spotify client for Android"
websiteUrl="https://jfenn.me/apps/pasta/" />
<ContributorsWedge
repo="fennifith/Pasta-for-Spotify" >
<ContributorWedge
login="fennifith"
name="James Fenn"
avatar="https://avatars3.githubusercontent.com/u/13000407"
task="Developer"
blog="https://jfenn.me/"
email="me@jfenn.me" />
<ContributorWedge
login="jlelse"
name="Jan-Lukas Else"
avatar="https://avatars3.githubusercontent.com/u/8822316"
task="Contributor"
blog="https://about.jlelse.de" />
<ContributorWedge
login="alexandrepiveteau"
name="Alexandre Piveteau"
avatar="https://avatars1.githubusercontent.com/u/6318990"
task="Contributor"
blog="https://alexandrepiveteau.ch" />
</ContributorsWedge>
<LicensesWedge/>
</about>
This documentation can also be found at https://jfenn.me/.