show license in the links section

This makes the license a link to the spdx.org page for the app's
license.  I think this is an improvement over the way the license was
displayed before 0.103 since it provides a direct link to the actual
text of the license.

The license icon is a modified version of the public domain icon:
https://commons.wikimedia.org/wiki/File:Cc-sa_white.svg

closes #960
This commit is contained in:
Hans-Christoph Steiner 2017-05-01 20:57:12 +02:00
parent e02c0cb555
commit de1cc566a1
4 changed files with 37 additions and 2 deletions

View File

@ -126,7 +126,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
public String[] tvScreenshots = new String[0]; public String[] tvScreenshots = new String[0];
public String[] wearScreenshots = new String[0]; public String[] wearScreenshots = new String[0];
public String license = "Unknown"; public String license;
public String authorName; public String authorName;
public String authorEmail; public String authorEmail;

View File

@ -744,6 +744,15 @@ public class AppDetailsRecyclerViewAdapter
updateExpandableItem(false); updateExpandableItem(false);
contentView.removeAllViews(); contentView.removeAllViews();
// License link
if (!TextUtils.isEmpty(app.license)) {
String firstLicense = app.license.split(",")[0];
String url = "https://spdx.org/licenses/" + firstLicense + ".html";
if (uriIsSetAndCanBeOpened(url)) {
addLinkItemView(contentView, R.string.menu_license, R.drawable.ic_license, url, app.license);
}
}
// Video link // Video link
if (uriIsSetAndCanBeOpened(app.video)) { if (uriIsSetAndCanBeOpened(app.video)) {
addLinkItemView(contentView, R.string.menu_video, R.drawable.ic_video, app.video); addLinkItemView(contentView, R.string.menu_video, R.drawable.ic_video, app.video);
@ -902,8 +911,17 @@ public class AppDetailsRecyclerViewAdapter
} }
private void addLinkItemView(ViewGroup parent, int resIdText, int resIdDrawable, final String url) { private void addLinkItemView(ViewGroup parent, int resIdText, int resIdDrawable, final String url) {
addLinkItemView(parent, resIdText, resIdDrawable, url, null);
}
private void addLinkItemView(ViewGroup parent, int resIdText, int resIdDrawable, final String url, String formatArg) {
TextView view = (TextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.app_details2_link_item, parent, false); TextView view = (TextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.app_details2_link_item, parent, false);
view.setText(resIdText); if (formatArg == null) {
view.setText(resIdText);
} else {
String text = parent.getContext().getString(resIdText, formatArg);
view.setText(text);
}
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(view, resIdDrawable, 0, 0, 0); TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(view, resIdDrawable, 0, 0, 0);
parent.addView(view); parent.addView(view);
view.setOnClickListener(new View.OnClickListener() { view.setOnClickListener(new View.OnClickListener() {

View File

@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportHeight="64.0"
android:viewportWidth="64.0">
<path android:fillColor="#666666"
android:pathData="M31.19,0C13.9,0.44 0,14.61 0,32C0,49.66 14.34,64 32,64C49.66,64 64,49.66 64,32C64,14.34 49.66,0 32,0C31.72,0 31.46,-0.01 31.19,0zM31.16,5.5C31.44,5.49 31.71,5.5 32,5.5C46.63,5.5 58.5,17.37 58.5,32C58.5,46.63 46.63,58.5 32,58.5C17.37,58.5 5.5,46.63 5.5,32C5.5,17.66 16.92,5.95 31.16,5.5z"
android:strokeLineCap="butt"
android:strokeLineJoin="round"
android:strokeWidth="2.5950698853"/>
<path android:fillColor="#666666"
android:pathData="M18.12,26.78L15.38,26.78L21.59,33.75L27.81,26.78L25.57,26.78C26.05,23.38 29.05,21.2 32.5,21.47C32.64,21.48 32.77,21.47 32.91,21.47C38.53,21.47 40.75,25.73 40.94,32C41.13,38.55 37.33,42.62 32.91,42.53C28.23,42.44 26.46,40.21 25.78,36.82L17.44,36.82C18.81,44.63 24.56,49.21 32.72,49.22C41.95,49.24 48.63,41.51 48.63,32C48.63,21.85 41.96,14.78 32.72,14.78C32.44,14.78 32.18,14.77 31.91,14.78C31.84,14.79 31.78,14.78 31.72,14.78C25.95,14.88 18.12,18.92 18.12,26.78z"
android:strokeLineCap="butt"
android:strokeLineJoin="round"
android:strokeWidth="2.5950698853"/>
</vector>

View File

@ -161,6 +161,7 @@
<string name="menu_issues">Issues</string> <string name="menu_issues">Issues</string>
<string name="menu_changelog">Changelog</string> <string name="menu_changelog">Changelog</string>
<string name="menu_video">Video</string> <string name="menu_video">Video</string>
<string name="menu_license">License: %s</string>
<string name="menu_source">Source Code</string> <string name="menu_source">Source Code</string>
<string name="menu_upgrade">Upgrade</string> <string name="menu_upgrade">Upgrade</string>
<string name="menu_donate">Donate</string> <string name="menu_donate">Donate</string>