An elegant library to credit the open source projects used in a commercial app
Avoid boiler plate code to display one page "open source".
- Avoid copy-paste of license text. Write the list of libraries in a few lines.
- Display the licenses in different ways. ViewHolder are customizable.
The default display
OpenSourceAdapter<OpenSourceViewHolder> adapter = new OpenSourceAdapter<OpenSourceViewHolder>(List<OpenSource> list, new OpenSourceExpandableViewHolder.Factory());
recyclerView.setAdapter(adapter);
Display the licences with OpenSourceDialogFragment
or OpenSourceAdapter
List<OpenSource> list;
...
// display inside an Activity
OpenSourceAdapter<OpenSourceViewHolder> adapter = new OpenSourceAdapter(list);
recyclerView.setAdapter(adapter);
// display in a Dialog
OpenSourceDialogFragment dialog = OpenSourceDialogFragment.newInstance(list);
dialog.show(getSupportFragmentManager(), "dialog");
// or call a Activity
startActivity(OpenSourceLibrariesActivity.createIntent(this, list));
ViewHolders are interchangeable. You can pass in parameters any OpenSourceViewHolder.Factory
instances .
OpenSourceAdapter adapter = new OpenSourceAdapter(list, new OpenSourceExpandableViewHolder.Factory());
startActivity(OpenSourceLibrariesActivity.createIntent(this, arrayList,new OpenSourceExpandableViewHolder.Factory()));
Bored that all the licenses page look the same? You can create own custom viewholder.
The custom View Holder extends from OpenSourceViewHolder
. It must have a static Factory
class.
You can see some examples : OpenSourceExpandableViewHolder
and CustomViewHolder
The list of libraries isn't magically resolved yet.
First let's construct the data. Select the license type with LicenseMap
// construct the data
List<OpenSource> list = new ArrayList<>();
list.add(new OpenSource.Builder("Butterknife", "Jake Wharton", LicenseMap.APACHE2(2013)).build());
list.add(new OpenSource.Builder("Expandable RecyclerView", "Big Nerd Ranch", LicenseMap.MIT(2015)).build());
// add a custom license
list.add(new OpenSource.Builder("facebook-android-sdk", "Facebook, Inc", "You are hereby granted a non-exclusive, worldwide, royalty-free license to ...").build());
You need a License missing in LicenseMap
.
You can create a new License by extending LicenseInfos
public class CustomLicense extends LicenseInfos
To use License Droid as a library, configure the project level build.gradle
, add jcenter as repository then add LicenseDroid :
buildscript {
repositories {
jcenter()
}
}
dependencies {
compile 'com.raychenon:licensedroid:0.3.1'
}
- The License Droid logo was designed by Nadya Kuzmina.
- The arrow up icon was designed by Denis Mikhutin https://www.iconfinder.com/icons/1031534
Copyright 2016 Raymond Chenon
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
http://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.