mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-28 20:40:13 +02:00
fix(core/ui): snap preview overlapping
This commit is contained in:
parent
c695145b50
commit
574775f65c
@ -6,11 +6,7 @@ import android.widget.LinearLayout
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Android
|
||||
import androidx.compose.material.icons.filled.Edit
|
||||
import androidx.compose.material.icons.filled.Laptop
|
||||
import androidx.compose.material.icons.filled.LocationOn
|
||||
import androidx.compose.material.icons.filled.Lock
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -27,7 +23,6 @@ import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
|
||||
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
|
||||
import me.rhunk.snapenhance.core.features.Feature
|
||||
import me.rhunk.snapenhance.core.ui.AppleLogo
|
||||
import me.rhunk.snapenhance.core.ui.removeForegroundDrawable
|
||||
import kotlin.random.Random
|
||||
|
||||
class MessageIndicators : Feature("Message Indicators") {
|
||||
@ -44,8 +39,6 @@ class MessageIndicators : Feature("Message Indicators") {
|
||||
val view = event.view as? ViewGroup ?: return@subscribe
|
||||
view.findViewWithTag<View>(messageInfoTag)?.let { view.removeView(it) }
|
||||
|
||||
event.view.removeForegroundDrawable("messageIndicators")
|
||||
|
||||
val message = event.databaseMessage ?: return@chatMessage
|
||||
if (message.contentType != ContentType.SNAP.id && message.contentType != ContentType.EXTERNAL_MEDIA.id) return@chatMessage
|
||||
val reader = ProtoReader(message.messageContent ?: return@chatMessage)
|
||||
|
@ -5,6 +5,7 @@ import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import android.graphics.drawable.ShapeDrawable
|
||||
import android.graphics.drawable.shapes.Shape
|
||||
import android.view.ViewGroup
|
||||
import me.rhunk.snapenhance.common.data.ContentType
|
||||
import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
|
||||
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
|
||||
@ -57,7 +58,8 @@ class SnapPreview : Feature("SnapPreview") {
|
||||
|
||||
context.event.subscribe(BindViewEvent::class) { event ->
|
||||
event.chatMessage { _, _ ->
|
||||
event.view.removeForegroundDrawable("snapPreview")
|
||||
val messageLinearLayout = (event.view as ViewGroup).getChildAt(0) as? ViewGroup ?: return@subscribe
|
||||
messageLinearLayout.removeForegroundDrawable("snapPreview")
|
||||
|
||||
val message = event.databaseMessage ?: return@chatMessage
|
||||
val messageReader = ProtoReader(message.messageContent ?: return@chatMessage)
|
||||
@ -67,7 +69,7 @@ class SnapPreview : Feature("SnapPreview") {
|
||||
|
||||
val mediaIdKey = messageReader.getString(4, 5, 1, 3, 2, 2) ?: return@chatMessage
|
||||
|
||||
event.view.addForegroundDrawable("snapPreview", ShapeDrawable(object: Shape() {
|
||||
messageLinearLayout.addForegroundDrawable("snapPreview", ShapeDrawable(object: Shape() {
|
||||
override fun draw(canvas: Canvas, paint: Paint) {
|
||||
val bitmap = mediaFileCache[mediaIdKey]?.let { decodeMedia(it) } ?: return
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user