Licenser

Additional

Language
Java
Version
1.0.5 (Sep 16, 2018)
Created
Feb 11, 2018
Updated
Oct 11, 2018
Owner
Marcos Calvo García (marcoscgdev)
Contributors
Marcos Calvo García (marcoscgdev)
Aubtin
2
Activity
Badge
Generate
Download
Source code

Advertisement

Licenser

An android library to display the licenses of your application libraries in a easy way.

Click here for the Kotlin version of this readme.


Now add the dependency to your app build.gradle file:

implementation 'com.github.marcoscgdev:Licenser:1.0.5'

Step: 2 - creating a dialog

You have to use an AppCompatActivity

new LicenserDialog(this)
        .setTitle("Licenses")
        .setCustomNoticeTitle("Notices for files:")
        .setBackgroundColor(Color.RED) // Optional
        .setLibrary(new Library("Android Support Libraries",
                "https://developer.android.com/topic/libraries/support-library/index.html",
                License.APACHE))
        .setLibrary(new Library("Example Library",
                "https://github.com/marcoscgdev",
                License.APACHE))
        .setLibrary(new Library("Licenser",
                "https://github.com/marcoscgdev/Licenser",
                License.MIT))
        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                // TODO: 11/02/2018
            }
        })
        .show();

NEW: You can set a custom AlertDialog theme.

new LicenserDialog(this, R.style.DialogStyle)
        ...

Library structure:

Library lib1 = new Library(String title, String url, int licenseType);

LICENSE TYPES (At this moment):

 - License.APACHE
 - License.MIT
 - License.GNU
 - License.CREATIVE_COMMONS
 - License.ISC
 - License.NTP
Library lib1 = new Library("Library name", "https://github.com/marcoscgdev", License.APACHE);

If you don't want a dialog, you can use the Licenser class:

Licenser licenser = new Licenser()
        .setCustomNoticeTitle("Notices for files:")
        .setLibrary(new Library("Android Support Libraries",
                "https://developer.android.com/topic/libraries/support-library/index.html",
                License.APACHE))
        .setLibrary(new Library("Example Library",
                "https://github.com/marcoscgdev",
                License.APACHE))
        .setLibrary(new Library("Licenser",
                "https://github.com/marcoscgdev/Licenser",
                License.MIT));

And show it in a webview:

WebView webView = (WebView) findViewById(R.id.webView);
webView.loadData(licenser.getHTMLContent(), "text/html; charset=UTF-8", null);

Extra functions

You can access this functions with both classes

String licenses = licenser.getHTMLContent(); // HTML content
List<Library> apacheLibraries = licenser.getApacheLibraries();
List<Library> mitLibraries = licenser.getMitLibraries();
List<Library> gnuLibraries = licenser.getGnuLibraries();

See the


sample project to clarify any queries you may have.