Dbrant has uploaded a new change for review. https://gerrit.wikimedia.org/r/191910
Change subject: [WIP] Use icons in Gallery license information. ...................................................................... [WIP] Use icons in Gallery license information. Using logic loosely based on the current MultimediaViewer extension's handling of license information. Change-Id: I621b87b2ae1cc89189c7cf7d8e9d1cf030a881c2 --- A icon-svgs/24/ic_license_cc.noflip.svg A icon-svgs/24/ic_license_cite.noflip.svg A icon-svgs/24/ic_license_pd.noflip.svg A wikipedia/res/drawable-hdpi/ic_license_cc.png A wikipedia/res/drawable-hdpi/ic_license_cite.png A wikipedia/res/drawable-hdpi/ic_license_pd.png A wikipedia/res/drawable-ldpi/ic_license_cc.png A wikipedia/res/drawable-ldpi/ic_license_cite.png A wikipedia/res/drawable-ldpi/ic_license_pd.png A wikipedia/res/drawable-mdpi/ic_license_cc.png A wikipedia/res/drawable-mdpi/ic_license_cite.png A wikipedia/res/drawable-mdpi/ic_license_pd.png A wikipedia/res/drawable-xhdpi/ic_license_cc.png A wikipedia/res/drawable-xhdpi/ic_license_cite.png A wikipedia/res/drawable-xhdpi/ic_license_pd.png A wikipedia/res/drawable-xxhdpi/ic_license_cc.png A wikipedia/res/drawable-xxhdpi/ic_license_cite.png A wikipedia/res/drawable-xxhdpi/ic_license_pd.png M wikipedia/res/layout/activity_gallery.xml M wikipedia/res/values-qq/strings.xml M wikipedia/res/values/strings.xml M wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java M wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryItem.java 23 files changed, 263 insertions(+), 51 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/10/191910/1 diff --git a/icon-svgs/24/ic_license_cc.noflip.svg b/icon-svgs/24/ic_license_cc.noflip.svg new file mode 100644 index 0000000..381c9bf --- /dev/null +++ b/icon-svgs/24/ic_license_cc.noflip.svg @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + id="Layer_1" + x="0px" + y="0px" + viewBox="0 0 24 24" + enable-background="new 0 0 24 24" + xml:space="preserve" + inkscape:version="0.91 r13725" + sodipodi:docname="ic_license_cc.noflip.svg"><metadata + id="metadata15"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs13" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1234" + inkscape:window-height="781" + id="namedview11" + showgrid="false" + inkscape:zoom="9.8333333" + inkscape:cx="-16.372881" + inkscape:cy="12" + inkscape:window-x="500" + inkscape:window-y="105" + inkscape:window-maximized="0" + inkscape:current-layer="Layer_1" /><g + id="g3" + style="fill:#aaaaaa;fill-opacity:1" + transform="matrix(1.6828087,0,0,1.6828087,-8.1937046,-9.8934625)"><path + d="m 12,6 c -3.9,0 -7,3.1 -7,7 0,3.9 3.1,7 7,7 3.9,0 7,-3.1 7,-7 0,-3.9 -3.1,-7 -7,-7 z m 0,13 C 8.7,19 6,16.3 6,13 6,9.7 8.7,7 12,7 c 3.3,0 6,2.7 6,6 0,3.3 -2.7,6 -6,6 z" + id="path5" + style="fill:#aaaaaa;fill-opacity:1" + inkscape:connector-curvature="0" /><path + d="m 10.3,14.4 c -0.7,0 -1,-0.4 -1,-1.2 0,-0.8 0.3,-1.2 1,-1.2 0.4,0 0.6,0.2 0.8,0.6 L 12,12.1 c -0.4,-0.7 -1,-1 -1.9,-1 -0.6,0 -1.1,0.2 -1.5,0.6 -0.4,0.4 -0.6,0.8 -0.6,1.5 0,0.7 0.2,1.2 0.6,1.6 0.4,0.4 0.9,0.6 1.5,0.6 0.8,0 1.4,-0.4 1.9,-1.1 l -0.9,-0.4 c -0.2,0.3 -0.5,0.5 -0.8,0.5 z" + id="path7" + style="fill:#aaaaaa;fill-opacity:1" + inkscape:connector-curvature="0" /><path + d="m 14.3,14.4 c -0.7,0 -1,-0.4 -1,-1.2 0,-0.8 0.3,-1.2 1,-1.2 0.4,0 0.6,0.2 0.8,0.6 L 16,12.1 c -0.4,-0.7 -1,-1 -1.9,-1 -0.6,0 -1.1,0.2 -1.5,0.6 -0.4,0.4 -0.6,0.8 -0.6,1.5 0,0.7 0.2,1.2 0.6,1.6 0.4,0.4 0.9,0.6 1.5,0.6 0.8,0 1.4,-0.4 1.9,-1.1 l -0.9,-0.4 c -0.2,0.3 -0.5,0.5 -0.8,0.5 z" + id="path9" + style="fill:#aaaaaa;fill-opacity:1" + inkscape:connector-curvature="0" /></g></svg> \ No newline at end of file diff --git a/icon-svgs/24/ic_license_cite.noflip.svg b/icon-svgs/24/ic_license_cite.noflip.svg new file mode 100644 index 0000000..a04b438 --- /dev/null +++ b/icon-svgs/24/ic_license_cite.noflip.svg @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + id="Layer_1" + x="0px" + y="0px" + viewBox="0 0 24 24" + enable-background="new 0 0 24 24" + xml:space="preserve" + inkscape:version="0.91 r13725" + sodipodi:docname="ic_license_cite.noflip.svg"><metadata + id="metadata9"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs7" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1017" + inkscape:window-height="624" + id="namedview5" + showgrid="false" + inkscape:zoom="9.8333333" + inkscape:cx="-5.3389831" + inkscape:cy="12" + inkscape:window-x="161" + inkscape:window-y="141" + inkscape:window-maximized="0" + inkscape:current-layer="Layer_1" /><path + d="m 3.4745762,1.9782082 0,20.3874098 14.0163438,0 c 2.166162,0 3.82264,-1.656477 3.82264,-3.822639 l 0,-16.5647708 -17.8389838,0 z M 17.49092,21.091406 l -11.4679177,0 0,-17.8389846 5.0968527,0 0,10.1937056 2.548426,-2.548427 2.548427,2.548427 0,-10.1937056 3.822639,0 0,15.2905576 c 0,1.401635 -1.146792,2.548427 -2.548427,2.548427 z" + id="path3" + style="fill:#aaaaaa;fill-opacity:1" + inkscape:connector-curvature="0" /></svg> \ No newline at end of file diff --git a/icon-svgs/24/ic_license_pd.noflip.svg b/icon-svgs/24/ic_license_pd.noflip.svg new file mode 100644 index 0000000..dcd7c72 --- /dev/null +++ b/icon-svgs/24/ic_license_pd.noflip.svg @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + id="Layer_1" + x="0px" + y="0px" + viewBox="0 0 24 24" + enable-background="new 0 0 24 24" + xml:space="preserve" + inkscape:version="0.91 r13725" + sodipodi:docname="ic_license_pd.noflip.svg"><metadata + id="metadata15"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs13" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1022" + inkscape:window-height="625" + id="namedview11" + showgrid="false" + inkscape:zoom="9.8333333" + inkscape:cx="-15.634421" + inkscape:cy="12" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="Layer_1" /><g + id="g3" + style="fill:#aaaaaa;fill-opacity:1" + transform="matrix(1.6828087,0,0,1.6828087,-8.1937046,-9.8934625)"><path + d="M 15.7,15.3 C 15.9,14.9 16,14.4 16,14 l -1.7,0 1.4,1.3 z" + id="path5" + style="fill:#aaaaaa;fill-opacity:1" + inkscape:connector-curvature="0" /><path + d="M 15.5,10.5 C 14.4,8.5 11.6,7.9 9.7,9.3 l 1.2,1.2 c 1.3,-1 3.1,0 3.2,1.5 l 1.8,0 c 0,-0.6 -0.2,-1.3 -0.4,-1.5 -0.2,-0.4 0.2,0.4 0,0 z" + id="path7" + style="fill:#aaaaaa;fill-opacity:1" + inkscape:connector-curvature="0" /><path + d="m 12,6 c -3.9,0 -7,3.1 -7,7 0,3.9 3.1,7 7,7 3.9,0 7,-3.1 7,-7 C 19,9.1 15.9,6 12,6 Z M 6,13 C 6,11.8 6.4,10.7 7,9.8 l 1.4,1.4 C 7.8,12.9 8,15 9.3,16.4 c 1.2,1.2 3.3,1.5 4.9,0.7 l 1,1.1 c -0.9,0.6 -2,0.9 -3.1,0.9 C 8.7,19 6,16.3 6,13 Z m 3.9,-0.2 3,3.1 C 12,16.2 11,15.9 10.4,15.1 10,14.4 9.9,13.5 9.9,12.8 Z M 16.3,17.2 7.9,8.7 C 8.9,7.6 10.4,7 12,7 c 3.3,0 6,2.7 6,6 0,1.6 -0.7,3.1 -1.7,4.2 z" + id="path9" + style="fill:#aaaaaa;fill-opacity:1" + inkscape:connector-curvature="0" /></g></svg> \ No newline at end of file diff --git a/wikipedia/res/drawable-hdpi/ic_license_cc.png b/wikipedia/res/drawable-hdpi/ic_license_cc.png new file mode 100644 index 0000000..5f0f227 --- /dev/null +++ b/wikipedia/res/drawable-hdpi/ic_license_cc.png Binary files differ diff --git a/wikipedia/res/drawable-hdpi/ic_license_cite.png b/wikipedia/res/drawable-hdpi/ic_license_cite.png new file mode 100644 index 0000000..750877a --- /dev/null +++ b/wikipedia/res/drawable-hdpi/ic_license_cite.png Binary files differ diff --git a/wikipedia/res/drawable-hdpi/ic_license_pd.png b/wikipedia/res/drawable-hdpi/ic_license_pd.png new file mode 100644 index 0000000..b687db6 --- /dev/null +++ b/wikipedia/res/drawable-hdpi/ic_license_pd.png Binary files differ diff --git a/wikipedia/res/drawable-ldpi/ic_license_cc.png b/wikipedia/res/drawable-ldpi/ic_license_cc.png new file mode 100644 index 0000000..7143cbc --- /dev/null +++ b/wikipedia/res/drawable-ldpi/ic_license_cc.png Binary files differ diff --git a/wikipedia/res/drawable-ldpi/ic_license_cite.png b/wikipedia/res/drawable-ldpi/ic_license_cite.png new file mode 100644 index 0000000..e43ec21 --- /dev/null +++ b/wikipedia/res/drawable-ldpi/ic_license_cite.png Binary files differ diff --git a/wikipedia/res/drawable-ldpi/ic_license_pd.png b/wikipedia/res/drawable-ldpi/ic_license_pd.png new file mode 100644 index 0000000..47f5feb --- /dev/null +++ b/wikipedia/res/drawable-ldpi/ic_license_pd.png Binary files differ diff --git a/wikipedia/res/drawable-mdpi/ic_license_cc.png b/wikipedia/res/drawable-mdpi/ic_license_cc.png new file mode 100644 index 0000000..3d116bb --- /dev/null +++ b/wikipedia/res/drawable-mdpi/ic_license_cc.png Binary files differ diff --git a/wikipedia/res/drawable-mdpi/ic_license_cite.png b/wikipedia/res/drawable-mdpi/ic_license_cite.png new file mode 100644 index 0000000..431a80c --- /dev/null +++ b/wikipedia/res/drawable-mdpi/ic_license_cite.png Binary files differ diff --git a/wikipedia/res/drawable-mdpi/ic_license_pd.png b/wikipedia/res/drawable-mdpi/ic_license_pd.png new file mode 100644 index 0000000..279e0b4 --- /dev/null +++ b/wikipedia/res/drawable-mdpi/ic_license_pd.png Binary files differ diff --git a/wikipedia/res/drawable-xhdpi/ic_license_cc.png b/wikipedia/res/drawable-xhdpi/ic_license_cc.png new file mode 100644 index 0000000..b904601 --- /dev/null +++ b/wikipedia/res/drawable-xhdpi/ic_license_cc.png Binary files differ diff --git a/wikipedia/res/drawable-xhdpi/ic_license_cite.png b/wikipedia/res/drawable-xhdpi/ic_license_cite.png new file mode 100644 index 0000000..570b83e --- /dev/null +++ b/wikipedia/res/drawable-xhdpi/ic_license_cite.png Binary files differ diff --git a/wikipedia/res/drawable-xhdpi/ic_license_pd.png b/wikipedia/res/drawable-xhdpi/ic_license_pd.png new file mode 100644 index 0000000..5cd6460 --- /dev/null +++ b/wikipedia/res/drawable-xhdpi/ic_license_pd.png Binary files differ diff --git a/wikipedia/res/drawable-xxhdpi/ic_license_cc.png b/wikipedia/res/drawable-xxhdpi/ic_license_cc.png new file mode 100644 index 0000000..23db7cd --- /dev/null +++ b/wikipedia/res/drawable-xxhdpi/ic_license_cc.png Binary files differ diff --git a/wikipedia/res/drawable-xxhdpi/ic_license_cite.png b/wikipedia/res/drawable-xxhdpi/ic_license_cite.png new file mode 100644 index 0000000..5641591 --- /dev/null +++ b/wikipedia/res/drawable-xxhdpi/ic_license_cite.png Binary files differ diff --git a/wikipedia/res/drawable-xxhdpi/ic_license_pd.png b/wikipedia/res/drawable-xxhdpi/ic_license_pd.png new file mode 100644 index 0000000..814e384 --- /dev/null +++ b/wikipedia/res/drawable-xxhdpi/ic_license_pd.png Binary files differ diff --git a/wikipedia/res/layout/activity_gallery.xml b/wikipedia/res/layout/activity_gallery.xml index 1e2f4b3..92a5d87 100644 --- a/wikipedia/res/layout/activity_gallery.xml +++ b/wikipedia/res/layout/activity_gallery.xml @@ -51,23 +51,27 @@ android:fadeScrollbars="false" android:textColor="@color/lead_text_color" android:textColorLink="@color/lead_text_color"/> - <TextView - android:id="@+id/gallery_credit_text" - android:layout_width="wrap_content" + <LinearLayout + android:layout_width="match_parent" android:layout_height="wrap_content" - android:textColor="@color/gallery_license_text" - android:textColorLink="@color/gallery_license_text" - android:ellipsize="end" - android:maxLines="2" - android:layout_marginTop="8dp"/> - <TextView - android:id="@+id/gallery_license_text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textColor="@color/gallery_license_text" - android:textColorLink="@color/gallery_license_text" - android:ellipsize="end" - android:maxLines="2" - android:layout_marginTop="4dp"/> + android:layout_marginTop="8dp" + android:orientation="horizontal" + android:gravity="center_vertical"> + <ImageView + android:id="@+id/gallery_license_icon" + android:layout_width="20dp" + android:layout_height="20dp" + android:contentDescription="@null"/> + <TextView + android:id="@+id/gallery_credit_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingLeft="8dp" + android:paddingRight="8dp" + android:textColor="@color/gallery_license_text" + android:textColorLink="@color/gallery_license_text" + android:ellipsize="end" + android:maxLines="2"/> + </LinearLayout> </LinearLayout> </FrameLayout> diff --git a/wikipedia/res/values-qq/strings.xml b/wikipedia/res/values-qq/strings.xml index 398fd84..f23f6c1 100644 --- a/wikipedia/res/values-qq/strings.xml +++ b/wikipedia/res/values-qq/strings.xml @@ -391,10 +391,6 @@ <string name="menu_gallery_visit_page">Menu label for navigating to the File page for the current image being shown in the gallery.</string> <string name="gallery_error_draw_failed">Error message shown when the current image could not be displayed.</string> <string name="license_title">Activity title of license text for the libraries we use</string> - <string name="gallery_license_text">Label that specifies the license under which the image is protected. The \"%s\" symbol will be replaced by the name of the license. -{{Identical|License}}</string> - <string name="gallery_credit_text">Label that specifies the person or entity to whom the image should be credited. The \"%s\" symbol will be replaced by the author of the image. -{{Identical|Author}}</string> <string name="gallery_image_info">Label for a dialog that shows detailed information about the current image shown in the gallery.</string> <string name="gallery_menu_share">Label for menu item to share the current image. {{Identical|Share}}</string> diff --git a/wikipedia/res/values/strings.xml b/wikipedia/res/values/strings.xml index 9e37f57..359ca5f 100644 --- a/wikipedia/res/values/strings.xml +++ b/wikipedia/res/values/strings.xml @@ -282,8 +282,6 @@ <string name="menu_gallery_visit_page">Go to file page</string> <string name="gallery_error_draw_failed">Could not draw the image.</string> <string name="license_title">License text for %s library</string> - <string name="gallery_license_text">License – %s</string> - <string name="gallery_credit_text">Author – %s</string> <string name="gallery_image_info">Image information</string> <string name="gallery_menu_share">Share</string> <string name="gallery_share_error">Could not share image: %s</string> diff --git a/wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java b/wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java index 2026413..34712b6 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java +++ b/wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java @@ -30,6 +30,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; +import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; import de.keyboardsurfer.android.widget.crouton.Crouton; @@ -79,7 +80,7 @@ private ViewGroup infoContainer; private ProgressBar progressBar; private TextView descriptionText; - private TextView licenseText; + private ImageView licenseIcon; private TextView creditText; private boolean controlsShowing = true; @@ -107,9 +108,16 @@ descriptionText.setShadowLayer(2, 1, 1, getResources().getColor(R.color.lead_text_shadow)); descriptionText.setMovementMethod(linkMovementMethod); - licenseText = (TextView) findViewById(R.id.gallery_license_text); - licenseText.setShadowLayer(2, 1, 1, getResources().getColor(R.color.lead_text_shadow)); - licenseText.setMovementMethod(linkMovementMethod); + licenseIcon = (ImageView) findViewById(R.id.gallery_license_icon); + licenseIcon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String licenseUrl = (String) v.getTag(); + if (TextUtils.isEmpty(licenseUrl)) { + Utils.handleExternalLink(GalleryActivity.this, Uri.parse(licenseUrl)); + } + } + }); creditText = (TextView) findViewById(R.id.gallery_credit_text); creditText.setShadowLayer(2, 1, 1, getResources().getColor(R.color.lead_text_shadow)); @@ -440,35 +448,33 @@ descriptionText.setVisibility(View.GONE); } - CharSequence licenseStr = ""; - if (item.getMetadata().containsKey("LicenseShortName")) { - licenseStr = item.getMetadata().get("LicenseShortName"); - } else if (item.getMetadata().containsKey("License")) { - licenseStr = item.getMetadata().get("License"); - } - if (!TextUtils.isEmpty(licenseStr)) { - // is there a license URL? If so, surround the string with it! - if (item.getMetadata().containsKey("LicenseUrl")) { - licenseStr = "<a href=\"" + item.getMetadata().get("LicenseUrl") - + "\">" + Utils.trim(licenseStr) + "</a>"; + // determine which icon to display... + if (item.isLicenseFree()) { + if (item.isLicensePD()) { + licenseIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_license_pd)); + } else if (item.isLicenseCC()) { + licenseIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_license_cc)); + } else { + licenseIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_license_cite)); } - licenseStr = Html - .fromHtml(String.format(getString(R.string.gallery_license_text), licenseStr)); - licenseText.setText(licenseStr); - licenseText.setVisibility(View.VISIBLE); } else { - licenseText.setVisibility(View.GONE); + licenseIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_license_cite)); } + // Give the license URL to the icon, to be received by the click handler (may be null). + licenseIcon.setTag(item.getLicenseUrl()); - CharSequence creditStr = ""; + String creditStr = ""; if (item.getMetadata().containsKey("Artist")) { - creditStr = String.format(getString(R.string.gallery_credit_text), Utils.trim( - Html.fromHtml(item.getMetadata().get("Artist")))); - creditText.setText(creditStr); - creditText.setVisibility(View.VISIBLE); - } else { - creditText.setVisibility(View.GONE); + creditStr = Html.fromHtml(item.getMetadata().get("Artist")).toString(); + } else if(item.getMetadata().containsKey("LicenseShortName")) { + // if we don't have the author name, then display the license name + creditStr = item.getMetadata().get("LicenseShortName"); + } else if(item.getMetadata().containsKey("UsageTerms")) { + // and if there's no license name, then at least show usage terms. + creditStr = item.getMetadata().get("UsageTerms"); } + creditText.setText(creditStr.trim()); + infoContainer.setVisibility(View.VISIBLE); } diff --git a/wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryItem.java b/wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryItem.java index a4ffdaf..ca29deb 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryItem.java +++ b/wikipedia/src/main/java/org/wikipedia/page/gallery/GalleryItem.java @@ -2,6 +2,7 @@ import org.json.JSONException; import org.json.JSONObject; +import android.text.TextUtils; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -28,6 +29,36 @@ private final int height; public int getHeight() { return height; } + private String licenseName; + private String licenseUrl; + private boolean licenseFree = true; + + public String getLicenseUrl() { + return licenseUrl; + } + + public boolean isLicenseCC() { + if (!TextUtils.isEmpty(licenseName)) { + if (licenseName.startsWith("cc")) { + return true; + } + } + return false; + } + + public boolean isLicensePD() { + if (!TextUtils.isEmpty(licenseName)) { + if (licenseName.startsWith("pd")) { + return true; + } + } + return false; + } + + public boolean isLicenseFree() { + return licenseFree; + } + public GalleryItem(String name) { this.name = name; this.url = null; @@ -52,7 +83,21 @@ Iterator<String> keys = extmetadata.keys(); while (keys.hasNext()) { String key = keys.next(); - metadata.put(key, extmetadata.getJSONObject(key).getString("value")); + String value = extmetadata.getJSONObject(key).getString("value"); + metadata.put(key, value); + switch (key) { + case "License": + licenseName = value; + break; + case "LicenseUrl": + licenseUrl = value; + break; + case "NonFree": + licenseFree = !value.equals("true"); + break; + default: + break; + } } } } -- To view, visit https://gerrit.wikimedia.org/r/191910 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I621b87b2ae1cc89189c7cf7d8e9d1cf030a881c2 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Dbrant <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
