jenkins-bot has submitted this change and it was merged.

Change subject: Link preview tweaks.
......................................................................


Link preview tweaks.

- The title is now clickable (Materially), and goes to the target article.
- Removed the thumbnail image next to the title.
- Removed dark background from title & overflow button.
- Removed the persistent button on top of the preview, and moved it to the
  bottom of the content, as it was originally. (And therefore removed the
  "overlay" view code)
- The bottom button is now Material-styled.
- Reduced the TextExtract length to 2 sentences, as it was before.
- Made the TextExtract receiver more fault-tolerant (optString instead of
  getString)
- Updated the image gallery Funnel to track whether it was entered via the
  link preview (in addition to Lead Image vs. non-lead image). (The schema
  already supports this generalization)
- Brought back client-side processing of sentences from the TextExtract.
  (Sorry to flip-flop on this, but additional testing of this
  functionality has convinced me that it really is better this way. Once
  we transition to the content service, we can take this out.)
- An executive decision to refer to articles as "articles" in this
  instance (Design and mgt. are in agreement).

Bug: T108374 T109342 T109340
Change-Id: Iec04b087d8864bf35181b9a6523cc2cca34ab7df
---
M app/src/main/java/org/wikipedia/analytics/GalleryFunnel.java
M app/src/main/java/org/wikipedia/page/PageFragment.java
M app/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java
M app/src/main/java/org/wikipedia/page/gallery/GalleryThumbnailScrollView.java
M app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
M app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewContents.java
M app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
M app/src/main/java/org/wikipedia/page/linkpreview/PreviewFetchTask.java
M app/src/main/java/org/wikipedia/page/linkpreview/SwipeableBottomDialog.java
A app/src/main/res/anim/thumbnail_item_press.xml
A app/src/main/res/anim/thumbnail_item_release.xml
M app/src/main/res/layout/dialog_link_preview.xml
D app/src/main/res/layout/dialog_link_preview_overlay.xml
M app/src/main/res/values-qq/strings.xml
M app/src/main/res/values/dimens.xml
M app/src/main/res/values/strings.xml
16 files changed, 227 insertions(+), 161 deletions(-)

Approvals:
  Sniedzielski: Looks good to me, approved
  Niedzielski: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/app/src/main/java/org/wikipedia/analytics/GalleryFunnel.java 
b/app/src/main/java/org/wikipedia/analytics/GalleryFunnel.java
index daf58f3..35fd2e1 100644
--- a/app/src/main/java/org/wikipedia/analytics/GalleryFunnel.java
+++ b/app/src/main/java/org/wikipedia/analytics/GalleryFunnel.java
@@ -8,17 +8,18 @@
 import org.wikipedia.WikipediaApp;
 
 public class GalleryFunnel extends TimedFunnel {
+    public static final int SOURCE_LEAD_IMAGE = 0;
+    public static final int SOURCE_NON_LEAD_IMAGE = 1;
+    public static final int SOURCE_LINK_PREVIEW = 2;
+
     private static final String SCHEMA_NAME = "MobileWikiAppMediaGallery";
     private static final int REV_ID = 12588701;
-    private static final int SOURCE_LEAD_IMAGE = 0;
-    private static final int SOURCE_NON_LEAD_IMAGE = 1;
 
     private final int source;
 
-    public GalleryFunnel(WikipediaApp app, Site site, boolean fromLeadImage) {
+    public GalleryFunnel(WikipediaApp app, Site site, int source) {
         super(app, SCHEMA_NAME, REV_ID, Funnel.SAMPLE_LOG_100, site);
-
-        this.source = fromLeadImage ? SOURCE_LEAD_IMAGE : 
SOURCE_NON_LEAD_IMAGE;
+        this.source = source;
     }
 
     @Override
diff --git a/app/src/main/java/org/wikipedia/page/PageFragment.java 
b/app/src/main/java/org/wikipedia/page/PageFragment.java
index 38fec9c..1d06c1b 100755
--- a/app/src/main/java/org/wikipedia/page/PageFragment.java
+++ b/app/src/main/java/org/wikipedia/page/PageFragment.java
@@ -8,6 +8,7 @@
 import org.wikipedia.Utils;
 import org.wikipedia.WikipediaApp;
 import org.wikipedia.analytics.ConnectionIssueFunnel;
+import org.wikipedia.analytics.GalleryFunnel;
 import org.wikipedia.analytics.LinkPreviewFunnel;
 import org.wikipedia.analytics.SavedPagesFunnel;
 import org.wikipedia.analytics.TabFunnel;
@@ -624,7 +625,7 @@
                     if (href.startsWith("/wiki/")) {
                         PageTitle imageTitle = 
model.getTitle().getSite().titleForInternalLink(href);
                         GalleryActivity.showGallery(getActivity(), 
model.getTitleOriginal(),
-                                imageTitle, false);
+                                imageTitle, 
GalleryFunnel.SOURCE_NON_LEAD_IMAGE);
                     } else {
                         linkHandler.onUrlClick(href);
                     }
@@ -639,7 +640,8 @@
                 try {
                     String href = 
Utils.decodeURL(messagePayload.getString("href"));
                     GalleryActivity.showGallery(getActivity(), 
model.getTitleOriginal(),
-                            new PageTitle(href, model.getTitle().getSite()), 
false);
+                            new PageTitle(href, model.getTitle().getSite()),
+                            GalleryFunnel.SOURCE_NON_LEAD_IMAGE);
                 } catch (JSONException e) {
                     ACRA.getErrorReporter().handleException(e);
                 }
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 512f065..9015853 100644
--- a/app/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java
+++ b/app/src/main/java/org/wikipedia/page/gallery/GalleryActivity.java
@@ -51,7 +51,7 @@
 
     public static final String EXTRA_PAGETITLE = "pageTitle";
     public static final String EXTRA_IMAGETITLE = "imageTitle";
