Skip to content

Commit

Permalink
Show toast for Copy button click under API 33
Browse files Browse the repository at this point in the history
Displays taost message feedback if device API is 32 or below
(before Android 13)
  • Loading branch information
mrghosti3 committed Apr 6, 2024
1 parent 266d8ba commit 7cac471
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -159,6 +162,7 @@ fun ExpandableTextCard(
showCopyButton: Boolean = false,
padding: Dp = 12.dp,
) {
val context = LocalContext.current
val clipboardManager = LocalClipboardManager.current

ExpandableCard(
Expand All @@ -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" )
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="ok">Aceptar</string>
<string name="unknown_error">¡Vaya! Algo salió mal.</string>
<string name="copy">Copy</string>
<string name="copy_alert">Copied</string>

<!-- Navigation Drawer -->
<string name="drawer_home">Inicio</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="ok">Tamam</string>
<string name="unknown_error">Hoop! bir şeyler yanlış gitti.</string>
<string name="copy">Copy</string>
<string name="copy_alert">Copied</string>

<!-- Navigation Drawer -->
<string name="drawer_home">Ana Sayfa</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="ok">确定</string>
<string name="unknown_error">糟糕!出了点问题。</string>
<string name="copy">Copy</string>
<string name="copy_alert">Copied</string>

<!-- Navigation Drawer -->
<string name="drawer_home">主页</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="ok">OK</string>
<string name="unknown_error">Oops! something went wrong.</string>
<string name="copy">Copy</string>
<string name="copy_alert">Copied</string>

<!-- Navigation Drawer -->
<string name="drawer_home">Home</string>
Expand Down

0 comments on commit 7cac471

Please sign in to comment.