feat: do not show copied toast on android >12

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2023-10-03 01:31:17 +02:00
parent a84ce38b1f
commit 00e66ea939
4 changed files with 50 additions and 30 deletions

View File

@ -50,6 +50,7 @@ import chat.revolt.api.routes.misc.Root
import chat.revolt.api.routes.misc.getRootRoute import chat.revolt.api.routes.misc.getRootRoute
import chat.revolt.components.generic.PageHeader import chat.revolt.components.generic.PageHeader
import chat.revolt.components.generic.PrimaryTabs import chat.revolt.components.generic.PrimaryTabs
import chat.revolt.internals.Platform
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import java.net.URI import java.net.URI
@ -140,11 +141,14 @@ fun AboutScreen(
fun copyDebugInformation() { fun copyDebugInformation() {
clipboardManager.setText(AnnotatedString(RevoltJson.encodeToString(viewModel.getDebugInformation()))) clipboardManager.setText(AnnotatedString(RevoltJson.encodeToString(viewModel.getDebugInformation())))
Toast.makeText(
context, if (Platform.needsShowClipboardNotification()) {
context.getString(R.string.copied), Toast.makeText(
Toast.LENGTH_SHORT context,
).show() context.getString(R.string.copied),
Toast.LENGTH_SHORT
).show()
}
} }
Column( Column(

View File

@ -21,6 +21,7 @@ import androidx.compose.ui.unit.dp
import chat.revolt.R import chat.revolt.R
import chat.revolt.api.RevoltAPI import chat.revolt.api.RevoltAPI
import chat.revolt.components.generic.SheetClickable import chat.revolt.components.generic.SheetClickable
import chat.revolt.internals.Platform
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@Composable @Composable
@ -64,11 +65,14 @@ fun ChannelContextSheet(
if (channel.id == null) return@SheetClickable if (channel.id == null) return@SheetClickable
clipboardManager.setText(AnnotatedString(channel.id)) clipboardManager.setText(AnnotatedString(channel.id))
Toast.makeText(
context, if (Platform.needsShowClipboardNotification()) {
context.getString(R.string.channel_context_sheet_actions_copy_id_copied), Toast.makeText(
Toast.LENGTH_SHORT context,
).show() context.getString(R.string.channel_context_sheet_actions_copy_id_copied),
Toast.LENGTH_SHORT
).show()
}
coroutineScope.launch { coroutineScope.launch {
onHideSheet() onHideSheet()

View File

@ -42,6 +42,7 @@ import chat.revolt.api.RevoltAPI
import chat.revolt.callbacks.UiCallbacks import chat.revolt.callbacks.UiCallbacks
import chat.revolt.components.chat.Message import chat.revolt.components.chat.Message
import chat.revolt.components.generic.SheetClickable import chat.revolt.components.generic.SheetClickable
import chat.revolt.internals.Platform
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@ -111,11 +112,13 @@ fun MessageContextSheet(
return@SheetClickable return@SheetClickable
} }
Toast.makeText( if (Platform.needsShowClipboardNotification()) {
context, Toast.makeText(
context.getString(R.string.copied), context,
Toast.LENGTH_SHORT context.getString(R.string.copied),
).show() Toast.LENGTH_SHORT
).show()
}
coroutineScope.launch { coroutineScope.launch {
shareSheetState.hide() shareSheetState.hide()
@ -165,11 +168,13 @@ fun MessageContextSheet(
"$REVOLT_APP/server/${server?.id}/channel/${message.channel}/${message.id}" "$REVOLT_APP/server/${server?.id}/channel/${message.channel}/${message.id}"
clipboardManager.setText(AnnotatedString(messageLink)) clipboardManager.setText(AnnotatedString(messageLink))
Toast.makeText( if (Platform.needsShowClipboardNotification()) {
context, Toast.makeText(
context.getString(R.string.message_context_sheet_actions_copy_link_copied), context,
Toast.LENGTH_SHORT context.getString(R.string.message_context_sheet_actions_copy_link_copied),
).show() Toast.LENGTH_SHORT
).show()
}
coroutineScope.launch { coroutineScope.launch {
shareSheetState.hide() shareSheetState.hide()
@ -197,11 +202,14 @@ fun MessageContextSheet(
if (message.id == null) return@SheetClickable if (message.id == null) return@SheetClickable
clipboardManager.setText(AnnotatedString(message.id)) clipboardManager.setText(AnnotatedString(message.id))
Toast.makeText(
context, if (Platform.needsShowClipboardNotification()) {
context.getString(R.string.message_context_sheet_actions_copy_id_copied), Toast.makeText(
Toast.LENGTH_SHORT context,
).show() context.getString(R.string.message_context_sheet_actions_copy_id_copied),
Toast.LENGTH_SHORT
).show()
}
coroutineScope.launch { coroutineScope.launch {
shareSheetState.hide() shareSheetState.hide()

View File

@ -51,6 +51,7 @@ import chat.revolt.components.generic.IconPlaceholder
import chat.revolt.components.generic.RemoteImage import chat.revolt.components.generic.RemoteImage
import chat.revolt.components.generic.SheetClickable import chat.revolt.components.generic.SheetClickable
import chat.revolt.components.generic.UIMarkdown import chat.revolt.components.generic.UIMarkdown
import chat.revolt.internals.Platform
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@Composable @Composable
@ -269,11 +270,14 @@ fun ServerContextSheet(
if (server.id == null) return@SheetClickable if (server.id == null) return@SheetClickable
clipboardManager.setText(AnnotatedString(server.id)) clipboardManager.setText(AnnotatedString(server.id))
Toast.makeText(
context, if (Platform.needsShowClipboardNotification()) {
context.getString(R.string.server_context_sheet_actions_copy_id_copied), Toast.makeText(
Toast.LENGTH_SHORT context,
).show() context.getString(R.string.server_context_sheet_actions_copy_id_copied),
Toast.LENGTH_SHORT
).show()
}
coroutineScope.launch { coroutineScope.launch {
onHideSheet() onHideSheet()