-    public static final String EXTRA_FROM_LEAD_IMAGE = "fromLeadImage";
+    public static final String EXTRA_SOURCE = "source";
 
     private WikipediaApp app;
     private PageTitle pageTitle;
@@ -163,7 +163,7 @@
         galleryPager.setOnPageChangeListener(new GalleryPageChangeListener());
 
         funnel = new GalleryFunnel(app, pageTitle.getSite(),
-                                   
getIntent().getBooleanExtra(EXTRA_FROM_LEAD_IMAGE, false));
+                                   getIntent().getIntExtra(EXTRA_SOURCE, 0));
 
         if (savedInstanceState == null) {
             if (initialImageTitle != null) {
@@ -224,12 +224,12 @@
      * @param imageTitle Image with which to begin the gallery.
      */
     public static void showGallery(Activity activity, PageTitle pageTitle, 
PageTitle imageTitle,
-                                   boolean fromLeadImage) {
+                                   int source) {
         Intent galleryIntent = new Intent();
         galleryIntent.setClass(activity, GalleryActivity.class);
         galleryIntent.putExtra(EXTRA_IMAGETITLE, imageTitle);
         galleryIntent.putExtra(EXTRA_PAGETITLE, pageTitle);
-        galleryIntent.putExtra(EXTRA_FROM_LEAD_IMAGE, fromLeadImage);
+        galleryIntent.putExtra(EXTRA_SOURCE, source);
         activity.startActivityForResult(galleryIntent, 
PageActivity.ACTIVITY_REQUEST_GALLERY);
     }
 
diff --git 
a/app/src/main/java/org/wikipedia/page/gallery/GalleryThumbnailScrollView.java 
b/app/src/main/java/org/wikipedia/page/gallery/GalleryThumbnailScrollView.java
index 764c127..81faa60 100644
--- 
a/app/src/main/java/org/wikipedia/page/gallery/GalleryThumbnailScrollView.java
+++ 
b/app/src/main/java/org/wikipedia/page/gallery/GalleryThumbnailScrollView.java
@@ -11,25 +11,20 @@
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
 import android.widget.ImageView;
 
 import com.squareup.picasso.Picasso;
 
 public class GalleryThumbnailScrollView extends RecyclerView {
     @NonNull private final Context mContext;
+    @NonNull private final Animation mPressAnimation;
+    @NonNull private final Animation mReleaseAnimation;
     @Nullable private GalleryViewListener mListener;
-
-    private final OnClickListener mItemClickListener = new OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            if (mListener != null) {
-                GalleryItem item = (GalleryItem) v.getTag();
-                mListener.onGalleryItemClicked(item.getName());
-            }
-        }
-    };
 
     public GalleryThumbnailScrollView(Context context) {
         this(context, null);
@@ -43,6 +38,9 @@
         super(context, attrs, defStyle);
         this.mContext = context;
         setLayoutManager(new LinearLayoutManager(context, 
LinearLayoutManager.HORIZONTAL, false));
+
+        mPressAnimation = AnimationUtils.loadAnimation(context, 
R.anim.thumbnail_item_press);
+        mReleaseAnimation = AnimationUtils.loadAnimation(context, 
R.anim.thumbnail_item_release);
     }
 
     public interface GalleryViewListener {
@@ -57,7 +55,7 @@
         setAdapter(new GalleryViewAdapter(collection));
     }
 
-    private class GalleryItemHolder extends ViewHolder {
+    private class GalleryItemHolder extends ViewHolder implements 
OnClickListener, OnTouchListener {
         private final ImageView mImageView;
         private GalleryItem mGalleryItem;
 
@@ -68,8 +66,8 @@
 
         public void bindItem(GalleryItem item) {
             mGalleryItem = item;
-            mImageView.setOnClickListener(mItemClickListener);
-            mImageView.setTag(mGalleryItem);
+            mImageView.setOnClickListener(this);
+            mImageView.setOnTouchListener(this);
             if (WikipediaApp.getInstance().isImageDownloadEnabled()
                     && !TextUtils.isEmpty(mGalleryItem.getThumbUrl())) {
                 Picasso.with(mContext)
@@ -79,6 +77,29 @@
                         .into(mImageView);
             }
         }
+
+        @Override
+        public void onClick(View v) {
+            if (mListener != null) {
+                mListener.onGalleryItemClicked(mGalleryItem.getName());
+            }
+        }
+
+        @Override
+        public boolean onTouch(View v, MotionEvent event) {
+            switch (event.getAction()) {
+                case MotionEvent.ACTION_DOWN:
+                    v.startAnimation(mPressAnimation);
+                    break;
+                case MotionEvent.ACTION_UP:
+                case MotionEvent.ACTION_CANCEL:
+                    v.startAnimation(mReleaseAnimation);
+                    break;
+                default:
+                    break;
+            }
+            return false;
+        }
     }
 
     private final class GalleryViewAdapter extends 
RecyclerView.Adapter<GalleryItemHolder> {
diff --git 
a/app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java 
b/app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
index d761607..411d023 100755
--- a/app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
+++ b/app/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java
@@ -25,6 +25,7 @@
 
 import org.json.JSONException;
 import org.json.JSONObject;
+import org.wikipedia.analytics.GalleryFunnel;
 import org.wikipedia.page.PageTitle;
 import org.wikipedia.R;
 import org.wikipedia.Utils;
@@ -148,7 +149,8 @@
                                                              
parentFragment.getTitle()
                                                                            
.getSite());
                         
GalleryActivity.showGallery(parentFragment.getActivity(),
-                                parentFragment.getTitleOriginal(), imageTitle, 
false);
+                                parentFragment.getTitleOriginal(), imageTitle,
+                                GalleryFunnel.SOURCE_LEAD_IMAGE);
                     }
                     return true;
                 }
