From 7cac47121261c1815ffff5ba7279510399457447 Mon Sep 17 00:00:00 2001 From: mrghosti3 Date: Sun, 7 Apr 2024 00:19:11 +0300 Subject: [PATCH] Show toast for Copy button click under API 33 Displays taost message feedback if device API is 32 or below (before Android 13) --- .../java/com/starry/greenstash/ui/common/ExpandableCard.kt | 7 +++++++ app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 5 files changed, 11 insertions(+) diff --git a/app/src/main/java/com/starry/greenstash/ui/common/ExpandableCard.kt b/app/src/main/java/com/starry/greenstash/ui/common/ExpandableCard.kt index c2e36cee..c1bc9fb2 100644 --- a/app/src/main/java/com/starry/greenstash/ui/common/ExpandableCard.kt +++ b/app/src/main/java/com/starry/greenstash/ui/common/ExpandableCard.kt @@ -25,6 +25,8 @@ package com.starry.greenstash.ui.common +import android.os.Build +import android.widget.Toast import androidx.compose.animation.animateContentSize import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.animateFloatAsState @@ -60,6 +62,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate import androidx.compose.ui.graphics.Shape import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.font.FontWeight @@ -159,6 +162,7 @@ fun ExpandableTextCard( showCopyButton: Boolean = false, padding: Dp = 12.dp, ) { + val context = LocalContext.current val clipboardManager = LocalClipboardManager.current ExpandableCard( @@ -179,6 +183,9 @@ fun ExpandableTextCard( if (showCopyButton) { FilledTonalButton(onClick = { clipboardManager.setText(AnnotatedString(description)) + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) { + Toast.makeText(context, R.string.copy_alert, Toast.LENGTH_SHORT).show() + } }) { Row { Icon(Icons.Filled.ContentCopy, contentDescription = "Copy Notes" ) diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d1dbce38..1e3b98c8 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -7,6 +7,7 @@ Aceptar ¡Vaya! Algo salió mal. Copy + Copied Inicio diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 8b875248..05378c2c 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -7,6 +7,7 @@ Tamam Hoop! bir şeyler yanlış gitti. Copy + Copied Ana Sayfa diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index ec9ee8d9..51062d94 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -7,6 +7,7 @@ 确定 糟糕!出了点问题。 Copy + Copied 主页 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9feb2e39..4972f992 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,6 +7,7 @@ OK Oops! something went wrong. Copy + Copied Home