android-components/components/support/license/README.md

1.6 KiB
Executable File

Android Components > Support > License

A component to help generate and display licensing agreements.

Setting up the dependency

Use Gradle to download the library from maven.mozilla.org (Setup repository):

implementation "org.mozilla.components:support-license:{latest-version}"

Usage

License Plugin

Add the license plugin directly to your project's build.gradle classpath:

// root build.gradle
buildscript {
    dependencies {
        classpath "com.google.android.gms:oss-licenses-plugin:0.10.4"
    }
}

Apply the plugin to the top of your application's build.gradle:

apply plugin: 'com.google.android.gms.oss-licenses-plugin'

Display licenses

Extend the abstract LibrariesListFragment and provide the resource location to the licenses and the metadata:

class MyLicense : LibrariesListFragment() {
    override val resources = LicenseResources(
        licenses = R.raw.third_party_licenses,
        licenseMetadata = R.raw.third_party_license_metadata,
    )
}

Optionally, add more fragment decorations as desired. For example:

class MyLicense : LibrariesListFragment() {
    override fun onResume() {
        super.onResume()

        showToolbar("Licenses we use")
    }
}

License

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/