diff --git 
a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewContents.java 
b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewContents.java
index 8b11a49..340d1ea 100755
--- a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewContents.java
+++ b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewContents.java
@@ -1,12 +1,20 @@
 package org.wikipedia.page.linkpreview;
 
+import android.text.TextUtils;
+
 import org.wikipedia.page.PageTitle;
 import org.wikipedia.Site;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.wikipedia.Utils;
 
+import java.text.BreakIterator;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
 public class LinkPreviewContents {
+    private static final int EXTRACT_MAX_SENTENCES = 2;
 
     private final PageTitle title;
     public PageTitle getTitle() {
@@ -25,9 +33,7 @@
 
     public LinkPreviewContents(JSONObject json, Site site) throws 
JSONException {
         title = new PageTitle(json.getString("title"), site);
-        // replace newlines in the extract with double newlines, so that 
they'll show up
-        // as paragraph breaks when displayed in a TextView.
-        extract = json.getString("extract").replace("\n", "\n\n");
+        extract = 
makeStringFromSentences(getSentences(removeParens(json.optString("extract")), 
site), EXTRACT_MAX_SENTENCES);
         if (json.has("thumbnail")) {
             
title.setThumbUrl(json.getJSONObject("thumbnail").optString("source"));
         }
@@ -78,4 +84,36 @@
         return (level == 0) ? outStr.toString() : text;
     }
 
+    /**
+     * Split a block of text into sentences, taking into account the language 
in which
+     * the text is assumed to be.
+     * @param text Text to be transformed into sentences.
+     * @param site Site that will provide the language of the given text.
+     * @return List of sentences.
+     */
+    public static List<String> getSentences(String text, Site site) {
+        List<String> sentenceList = new ArrayList<>();
+        BreakIterator iterator = BreakIterator.getSentenceInstance(new 
Locale(site.getLanguageCode()));
+        // feed the text into the iterator, with line breaks removed:
+        text = text.replaceAll("(\r|\n)", " ");
+        iterator.setText(text);
+        for (int start = iterator.first(), end = iterator.next(); end != 
BreakIterator.DONE; start = end, end = iterator.next()) {
+            String sentence = text.substring(start, end).trim();
+            if (TextUtils.isGraphic(sentence)) {
+                // if it's the first sentence, then remove parentheses from it.
+                String formattedSentence = sentenceList.isEmpty() ? 
removeParens(sentence) : sentence;
+                sentenceList.add(formattedSentence);
+            }
+        }
+        // if we couldn't detect any sentences using the BreakIterator, then 
just return the
+        // original text as a single sentence.
+        if (sentenceList.isEmpty()) {
+            sentenceList.add(text);
+        }
+        return sentenceList;
+    }
+
+    private String makeStringFromSentences(List<String> sentences, int 
maxSentences) {
+        return TextUtils.join(" ", sentences.subList(0, Math.min(maxSentences, 
sentences.size())));
+    }
 }
diff --git 
a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java 
b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
index e3aebf7..e64b538 100755
--- a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
+++ b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.java
@@ -1,6 +1,7 @@
 package org.wikipedia.page.linkpreview;
 
 import org.mediawiki.api.json.Api;
+import org.wikipedia.analytics.GalleryFunnel;
 import org.wikipedia.history.HistoryEntry;
 import org.wikipedia.page.PageActivity;
 import org.wikipedia.page.PageActivityLongPressHandler;
@@ -14,15 +15,12 @@
 import org.wikipedia.page.gallery.GalleryThumbnailScrollView;
 import org.wikipedia.util.ApiUtil;
 import org.wikipedia.util.FeedbackUtil;
+import org.wikipedia.views.ViewUtil;
 
-import com.squareup.picasso.Callback;
-import com.squareup.picasso.Picasso;
 import android.content.DialogInterface;
-import android.graphics.Color;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.v7.widget.PopupMenu;
-import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.MenuItem;
@@ -30,8 +28,7 @@
 import android.view.ViewGroup;
 import android.view.animation.Animation;
 import android.view.animation.AnimationUtils;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
@@ -39,17 +36,13 @@
 
 public class LinkPreviewDialog extends SwipeableBottomDialog implements 
DialogInterface.OnDismissListener {
     private static final String TAG = "LinkPreviewDialog";
-    private static final int THUMBNAIL_SIZE = 320;
 
     private boolean navigateSuccess = false;
 
-    private View previewContainer;
     private ProgressBar progressBar;
     private TextView extractText;
-    private ImageView previewImage;
     private GalleryThumbnailScrollView thumbnailGallery;
 
-    private WikipediaApp app;
     private PageTitle pageTitle;
     private int entrySource;
 
@@ -63,7 +56,8 @@
         @Override
         public void onGalleryItemClicked(String imageName) {
             PageTitle imageTitle = new PageTitle(imageName, 
pageTitle.getSite());
-            GalleryActivity.showGallery(getActivity(), pageTitle, imageTitle, 
false);
+            GalleryActivity.showGallery(getActivity(), pageTitle, imageTitle,
+                    GalleryFunnel.SOURCE_LINK_PREVIEW);
         }
     };
 
@@ -92,23 +86,26 @@
 
     @Override
     protected View inflateDialogView(LayoutInflater inflater, ViewGroup 
container) {
-        app = WikipediaApp.getInstance();
+        WikipediaApp app = WikipediaApp.getInstance();
         pageTitle = getArguments().getParcelable("title");
         entrySource = getArguments().getInt("entrySource");
 
         View rootView = inflater.inflate(R.layout.dialog_link_preview, 
container);
-        previewContainer = rootView.findViewById(R.id.link_preview_container);
         progressBar = (ProgressBar) 
rootView.findViewById(R.id.link_preview_progress);
+        
rootView.findViewById(R.id.link_preview_toolbar).setOnClickListener(goToPageListener);
         TextView titleText = (TextView) 
rootView.findViewById(R.id.link_preview_title);
         titleText.setText(pageTitle.getDisplayText());
-        if (!ApiUtil.hasLollipop()) {
-            final int bottomPadding = (int)(8 * app.getScreenDensity());
-            titleText.setPadding(titleText.getPaddingLeft(), 
titleText.getPaddingTop(),
-                    titleText.getPaddingRight(), titleText.getPaddingBottom() 
+ bottomPadding);
+        if (!ApiUtil.hasHoneyComb()) {
+            // for GB, reset line spacing to 1, since it doesn't handle <1 
very well.
+            titleText.setLineSpacing(0, 1.0f);
+        } else if (!ApiUtil.hasLollipop()) {
+            // for <5.0, give the title a bit more bottom padding, since these 
versions
+            // incorrectly cut off the bottom of the text when line spacing is 
<1.
+            final int bottomPadding = 8;
+            ViewUtil.setBottomPaddingDp(titleText, bottomPadding);
         }
 
         onNavigateListener = new DefaultOnNavigateListener();
-        previewImage = (ImageView) 
rootView.findViewById(R.id.link_preview_image);
         extractText = (TextView) 
rootView.findViewById(R.id.link_preview_extract);
 
         thumbnailGallery = (GalleryThumbnailScrollView) 
rootView.findViewById(R.id.link_preview_thumbnail_gallery);
@@ -117,11 +114,7 @@
             thumbnailGallery.setGalleryViewListener(galleryViewListener);
         }
 
-        previewImage.setOnClickListener(goToPageListener);
-
-        View overlayView = 
setOverlayLayout(R.layout.dialog_link_preview_overlay);
-        View goButton = overlayView.findViewById(R.id.link_preview_go_button);
-        goButton.setOnClickListener(goToPageListener);
+        
rootView.findViewById(R.id.link_preview_go_button).setOnClickListener(goToPageListener);
 
         final View overflowButton = 
rootView.findViewById(R.id.link_preview_overflow_button);
         overflowButton.setOnClickListener(new View.OnClickListener() {
@@ -253,31 +246,13 @@
     }
 
     private void layoutPreview() {
-        previewContainer.setVisibility(View.VISIBLE);
         if (contents.getExtract().length() > 0) {
             extractText.setText(contents.getExtract());
         }
 
-        FrameLayout.LayoutParams extractLayoutParams = 
(FrameLayout.LayoutParams) extractText.getLayoutParams();
+        LinearLayout.LayoutParams extractLayoutParams = 
(LinearLayout.LayoutParams) extractText.getLayoutParams();
         extractLayoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
         extractText.setLayoutParams(extractLayoutParams);
-
-        if (!TextUtils.isEmpty(contents.getTitle().getThumbUrl()) && 
app.isImageDownloadEnabled()) {
-            Picasso.with(getActivity())
-                    .load(contents.getTitle().getThumbUrl())
-                    .placeholder(R.drawable.ic_pageimage_placeholder)
-                    .error(R.drawable.ic_pageimage_placeholder)
-                    .into(previewImage, new Callback() {
-                        @Override
-                        public void onSuccess() {
-                            previewImage.setBackgroundColor(Color.WHITE);
-                        }
-
-                        @Override
-                        public void onError() {
-                        }
-                    });
-        }
     }
 
     private class GalleryThumbnailFetchTask extends GalleryCollectionFetchTask 
{
diff --git 
a/app/src/main/java/org/wikipedia/page/linkpreview/PreviewFetchTask.java 
b/app/src/main/java/org/wikipedia/page/linkpreview/PreviewFetchTask.java
index f2a38a4..9e43931 100755
--- a/app/src/main/java/org/wikipedia/page/linkpreview/PreviewFetchTask.java
+++ b/app/src/main/java/org/wikipedia/page/linkpreview/PreviewFetchTask.java
@@ -19,8 +19,8 @@
     public void buildQueryParams(RequestBuilder builder) {
         builder.param("prop", "extracts|pageimages|pageterms")
                .param("redirects", "true")
-               //.param("exchars", "4096")
-               .param("exsentences", "4")
+               .param("exchars", "512")
+               //.param("exsentences", "2")
                .param("explaintext", "true")
                .param("piprop", "thumbnail|name")
                .param("pithumbsize", 
Integer.toString(WikipediaApp.PREFERRED_THUMB_SIZE))
diff --git 
a/app/src/main/java/org/wikipedia/page/linkpreview/SwipeableBottomDialog.java 
b/app/src/main/java/org/wikipedia/page/linkpreview/SwipeableBottomDialog.java
index 1a5f0b3..babd012 100644
--- 
a/app/src/main/java/org/wikipedia/page/linkpreview/SwipeableBottomDialog.java
+++ 
b/app/src/main/java/org/wikipedia/page/linkpreview/SwipeableBottomDialog.java
@@ -6,10 +6,10 @@
 import android.graphics.Color;
 import android.graphics.drawable.ColorDrawable;
 import android.os.Bundle;
-import android.support.annotation.LayoutRes;
 import android.support.annotation.NonNull;
 import android.support.v4.app.DialogFragment;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AbsListView;
@@ -67,13 +67,6 @@
             if (firstVisibleItem == 0) {
                 dismiss();
             }
-        }
-    };
-
-    private View.OnClickListener dismissOnClickListener = new 
View.OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            dismiss();
         }
     };
 
@@ -138,10 +131,6 @@
         dialogPeekHeight = height;
     }
 
