From 6d528d0e92f236a60a3dfc9385442b4b9e675fe7 Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 2 Jun 2023 15:35:35 +0930 Subject: [PATCH 1/3] Fix long message not visible on react --- .../v2/ConversationReactionOverlay.java | 10 ++++++--- .../securesms/util/ViewUtilities.kt | 21 +++++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.java index 82eceffa61..c3dc2ceeee 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.java @@ -81,6 +81,7 @@ public final class ConversationReactionOverlay extends FrameLayout { private View dropdownAnchor; private LinearLayout conversationItem; + private View conversationBubble; private View backgroundView; private ConstraintLayout foregroundView; private EmojiImageView[] emojiViews; @@ -116,6 +117,7 @@ public final class ConversationReactionOverlay extends FrameLayout { dropdownAnchor = findViewById(R.id.dropdown_anchor); conversationItem = findViewById(R.id.conversation_item); + conversationBubble = conversationItem.findViewById(R.id.conversation_item_bubble); backgroundView = findViewById(R.id.conversation_reaction_scrubber_background); foregroundView = findViewById(R.id.conversation_reaction_scrubber_foreground); @@ -165,7 +167,6 @@ public final class ConversationReactionOverlay extends FrameLayout { Bitmap conversationItemSnapshot = selectedConversationModel.getBitmap(); - View conversationBubble = conversationItem.findViewById(R.id.conversation_item_bubble); conversationBubble.setLayoutParams(new LinearLayout.LayoutParams(conversationItemSnapshot.getWidth(), conversationItemSnapshot.getHeight())); conversationBubble.setBackground(new BitmapDrawable(getResources(), conversationItemSnapshot)); TextView conversationTimestamp = conversationItem.findViewById(R.id.conversation_item_timestamp); @@ -351,11 +352,14 @@ public final class ConversationReactionOverlay extends FrameLayout { int revealDuration = getContext().getResources().getInteger(R.integer.reaction_scrubber_reveal_duration); + conversationBubble.animate() + .scaleX(endScale) + .scaleY(endScale) + .setDuration(revealDuration); + conversationItem.animate() .x(endX) .y(endY) - .scaleX(endScale) - .scaleY(endScale) .setDuration(revealDuration); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/ViewUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/util/ViewUtilities.kt index ffe5e9094f..8345473490 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/ViewUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/ViewUtilities.kt @@ -8,6 +8,7 @@ import android.content.Context import android.graphics.Bitmap import android.graphics.PointF import android.graphics.Rect +import android.util.Size import android.view.View import androidx.annotation.ColorInt import androidx.annotation.DimenRes @@ -15,6 +16,7 @@ import network.loki.messenger.R import org.session.libsession.utilities.getColorFromAttr import android.view.inputmethod.InputMethodManager import androidx.core.graphics.applyCanvas +import kotlin.math.roundToInt fun View.contains(point: PointF): Boolean { return hitRect.contains(point.x.toInt(), point.y.toInt()) @@ -68,8 +70,23 @@ fun View.hideKeyboard() { imm.hideSoftInputFromWindow(this.windowToken, 0) } -fun View.drawToBitmap(config: Bitmap.Config = Bitmap.Config.ARGB_8888): Bitmap = - Bitmap.createBitmap(width, height, config).applyCanvas { + +fun View.drawToBitmap(config: Bitmap.Config = Bitmap.Config.ARGB_8888, longestWidth: Int = 2000): Bitmap { + val size = Size(measuredWidth, measuredHeight).coerceAtMost(longestWidth) + val scale = size.width / measuredWidth.toFloat() + + return Bitmap.createBitmap(size.width, size.height, config).applyCanvas { + scale(scale, scale) translate(-scrollX.toFloat(), -scrollY.toFloat()) draw(this) } +} + +fun Size.coerceAtMost(longestWidth: Int): Size = + (width.toFloat() / height).let { aspect -> + if (aspect > 1) { + width.coerceAtMost(longestWidth).let { Size(it, (it / aspect).roundToInt()) } + } else { + height.coerceAtMost(longestWidth).let { Size((it * aspect).roundToInt(), it) } + } + } From cbe90e7bfce46abff1e1c11a2468ddadd6b4d48b Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 2 Jun 2023 15:46:28 +0930 Subject: [PATCH 2/3] Cleanup ConversationReactionOverlay --- .../conversation/v2/ConversationReactionOverlay.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.java index c3dc2ceeee..20462bef34 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationReactionOverlay.java @@ -82,6 +82,7 @@ public final class ConversationReactionOverlay extends FrameLayout { private View dropdownAnchor; private LinearLayout conversationItem; private View conversationBubble; + private TextView conversationTimestamp; private View backgroundView; private ConstraintLayout foregroundView; private EmojiImageView[] emojiViews; @@ -118,6 +119,7 @@ public final class ConversationReactionOverlay extends FrameLayout { dropdownAnchor = findViewById(R.id.dropdown_anchor); conversationItem = findViewById(R.id.conversation_item); conversationBubble = conversationItem.findViewById(R.id.conversation_item_bubble); + conversationTimestamp = conversationItem.findViewById(R.id.conversation_item_timestamp); backgroundView = findViewById(R.id.conversation_reaction_scrubber_background); foregroundView = findViewById(R.id.conversation_reaction_scrubber_foreground); @@ -169,7 +171,6 @@ public final class ConversationReactionOverlay extends FrameLayout { conversationBubble.setLayoutParams(new LinearLayout.LayoutParams(conversationItemSnapshot.getWidth(), conversationItemSnapshot.getHeight())); conversationBubble.setBackground(new BitmapDrawable(getResources(), conversationItemSnapshot)); - TextView conversationTimestamp = conversationItem.findViewById(R.id.conversation_item_timestamp); conversationTimestamp.setText(DateUtils.getDisplayFormattedTimeSpanString(getContext(), Locale.getDefault(), messageRecord.getTimestamp())); updateConversationTimestamp(messageRecord); @@ -191,12 +192,8 @@ public final class ConversationReactionOverlay extends FrameLayout { } private void updateConversationTimestamp(MessageRecord message) { - View bubble = conversationItem.findViewById(R.id.conversation_item_bubble); - View timestamp = conversationItem.findViewById(R.id.conversation_item_timestamp); - conversationItem.removeAllViewsInLayout(); - conversationItem.addView(message.isOutgoing() ? timestamp : bubble); - conversationItem.addView(message.isOutgoing() ? bubble : timestamp); - conversationItem.requestLayout(); + if (message.isOutgoing()) conversationBubble.bringToFront(); + else conversationTimestamp.bringToFront(); } private void showAfterLayout(@NonNull MessageRecord messageRecord, From e99133fd8baa9b1aabc6fa86a6f3593647ecb343 Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 5 Jun 2023 13:13:49 +0930 Subject: [PATCH 3/3] Fix back button background in light themes --- app/src/main/res/values/themes.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 59525f7844..6d582bb16c 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -303,7 +303,6 @@ ?dividerVertical #F2F2F2 @color/classic_accent - ?android:colorControlHighlight @style/Widget.Session.TabLayout @@ -312,7 +311,6 @@ ?dividerVertical #F2F2F2 @color/ocean_accent - ?android:colorControlHighlight @style/Widget.Session.TabLayout @@ -338,6 +336,7 @@ @color/classic_dark_1 @color/classic_dark_3 @color/classic_dark_3 + @color/classic_dark_3 @style/Dark.Popup @null @style/ThemeOverlay.AppCompat.Dark.ActionBar @@ -410,6 +409,7 @@ @color/classic_light_5 @color/classic_light_3 @color/classic_light_3 + @color/classic_light_3 @style/Classic.Light.BottomSheet ?android:textColorPrimary ?actionBarPopupTheme @@ -496,6 +496,7 @@ @color/ocean_dark_1 @color/ocean_dark_4 @color/ocean_dark_4 + @color/ocean_dark_4 @style/Ocean.Dark.BottomSheet ?actionBarPopupTheme ?android:textColorPrimary @@ -576,6 +577,7 @@ @color/ocean_light_6 @color/ocean_light_3 @color/ocean_light_4 + @color/ocean_light_4 @style/Ocean.Light.BottomSheet @style/Light.Popup ?actionBarPopupTheme