Licensy is a handy Android library crafted in Kotlin. I always use opensouce libraries in all of my projects and I believe everyone does the same. In my projects I always try to put credits for the libraries or resources I use in my code. I looked for this type of library which will allow me to give the credits or add the licenses of the library in a proper manner for a long time. Guess what? I decided to create one.
- Lightweight
- Highly customizable
- Supports both Kotlin and Java
- Three different styles, a View, a Dialog and a BottomSheet.
- 1 for Test app home
- 2 for View
- 3 for Dialog
- 4 for BottomSheet
Shots
1 | 2 | 3 | 4 |
---|---|---|---|
Animation showing the view in details
1 | 2 | 3 | 4 |
---|---|---|---|
You can download the test apk to try out the features of this library - Download
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven{
url = uri("https://jitpack.io")
}
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add this to your module's build.gradle.kts
file (latest version ):
dependencies {
...
implementation("com.github.ahmmedrejowan:Licensy:0.2")
}
dependencies {
...
implementation 'com.github.ahmmedrejowan:Licensy:0.2'
}
There are 3 different usages of this library.
- Use it as a View
LicensyView
- Use it as a Dialog
LicensyDialog
- Use it as a BottomSheet
LicensyBottomSheet
This can be used in anywhere, in any Activity
or Fragment
.
<com.rejowan.licensy.LicensyView
android:id="@+id/licensyView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
This can be customized with attributes as well. Those attributes will take effect to all elements inside the view.
<com.rejowan.licensy.LicensyView
android:id="@+id/licensyView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
app:lv_background_color=""
app:lv_background_color_expand=""
app:lv_divider_color=""
app:lv_image_tint=""
app:lv_open_image=""
app:lv_text_color_link=""
app:lv_text_color_primary=""
app:lv_text_color_secondary=""
app:lv_text_size_title="" />
All the attributes in XML will also work here. But the main function is the setLicense(listOfLicenses: List<LicenseContent>)
method.
licensyView.setLicenses(listOfLicenses) // set the licenses to the view
The LicenseContent
is this-
data class LicenseContent(
val title: String,
val author: String,
val licenses: Licenses,
val copyrightYear: String? = null,
val url: String? = null
)
This one has it's predefined layout. I kept it simple but added some spice as well. As always, it's also customizable.
val licensyDialog = LicensyDialog(this)
licensyDialog.setLicenses(list)
licensyDialog.show()
val licensyDialog = LicensyDialog(this)
licensyDialog.setTitle("Licenses")
licensyDialog.setCloseText("Dismiss")
licensyDialog.setAccentColor(Color.GREEN)
licensyDialog.setBackgroundColor(Color.DKGRAY)
licensyDialog.setLicenses(list)
licensyDialog.setOnDialogListener(object : OnDialogListener {
override fun onShow() {
Log.e("Licensy", "Dialog shown")
}
override fun onDismiss() {
Log.e("Licensy", "Dialog dismissed")
}
})
licensyDialog.setCustomization()
licensyDialog.show()
You need to pass the LicensyCustomization to customize the items inside the list of licenses. Like this - setCustomization(customization: LicensyCustomization)
This is the LicensyCustomization
data class
data class LicensyCustomization(
@ColorInt val lvPrimaryColor: Int = Color.parseColor("#121211"),
@ColorInt val lvSecondaryColor: Int = Color.parseColor("#444444"),
@ColorInt val lvLinkColor: Int = Color.parseColor("#0077cc"),
val lvTitleTextSize: Float = 0f,
@ColorInt val lvBackgroundColor: Int = Color.WHITE,
@ColorInt val lvBackgroundColorExpand: Int = Color.parseColor("#f8f8f8"),
val lvOpenImage: Int = R.drawable.ic_licensy_open,
@ColorInt val imageTint: Int = Color.parseColor("#444444"),
@ColorInt val lvDividerColor: Int = Color.parseColor("#e0e0e0")
)
This also has the same level of customization as the LicensyDialog
. Here is a simple example-
val licensyBottomSheet = LicensyBottomSheet(this)
licensyBottomSheet.setLicenses(list)
licensyBottomSheet.show()
Attribute | Format | Description | Example |
---|---|---|---|
lv_text_color_primary |
color | Primary text color | #FF0000 |
lv_text_color_secondary |
color | Secondary text color | #00FF00 |
lv_text_color_link |
color | Link text color | #0000FF |
lv_text_size_title |
dimension | Title text size | 16sp |
lv_background_color |
color | Background color | #FFFFFF |
lv_background_color_expand |
color | Background color when expanded | #F0F0F0 |
lv_open_image |
reference | Reference to the open image | @drawable/ic_open |
lv_image_tint |
color | Tint color for the image | #CCCCCC |
lv_divider_color |
color | Color of divider between sections | #888888 |
- The library is in its early stages, so there may be some bugs.
- If you find any bugs, please report them in the
Issues
tab. - Sample app is available in the app directory.
- Right now, it only supports a few Licences, I'll be adding more in the future. Feel free to add using pull request.
- Inspired by LicensesDialog by PSDev
- Inspired by Licenser by marcoscgdev
- Inspired by LicensesDialog by colinrtwhite
Please fork this repository and contribute back using pull requests.
Any contributions, large or small, major features, bug fixes, are welcomed and appreciated.
Let me know which features you want in the future in Request Feature
tab.
If this project helps you a little bit, then give a to Star ⭐ the Repo.
Copyright 2024 ahmmedrejowan
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.