-    public View setOverlayLayout(@LayoutRes int layout) {
-        return getActivity().getLayoutInflater().inflate(layout, rootView);
-    }
-
     private int getDialogWidth() {
         return Math.min(getResources().getDisplayMetrics().widthPixels,
                 (int) 
getResources().getDimension(R.dimen.swipeableDialogMaxWidth));
@@ -151,7 +140,15 @@
         View view = new View(getActivity());
         view.setLayoutParams(new ListView.LayoutParams(width, height));
         view.setClickable(true);
-        view.setOnClickListener(dismissOnClickListener);
+        view.setOnTouchListener(new View.OnTouchListener() {
+            @Override
+            public boolean onTouch(View v, MotionEvent event) {
+                if (event.getAction() == MotionEvent.ACTION_DOWN) {
+                    dismiss();
+                }
+                return true;
+            }
+        });
         return view;
     }
 
diff --git a/app/src/main/res/anim/thumbnail_item_press.xml 
b/app/src/main/res/anim/thumbnail_item_press.xml
new file mode 100644
index 0000000..f5f2f35
--- /dev/null
+++ b/app/src/main/res/anim/thumbnail_item_press.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android";
+    android:fillAfter="true">
+    <scale
+        android:duration="100"
+        android:startOffset="0"
+        android:fromXScale="1"
+        android:fromYScale="1"
+        android:pivotX="50%"
+        android:pivotY="50%"
+        android:toXScale="@dimen/linkPreviewThumbPressOverScale"
+        android:toYScale="@dimen/linkPreviewThumbPressOverScale"/>
+    <scale
+        android:duration="100"
+        android:startOffset="100"
+        android:fromXScale="@dimen/linkPreviewThumbPressOverScale"
+        android:fromYScale="@dimen/linkPreviewThumbPressOverScale"
+        android:pivotX="50%"
+        android:pivotY="50%"
+        android:toXScale="@dimen/linkPreviewThumbPressScale"
+        android:toYScale="@dimen/linkPreviewThumbPressScale"/>
+</set>
\ No newline at end of file
diff --git a/app/src/main/res/anim/thumbnail_item_release.xml 
b/app/src/main/res/anim/thumbnail_item_release.xml
new file mode 100644
index 0000000..4acb242
--- /dev/null
+++ b/app/src/main/res/anim/thumbnail_item_release.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<scale
+    xmlns:android="http://schemas.android.com/apk/res/android";
+    android:duration="@android:integer/config_shortAnimTime"
+    android:startOffset="0"
+    android:fromXScale="@dimen/linkPreviewThumbPressScale"
+    android:fromYScale="@dimen/linkPreviewThumbPressScale"
+    android:pivotX="50%"
+    android:pivotY="50%"
+    android:toXScale="1"
+    android:toYScale="1"/>
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_link_preview.xml 
b/app/src/main/res/layout/dialog_link_preview.xml
index 474932f..be6edb7 100755
--- a/app/src/main/res/layout/dialog_link_preview.xml
+++ b/app/src/main/res/layout/dialog_link_preview.xml
@@ -7,88 +7,96 @@
 
     <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
+        android:layout_height="wrap_content"
         android:orientation="vertical">
 
         <View
             android:layout_width="match_parent"
             android:layout_height="8dp"
-            android:background="@drawable/link_preview_top_shadow"
-            />
+            android:background="@drawable/link_preview_top_shadow"/>
 
         <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:background="?attr/link_preview_toolbar_color"
-            android:orientation="horizontal">
-            <ImageView
-                android:id="@+id/link_preview_image"
-                android:layout_width="72dp"
-                android:layout_height="72dp"
-                android:src="@drawable/ic_pageimage_placeholder"
-                android:contentDescription="@null"
-                android:scaleType="centerCrop"/>
-            <TextView
-                android:id="@+id/link_preview_title"
-                android:layout_width="0dp"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:gravity="center_vertical"
-                style="@style/RtlAwareTextView"
-                android:paddingLeft="12dp"
-                android:paddingRight="12dp"
-                android:textSize="20sp"
-                android:fontFamily="serif"
-                android:lineSpacingMultiplier="0.8"
-                android:maxLines="3"
-                android:ellipsize="end"
-                android:textColor="@android:color/white"
-                tools:text="Lorem ipsum"/>
-            <ImageView
-                android:id="@+id/link_preview_overflow_button"
-                android:layout_width="48dp"
-                android:layout_height="48dp"
-                android:layout_gravity="center_vertical"
-                android:clickable="true"
-                android:padding="12dp"
-                android:background="?attr/actionBarItemBackground"
-                
android:contentDescription="@string/abc_action_menu_overflow_description"
-                android:src="@drawable/ic_more_vert" />
-        </LinearLayout>
-
-        <FrameLayout
-            android:id="@+id/link_preview_container"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
+            android:orientation="vertical"
             android:background="?attr/link_preview_background_color">
