Skip to content

DarthGrave/AboutLibraries

 
 

Repository files navigation

AboutLibraries Status Maven Central Android Arsenal

Join the chat at https://gitter.im/mikepenz/AboutLibraries

The AboutLibraries library allows you to easily create an used open source libraries fragment/activity within your app. As an extra feature you can also add an about this app section. All the library information is automatically collected from the POM information of the depencencies and included during compile time. No runtime overhead. Strong caching, so build times stay short. Due to usage of maven POM information practically any dependency is supported.

Here's a quick overview of functions it include:

  • used open source libraries
    • name, description, creator, license, version, ...
  • about this app section (optional)
  • autodetect libraries (via the gradle depencies)
  • many included library details
  • automatic created fragment/activity
  • feature rich builder to simply create and start the fragment / activities
  • large amount of configuration options
    • usage standalone possible too
  • much much more... try the sample for a quick overview.

Motivation

Most modern apps feature a "Used Library"-section, which requires information about those respective libs. As it gets annoying to always copy those strings to your app, AboutLibraries is there for the rescue.

Migration

Get started

More...

Screenshots

Image Image

Include in your project

Latest releases

Gradle Plugin

As a new feature of the AboutLibraries v8.x.y we offer a gradle plugin which will resolve the dependency during compilation, and only includes the libraries which are really specified as dependencies.

// Root build.gradle
classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${latestAboutLibsRelease}"

// App build.gradle
apply plugin: 'com.mikepenz.aboutlibraries.plugin'

Using Maven

The AboutLibraries Library is pushed to Maven Central.

CORE module

implementation "com.mikepenz:aboutlibraries-core:${latestAboutLibsRelease}"

UI module

implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"

//required support lib modules
implementation "androidx.appcompat:appcompat:${versions.appcompat | 1.x.y}"
implementation "androidx.cardview:cardview:${versions.cardview | 1.x.y}"
implementation "androidx.recyclerview:recyclerview:${versions.recyclerview | 1.1.y}"
implementation "com.google.android.material:material:${versions.material | 1.1.y}"

WITHOUT gradle plugin (not recommended)

If you do not want to use the gradle plugin, you need to add the legacy definition files, which will then be included in the built apk, and resolved via reflection during runtime.

NOTE: This is not recommended. Please migrate to use the gradle plugin

implementation "com.mikepenz:aboutlibraries-definitions:${latestAboutLibsRelease}"

Basic Usage

You can use this library in a few different ways. You can create your own activity, including a custom style and just use the information, or you can use the built-in Activity or Fragment and just pass the libs you would love to include.

Upgrade Notes

If you upgrade from < 8.x.y follow the MIGRATION GUIDE

Activity / Fragment

Activity

LibsBuilder()
    .start(this) // start the activity

Fragment

val fragment = LibsBuilder()
    .withFields(R.string::class.java.fields) // in some cases it may be needed to provide the R class, if it can not be automatically resolved
    .withLibraryModification("aboutlibraries", Libs.LibraryFields.LIBRARY_NAME, "_AboutLibraries") // optionally apply modifications for library information
    .supportFragment()

Gradle API

The gradle plugin will automatically run when building the application, so no action is required to build the library information showed / retrieved via the Libs class. But there are additional commands which may be helpful for various situations.

Export Library information

./gradlew exportLibraries

Exports all libraries in a CSV format with the name, artifactId, and licenseId. And a seperate list with all licenses used, and a potential list of unmatched libraries / licenses.

Find

./gradlew findLibraries

Finds all included libraries with their name, and the unique AboutLibraries identifier which can be used to modify libraries and their information, or create custom mapping information if required. See the Config section for more information.

Advanced Usage

About this App UI

You can also use the AboutLibraries activity as an "about this app" screen. Add the following .xml file (or just the strings - the key must be the same) to your project.

<resources>
    <string name="aboutLibraries_description_showIcon">true</string>
    <string name="aboutLibraries_description_showVersion">true</string>
    <string name="aboutLibraries_description_text">Place your description here :D</string>
</resources>

or use the builder and add following:

	.withAboutIconShown(true)
	.withAboutVersionShown(true)
	.withAboutDescription("This is a small sample which can be set in the about my app description file.<br /><b>You can style this with html markup :D</b>")

Style the AboutLibraries

Create your custom style. If you don't need a custom theme see the next section, how you can set the colors just by overwriting the original colors.

// define a custom style
<style name="CustomAboutLibrariesStyle" parent="">
    <!-- AboutLibraries specific values -->
    <item name="aboutLibrariesWindowBackground">?android:colorBackground</item>
    <item name="aboutLibrariesCardBackground">?cardBackgroundColor</item>
    <item name="aboutLibrariesDescriptionTitle">?android:textColorPrimary</item>
    <item name="aboutLibrariesDescriptionText">?android:textColorSecondary</item>
    <item name="aboutLibrariesDescriptionDivider">@color/opensource_divider</item>
    <item name="aboutLibrariesOpenSourceTitle">?android:textColorPrimary</item>
    <item name="aboutLibrariesOpenSourceText">?android:textColorSecondary</item>
    <item name="aboutLibrariesSpecialButtonText">?android:textColorPrimary</item>
    <item name="aboutLibrariesOpenSourceDivider">@color/opensource_divider</item>
</style>

// define the custom styles for the theme
<style name="SampleApp" parent="Theme.MaterialComponents.Light.NoActionBar">
    ...
    <item name="aboutLibrariesStyle">@style/CustomAboutLibrariesStyle</item>
    ...
</style>

Gradle Plugin Configuration

It is possible to provide custom configurations / adjustments to the automatic detection. This can be done via the gradle plugin.

aboutLibraries {
    configPath = "config" // the path to the directory containing configuration files
}

This directory may contain one or more of the following configurations:

custom_enchant_mapping.prop // allows providing custom mapping files to overwrite the information from the POM file
custom_license_mappings.prop // allows defining the licenseId which should be used for the library (if not resolveable via the POM file)
custom_license_year_mappings.prop // allows defining the license Year for this library (this information CANNOT be resolved from the POM file)
custom_name_mappings.prop // allows overwriting the name of a library if the POM specifies unexpected information

See the corresponding files here for the format and content: https://github.com/mikepenz/AboutLibraries/tree/develop/library-definitions/src/main/res/raw

ProGuard

Exclude R from ProGuard to enable the libraries auto detection

-keep class .R
-keep class **.R$* {
    <fields>;
}

In case you want to minimize your resources as much as possible use the following rules (Thanks to @rubengees and @AllanWang as discussed here: mikepenz#331)

-keepclasseswithmembers class **.R$* {
    public static final int define_*;
}

These rules will require you to add the libraries manually. (see more in the above linked issue)

Contribute

You can contribute by creating a information file for a new library, and open a pull-request at the creators Git repository. If he doesn't include the information file in his repo, or if the library isn't maintained anymore you can create a pull-request here. Find more information in the wiki Create a definition file

Already in use in following apps

(feel free to send me new projects)

Wiki

You can find anything you search for in the wiki. (If not open an issue)

Bring me to the wiki

Developed By

License

Copyright 2020 Mike Penz

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

   https://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.

About

AboutLibraries is a library to offer some information of libraries.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 64.6%
  • Groovy 18.2%
  • JavaScript 7.0%
  • CSS 5.9%
  • HTML 3.3%
  • Python 0.8%
  • Other 0.2%