From 860047c2d3835bef37f9d6833e84a35866ba7665 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Fri, 20 Jul 2018 14:24:04 -0700 Subject: [PATCH] Remove CornerMaskingView. --- ...sation_activity_attachment_editor_stub.xml | 29 ++--- res/values/attrs.xml | 3 - .../securesms/ConversationItem.java | 1 - .../components/CornerMaskingView.java | 121 ------------------ .../securesms/mms/AttachmentManager.java | 3 + 5 files changed, 14 insertions(+), 143 deletions(-) delete mode 100644 src/org/thoughtcrime/securesms/components/CornerMaskingView.java diff --git a/res/layout/conversation_activity_attachment_editor_stub.xml b/res/layout/conversation_activity_attachment_editor_stub.xml index 5d6821b831..61fb384620 100644 --- a/res/layout/conversation_activity_attachment_editor_stub.xml +++ b/res/layout/conversation_activity_attachment_editor_stub.xml @@ -43,25 +43,18 @@ app:foregroundTintColor="@color/grey_500" app:backgroundTintColor="?conversation_item_bubble_background"/> - - - - - + android:visibility="gone" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:paddingLeft="@dimen/message_bubble_horizontal_padding" + android:paddingRight="@dimen/message_bubble_horizontal_padding" + android:background="@drawable/message_bubble_background_sent_alone" + app:doc_titleColor="?attr/conversation_item_sent_text_primary_color" + app:doc_captionColor="?attr/conversation_item_sent_text_secondary_color"/> diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 0390480837..bc3761eff1 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -283,7 +283,4 @@ - - - diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index b6797811a8..d3affac84a 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -49,7 +49,6 @@ import org.thoughtcrime.securesms.components.AudioView; import org.thoughtcrime.securesms.components.AvatarImageView; import org.thoughtcrime.securesms.components.ConversationItemFooter; import org.thoughtcrime.securesms.components.ConversationItemThumbnail; -import org.thoughtcrime.securesms.components.CornerMaskingView; import org.thoughtcrime.securesms.components.DocumentView; import org.thoughtcrime.securesms.components.QuoteView; import org.thoughtcrime.securesms.components.SharedContactView; diff --git a/src/org/thoughtcrime/securesms/components/CornerMaskingView.java b/src/org/thoughtcrime/securesms/components/CornerMaskingView.java deleted file mode 100644 index 1e0a8f0a94..0000000000 --- a/src/org/thoughtcrime/securesms/components/CornerMaskingView.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.thoughtcrime.securesms.components; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Path; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.RectF; -import android.os.Build; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.util.AttributeSet; -import android.widget.FrameLayout; - -import org.thoughtcrime.securesms.R; - -public class CornerMaskingView extends FrameLayout { - - private final float[] radii = new float[8]; - private final Paint dstPaint = new Paint(); - private final Paint clearPaint = new Paint(); - private final Path outline = new Path(); - private final Path corners = new Path(); - private final RectF bounds = new RectF(); - - public CornerMaskingView(@NonNull Context context) { - super(context); - init(null); - } - - public CornerMaskingView(@NonNull Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - init(attrs); - } - - public CornerMaskingView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(attrs); - } - - private void init(@Nullable AttributeSet attrs) { - setLayerType(LAYER_TYPE_HARDWARE, null); - - dstPaint.setColor(Color.BLACK); - dstPaint.setStyle(Paint.Style.FILL); - dstPaint.setAntiAlias(true); - dstPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN)); - - clearPaint.setColor(Color.BLACK); - clearPaint.setStyle(Paint.Style.FILL); - clearPaint.setAntiAlias(true); - clearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); - - if (attrs != null) { - TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.CornerMaskingView, 0, 0); - setRadius(typedArray.getDimensionPixelOffset(R.styleable.CornerMaskingView_cmv_radius, 0)); - typedArray.recycle(); - } - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - bounds.left = 0; - bounds.top = 0; - bounds.right = canvas.getWidth(); - bounds.bottom = canvas.getHeight(); - - corners.reset(); - corners.addRoundRect(bounds, radii, Path.Direction.CW); - - // Note: There's a bug in the P beta where most PorterDuff modes aren't working. But CLEAR does. - // So we find and inverse path and use Mode.CLEAR for versions that support Path.op(). - // See issue https://issuetracker.google.com/issues/111394085. - if (Build.VERSION.SDK_INT >= 19) { - outline.reset(); - outline.addRect(bounds, Path.Direction.CW); - outline.op(corners, Path.Op.DIFFERENCE); - canvas.drawPath(outline, clearPaint); - } else { - corners.addRoundRect(bounds, radii, Path.Direction.CW); - canvas.drawPath(corners, dstPaint); - } - } - - public void setRadius(int radius) { - setRadii(radius, radius, radius, radius); - } - - public void setRadii(int topLeft, int topRight, int bottomRight, int bottomLeft) { - radii[0] = radii[1] = topLeft; - radii[2] = radii[3] = topRight; - radii[4] = radii[5] = bottomRight; - radii[6] = radii[7] = bottomLeft; - invalidate(); - } - - public void setTopLeftRadius(int radius) { - radii[0] = radii[1] = radius; - invalidate(); - } - - public void setTopRightRadius(int radius) { - radii[2] = radii[3] = radius; - invalidate(); - } - - public void setBottomRightRadius(int radius) { - radii[4] = radii[5] = radius; - invalidate(); - } - - public void setBottomLeftRadius(int radius) { - radii[6] = radii[7] = radius; - invalidate(); - } -} diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java index 2830f0b2c4..9268075cb0 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java @@ -24,6 +24,7 @@ import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; +import android.graphics.PorterDuff; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; @@ -57,6 +58,7 @@ import org.thoughtcrime.securesms.providers.PersistentBlobProvider; import org.thoughtcrime.securesms.scribbles.ScribbleActivity; import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.MediaUtil; +import org.thoughtcrime.securesms.util.ThemeUtil; import org.thoughtcrime.securesms.util.ViewUtil; import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener; import org.thoughtcrime.securesms.util.concurrent.ListenableFuture; @@ -108,6 +110,7 @@ public class AttachmentManager { removableMediaView.setRemoveClickListener(new RemoveButtonListener()); removableMediaView.setEditClickListener(new EditButtonListener()); thumbnail.setOnClickListener(new ThumbnailClickListener()); + documentView.getBackground().setColorFilter(ThemeUtil.getThemedColor(context, R.attr.conversation_item_bubble_background), PorterDuff.Mode.MULTIPLY); } }