+
+            <LinearLayout
+                android:id="@+id/link_preview_toolbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:clickable="true"
+                android:background="?attr/selectableItemBackground"
+                android:minHeight="64dp">
+                <TextView
+                    android:id="@+id/link_preview_title"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="12dp"
+                    android:layout_marginBottom="12dp"
+                    android:layout_weight="1"
+                    android:layout_gravity="center_vertical"
+                    style="@style/RtlAwareTextView"
+                    android:textColor="?attr/link_preview_text_color"
+                    android:paddingLeft="16dp"
+                    android:paddingRight="16dp"
+                    android:paddingBottom="4dp"
+                    android:textSize="22sp"
+                    android:fontFamily="serif"
+                    android:lineSpacingMultiplier="0.8"
+                    android:maxLines="2"
+                    android:ellipsize="end"
+                    tools:text="Lorem ipsum"/>
+                <ImageView
+                    android:id="@+id/link_preview_overflow_button"
+                    android:layout_width="48dp"
+                    android:layout_height="48dp"
+                    android:layout_gravity="center_vertical"
+                    android:clickable="true"
+                    android:padding="12dp"
+                    android:background="?attr/actionBarItemBackground"
+                    
android:contentDescription="@string/abc_action_menu_overflow_description"
+                    android:src="@drawable/ic_more_vert"
+                    android:tint="?attr/link_preview_text_color"/>
+            </LinearLayout>
+
             <TextView
                 android:id="@+id/link_preview_extract"
                 android:layout_width="match_parent"
-                android:layout_height="200dp"
+                android:layout_height="240dp"
                 style="@style/RtlAwareTextView"
-                android:paddingTop="12dp"
+                android:paddingTop="4dp"
                 android:paddingBottom="12dp"
                 android:paddingLeft="16dp"
                 android:paddingRight="16dp"
-                android:textSize="17sp"
-                android:lineSpacingMultiplier="1.2"
+                android:textSize="16sp"
+                android:lineSpacingMultiplier="1.3"
                 android:textColor="?attr/link_preview_text_color"
                 android:textIsSelectable="true"
                 tools:text="Lorem ipsum"/>
-        </FrameLayout>
 
-        <org.wikipedia.page.gallery.GalleryThumbnailScrollView
-            android:id="@+id/link_preview_thumbnail_gallery"
-            android:layout_width="match_parent"
-            android:layout_height="120dp"
-            android:background="?attr/link_preview_background_color"
-            android:visibility="gone"/>
+            <org.wikipedia.page.gallery.GalleryThumbnailScrollView
+                android:id="@+id/link_preview_thumbnail_gallery"
+                android:layout_width="match_parent"
+                android:layout_height="120dp"
+                android:background="?attr/link_preview_background_color"
+                android:visibility="gone"/>
 
-        <View
-            android:layout_width="match_parent"
-            android:layout_height="64dp"
-            android:background="?attr/link_preview_background_color"
-            />
+            <Button
+                android:id="@+id/link_preview_go_button"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="16dp"
+                android:layout_marginRight="16dp"
+                android:layout_marginTop="8dp"
+                android:layout_marginBottom="8dp"
+                android:padding="4dp"
+                android:textColor="?attr/link_color"
+                style="@style/Widget.AppCompat.Button.Borderless"
+                android:text="@string/button_continue_to_article"/>
+
+        </LinearLayout>
 
     </LinearLayout>
 
