mirror of
https://github.com/florisboard/florisboard.git
synced 2025-12-28 05:35:22 +00:00
Change OSS notices from Google GMS to mikepenz/AboutLibraries plugin
Note: the prior GMS Gradle plugin [oss-licenses-plugin](https://github.com/google/play-services-plugins/tree/master/oss-licenses-plugin) was, despite belonging to the GMS service stack, open-source. However it was a bit clunky to use and it does not keep up with the newest Gradle plugin standards, so it got replaced by Mike Penz' AboutLibraries library/plugin. This plugin allows me to define custom licenses and have an JC integration without needing to maintain much code, which is always a plus.
This commit is contained in:
parent
c2aa87beab
commit
91cbe6d8ec
@ -84,6 +84,8 @@ to get more information on this topic.
|
||||
[Android Jetpack](https://github.com/androidx)
|
||||
* [Accompanist Compose UI libraries](https://github.com/google/accompanist/) by
|
||||
[Google](https://github.com/google)
|
||||
* [AboutLibraries](https://github.com/mikepenz/AboutLibraries) by
|
||||
[mikepenz](https://github.com/mikepenz)
|
||||
* [Google Material icons](https://github.com/google/material-design-icons) by
|
||||
[Google](https://github.com/google)
|
||||
* [JetPref preference library](https://github.com/patrickgold/jetpref) by
|
||||
|
||||
@ -19,13 +19,11 @@
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.agp.application)
|
||||
//alias(libs.plugins.gms.oss.licenses)
|
||||
// Must still use old syntax sadly
|
||||
id(libs.plugins.gms.oss.licenses.get().pluginId)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.mannodermaus.android.junit5)
|
||||
alias(libs.plugins.mikepenz.aboutlibraries)
|
||||
}
|
||||
|
||||
android {
|
||||
@ -155,6 +153,10 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
aboutLibraries {
|
||||
configPath = "app/src/main/config"
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests {
|
||||
isIncludeAndroidResources = true
|
||||
@ -194,6 +196,8 @@ dependencies {
|
||||
implementation(libs.jetpref.material.ui)
|
||||
implementation(libs.kotlinx.coroutines)
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
implementation(libs.mikepenz.aboutlibraries.core)
|
||||
implementation(libs.mikepenz.aboutlibraries.compose)
|
||||
|
||||
testImplementation(libs.equalsverifier)
|
||||
testImplementation(libs.kotest.assertions.core)
|
||||
|
||||
14
app/src/main/config/libraries/google-material-icons.json
Normal file
14
app/src/main/config/libraries/google-material-icons.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"uniqueId": "google-material-icons",
|
||||
"name": "Google Material Icons",
|
||||
"developers": [
|
||||
{
|
||||
"name": "Google Inc.",
|
||||
"organisationUrl": "https://github.com/google"
|
||||
}
|
||||
],
|
||||
"website": "https://github.com/google/material-design-icons",
|
||||
"licenses": [
|
||||
"Apache-2.0"
|
||||
]
|
||||
}
|
||||
14
app/src/main/config/libraries/icu4c.json
Normal file
14
app/src/main/config/libraries/icu4c.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"uniqueId": "icu4c",
|
||||
"name": "ICU4C Native C library",
|
||||
"developers": [
|
||||
{
|
||||
"name": "The Unicode Consortium",
|
||||
"organisationUrl": "https://github.com/unicode-org"
|
||||
}
|
||||
],
|
||||
"website": "https://github.com/unicode-org/icu",
|
||||
"licenses": [
|
||||
"icu4c"
|
||||
]
|
||||
}
|
||||
6
app/src/main/config/licenses/icu4c.json
Normal file
6
app/src/main/config/licenses/icu4c.json
Normal file
File diff suppressed because one or more lines are too long
@ -16,29 +16,15 @@
|
||||
|
||||
package dev.patrickgold.florisboard.app.settings.about
|
||||
|
||||
import android.webkit.URLUtil
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
|
||||
import dev.patrickgold.florisboard.R
|
||||
import dev.patrickgold.florisboard.lib.android.launchUrl
|
||||
import dev.patrickgold.florisboard.lib.compose.FlorisScreen
|
||||
import dev.patrickgold.florisboard.lib.compose.florisScrollbar
|
||||
import dev.patrickgold.florisboard.lib.compose.stringRes
|
||||
import dev.patrickgold.jetpref.datastore.ui.Preference
|
||||
import dev.patrickgold.jetpref.material.ui.JetPrefAlertDialog
|
||||
|
||||
data class Library(val name: String, val licenseText: String)
|
||||
|
||||
@Composable
|
||||
fun ThirdPartyLicensesScreen() = FlorisScreen {
|
||||
@ -46,67 +32,14 @@ fun ThirdPartyLicensesScreen() = FlorisScreen {
|
||||
scrollable = false
|
||||
iconSpaceReserved = false
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
var dialogLibraryToShow by rememberSaveable {
|
||||
mutableStateOf<Library?>(null)
|
||||
}
|
||||
|
||||
val libraries = remember {
|
||||
val list = mutableListOf<Library>()
|
||||
val licensesData = context.resources
|
||||
.openRawResource(R.raw.third_party_licenses)
|
||||
.readBytes()
|
||||
val licensesMetaDataReader = context.resources
|
||||
.openRawResource(R.raw.third_party_license_metadata)
|
||||
.bufferedReader()
|
||||
licensesMetaDataReader.use { it.readLines() }.map { line ->
|
||||
val (section, name) = line.split(" ", limit = 2)
|
||||
val (startOffset, length) = section.split(":", limit = 2).map { it.toInt() }
|
||||
val licenseData = licensesData.sliceArray(startOffset until startOffset + length)
|
||||
val licenseText = licenseData.toString(Charsets.UTF_8)
|
||||
Library(name, licenseText)
|
||||
}.all { list.add(it) }
|
||||
list.add(
|
||||
Library("ICU4C Native C library", "https://github.com/unicode-org/icu/blob/main/icu4c/LICENSE")
|
||||
)
|
||||
list.add(
|
||||
Library("Google Material Icons", "https://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
)
|
||||
list.sortedBy { it.name.lowercase() }.toList()
|
||||
}
|
||||
val lazyListState = rememberLazyListState()
|
||||
|
||||
content {
|
||||
val state = rememberLazyListState()
|
||||
LazyColumn(
|
||||
LibrariesContainer(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.florisScrollbar(state = state, isVertical = true),
|
||||
state = state,
|
||||
) {
|
||||
items(libraries) { library ->
|
||||
val isUrl = URLUtil.isValidUrl(library.licenseText)
|
||||
Preference(
|
||||
title = library.name,
|
||||
onClick = {
|
||||
if (isUrl) {
|
||||
context.launchUrl(library.licenseText)
|
||||
} else {
|
||||
dialogLibraryToShow = library
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (dialogLibraryToShow != null) {
|
||||
JetPrefAlertDialog(
|
||||
title = dialogLibraryToShow?.name ?: "",
|
||||
dismissLabel = stringRes(android.R.string.ok),
|
||||
onDismiss = { dialogLibraryToShow = null },
|
||||
) {
|
||||
Text(dialogLibraryToShow?.licenseText ?: "")
|
||||
}
|
||||
}
|
||||
.florisScrollbar(lazyListState, isVertical = true),
|
||||
lazyListState = lazyListState,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,16 +19,9 @@
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.agp.application) apply false
|
||||
//alias(libs.plugins.gms.oss.licenses) apply false
|
||||
alias(libs.plugins.kotlin.android) apply false
|
||||
alias(libs.plugins.kotlin.serialization) apply false
|
||||
alias(libs.plugins.ksp) apply false
|
||||
alias(libs.plugins.mannodermaus.android.junit5) apply false
|
||||
}
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
// We currently have to rely on the legacy way of defining plugins
|
||||
classpath("com.google.android.gms:oss-licenses-plugin:${libs.plugins.gms.oss.licenses.get().version}")
|
||||
}
|
||||
alias(libs.plugins.mikepenz.aboutlibraries) apply false
|
||||
}
|
||||
|
||||
@ -12,13 +12,13 @@ androidx-emoji2 = "1.1.0"
|
||||
androidx-navigation = "2.4.2"
|
||||
androidx-room = "2.4.2"
|
||||
cache4k = "0.5.0"
|
||||
gms-oss-licenses-plugin = "0.10.5"
|
||||
jetpref = "0.1.0-beta08"
|
||||
kotlin = "1.6.10"
|
||||
kotlinx-coroutines = "1.6.1"
|
||||
kotlinx-serialization-json = "1.3.2"
|
||||
ksp = "1.6.10-1.0.4"
|
||||
mannodermaus-android-junit5 = "1.8.2.0"
|
||||
mikepenz-aboutlibraries = "10.2.0"
|
||||
|
||||
# Testing
|
||||
androidx-test-ext = "1.1.2"
|
||||
@ -53,6 +53,8 @@ jetpref-datastore-ui = { module = "dev.patrickgold.jetpref:jetpref-datastore-ui"
|
||||
jetpref-material-ui = { module = "dev.patrickgold.jetpref:jetpref-material-ui", version.ref = "jetpref" }
|
||||
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
|
||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" }
|
||||
mikepenz-aboutlibraries-core = { module = "com.mikepenz:aboutlibraries-core", version.ref = "mikepenz-aboutlibraries" }
|
||||
mikepenz-aboutlibraries-compose = { module = "com.mikepenz:aboutlibraries-compose", version.ref = "mikepenz-aboutlibraries" }
|
||||
|
||||
# Testing
|
||||
androidx-test-ext = { module = "androidx.test.ext:junit", version.ref = "androidx-test-ext" }
|
||||
@ -66,8 +68,8 @@ kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref
|
||||
[plugins]
|
||||
# Main
|
||||
agp-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
|
||||
gms-oss-licenses = { id = "com.google.android.gms.oss-licenses-plugin", version.ref = "gms-oss-licenses-plugin" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||
mannodermaus-android-junit5 = { id = "de.mannodermaus.android-junit5", version.ref = "mannodermaus-android-junit5" }
|
||||
mikepenz-aboutlibraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "mikepenz-aboutlibraries" }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user