Search in sources :

Example 1 with Projection

use of org.thoughtcrime.securesms.util.Projection in project Signal-Android by WhisperSystems.

the class ConversationItem method getColorizerProjections.

@Override
@NonNull
public ProjectionList getColorizerProjections(@NonNull ViewGroup coordinateRoot) {
    colorizerProjections.clear();
    if (messageRecord.isOutgoing() && !hasNoBubble(messageRecord) && !messageRecord.isRemoteDelete() && bodyBubbleCorners != null && bodyBubble.getVisibility() == VISIBLE) {
        Projection bodyBubbleToRoot = Projection.relativeToParent(coordinateRoot, bodyBubble, bodyBubbleCorners).translateX(bodyBubble.getTranslationX());
        Projection videoToBubble = bodyBubble.getVideoPlayerProjection();
        float translationX = Util.halfOffsetFromScale(bodyBubble.getWidth(), bodyBubble.getScaleX());
        float translationY = Util.halfOffsetFromScale(bodyBubble.getHeight(), bodyBubble.getScaleY());
        if (videoToBubble != null) {
            Projection videoToRoot = Projection.translateFromDescendantToParentCoords(videoToBubble, bodyBubble, coordinateRoot);
            List<Projection> projections = Projection.getCapAndTail(bodyBubbleToRoot, videoToRoot);
            if (!projections.isEmpty()) {
                projections.get(0).scale(bodyBubble.getScaleX()).translateX(translationX).translateY(translationY);
                projections.get(1).scale(bodyBubble.getScaleX()).translateX(translationX).translateY(-translationY);
            }
            colorizerProjections.addAll(projections);
        } else {
            colorizerProjections.add(bodyBubbleToRoot.scale(bodyBubble.getScaleX()).translateX(translationX).translateY(translationY));
        }
    }
    if (messageRecord.isOutgoing() && hasNoBubble(messageRecord) && hasWallpaper && bodyBubble.getVisibility() == VISIBLE) {
        ConversationItemFooter footer = getActiveFooter(messageRecord);
        Projection footerProjection = footer.getProjection(coordinateRoot);
        if (footerProjection != null) {
            colorizerProjections.add(footerProjection.translateX(bodyBubble.getTranslationX()).scale(bodyBubble.getScaleX()).translateX(Util.halfOffsetFromScale(footer.getWidth(), bodyBubble.getScaleX())).translateY(-Util.halfOffsetFromScale(footer.getHeight(), bodyBubble.getScaleY())));
        }
    }
    if (!messageRecord.isOutgoing() && hasQuote(messageRecord) && quoteView != null && bodyBubble.getVisibility() == VISIBLE) {
        bodyBubble.setQuoteViewProjection(quoteView.getProjection(bodyBubble));
        float bubbleOffsetFromScale = Util.halfOffsetFromScale(bodyBubble.getHeight(), bodyBubble.getScaleY());
        Projection cProj = quoteView.getProjection(coordinateRoot).translateX(bodyBubble.getTranslationX() + this.getTranslationX() + Util.halfOffsetFromScale(quoteView.getWidth(), bodyBubble.getScaleX())).translateY(bubbleOffsetFromScale - quoteView.getY() + (quoteView.getY() * bodyBubble.getScaleY())).scale(bodyBubble.getScaleX());
        colorizerProjections.add(cProj);
    }
    for (int i = 0; i < colorizerProjections.size(); i++) {
        colorizerProjections.get(i).translateY(getTranslationY());
    }
    return colorizerProjections;
}
Also used : ConversationItemFooter(org.thoughtcrime.securesms.components.ConversationItemFooter) Projection(org.thoughtcrime.securesms.util.Projection) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) NonNull(androidx.annotation.NonNull)

Example 2 with Projection

use of org.thoughtcrime.securesms.util.Projection in project Signal-Android by WhisperSystems.

the class ConversationItem method getProjectionTop.

private static int getProjectionTop(@NonNull View child) {
    Projection projection = Projection.relativeToViewRoot(child, null);
    int y = (int) projection.getY();
    projection.release();
    return y;
}
Also used : Projection(org.thoughtcrime.securesms.util.Projection) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint)

Example 3 with Projection

use of org.thoughtcrime.securesms.util.Projection in project Signal-Android by WhisperSystems.

the class GiphyMp4ProjectionRecycler method updateVideoDisplayPositionAndSize.

private void updateVideoDisplayPositionAndSize(@NonNull RecyclerView recyclerView, @NonNull GiphyMp4ProjectionPlayerHolder holder, @NonNull GiphyMp4Playable giphyMp4Playable) {
    if (!giphyMp4Playable.canPlayContent()) {
        return;
    }
    Projection projection = giphyMp4Playable.getGiphyMp4PlayableProjection(recyclerView);
    holder.getContainer().setX(projection.getX());
    holder.getContainer().setY(projection.getY() + recyclerView.getTranslationY());
    ViewGroup.LayoutParams params = holder.getContainer().getLayoutParams();
    if (params.width != projection.getWidth() || params.height != projection.getHeight()) {
        params.width = projection.getWidth();
        params.height = projection.getHeight();
        holder.getContainer().setLayoutParams(params);
    }
    holder.setCorners(projection.getCorners());
    projection.release();
}
Also used : ViewGroup(android.view.ViewGroup) Projection(org.thoughtcrime.securesms.util.Projection)

Example 4 with Projection

use of org.thoughtcrime.securesms.util.Projection in project Signal-Android by WhisperSystems.

the class ConversationItem method isTouchBelowBoundary.

private boolean isTouchBelowBoundary(@NonNull View child) {
    Projection childProjection = Projection.relativeToParent(this, child, null);
    float childBoundary = childProjection.getY() + childProjection.getHeight();
    return lastYDownRelativeToThis > childBoundary;
}
Also used : Projection(org.thoughtcrime.securesms.util.Projection)

Example 5 with Projection

use of org.thoughtcrime.securesms.util.Projection in project Signal-Android by WhisperSystems.

the class ConversationItem method getProjectionBottom.

private static int getProjectionBottom(@NonNull View child) {
    Projection projection = Projection.relativeToViewRoot(child, null);
    int bottom = (int) projection.getY() + projection.getHeight();
    projection.release();
    return bottom;
}
Also used : Projection(org.thoughtcrime.securesms.util.Projection) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint)

Aggregations

Projection (org.thoughtcrime.securesms.util.Projection)6 SuppressLint (android.annotation.SuppressLint)3 TextPaint (android.text.TextPaint)3 ViewGroup (android.view.ViewGroup)2 NonNull (androidx.annotation.NonNull)2 ColorStateList (android.content.res.ColorStateList)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 DisplayMetrics (android.util.DisplayMetrics)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)1 SwitchCompat (androidx.appcompat.widget.SwitchCompat)1 Toolbar (androidx.appcompat.widget.Toolbar)1 ContextCompat (androidx.core.content.ContextCompat)1 ImageViewCompat (androidx.core.widget.ImageViewCompat)1 TextViewCompat (androidx.core.widget.TextViewCompat)1