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

View File

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

View File

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