Mholloway has uploaded a new change for review.
https://gerrit.wikimedia.org/r/246854
Change subject: Update license description handling
......................................................................
Update license description handling
-Added a showMessageAsPlainText function to FeedbackUtil to strip HTML
markup from string before displaying to the user
-Show license description in a Snackbar instead of a Toast
-Invert the behavior so that a regular click shows the license description
summary in a snackbar, and a long click fires a chooser to visit the
license info page in an external browser
Bug: T110946
Change-Id: Ic81704892e677af03ef01fd9dabdfd6fa54c329b
---
M app/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java
M app/src/main/java/org/wikipedia/util/FeedbackUtil.java
2 files changed, 34 insertions(+), 23 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia
refs/changes/54/246854/1
diff --git a/app/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java
b/app/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java
index 5cba842..b9f6167 100644
--- a/app/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java
+++ b/app/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java
@@ -95,6 +95,27 @@
private TextView creditText;
private boolean controlsShowing = true;
+ private View.OnClickListener licenseShortClickListener = new
View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (v.getContentDescription() == null) {
+ return;
+ }
+ FeedbackUtil.showMessageAsPlainText((Activity) v.getContext(),
v.getContentDescription());
+ }
+ };
+
+ private View.OnLongClickListener licenseLongClickListener = new
View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ String licenseUrl = (String) v.getTag();
+ if (!TextUtils.isEmpty(licenseUrl)) {
+ Utils.handleExternalLink(GalleryActivity.this,
Uri.parse(resolveProtocolRelativeUrl(licenseUrl)));
+ }
+ return true;
+ }
+ };
+
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// force the theme to dark...
@@ -127,29 +148,8 @@
descriptionText.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(resolveProtocolRelativeUrl(licenseUrl)));
- }
- }
- });
- licenseIcon.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if (v.getContentDescription() == null) {
- return false;
- }
- int[] pos = new int[2];
- v.getLocationInWindow(pos);
- Toast t = Toast.makeText(GalleryActivity.this,
v.getContentDescription(), Toast.LENGTH_SHORT);
- t.setGravity(Gravity.TOP | Gravity.START, pos[0], pos[1]);
- t.show();
- return true;
- }
- });
+ licenseIcon.setOnClickListener(licenseShortClickListener);
+ licenseIcon.setOnLongClickListener(licenseLongClickListener);
creditText = (TextView) findViewById(R.id.gallery_credit_text);
creditText.setShadowLayer(2, 1, 1,
getResources().getColor(R.color.lead_text_shadow));
diff --git a/app/src/main/java/org/wikipedia/util/FeedbackUtil.java
b/app/src/main/java/org/wikipedia/util/FeedbackUtil.java
index 613cad1..ffd7739 100644
--- a/app/src/main/java/org/wikipedia/util/FeedbackUtil.java
+++ b/app/src/main/java/org/wikipedia/util/FeedbackUtil.java
@@ -2,6 +2,7 @@
import android.app.Activity;
import android.support.design.widget.Snackbar;
+import android.text.Html;
import android.view.View;
import android.widget.TextView;
@@ -26,6 +27,16 @@
makeSnackbar(containerView, error.getError(), LENGTH_DEFAULT).show();
}
+ /**
+ * Show an HTML character sequence in a snackbar as plain text.
Html.fromHtml produces rich
+ * text (resulting, for instance, in link-looking text that does nothing
when clicked; the extra
+ * setText call is needed to render this as plain text. Also handles
plain text input fine.
+ */
+ public static void showMessageAsPlainText(Activity activity, CharSequence
possibleHtml) {
+ CharSequence richText = Html.fromHtml(possibleHtml.toString());
+ makeSnackbar(findBestView(activity), richText,
Snackbar.LENGTH_LONG).setText(richText.toString()).show();
+ }
+
private static void showMessage(View containerView, CharSequence text, int
duration) {
makeSnackbar(containerView, text, duration).show();
}
--
To view, visit https://gerrit.wikimedia.org/r/246854
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic81704892e677af03ef01fd9dabdfd6fa54c329b
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mholloway <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits