-
Notifications
You must be signed in to change notification settings - Fork 3
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
chrgernoe
merged 4 commits into
master
from
feature/155_list-used-libraries-and-licenses
Jan 8, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/src/main/java/com/yacgroup/yacguide/AboutLibrariesActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (C) 2023 Christian Sommer | ||
* | ||
* 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 | ||
* may become obsolete. | ||
*/ | ||
|
||
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() { | ||
|
||
private lateinit var _activityUtils: ActivityUtils | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
_activityUtils = ActivityUtils(this) | ||
setTitle(R.string.software_and_licenses) | ||
setContentView(R.layout.activity_about_libraries) | ||
_displayContent() | ||
} | ||
|
||
private fun _displayContent() { | ||
// 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() | ||
libs.libraries.sortedBy { it.uniqueId }.forEach { | ||
_createEntry(it) | ||
} | ||
} | ||
|
||
private fun _createEntry(lib: Library) { | ||
layoutInflater.inflate(R.layout.about_libraries_entry, null).let { | ||
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( | ||
separator = ", ", | ||
transform = { license -> license.name } | ||
) | ||
it.findViewById<TextView>(R.id.aboutLibrariesLicenses).text = licenses | ||
findViewById<LinearLayout>(R.id.aboutLibrariesContent).addView(it) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
Copyright (C) 2023 Christian Sommer | ||
|
||
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="@dimen/activity_horizontal_margin" | ||
android:layout_marginEnd="@dimen/activity_horizontal_margin" | ||
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="@dimen/activity_horizontal_margin" | ||
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="@dimen/activity_horizontal_margin" | ||
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_marginTop="10dp" | ||
style="@style/ThinDivider"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
Copyright (C) 2023 Christian Sommer | ||
|
||
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"uniqueId": "org.apache.commons:commons-csv", | ||
"licenses": [ | ||
"Apache-2.0" | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.