From 5ecb2a8db45ba0c43ef76007c2923b193cad66f4 Mon Sep 17 00:00:00 2001 From: k1ngsterr1 Date: Thu, 19 Mar 2026 23:35:28 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BD=D0=B8=D0=B2=D0=B5=D1=80=D1=81?= =?UTF-8?q?=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BE=D0=B1=D0=BE=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=81=D0=B5=D1=85=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../messenger/ui/chats/ChatDetailScreen.kt | 70 +++---------------- 1 file changed, 8 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt index 251efa4..d95bae2 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt @@ -2,13 +2,7 @@ package com.rosetta.messenger.ui.chats import android.app.Activity import android.content.Context -import android.graphics.Bitmap -import android.graphics.BitmapFactory -import android.graphics.Shader -import android.graphics.drawable.BitmapDrawable import android.net.Uri -import android.view.Gravity -import android.view.View import android.view.inputmethod.InputMethodManager import androidx.activity.compose.BackHandler import androidx.activity.compose.rememberLauncherForActivityResult @@ -80,7 +74,6 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import androidx.compose.ui.viewinterop.AndroidView import androidx.compose.ui.zIndex import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver @@ -2335,10 +2328,9 @@ fun ChatDetailScreen( // Keep wallpaper on a fixed full-screen layer so it doesn't rescale // when content paddings (bottom bar/IME) change. if (chatWallpaperResId != null) { - TiledChatWallpaper( + ChatWallpaperBackground( wallpaperResId = chatWallpaperResId, - modifier = Modifier.matchParentSize(), - tileScale = 0.9f + modifier = Modifier.matchParentSize() ) } else { Box( @@ -3676,60 +3668,14 @@ private fun GroupMembersSubtitleSkeleton() { } @Composable -private fun TiledChatWallpaper( +private fun ChatWallpaperBackground( wallpaperResId: Int, - modifier: Modifier = Modifier, - tileScale: Float = 0.9f + modifier: Modifier = Modifier ) { - val context = LocalContext.current - val wallpaperDrawable = - remember(wallpaperResId, tileScale, context) { - val decoded = BitmapFactory.decodeResource(context.resources, wallpaperResId) - val normalizedScale = tileScale.coerceIn(0.2f, 2f) - - val scaledBitmap = - decoded?.let { original -> - if (normalizedScale == 1f) { - original - } else { - val width = - (original.width * normalizedScale) - .toInt() - .coerceAtLeast(1) - val height = - (original.height * normalizedScale) - .toInt() - .coerceAtLeast(1) - val scaled = - Bitmap.createScaledBitmap( - original, - width, - height, - true - ) - if (scaled != original) { - original.recycle() - } - scaled - } - } - - val safeBitmap = - scaledBitmap - ?: Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) - .apply { - eraseColor(android.graphics.Color.TRANSPARENT) - } - - BitmapDrawable(context.resources, safeBitmap).apply { - setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT) - gravity = Gravity.TOP or Gravity.START - } - } - - AndroidView( + Image( + painter = painterResource(id = wallpaperResId), + contentDescription = "Chat wallpaper", modifier = modifier, - factory = { ctx -> View(ctx).apply { background = wallpaperDrawable } }, - update = { view -> view.background = wallpaperDrawable } + contentScale = ContentScale.Crop ) }