BearND has uploaded a new change for review. https://gerrit.wikimedia.org/r/189872
Change subject: ShareAFact: add preview + redesign ...................................................................... ShareAFact: add preview + redesign Redesigned the layout. Also added cc-by-sa and (R) icons. TODO: [] RTL mode [] use standard share icon [] call regular share functionality for second button Bug: T86843 Change-Id: Ie6990b1ae38808574ad083e935ef75170c883af2 --- A wikipedia/res/drawable/cc_by_sa_gray.png A wikipedia/res/layout/dialog_share_preview.xml M wikipedia/res/values-qq/strings.xml M wikipedia/res/values/strings.xml M wikipedia/res/values/styles.xml M wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java A wikipedia/src/main/java/org/wikipedia/page/snippet/PreviewDialogFragment.java M wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetImage.java M wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetShareAdapter.java 9 files changed, 261 insertions(+), 150 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/72/189872/1 diff --git a/wikipedia/res/drawable/cc_by_sa_gray.png b/wikipedia/res/drawable/cc_by_sa_gray.png new file mode 100644 index 0000000..c639da2 --- /dev/null +++ b/wikipedia/res/drawable/cc_by_sa_gray.png Binary files differ diff --git a/wikipedia/res/layout/dialog_share_preview.xml b/wikipedia/res/layout/dialog_share_preview.xml new file mode 100644 index 0000000..0ff6530 --- /dev/null +++ b/wikipedia/res/layout/dialog_share_preview.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_margin="0dp" + android:background="@color/white_progressive_dark" + android:orientation="vertical"> + + <ImageView + android:id="@+id/preview_img" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal|center_vertical" + android:layout_marginTop="16dp" + android:scaleType="centerInside" + android:src="@drawable/empty_nearby" + android:background="@android:color/black" + android:contentDescription="@string/snippet_share_preview_image_desc" /> + + <Button + android:id="@+id/share_as_image_button" + style="@style/button_blue_on_white" + android:layout_gravity="center_horizontal" + android:text="@string/share_snippet_button" /> + + <Button + android:id="@+id/share_as_text_button" + style="@style/button_blue_on_white" + android:layout_gravity="center_horizontal" + android:text="@string/share_normal_button" /> + +</LinearLayout> \ No newline at end of file diff --git a/wikipedia/res/values-qq/strings.xml b/wikipedia/res/values-qq/strings.xml index 00e444e..6dae69a 100644 --- a/wikipedia/res/values-qq/strings.xml +++ b/wikipedia/res/values-qq/strings.xml @@ -398,4 +398,7 @@ * %1$s is the title of the page the text snippet is from. * %2$s is an HTML link to the page.</string> <string name="expand_refs">Title for a button that, when clicked, will expand the list of references or notes at the bottom of a page.</string> + <string name="share_snippet_button">Button on share snippet preview to share as image card.</string> + <string name="share_normal_button">Button on share snippet preview to share as normal (text + maybe the lead image).</string> + <string name="snippet_share_preview_image_desc">Content description for the share a fact preview image. This string is only used for screen readers.</string> </resources> diff --git a/wikipedia/res/values/strings.xml b/wikipedia/res/values/strings.xml index 4561093..15230d1 100644 --- a/wikipedia/res/values/strings.xml +++ b/wikipedia/res/values/strings.xml @@ -289,4 +289,10 @@ <string name="err_cannot_save_file">Cannot save file</string> <string name="snippet_share_intro">\"%1$s\" on @Wikipedia: %2$s</string> <string name="expand_refs">Tap to expand</string> + <string name="title_activity_share_preview">Preview</string> + <string name="action_settings">Settings</string> + <string name="share_snippet_button">Share as image</string> + <string name="share_normal_button">Share as text</string> + <string name="snippet_share_preview_image_desc">Preview image</string> + </resources> diff --git a/wikipedia/res/values/styles.xml b/wikipedia/res/values/styles.xml index a4ad439..41f6247 100644 --- a/wikipedia/res/values/styles.xml +++ b/wikipedia/res/values/styles.xml @@ -30,6 +30,12 @@ <item name="android:textColor">@color/green_complete_dark</item> </style> + <style name="button_blue_on_white" parent="button_progressive"> + <item name="android:background">@drawable/button_selector_white</item> + <item name="android:textColor">@color/blue_progressive_dark</item> + <item name="android:layout_marginTop">0dp</item> + </style> + <style name="button_gray" parent="button_progressive"> <item name="android:background">@drawable/button_selector_gray</item> </style> diff --git a/wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java b/wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java index 403e923..de66be8 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java +++ b/wikipedia/src/main/java/org/wikipedia/page/leadimages/LeadImagesHandler.java @@ -2,6 +2,7 @@ import android.content.Context; import android.graphics.Bitmap; +import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Point; import android.os.Build; @@ -97,7 +98,6 @@ private int displayHeight; private int imageBaseYOffset = 0; private float displayDensity; - private Bitmap leadImageBitmap; public interface OnLeadImageLayoutListener { void onLayoutComplete(); @@ -183,7 +183,28 @@ } public Bitmap getLeadImageBitmap() { - return leadImageBitmap; + return getBitmapFromView(image1); + } + + // ideas from: + // http://stackoverflow.com/questions/2801116/converting-a-view-to-bitmap-without-displaying-it-in-android + // View has to be already displayed + private static Bitmap getBitmapFromView(ImageView view) { + // Define a bitmap with the same size as the view + Bitmap returnedBitmap + = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); + // Bind a canvas to it + Canvas canvas = new Canvas(returnedBitmap); +// // Get the view's background +// Drawable bgDrawable = view.getBackground(); +// if (bgDrawable != null) +// // has background drawable, then draw it on the canvas +// bgDrawable.draw(canvas); +// else +// // does not have background drawable, then draw white background on the canvas +// canvas.drawColor(Color.WHITE); + view.draw(canvas); + return returnedBitmap; } public int getImageBaseYOffset() { @@ -192,7 +213,6 @@ @Override public void onImageLoaded(Bitmap bitmap, final PointF faceLocation) { - leadImageBitmap = bitmap; final int bmpHeight = bitmap.getHeight(); final float aspect = (float)bitmap.getHeight() / (float)bitmap.getWidth(); imageContainer.post(new Runnable() { diff --git a/wikipedia/src/main/java/org/wikipedia/page/snippet/PreviewDialogFragment.java b/wikipedia/src/main/java/org/wikipedia/page/snippet/PreviewDialogFragment.java new file mode 100644 index 0000000..0752935 --- /dev/null +++ b/wikipedia/src/main/java/org/wikipedia/page/snippet/PreviewDialogFragment.java @@ -0,0 +1,40 @@ +package org.wikipedia.page.snippet; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.DialogInterface; +import android.os.Bundle; +import android.support.v4.app.DialogFragment; +import android.view.LayoutInflater; + +import org.wikipedia.R; + +/** + * + */ +public class PreviewDialogFragment extends DialogFragment { + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + // Get the layout inflater + LayoutInflater inflater = getActivity().getLayoutInflater(); + + // Inflate and set the layout for the dialog + // Pass null as the parent view because its going in the dialog layout + builder.setView(inflater.inflate(R.layout.dialog_share_preview, null)) + // Add action buttons + .setPositiveButton("Share", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + // sign in the user ... + } + }) + .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + PreviewDialogFragment.this.getDialog().cancel(); + } + }); + + return builder.create(); + } +} diff --git a/wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetImage.java b/wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetImage.java index 22c5d27..f91da9f 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetImage.java +++ b/wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetImage.java @@ -5,9 +5,8 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.graphics.Rect; import android.graphics.Typeface; -import android.os.Build; +import android.graphics.drawable.Drawable; import android.text.Html; import android.text.Layout; import android.text.StaticLayout; @@ -24,172 +23,161 @@ } /** - * Initially we create a a fixed size Bitmap that is a bit taller than what we need. - * We manually keep track of the vertical space (y) we draw on. - * Once we're done drawing we adjust the height of the bitmap. - * - * If we have a lead image, it goes on top, followed by the title, an opening double quote sign, - * then the text, and lastly the Wikipedia wordmark. - * - * The lead image portion gets clipped and scaled to fit the width of the screen. It's reusing - * the faceYOffset for the face detection adjustment and the Bitmap from LeadImageHandler. + * Creates a card image usable for sharing and the preview of the same. + * If we have a leadImageBitmap the use that as the background. If not then + * just use a black background. */ public static Bitmap createImage(Context context, Bitmap leadImageBitmap, int faceYOffset, - String title, CharSequence textSnippet) { - final int width = 560; - final int initialHeight = 2000; // will be cut down later - final int maxImageHeight = 330; - final int horizontalPadding = 24; - final int textIndent = 52; - final int belowTitle = 8; // when title inside image: bottom padding - final int aboveTitle = 32; // when title under image: top padding - final int aboveQuotationMark = 16; // between bottom of title or image and top of quotation mark - final int aboveText = 40; // between top of quotation mark and top of text - final int aboveWordmark = 40; // between end of text and top of wordmark - final int maxTitleLines = 3; - final int maxTextLines = 10; - - final int titleLineWidth = width - 2 * horizontalPadding; - final int textLineWidth = titleLineWidth - textIndent; - - final float titleFontSize = 40.0f; - final float minTitleFontSize = 32.0f; - final float textFontSize = 32.0f; - final float minTextFontSize = 24.0f; - final float wordmarkFontSize = 32.0f; - final float quoteFontSize = 96.0f; - final float titleSpacingMultiplier = 0.8f; - final float spacingMultiplier = 1.4f; + String title, String description, CharSequence textSnippet) { + final int width = 640; + final int height = 360; + final int horizontalPadding = 30; + final int textLineWidth = width - 2 * horizontalPadding; + final float spacingMultiplier = 1.0f; final Typeface serif = Typeface.create("serif", Typeface.NORMAL); - Bitmap resultBitmap = Bitmap.createBitmap(width, initialHeight, Bitmap.Config.ARGB_8888); - // final int backgroundColor = Color.parseColor("#242438"); - final int backgroundColor = -14408648; - resultBitmap.eraseColor(backgroundColor); - - int y = 0, dy = 0; - - // prepare title layout - TextPaint textPaint = new TextPaint(); - textPaint.setAntiAlias(true); - textPaint.setColor(context.getResources().getColor(R.color.lead_text_color)); - textPaint.setTextSize(titleFontSize); - textPaint.setTypeface(serif); - // and give it a nice drop shadow! - textPaint.setShadowLayer(2, 1, 1, context.getResources().getColor(R.color.lead_text_shadow)); - - StaticLayout textLayout = optimizeTextSize(title, - titleLineWidth, maxTitleLines, textPaint, - titleSpacingMultiplier, titleFontSize, minTitleFontSize); - - Canvas canvas = new Canvas(resultBitmap); + Bitmap resultBitmap; if (leadImageBitmap != null) { - // draw lead image - Bitmap tmpLeadImageBitmap - = scaleCropToFitFace(leadImageBitmap, width, maxImageHeight, faceYOffset); - - y = tmpLeadImageBitmap.getHeight(); - canvas.drawBitmap(tmpLeadImageBitmap, - null, - new Rect(0, 0, tmpLeadImageBitmap.getWidth(), tmpLeadImageBitmap.getHeight()), - null); - - tmpLeadImageBitmap.recycle(); - - dy = tmpLeadImageBitmap.getHeight() - textLayout.getHeight() - belowTitle; - canvas.translate(horizontalPadding, dy); - - // draw title inside lead image - textLayout.draw(canvas); - - dy = textLayout.getHeight() + aboveQuotationMark; - canvas.translate(0, dy); + // use lead image + resultBitmap = scaleCropToFitFace(leadImageBitmap, width, height, faceYOffset); } else { - dy += aboveTitle; - canvas.translate(horizontalPadding, dy); - y += dy; - - // draw title under lead image - textLayout.draw(canvas); - - dy = textLayout.getHeight() + aboveQuotationMark; - canvas.translate(0, dy); - y += dy; + resultBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + // final int backgroundColor = Color.parseColor("#242438"); + final int backgroundColor = -14408648; + resultBitmap.eraseColor(backgroundColor); } - // draw quotation mark - textPaint = new TextPaint(); + Canvas canvas = new Canvas(resultBitmap); + + // text snippet + final int textY = 20; + final int textMaxHeight = 200; + final int textMaxLines = 9; + final float textMaxFontSize = 64.0f; + final float textMinFontSize = 20.0f; + + TextPaint textPaint = new TextPaint(); textPaint.setAntiAlias(true); - textPaint.setColor(Color.GRAY); - textPaint.setTextSize(quoteFontSize); - textPaint.setTypeface(serif); + textPaint.setColor(Color.WHITE); + textPaint.setTextSize(textMaxFontSize); + textPaint.setStyle(Paint.Style.FILL); + textPaint.setShadowLayer(1.0f, 1.0f, 1.0f, Color.GRAY); - textLayout = buildLayout("\u201C", textPaint, textIndent, spacingMultiplier); + StaticLayout textLayout = optimizeTextSize(textSnippet, + textLineWidth, textMaxHeight, textMaxLines, + textPaint, spacingMultiplier, textMaxFontSize, textMinFontSize); + canvas.save(); + canvas.translate(horizontalPadding, textY); textLayout.draw(canvas); + canvas.restore(); - dy = aboveText; - canvas.translate(textIndent, dy); - y += dy; + // draw CC-by-SA icons + final int ccBySaIconsY = 319; + final int ccBySaIconsWidth = 52; + final int ccBySaIconsHeight = 16; + Drawable d = context.getResources().getDrawable(R.drawable.cc_by_sa_gray); + d.setBounds( + horizontalPadding, + ccBySaIconsY, + horizontalPadding + ccBySaIconsWidth, + ccBySaIconsY + ccBySaIconsHeight); + d.draw(canvas); - // draw textSnippet + // description + final int descriptionLineWidth = 360; + if (!TextUtils.isEmpty(description)) { + final int descriptionY = 287; + final int descriptionMaxHeight = 24; + final int descriptionMaxLines = 2; + final float descriptionMaxFontSize = 15.0f; + final float descriptionMinFontSize = 10.0f; + + textPaint = new TextPaint(); + textPaint.setAntiAlias(true); + textPaint.setColor(Color.WHITE); + textPaint.setTextSize(descriptionMaxFontSize); + textPaint.setStyle(Paint.Style.FILL); + textPaint.setShadowLayer(1.0f, 0.0f, 0.0f, Color.GRAY); + + textLayout = optimizeTextSize(description, + descriptionLineWidth, descriptionMaxHeight, descriptionMaxLines, + textPaint, spacingMultiplier, descriptionMaxFontSize, descriptionMinFontSize); + canvas.save(); + canvas.translate(horizontalPadding, descriptionY); + textLayout.draw(canvas); + canvas.restore(); + } + + // title + final int titleY = 242; + final int titleMaxHeight = 44; + final int titleMaxLines = 2; + final float titleMaxFontSize = 30.0f; + final float titleMinFontSize = 19.0f; + final float titleSpacingMultiplier = 0.7f; + textPaint = new TextPaint(); textPaint.setAntiAlias(true); textPaint.setColor(Color.WHITE); - textPaint.setTextSize(textFontSize); + textPaint.setTextSize(titleMaxFontSize); textPaint.setStyle(Paint.Style.FILL); + textPaint.setTypeface(serif); + textPaint.setShadowLayer(1.0f, 0.0f, 1.0f, Color.GRAY); - textLayout = optimizeTextSize(textSnippet, - textLineWidth, maxTextLines, textPaint, - spacingMultiplier, textFontSize, minTextFontSize); + textLayout = optimizeTextSize(title, + descriptionLineWidth, titleMaxHeight, titleMaxLines, + textPaint, titleSpacingMultiplier, titleMaxFontSize, titleMinFontSize); + canvas.save(); + canvas.translate(horizontalPadding, titleY); textLayout.draw(canvas); + canvas.restore(); - dy = textLayout.getHeight() + aboveWordmark; - canvas.translate(-textIndent, dy); - y += dy; + // wordmark + final int wordmarkY = 293; + final float wordmarkFontSize = 24.0f; - // draw wordmark textPaint = new TextPaint(); textPaint.setAntiAlias(true); - textPaint.setColor(Color.GRAY); + textPaint.setColor(Color.LTGRAY); textPaint.setTextSize(wordmarkFontSize); textPaint.setTypeface(serif); +// textPaint.setShadowLayer(0.0f, 0.0f, 0.0f, Color.GRAY); textLayout = buildLayout(Html.fromHtml(context.getString(R.string.wp_stylized)), textPaint, width, 1.0f); + canvas.save(); // -- + final float wordMarkWidth = textLayout.getLineWidth(0); + canvas.translate(width - horizontalPadding - wordMarkWidth, wordmarkY); textLayout.draw(canvas); - dy = textLayout.getHeight() + horizontalPadding; - y += dy; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - resultBitmap.setHeight(y); - } else { - resultBitmap = setImageHeight(resultBitmap, y); - } + final float rFontSize = 12.0f; + final int rXOffset = -4; + final int rYOffset = 12; + textPaint.setTextSize(rFontSize); + canvas.translate(wordMarkWidth + rXOffset, rYOffset); + textLayout = buildLayout("\u24C7", textPaint, width, 1.0f); + textLayout.draw(canvas); + canvas.restore(); // -- return resultBitmap; - } - - private static Bitmap setImageHeight(Bitmap bmp, int y) { - Bitmap croppedImage = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), y); - bmp.recycle(); - return croppedImage; } /** * If the title or text is too long we first reduce the font size. * If that is not enough it gets ellipsized. */ - private static StaticLayout optimizeTextSize(CharSequence text, int lineWidth, int maxLines, + private static StaticLayout optimizeTextSize(CharSequence text, int lineWidth, + int maxHeight, int maxLines, TextPaint textPaint, float spacingMultiplier, float maxFontSize, float minFontSize) { boolean fits = false; StaticLayout textLayout = null; // Try decreasing font size first - for (float fontSize = maxFontSize; fontSize >= minFontSize; fontSize -= 2.0f) { + for (float fontSize = maxFontSize; fontSize >= minFontSize; fontSize -= 1.0f) { textPaint.setTextSize(fontSize); textLayout = buildLayout(text, textPaint, lineWidth, spacingMultiplier); - if (textLayout.getLineCount() <= maxLines) { + if (textLayout.getHeight() <= maxHeight) { fits = true; break; } @@ -208,6 +196,7 @@ textLayout = buildLayout(textStr.substring(0, end) + "...", textPaint, lineWidth, spacingMultiplier); if (textLayout.getLineCount() <= maxLines) { +// if (textLayout.getHeight() <= maxHeight) { fits = true; } } @@ -216,7 +205,7 @@ // last resort: use TextUtils.ellipsize() if (!fits) { final float textRatio = .87f; - float maxWidth = textRatio * maxLines * lineWidth; + final float maxWidth = textRatio * maxLines * lineWidth; text = TextUtils.ellipsize(text, textPaint, maxWidth, TextUtils.TruncateAt.END); textLayout = buildLayout(text, textPaint, lineWidth, spacingMultiplier); } @@ -226,8 +215,7 @@ private static StaticLayout buildLayout(CharSequence text, TextPaint textPaint, int lineWidth, float spacingMultiplier) { - StaticLayout textLayout; - textLayout = new StaticLayout( + return new StaticLayout( text, textPaint, lineWidth, @@ -235,13 +223,12 @@ spacingMultiplier, 0.0f, false); - return textLayout; } // Borrowed from http://stackoverflow.com/questions/5226922/crop-to-fit-image-in-android // Modified to allow for face detection adjustment, startY private static Bitmap scaleCropToFitFace(Bitmap original, int targetWidth, int targetHeight, - int startY) { + int yOffset) { // Need to scale the image, keeping the aspect ratio first int width = original.getWidth(); int height = original.getHeight(); @@ -252,27 +239,24 @@ float scaledHeight; int startX = 0; + int startY = 0; + // ignoring faceOffset since we're trying to get that in the original Bitmap already + // TODO: refactor to not pass it in, once this gets working if (widthScale > heightScale) { scaledWidth = targetWidth; scaledHeight = height * widthScale; // crop height by... - // not needed here since we already have startY passed in (=face detection adjustment) - // startY = (int) ((scaledHeight - targetHeight) / 2); - - final int minY = 8; - startY = (int) (startY * heightScale); - if (startY < minY) { - startY = minY; - } +// startY = (int) ((scaledHeight - targetHeight) / 2); } else { scaledHeight = targetHeight; scaledWidth = width * heightScale; // crop width by.. - startX = (int) ((scaledWidth - targetWidth) / 2); +// startX = (int) ((scaledWidth - targetWidth) / 2); } - Bitmap scaledBitmap = Bitmap.createScaledBitmap(original, (int) scaledWidth, (int) scaledHeight, true); + Bitmap scaledBitmap + = Bitmap.createScaledBitmap(original, (int) scaledWidth, (int) scaledHeight, true); Bitmap bitmap = Bitmap.createBitmap(scaledBitmap, startX, startY, targetWidth, targetHeight); scaledBitmap.recycle(); return bitmap; diff --git a/wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetShareAdapter.java b/wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetShareAdapter.java index 76e1d2b..1d5ef78 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetShareAdapter.java +++ b/wikipedia/src/main/java/org/wikipedia/page/snippet/SnippetShareAdapter.java @@ -9,10 +9,14 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.ImageView; import org.wikipedia.PageTitle; import org.wikipedia.R; import org.wikipedia.WikipediaApp; +import org.wikipedia.page.BottomDialog; import org.wikipedia.page.Page; import org.wikipedia.page.PageActivity; import org.wikipedia.page.PageProperties; @@ -29,11 +33,6 @@ private static ClipboardManager.OnPrimaryClipChangedListener CLIP_LISTENER; private MenuItem copyMenuItem; private ShareAFactFunnel funnel; - - public static boolean isTextSelectionMenu(Menu menu) { - // While not perfect, this at least filters out our own "Find in page" action mode - return menu.getItem(0) != null && menu.getItem(0).getItemId() != 0; - } public SnippetShareAdapter(PageActivity activity) { this.activity = activity; @@ -142,7 +141,7 @@ } private void shareSnippet(CharSequence input) { - final int minTextSnippetLength = 6; + final int minTextSnippetLength = 1; String selectedText = input.toString().trim(); if (selectedText.length() < minTextSnippetLength) { return; @@ -159,9 +158,28 @@ Bitmap resultBitmap = SnippetImage.createImage(activity, curPageFragment.getLeadImageBitmap(), curPageFragment.getImageBaseYOffset(), - title.getDisplayText(), selectedText); - ShareUtils.shareImage(activity, resultBitmap, "*/*", - title.getDisplayText(), title.getDisplayText(), introText, false); - funnel.logShareIntent(selectedText); + title.getDisplayText(), + title.getDescription(), + selectedText); + new PreviewDialog(activity, resultBitmap, title.getDisplayText(), introText, selectedText, funnel).show(); + } +} + +class PreviewDialog extends BottomDialog { + public PreviewDialog(final PageActivity activity, final Bitmap resultBitmap, + final String title, final String introText, final String selectedText, + final ShareAFactFunnel funnel) { + super(activity, R.layout.dialog_share_preview); + ImageView previewImage = (ImageView) getDialogLayout().findViewById(R.id.preview_img); + previewImage.setImageBitmap(resultBitmap); + Button shareButton = (Button) getDialogLayout().findViewById(R.id.share_as_image_button); + shareButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ShareUtils.shareImage(activity, resultBitmap, "*/*", + title, title, introText, false); + funnel.logShareIntent(selectedText); + } + }); } } -- To view, visit https://gerrit.wikimedia.org/r/189872 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie6990b1ae38808574ad083e935ef75170c883af2 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: BearND <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
