Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add view that lists all used libraries and their licenses #381

Merged
merged 4 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id "com.github.triplet.play" version "3.6.0"
id "com.mikepenz.aboutlibraries.plugin"
}
apply plugin: "com.android.application"
apply plugin: "kotlin-android"
Expand Down Expand Up @@ -99,6 +100,11 @@ android {
}
}

// https://github.com/mikepenz/AboutLibraries/blob/develop/plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/AboutLibrariesExtension.kt
aboutLibraries {
prettyPrint = true
}

dependencies {
// Room
implementation fileTree(include: ["*.jar"], dir: "libs")
Expand All @@ -107,23 +113,23 @@ dependencies {
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.test:core-ktx:1.5.0"

def room_version = "2.4.3"
def roomVersion = "2.4.3"

implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-runtime:$roomVersion"
kapt "androidx.room:room-compiler:$roomVersion"

// optional - Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-ktx:$roomVersion"

// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"
implementation "androidx.room:room-rxjava2:$roomVersion"

// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:$room_version"
implementation "androidx.room:room-guava:$roomVersion"

implementation "net.sf.kxml:kxml2:2.3.0"
implementation "com.caverock:androidsvg:1.4"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"

// Tests
Expand All @@ -143,9 +149,9 @@ dependencies {
*
* https://github.com/noties/Markwon
*/
def markwon_version = "4.6.2"
implementation "io.noties.markwon:core:$markwon_version"
implementation "io.noties.markwon:linkify:$markwon_version"
def markwonVersion = "4.6.2"
implementation "io.noties.markwon:core:$markwonVersion"
implementation "io.noties.markwon:linkify:$markwonVersion"

/*
* CSV library for tour book export
Expand All @@ -156,6 +162,15 @@ dependencies {

// For introspection
implementation "org.jetbrains.kotlin:kotlin-reflect:1.6.0"

/*
* Listing all used libraries
*
* https://github.com/mikepenz/AboutLibraries
*/
implementation "com.mikepenz:aboutlibraries-core:${aboutlibrariesVersion}"
//implementation "com.mikepenz:aboutlibraries-compose:${aboutlibrariesVersion}"
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
//implementation "com.mikepenz:aboutlibraries:${aboutlibrariesVersion}"
}
repositories {
mavenCentral()
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
android:parentActivityName=".AboutActivity"
android:theme="@style/AppTheme.ActionBar">
</activity>
<activity
android:name=".AboutLibrariesActivity"
android:exported="false"
android:parentActivityName=".AboutActivity"
android:theme="@style/AppTheme.ActionBar">
</activity>

<provider
android:name="androidx.core.content.FileProvider"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/yacgroup/yacguide/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class AboutActivity : BaseNavigationActivity() {
_createEntry(getString(R.string.privacy_policy), callback = { _showPrivacyPolicy() })
_createEntry(getString(R.string.source_code_and_support), getString(R.string.github_url))
_createEntry(getString(R.string.license), getString(R.string.license_url))
_createEntry(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it make sense to migrate this view to RecyclerView using BaseViewItemAdapter, too? If yes, you may create a ticket for that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have a look. Thanks for the hint.

getString(R.string.open_source_libraries),
getString(R.string.open_source_libraries_details),
callback = { _showLibraries()}
)
_createEntry(
getString(R.string.whats_new),
WhatsNewInfo(this).getReleaseNotesUrl()
Expand Down Expand Up @@ -82,4 +87,9 @@ class AboutActivity : BaseNavigationActivity() {
setNegativeButton()
}.show()
}

private fun _showLibraries() {
val intent = Intent(this, AboutLibrariesActivity::class.java)
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
startActivity(intent)
}
}
75 changes: 75 additions & 0 deletions app/src/main/java/com/yacgroup/yacguide/AboutLibrariesActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (C) 2022 Christian Sommer
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/*
* NOTE:
* The library can automatically generate a view.
* However, it uses material design elements which makes things a bit inconsistent within
* this app. As soon as the app is migrated to material design, this and related code
* maybe become obsolete.
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
*/

package com.yacgroup.yacguide

import android.os.Bundle
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.aboutlibraries.entity.Library
import com.yacgroup.yacguide.utils.ActivityUtils

class AboutLibrariesActivity : AppCompatActivity () {
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved

private lateinit var _activityUtils: ActivityUtils

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
_activityUtils = ActivityUtils(this)
setTitle(R.string.open_source_libraries)
setContentView(R.layout.activity_about_libraries)
_displaycontent()
}

private fun _displaycontent() {
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
// The resource JSON file is automatically generated
// by the Gradle plugin com.mikepenz.aboutlibraries.plugin
val jsonStr = resources.openRawResource(R.raw.aboutlibraries)
.bufferedReader().use { it.readText() }
val libs = Libs.Builder()
.withJson(jsonStr)
.build()
for (lib in libs.libraries.sortedBy { it.uniqueId }) {
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
_createEntry(lib)
}
}

private fun _createEntry(lib: Library) {
layoutInflater.inflate(R.layout.about_libraries_entry, null).let {
val content = findViewById<LinearLayout>(R.id.aboutLibrariesContent)
it.setOnClickListener { _activityUtils.openUrl(lib.website.orEmpty()) }
it.findViewById<TextView>(R.id.aboutLibrariesName).text = lib.uniqueId
it.findViewById<TextView>(R.id.aboutLibrariesVersion).text = lib.artifactVersion
val licenses= lib.licenses.joinToString(
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
separator=", ",
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
transform = { license -> license.name }
)
it.findViewById<TextView>(R.id.aboutLibrariesLicenses).text = licenses
content.addView(it)
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class PrivacyPolicyActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setTitle(R.string.privacy_policy)
setContentView(R.layout.activity_privacy_policy)
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
_displayContent()
}

Expand All @@ -52,4 +51,4 @@ class PrivacyPolicyActivity : AppCompatActivity() {
val privacyTextView = findViewById<TextView>(R.id.privacyPolicyTextView)
markwon.setMarkdown(privacyTextView, privacyStr)
}
}
}
71 changes: 71 additions & 0 deletions app/src/main/res/layout/about_libraries_entry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2022 Christian Sommer
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:foreground="?android:attr/selectableItemBackground">

<TextView
android:id="@+id/aboutLibrariesName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:textAlignment="textStart"
android:textSize="16sp"
android:textColor="?android:textColorPrimary"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<TextView
android:id="@+id/aboutLibrariesLicenses"
android:layout_width="0dp"
android:layout_weight="0.8"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"
android:textAlignment="textStart"
android:textSize="14sp"
android:textColor="?android:textColorSecondary"/>

<TextView
android:id="@+id/aboutLibrariesVersion"
android:layout_width="0dp"
android:layout_weight="0.2"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:textAlignment="textEnd"
android:textSize="14sp"
android:textColor="?android:textColorSecondary"/>
</LinearLayout>

<View
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="10dp"
android:background="?android:attr/listDivider"/>

</LinearLayout>
29 changes: 29 additions & 0 deletions app/src/main/res/layout/activity_about_libraries.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2022 Christian Sommer
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:id="@+id/aboutLibrariesContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>

</ScrollView>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
<string name="data_src">Datenbezugsquelle</string>
<string name="privacy_policy">Datenschutzerklärung</string>
<string name="license">Lizenz</string>
<string name="open_source_libraries">Bibliotheken und Lizenzen</string>
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
<string name="open_source_libraries_details">Bibliotheken die diese App möglich machen.</string>
chrgernoe marked this conversation as resolved.
Show resolved Hide resolved
<string name="version">Version</string>
<string name="contact">Kontakt</string>
<string name="contact_details">Generelles Feedback und Fehler melden</string>
Expand Down
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = "1.7.20"
ext.kotlinVersion = "1.7.20"
ext.aboutlibrariesVersion = "10.5.2"

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.8.2.0"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

plugins {
id "com.mikepenz.aboutlibraries.plugin" version "${aboutlibrariesVersion}" apply false
}

allprojects {
repositories {
google()
Expand Down