This library is an extension of a LinearLayout that allows licenses to be displayed within its own Popup Views. The default view would be blank and to add licences to it, you would need to use the addLicense or addMultipleLicenses functions.
Do note that the orientation of the view is automatically set to vertical.
Some licenses are included by default, such as:
- Apache 2.0
- GNU GPL v3
and many more. The full list can be found under the LicenseType class.
This library is available in JCenter and Maven Central. To install, you would need to include the following into your
This view can be used similar to a linear layout. To set up the licenseView, simply call
licenseView.addLicense in your onCreate function. The possible arguments for
// Adds a license to the view. The license type is assumed to be None, and the license header and license text are assumed to be blank. public void addLicense(String name) // Adds a license to the view with a specified license type. The license header is assumed to be blank. The license text is assumed to be blank if none of the license types match that of any existing license types. public void addLicense(String name, @NotNull String licenseType) // Adds a license to the view with a specified license type and license header. The license text is assumed to be blank if none of the license types match that of any existing license types. // HTML tags will be parsed in the license header and the license text. public void addLicense(String name, @NotNull String licenseType, @NotNull String licenseHeader) // Adds a license to the view with a specified license type, license header and license text. The license text for any set licenses will be overwritten as well. // HTML tags will be parsed in the license header and the license text. public void addLicense(final String name, @NotNull final String licenseType, @NotNull final String licenseHeader, @NotNull final String licenseText) // Adds a license to the view through an array. An IllegalArgumentException will be thrown if the array size does not match the argument size for any of the existing addLicense functions. public void addLicense(@NotNull String license)
Multiple licenses could also be added at a time through the
addMultipleLicenses function, taking a List of String arrays as an argument.
There are also setters for the following variables:
setFragmentManager: Sets the Fragment manager if the view is initialized in an activity that does not have
setTextSize: Sets the size of the text to be shown in the popup, defaults to 18.
setTextColor: Sets the color of the text to be shown in the popup.
setLinkColor: Sets the color of the link to be shown in the popup.
setPadding: Sets the padding around the text in the popup, defaults to 20.
setTypeface: Sets the typeface for the text in the popup, defaults to no typeface (null) with Typeface.NORMAL.
setAlertDialogStyle: Sets the style for the AlertDialog shown in the popup, defaults to R.style.Theme_AppCompat_Light_Dialog_Alert.
All the setters should be set before any
addLicense functions are called.
For the layout XML, simply include the view as if it is an LinearLayout. e.g.:
<com.pcchin.licenseview.LicenseView android:width="match_parent" android:height="wrap_content" />
Any contribution is welcome, feel free to add any issues or pull requests to the repository.
This library is licensed under the Apache 2.0 License.