mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Merge remote-tracking branch 'upstream/dev' into bluetooth-manager-crash
This commit is contained in:
commit
346bdc1774
@ -81,6 +81,8 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||||||
|
|
||||||
private View dropdownAnchor;
|
private View dropdownAnchor;
|
||||||
private LinearLayout conversationItem;
|
private LinearLayout conversationItem;
|
||||||
|
private View conversationBubble;
|
||||||
|
private TextView conversationTimestamp;
|
||||||
private View backgroundView;
|
private View backgroundView;
|
||||||
private ConstraintLayout foregroundView;
|
private ConstraintLayout foregroundView;
|
||||||
private EmojiImageView[] emojiViews;
|
private EmojiImageView[] emojiViews;
|
||||||
@ -116,6 +118,8 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||||||
|
|
||||||
dropdownAnchor = findViewById(R.id.dropdown_anchor);
|
dropdownAnchor = findViewById(R.id.dropdown_anchor);
|
||||||
conversationItem = findViewById(R.id.conversation_item);
|
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);
|
backgroundView = findViewById(R.id.conversation_reaction_scrubber_background);
|
||||||
foregroundView = findViewById(R.id.conversation_reaction_scrubber_foreground);
|
foregroundView = findViewById(R.id.conversation_reaction_scrubber_foreground);
|
||||||
|
|
||||||
@ -165,10 +169,8 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||||||
|
|
||||||
Bitmap conversationItemSnapshot = selectedConversationModel.getBitmap();
|
Bitmap conversationItemSnapshot = selectedConversationModel.getBitmap();
|
||||||
|
|
||||||
View conversationBubble = conversationItem.findViewById(R.id.conversation_item_bubble);
|
|
||||||
conversationBubble.setLayoutParams(new LinearLayout.LayoutParams(conversationItemSnapshot.getWidth(), conversationItemSnapshot.getHeight()));
|
conversationBubble.setLayoutParams(new LinearLayout.LayoutParams(conversationItemSnapshot.getWidth(), conversationItemSnapshot.getHeight()));
|
||||||
conversationBubble.setBackground(new BitmapDrawable(getResources(), conversationItemSnapshot));
|
conversationBubble.setBackground(new BitmapDrawable(getResources(), conversationItemSnapshot));
|
||||||
TextView conversationTimestamp = conversationItem.findViewById(R.id.conversation_item_timestamp);
|
|
||||||
conversationTimestamp.setText(DateUtils.getDisplayFormattedTimeSpanString(getContext(), Locale.getDefault(), messageRecord.getTimestamp()));
|
conversationTimestamp.setText(DateUtils.getDisplayFormattedTimeSpanString(getContext(), Locale.getDefault(), messageRecord.getTimestamp()));
|
||||||
|
|
||||||
updateConversationTimestamp(messageRecord);
|
updateConversationTimestamp(messageRecord);
|
||||||
@ -190,12 +192,8 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateConversationTimestamp(MessageRecord message) {
|
private void updateConversationTimestamp(MessageRecord message) {
|
||||||
View bubble = conversationItem.findViewById(R.id.conversation_item_bubble);
|
if (message.isOutgoing()) conversationBubble.bringToFront();
|
||||||
View timestamp = conversationItem.findViewById(R.id.conversation_item_timestamp);
|
else conversationTimestamp.bringToFront();
|
||||||
conversationItem.removeAllViewsInLayout();
|
|
||||||
conversationItem.addView(message.isOutgoing() ? timestamp : bubble);
|
|
||||||
conversationItem.addView(message.isOutgoing() ? bubble : timestamp);
|
|
||||||
conversationItem.requestLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showAfterLayout(@NonNull MessageRecord messageRecord,
|
private void showAfterLayout(@NonNull MessageRecord messageRecord,
|
||||||
@ -351,11 +349,14 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
|||||||
|
|
||||||
int revealDuration = getContext().getResources().getInteger(R.integer.reaction_scrubber_reveal_duration);
|
int revealDuration = getContext().getResources().getInteger(R.integer.reaction_scrubber_reveal_duration);
|
||||||
|
|
||||||
|
conversationBubble.animate()
|
||||||
|
.scaleX(endScale)
|
||||||
|
.scaleY(endScale)
|
||||||
|
.setDuration(revealDuration);
|
||||||
|
|
||||||
conversationItem.animate()
|
conversationItem.animate()
|
||||||
.x(endX)
|
.x(endX)
|
||||||
.y(endY)
|
.y(endY)
|
||||||
.scaleX(endScale)
|
|
||||||
.scaleY(endScale)
|
|
||||||
.setDuration(revealDuration);
|
.setDuration(revealDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import android.content.Context
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.PointF
|
import android.graphics.PointF
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
|
import android.util.Size
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.DimenRes
|
import androidx.annotation.DimenRes
|
||||||
@ -15,6 +16,7 @@ import network.loki.messenger.R
|
|||||||
import org.session.libsession.utilities.getColorFromAttr
|
import org.session.libsession.utilities.getColorFromAttr
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import androidx.core.graphics.applyCanvas
|
import androidx.core.graphics.applyCanvas
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
fun View.contains(point: PointF): Boolean {
|
fun View.contains(point: PointF): Boolean {
|
||||||
return hitRect.contains(point.x.toInt(), point.y.toInt())
|
return hitRect.contains(point.x.toInt(), point.y.toInt())
|
||||||
@ -68,8 +70,23 @@ fun View.hideKeyboard() {
|
|||||||
imm.hideSoftInputFromWindow(this.windowToken, 0)
|
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())
|
translate(-scrollX.toFloat(), -scrollY.toFloat())
|
||||||
draw(this)
|
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) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -304,7 +304,6 @@
|
|||||||
<item name="dividerHorizontal">?dividerVertical</item>
|
<item name="dividerHorizontal">?dividerVertical</item>
|
||||||
<item name="message_received_background_color">#F2F2F2</item>
|
<item name="message_received_background_color">#F2F2F2</item>
|
||||||
<item name="colorAccent">@color/classic_accent</item>
|
<item name="colorAccent">@color/classic_accent</item>
|
||||||
<item name="colorControlHighlight">?android:colorControlHighlight</item>
|
|
||||||
<item name="tabStyle">@style/Widget.Session.TabLayout</item>
|
<item name="tabStyle">@style/Widget.Session.TabLayout</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@ -313,7 +312,6 @@
|
|||||||
<item name="dividerHorizontal">?dividerVertical</item>
|
<item name="dividerHorizontal">?dividerVertical</item>
|
||||||
<item name="message_received_background_color">#F2F2F2</item>
|
<item name="message_received_background_color">#F2F2F2</item>
|
||||||
<item name="colorAccent">@color/ocean_accent</item>
|
<item name="colorAccent">@color/ocean_accent</item>
|
||||||
<item name="colorControlHighlight">?android:colorControlHighlight</item>
|
|
||||||
<item name="tabStyle">@style/Widget.Session.TabLayout</item>
|
<item name="tabStyle">@style/Widget.Session.TabLayout</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@ -339,6 +337,7 @@
|
|||||||
<item name="colorSettingsBackground">@color/classic_dark_1</item>
|
<item name="colorSettingsBackground">@color/classic_dark_1</item>
|
||||||
<item name="colorDividerBackground">@color/classic_dark_3</item>
|
<item name="colorDividerBackground">@color/classic_dark_3</item>
|
||||||
<item name="android:colorControlHighlight">@color/classic_dark_3</item>
|
<item name="android:colorControlHighlight">@color/classic_dark_3</item>
|
||||||
|
<item name="colorControlHighlight">@color/classic_dark_3</item>
|
||||||
<item name="actionBarPopupTheme">@style/Dark.Popup</item>
|
<item name="actionBarPopupTheme">@style/Dark.Popup</item>
|
||||||
<item name="actionBarWidgetTheme">@null</item>
|
<item name="actionBarWidgetTheme">@null</item>
|
||||||
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
||||||
@ -412,6 +411,7 @@
|
|||||||
<item name="colorSettingsBackground">@color/classic_light_5</item>
|
<item name="colorSettingsBackground">@color/classic_light_5</item>
|
||||||
<item name="colorDividerBackground">@color/classic_light_3</item>
|
<item name="colorDividerBackground">@color/classic_light_3</item>
|
||||||
<item name="android:colorControlHighlight">@color/classic_light_3</item>
|
<item name="android:colorControlHighlight">@color/classic_light_3</item>
|
||||||
|
<item name="colorControlHighlight">@color/classic_light_3</item>
|
||||||
<item name="bottomSheetDialogTheme">@style/Classic.Light.BottomSheet</item>
|
<item name="bottomSheetDialogTheme">@style/Classic.Light.BottomSheet</item>
|
||||||
<item name="android:actionMenuTextColor">?android:textColorPrimary</item>
|
<item name="android:actionMenuTextColor">?android:textColorPrimary</item>
|
||||||
<item name="popupTheme">?actionBarPopupTheme</item>
|
<item name="popupTheme">?actionBarPopupTheme</item>
|
||||||
@ -499,6 +499,7 @@
|
|||||||
<item name="colorSettingsBackground">@color/ocean_dark_1</item>
|
<item name="colorSettingsBackground">@color/ocean_dark_1</item>
|
||||||
<item name="colorDividerBackground">@color/ocean_dark_4</item>
|
<item name="colorDividerBackground">@color/ocean_dark_4</item>
|
||||||
<item name="android:colorControlHighlight">@color/ocean_dark_4</item>
|
<item name="android:colorControlHighlight">@color/ocean_dark_4</item>
|
||||||
|
<item name="colorControlHighlight">@color/ocean_dark_4</item>
|
||||||
<item name="bottomSheetDialogTheme">@style/Ocean.Dark.BottomSheet</item>
|
<item name="bottomSheetDialogTheme">@style/Ocean.Dark.BottomSheet</item>
|
||||||
<item name="popupTheme">?actionBarPopupTheme</item>
|
<item name="popupTheme">?actionBarPopupTheme</item>
|
||||||
<item name="actionMenuTextColor">?android:textColorPrimary</item>
|
<item name="actionMenuTextColor">?android:textColorPrimary</item>
|
||||||
@ -580,6 +581,7 @@
|
|||||||
<item name="colorSettingsBackground">@color/ocean_light_6</item>
|
<item name="colorSettingsBackground">@color/ocean_light_6</item>
|
||||||
<item name="colorDividerBackground">@color/ocean_light_3</item>
|
<item name="colorDividerBackground">@color/ocean_light_3</item>
|
||||||
<item name="android:colorControlHighlight">@color/ocean_light_4</item>
|
<item name="android:colorControlHighlight">@color/ocean_light_4</item>
|
||||||
|
<item name="colorControlHighlight">@color/ocean_light_4</item>
|
||||||
<item name="bottomSheetDialogTheme">@style/Ocean.Light.BottomSheet</item>
|
<item name="bottomSheetDialogTheme">@style/Ocean.Light.BottomSheet</item>
|
||||||
<item name="actionBarPopupTheme">@style/Light.Popup</item>
|
<item name="actionBarPopupTheme">@style/Light.Popup</item>
|
||||||
<item name="popupTheme">?actionBarPopupTheme</item>
|
<item name="popupTheme">?actionBarPopupTheme</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user