diff --git a/app/src/main/res/layout/dialog_link_preview_overlay.xml 
b/app/src/main/res/layout/dialog_link_preview_overlay.xml
deleted file mode 100644
index 72b46cc..0000000
--- a/app/src/main/res/layout/dialog_link_preview_overlay.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Button
-    xmlns:android="http://schemas.android.com/apk/res/android";
-    android:id="@+id/link_preview_go_button"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:layout_gravity="bottom"
-    android:layout_margin="4dp"
-    android:padding="4dp"
-    android:background="@drawable/button_selector_green_progressive"
-    android:textColor="@android:color/white"
-    android:textAppearance="?android:attr/textAppearanceMedium"
-    android:text="@string/button_continue_to_article"/>
diff --git a/app/src/main/res/values-qq/strings.xml 
b/app/src/main/res/values-qq/strings.xml
index dbc9aa2..c5c9b6f 100644
--- a/app/src/main/res/values-qq/strings.xml
+++ b/app/src/main/res/values-qq/strings.xml
@@ -386,5 +386,5 @@
   <string name="menu_open_in_new_tab">Menu item for opening a link in a new 
tab.</string>
   <string name="menu_long_press_copy_page">Menu item for copying a link to the 
system clipbord for pasting later.</string>
 
-  <string name="button_continue_to_article">Button to continue to the full 
page from the current link preview.</string>
+  <string name="button_continue_to_article">Button to continue to the full 
article from the current link preview.</string>
 </resources>
diff --git a/app/src/main/res/values/dimens.xml 
b/app/src/main/res/values/dimens.xml
index 9b08be1..253c88f 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -40,6 +40,8 @@
     <dimen name="linkPreviewImageSize">112dp</dimen>
     <!-- Default height with which the Link Preview peeks out from the bottom 
-->
     <dimen name="linkPreviewPeekHeight">320dp</dimen>
+    <item type="dimen" format="float" 
name="linkPreviewThumbPressScale">1.03</item>
+    <item type="dimen" format="float" 
name="linkPreviewThumbPressOverScale">1.05</item>
 
     <!-- Share-a-fact image preview -->
     <dimen name="share_image_width">320dp</dimen>
diff --git a/app/src/main/res/values/strings.xml 
b/app/src/main/res/values/strings.xml
index d47e475..6442b5d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -298,5 +298,5 @@
     <string name="format_error_server_message">Message: \"%s\"</string>
     <string name="format_error_server_code">Code: \"%s\"</string>
     <string name="address_copied">Address copied to clipboard.</string>
-    <string name="button_continue_to_article">Continue to page</string>
+    <string name="button_continue_to_article">Continue to article</string>
 </resources>

-- 
To view, visit https://gerrit.wikimedia.org/r/232386
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iec04b087d8864bf35181b9a6523cc2cca34ab7df
Gerrit-PatchSet: 8
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to