From e75e201a0dc25cdf74b679a3d94571bf19d5792c Mon Sep 17 00:00:00 2001 From: benya Date: Mon, 6 Apr 2026 01:55:53 +0300 Subject: [PATCH] feat: add media grid bulk actions in chat info --- .../messenger/ui/chat/ChatScreen.kt | 49 +++++++++++++++++++ .../app/src/main/res/values-ru/strings.xml | 4 ++ android/app/src/main/res/values/strings.xml | 4 ++ 3 files changed, 57 insertions(+) diff --git a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt index 213a83c..67658ed 100644 --- a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt +++ b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt @@ -110,6 +110,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.snapshotFlow import androidx.compose.runtime.setValue +import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.platform.LocalConfiguration @@ -119,6 +120,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.TextRange +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.layout.ContentScale @@ -5976,6 +5978,8 @@ private fun ChatInfoTabContent( onUnbanMember: (Long) -> Unit, onEntryClick: (ChatInfoEntry) -> Unit, ) { + val context = LocalContext.current + val clipboardManager = LocalClipboardManager.current if (tab == ChatInfoTab.Members) { ChatMembersTabContent( members = members, @@ -6029,6 +6033,9 @@ private fun ChatInfoTabContent( val selectedEntries = remember(filtered, selectionCount) { filtered.filter { entry -> buildChatInfoEntrySelectionKey(entry) in selectedMediaKeys } } + val selectedUrls = remember(selectedEntries) { + selectedEntries.mapNotNull { it.resourceUrl ?: it.previewImageUrl }.distinct() + } Column( modifier = Modifier .fillMaxWidth() @@ -6054,11 +6061,53 @@ private fun ChatInfoTabContent( style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold, ) + TextButton( + onClick = { + selectedMediaKeys = filtered + .take(120) + .map(::buildChatInfoEntrySelectionKey) + .toSet() + }, + ) { + Text(stringResource(id = R.string.chat_info_select_all)) + } if (selectedEntries.size == 1) { TextButton(onClick = { onEntryClick(selectedEntries.first()) }) { Text(stringResource(id = R.string.chat_info_open_selected)) } } + if (selectedUrls.isNotEmpty()) { + TextButton( + onClick = { + clipboardManager.setText( + AnnotatedString(selectedUrls.joinToString(separator = "\n")), + ) + Toast.makeText( + context, + context.getString(R.string.chat_info_links_copied), + Toast.LENGTH_SHORT, + ).show() + }, + ) { + Text(stringResource(id = R.string.chat_info_copy_links)) + } + TextButton( + onClick = { + val shareIntent = Intent(Intent.ACTION_SEND).apply { + type = "text/plain" + putExtra(Intent.EXTRA_TEXT, selectedUrls.joinToString(separator = "\n")) + } + context.startActivity( + Intent.createChooser( + shareIntent, + context.getString(R.string.chat_info_share_links), + ), + ) + }, + ) { + Text(stringResource(id = R.string.chat_info_share_links)) + } + } TextButton(onClick = { selectedMediaKeys = emptySet() }) { Text(stringResource(id = R.string.chat_info_clear_selection)) } diff --git a/android/app/src/main/res/values-ru/strings.xml b/android/app/src/main/res/values-ru/strings.xml index 884524f..cedccf8 100644 --- a/android/app/src/main/res/values-ru/strings.xml +++ b/android/app/src/main/res/values-ru/strings.xml @@ -165,6 +165,10 @@ Выбрано: %1$d Открыть Сбросить + Все + Копировать ссылки + Поделиться + Ссылки скопированы Удерживайте медиа, чтобы перейти в режим выбора. Участники (%1$d) Заблокированные (%1$d) diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 59ce07c..b4d5030 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -165,6 +165,10 @@ %1$d selected Open Clear + All + Copy links + Share links + Links copied Long press media to select multiple items. Members (%1$d) Banned (%1$d)