diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java b/app/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java index b0023ed4e0..3a795389c2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/ConversationItemFooter.java @@ -10,6 +10,7 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; @@ -207,9 +208,9 @@ public class ConversationItemFooter extends ConstraintLayout { setBackground(null); } - public @Nullable Projection getProjection() { + public @Nullable Projection getProjection(@NonNull ViewGroup coordinateRoot) { if (getVisibility() == VISIBLE) { - return Projection.relativeToViewRoot(this, new Projection.Corners(ViewUtil.dpToPx(11))); + return Projection.relativeToParent(coordinateRoot, this, new Projection.Corners(ViewUtil.dpToPx(11))); } else { return null; } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java index c521f0ddec..588f8725cf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationAdapter.java @@ -691,8 +691,8 @@ public class ConversationAdapter } @Override - public @NonNull List getColorizerProjections() { - return getBindable().getColorizerProjections(); + public @NonNull List getColorizerProjections(@NonNull ViewGroup coordinateRoot) { + return getBindable().getColorizerProjections(coordinateRoot); } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java index 9948b2b4f0..7f28c5d267 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -1715,7 +1715,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo } @Override - public @NonNull List getColorizerProjections() { + public @NonNull List getColorizerProjections(@NonNull ViewGroup coordinateRoot) { List projections = new LinkedList<>(); if (messageRecord.isOutgoing() && @@ -1723,10 +1723,10 @@ public final class ConversationItem extends RelativeLayout implements BindableCo !messageRecord.isRemoteDelete() && bodyBubbleCorners != null) { - Projection bodyBubbleToRoot = Projection.relativeToViewRoot(bodyBubble, bodyBubbleCorners).translateX(bodyBubble.getTranslationX()); + Projection bodyBubbleToRoot = Projection.relativeToParent(coordinateRoot, bodyBubble, bodyBubbleCorners).translateX(bodyBubble.getTranslationX()); Projection videoToBubble = bodyBubble.getVideoPlayerProjection(); if (videoToBubble != null) { - Projection videoToRoot = Projection.translateFromDescendantToParentCoords(videoToBubble, bodyBubble, (ViewGroup) getRootView()); + Projection videoToRoot = Projection.translateFromDescendantToParentCoords(videoToBubble, bodyBubble, coordinateRoot); projections.addAll(Projection.getCapAndTail(bodyBubbleToRoot, videoToRoot)); } else { projections.add(bodyBubbleToRoot); @@ -1737,7 +1737,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo hasNoBubble(messageRecord) && hasWallpaper) { - Projection footerProjection = getActiveFooter(messageRecord).getProjection(); + Projection footerProjection = getActiveFooter(messageRecord).getProjection(coordinateRoot); if (footerProjection != null) { projections.add(footerProjection.translateX(bodyBubble.getTranslationX())); } @@ -1748,7 +1748,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo quoteView != null) { bodyBubble.setQuoteViewProjection(quoteView.getProjection(bodyBubble)); - projections.add(quoteView.getProjection((ViewGroup) getRootView()).translateX(bodyBubble.getTranslationX() + this.getTranslationX())); + projections.add(quoteView.getProjection(coordinateRoot).translateX(bodyBubble.getTranslationX() + this.getTranslationX())); } return projections; diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationUpdateItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationUpdateItem.java index 1f860b4e30..8e2d2f74f7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationUpdateItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationUpdateItem.java @@ -221,7 +221,7 @@ public final class ConversationUpdateItem extends FrameLayout } @Override - public @NonNull List getColorizerProjections() { + public @NonNull List getColorizerProjections(@NonNull ViewGroup coordinateRoot) { return Collections.emptyList(); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/colors/Colorizable.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/colors/Colorizable.kt index 8ea2c9b3b1..9e76007479 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/colors/Colorizable.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/colors/Colorizable.kt @@ -1,5 +1,6 @@ package org.thoughtcrime.securesms.conversation.colors +import android.view.ViewGroup import org.thoughtcrime.securesms.util.Projection /** @@ -7,5 +8,5 @@ import org.thoughtcrime.securesms.util.Projection * generating its own projection. */ interface Colorizable { - val colorizerProjections: List + fun getColorizerProjections(coordinateRoot: ViewGroup): List } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/colors/RecyclerViewColorizer.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/colors/RecyclerViewColorizer.kt index 38c1e7d046..7a0aba26b0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/colors/RecyclerViewColorizer.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/colors/RecyclerViewColorizer.kt @@ -98,7 +98,7 @@ class RecyclerViewColorizer(private val recyclerView: RecyclerView) { if (child != null) { val holder = parent.getChildViewHolder(child) if (holder is Colorizable) { - holder.colorizerProjections.forEach { + holder.getColorizerProjections(parent).forEach { c.drawPath(it.path, holePunchPaint) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/mutiselect/MultiselectItemDecoration.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/mutiselect/MultiselectItemDecoration.kt index 3ce1ef45a9..a30a1323db 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/mutiselect/MultiselectItemDecoration.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/mutiselect/MultiselectItemDecoration.kt @@ -127,7 +127,7 @@ class MultiselectItemDecoration( val parts: MultiselectCollection = child.conversationMessage.multiselectCollection - val projections: List = child.colorizerProjections + if (child.canPlayContent()) listOf(child.getGiphyMp4PlayableProjection(child.rootView as ViewGroup)) else emptyList() + val projections: List = child.getColorizerProjections(parent) + if (child.canPlayContent()) listOf(child.getGiphyMp4PlayableProjection(parent)) else emptyList() path.reset() projections.forEach { it.applyToPath(path) } @@ -307,7 +307,7 @@ class MultiselectItemDecoration( parent.forEach { child -> if (child is Multiselectable && child.conversationMessage == inFocus.conversationMessage) { path.addRect(child.left.toFloat(), child.top.toFloat(), child.right.toFloat(), child.bottom.toFloat(), Path.Direction.CW) - child.colorizerProjections.forEach { + child.getColorizerProjections(parent).forEach { path.op(it.path, Path.Op.DIFFERENCE) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/messagedetails/MessageHeaderViewHolder.java b/app/src/main/java/org/thoughtcrime/securesms/messagedetails/MessageHeaderViewHolder.java index 9905ec3936..1151a72475 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/messagedetails/MessageHeaderViewHolder.java +++ b/app/src/main/java/org/thoughtcrime/securesms/messagedetails/MessageHeaderViewHolder.java @@ -250,11 +250,8 @@ final class MessageHeaderViewHolder extends RecyclerView.ViewHolder implements G } @Override - public @NonNull List getColorizerProjections() { - return conversationItem.getColorizerProjections() - .stream() - .map(p -> Projection.translateFromRootToDescendantCoords(p, (ViewGroup) itemView.getParent())) - .collect(Collectors.toList()); + public @NonNull List getColorizerProjections(@NonNull ViewGroup coordinateRoot) { + return conversationItem.getColorizerProjections(coordinateRoot); } private class ExpiresUpdater implements Runnable { diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/Projection.java b/app/src/main/java/org/thoughtcrime/securesms/util/Projection.java index 1bc935cb57..033d213b85 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/Projection.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/Projection.java @@ -142,16 +142,6 @@ public final class Projection { return new Projection(viewBounds.left, viewBounds.top, toProject.getWidth(), toProject.getHeight(), corners); } - public static @NonNull Projection translateFromRootToDescendantCoords(@NonNull Projection rootProjection, @NonNull View descendant) { - Rect viewBounds = new Rect(); - - viewBounds.set((int) rootProjection.x, (int) rootProjection.y, (int) rootProjection.x + rootProjection.width, (int) rootProjection.y + rootProjection.height); - - ((ViewGroup) descendant.getRootView()).offsetRectIntoDescendantCoords(descendant, viewBounds); - - return new Projection(viewBounds.left, viewBounds.top, rootProjection.width, rootProjection.height, rootProjection.corners); - } - public static @NonNull Projection translateFromDescendantToParentCoords(@NonNull Projection descendantProjection, @NonNull View descendant, @NonNull ViewGroup parent) { Rect viewBounds = new Rect();