Add website button to license activity
app/src/main/java/eu/lepiller/nani/LicenseActivity.java
17 | 17 | ExpandableListAdapter adapter; | |
18 | 18 | ||
19 | 19 | public static class License { | |
20 | - | private final String name, description, license; | |
20 | + | private final String name, description, license, url; | |
21 | 21 | private final List<License> subProjects; | |
22 | 22 | private final Drawable drawable; | |
23 | 23 | ||
24 | - | License(String name, Drawable drawable, String description, String license, List<License> subProjects) { | |
24 | + | License(String name, Drawable drawable, String url, String description, String license, List<License> subProjects) { | |
25 | 25 | this.name = name; | |
26 | 26 | this.drawable = drawable; | |
27 | + | this.url = url; | |
27 | 28 | this.description = description; | |
28 | 29 | this.license = license; | |
29 | 30 | this.subProjects = subProjects; | |
… | |||
49 | 50 | public Drawable getDrawable() { | |
50 | 51 | return drawable; | |
51 | 52 | } | |
53 | + | ||
54 | + | public String getUrl() { | |
55 | + | return url; | |
56 | + | } | |
52 | 57 | } | |
53 | 58 | ||
54 | 59 | private static final List<License> licenseInformation = new ArrayList<>(); | |
… | |||
60 | 65 | ||
61 | 66 | licenseInformation.clear(); | |
62 | 67 | List<License> erdrgLicenses = new ArrayList<>(); | |
63 | - | erdrgLicenses.add(new License(getString(R.string.jmdict_title), null, | |
68 | + | erdrgLicenses.add(new License(getString(R.string.jmdict_title), null, "http://www.edrdg.org/wiki/index.php/JMdict-EDICT_Dictionary_Project", | |
64 | 69 | getString(R.string.jmdict_descr), getString(R.string.jmdict_license), null)); | |
65 | - | erdrgLicenses.add(new License(getString(R.string.radk_title), null, | |
70 | + | erdrgLicenses.add(new License(getString(R.string.radk_title), null, "http://www.edrdg.org/krad/kradinf.html", | |
66 | 71 | getString(R.string.radk_descr), getString(R.string.radk_license), null)); | |
67 | - | erdrgLicenses.add(new License(getString(R.string.kanjidic_title), null, | |
72 | + | erdrgLicenses.add(new License(getString(R.string.kanjidic_title), null, "http://www.edrdg.org/wiki/index.php/KANJIDIC_Project", | |
68 | 73 | getString(R.string.kanjidic_descr), getString(R.string.kanjidic_license), null)); | |
69 | 74 | licenseInformation.add( | |
70 | - | new License(getString(R.string.erdrg_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_nani_edrdg, getTheme()), | |
75 | + | new License(getString(R.string.erdrg_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_nani_edrdg, getTheme()), null, | |
71 | 76 | getString(R.string.erdrg_descr), "", erdrgLicenses)); | |
72 | 77 | ||
73 | 78 | licenseInformation.add( | |
74 | - | new License(getString(R.string.kanjivg_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_kanjivg, getTheme()), | |
79 | + | new License(getString(R.string.kanjivg_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_kanjivg, getTheme()), "http://kanjivg.tagaini.net/", | |
75 | 80 | getString(R.string.kanjivg_descr), getString(R.string.kanjivg_license), null) | |
76 | 81 | ); | |
77 | 82 | licenseInformation.add( | |
78 | - | new License(getString(R.string.jibiki_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_jibiki, getTheme()), | |
83 | + | new License(getString(R.string.jibiki_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_jibiki, getTheme()), "https://jibiki.fr", | |
79 | 84 | getString(R.string.jibiki_descr), getString(R.string.jibiki_license), null) | |
80 | 85 | ); | |
81 | 86 | licenseInformation.add( | |
82 | - | new License(getString(R.string.wadoku_title), ResourcesCompat.getDrawable(getResources(), R.drawable.wadoku, getTheme()), | |
87 | + | new License(getString(R.string.wadoku_title), ResourcesCompat.getDrawable(getResources(), R.drawable.wadoku, getTheme()), "https://wadoku.de", | |
83 | 88 | getString(R.string.wadoku_descr), getString(R.string.wadoku_license), null) | |
84 | 89 | ); | |
85 | 90 | licenseInformation.add( | |
86 | - | new License(getString(R.string.tatoeba_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_tatoeba, getTheme()), | |
91 | + | new License(getString(R.string.tatoeba_title), ResourcesCompat.getDrawable(getResources(), R.drawable.ic_tatoeba, getTheme()), "https://tatoeba.org", | |
87 | 92 | getString(R.string.tatoeba_descr), getString(R.string.tatoeba_license), null) | |
88 | 93 | ); | |
89 | 94 |
app/src/main/java/eu/lepiller/nani/LicenseAdapter.java
1 | 1 | package eu.lepiller.nani; | |
2 | 2 | ||
3 | 3 | import android.content.Context; | |
4 | + | import android.content.Intent; | |
4 | 5 | import android.graphics.drawable.Drawable; | |
6 | + | import android.net.Uri; | |
5 | 7 | import android.provider.ContactsContract; | |
6 | 8 | import android.view.LayoutInflater; | |
7 | 9 | import android.view.View; | |
8 | 10 | import android.view.ViewGroup; | |
9 | 11 | import android.widget.BaseExpandableListAdapter; | |
12 | + | import android.widget.Button; | |
10 | 13 | import android.widget.ImageView; | |
11 | 14 | import android.widget.TextView; | |
12 | 15 | ||
… | |||
89 | 92 | view = layoutInflater.inflate(R.layout.layout_license, viewGroup, false); | |
90 | 93 | } | |
91 | 94 | ||
92 | - | TextView nameView = (TextView) view.findViewById(R.id.name); | |
93 | - | TextView descriptionView = (TextView) view.findViewById(R.id.description); | |
94 | - | TextView licenseView = (TextView) view.findViewById(R.id.license); | |
95 | + | TextView nameView = view.findViewById(R.id.name); | |
96 | + | TextView descriptionView = view.findViewById(R.id.description); | |
97 | + | TextView licenseView = view.findViewById(R.id.license); | |
98 | + | Button projectButton = view.findViewById(R.id.website_button); | |
95 | 99 | ||
96 | 100 | descriptionView.setText(licenses.get(i).getDescription()); | |
97 | 101 | nameView.setVisibility(View.GONE); | |
98 | 102 | licenseView.setVisibility(View.GONE); | |
103 | + | projectButton.setVisibility(View.GONE); | |
99 | 104 | return view; | |
100 | 105 | } else { | |
101 | 106 | boolean subproject = projects != null && projects.size() > 0; | |
… | |||
107 | 112 | view = layoutInflater.inflate(R.layout.layout_license, viewGroup, false); | |
108 | 113 | } | |
109 | 114 | ||
110 | - | TextView nameView = (TextView) view.findViewById(R.id.name); | |
111 | - | TextView descriptionView = (TextView) view.findViewById(R.id.description); | |
112 | - | TextView licenseView = (TextView) view.findViewById(R.id.license); | |
115 | + | TextView nameView = view.findViewById(R.id.name); | |
116 | + | TextView descriptionView = view.findViewById(R.id.description); | |
117 | + | TextView licenseView = view.findViewById(R.id.license); | |
118 | + | Button projectButton = view.findViewById(R.id.website_button); | |
113 | 119 | ||
114 | 120 | nameView.setVisibility(subproject? View.VISIBLE: View.GONE); | |
121 | + | projectButton.setVisibility(license.getUrl() == null? View.GONE: View.VISIBLE); | |
115 | 122 | licenseView.setVisibility(View.VISIBLE); | |
116 | 123 | ||
124 | + | if(license.getUrl() != null) | |
125 | + | projectButton.setOnClickListener(view1 -> { | |
126 | + | Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(license.getUrl())); | |
127 | + | context.startActivity(browserIntent); | |
128 | + | }); | |
129 | + | ||
117 | 130 | nameView.setText(license.getName()); | |
118 | 131 | descriptionView.setText(license.getDescription()); | |
119 | 132 | licenseView.setText(license.getLicense()); |
app/src/main/res/layout/layout_license.xml
25 | 25 | android:layout_height="wrap_content" | |
26 | 26 | android:layout_marginTop="16dp" | |
27 | 27 | app:lineHeight="22dp" /> | |
28 | + | ||
29 | + | <LinearLayout | |
30 | + | android:orientation="vertical" | |
31 | + | android:layout_width="match_parent" | |
32 | + | android:layout_height="wrap_content"> | |
33 | + | <Button | |
34 | + | android:layout_width="wrap_content" | |
35 | + | android:layout_height="wrap_content" | |
36 | + | android:gravity="center" | |
37 | + | android:layout_gravity="center" | |
38 | + | android:text="@string/project_website" | |
39 | + | android:id="@+id/website_button" | |
40 | + | android:padding="8dp" | |
41 | + | android:layout_marginTop="16dp" | |
42 | + | android:background="@color/colorSubtitle" | |
43 | + | android:textColor="@color/colorGrey" /> | |
44 | + | </LinearLayout> | |
28 | 45 | </LinearLayout> | |
28 | 45 | = | |
29 | 46 | = | \ No newline at end of file |
app/src/main/res/values/strings.xml
141 | 141 | <http://www.gnu.org/licenses/gpl.html>. | |
142 | 142 | </string> | |
143 | 143 | <string name="data_licenses">Data Licenses</string> | |
144 | - | <string name="data_intro">Nani? uses data from third party distributed under different licenses.</string> | |
144 | + | <string name="data_intro">Nani? uses data from third parties, distributed under different licenses. Here is the list of third-party data providers and their license.</string> | |
145 | + | <string name="project_website">Visit Website</string> | |
145 | 146 | ||
146 | 147 | <string name="erdrg_title">Electronic Dictionary Research and Development Group</string> | |
147 | 148 | <string name="erdrg_descr">The Electronic Dictionary Research and Development Group was |