kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix color offset on devices with notches.
rodzic
a385cb0b68
commit
52cfb57d36
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -691,8 +691,8 @@ public class ConversationAdapter
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<Projection> getColorizerProjections() {
|
||||
return getBindable().getColorizerProjections();
|
||||
public @NonNull List<Projection> getColorizerProjections(@NonNull ViewGroup coordinateRoot) {
|
||||
return getBindable().getColorizerProjections(coordinateRoot);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1715,7 +1715,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<Projection> getColorizerProjections() {
|
||||
public @NonNull List<Projection> getColorizerProjections(@NonNull ViewGroup coordinateRoot) {
|
||||
List<Projection> 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;
|
||||
|
|
|
@ -221,7 +221,7 @@ public final class ConversationUpdateItem extends FrameLayout
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<Projection> getColorizerProjections() {
|
||||
public @NonNull List<Projection> getColorizerProjections(@NonNull ViewGroup coordinateRoot) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Projection>
|
||||
fun getColorizerProjections(coordinateRoot: ViewGroup): List<Projection>
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ class MultiselectItemDecoration(
|
|||
|
||||
val parts: MultiselectCollection = child.conversationMessage.multiselectCollection
|
||||
|
||||
val projections: List<Projection> = child.colorizerProjections + if (child.canPlayContent()) listOf(child.getGiphyMp4PlayableProjection(child.rootView as ViewGroup)) else emptyList()
|
||||
val projections: List<Projection> = 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)
|
||||
}
|
||||
|
||||
|
|
|
@ -250,11 +250,8 @@ final class MessageHeaderViewHolder extends RecyclerView.ViewHolder implements G
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<Projection> getColorizerProjections() {
|
||||
return conversationItem.getColorizerProjections()
|
||||
.stream()
|
||||
.map(p -> Projection.translateFromRootToDescendantCoords(p, (ViewGroup) itemView.getParent()))
|
||||
.collect(Collectors.toList());
|
||||
public @NonNull List<Projection> getColorizerProjections(@NonNull ViewGroup coordinateRoot) {
|
||||
return conversationItem.getColorizerProjections(coordinateRoot);
|
||||
}
|
||||
|
||||
private class ExpiresUpdater implements Runnable {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue