Adds Name Playback on messages as well.

This commit is contained in:
Vitor Pamplona
2023-06-16 16:18:06 -04:00
parent 8e725259eb
commit 4e57eed5d8
3 changed files with 45 additions and 47 deletions

View File

@@ -71,6 +71,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import com.vitorpamplona.amethyst.ui.theme.ChatBubbleShapeMe import com.vitorpamplona.amethyst.ui.theme.ChatBubbleShapeMe
import com.vitorpamplona.amethyst.ui.theme.ChatBubbleShapeThem import com.vitorpamplona.amethyst.ui.theme.ChatBubbleShapeThem
import com.vitorpamplona.amethyst.ui.theme.RelayIconFilter import com.vitorpamplona.amethyst.ui.theme.RelayIconFilter
import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
import com.vitorpamplona.amethyst.ui.theme.mediumImportanceLink import com.vitorpamplona.amethyst.ui.theme.mediumImportanceLink
import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.theme.placeholderText
import com.vitorpamplona.amethyst.ui.theme.subtleBorder import com.vitorpamplona.amethyst.ui.theme.subtleBorder
@@ -498,15 +499,22 @@ private fun DrawAuthorInfo(
} }
) )
CreateClickableTextWithEmoji( userDisplayName?.let {
clickablePart = remember { " $userDisplayName" }, Spacer(modifier = StdHorzSpacer)
suffix = "",
tags = userTags, CreateClickableTextWithEmoji(
fontWeight = FontWeight.Bold, clickablePart = it,
overrideColor = MaterialTheme.colors.onBackground, suffix = "",
route = route, tags = userTags,
nav = nav fontWeight = FontWeight.Bold,
) overrideColor = MaterialTheme.colors.onBackground,
route = route,
nav = nav
)
Spacer(modifier = StdHorzSpacer)
DrawPlayName(it)
}
} }
} }

View File

@@ -2,7 +2,6 @@ package com.vitorpamplona.amethyst.ui.note
import android.content.Context import android.content.Context
import android.util.Log import android.util.Log
import androidx.compose.foundation.layout.size
import androidx.compose.material.Icon import androidx.compose.material.Icon
import androidx.compose.material.IconButton import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
@@ -18,7 +17,6 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.model.User
@@ -26,6 +24,7 @@ import com.vitorpamplona.amethyst.service.tts.TextToSpeechHelper
import com.vitorpamplona.amethyst.ui.actions.ImmutableListOfLists import com.vitorpamplona.amethyst.ui.actions.ImmutableListOfLists
import com.vitorpamplona.amethyst.ui.actions.toImmutableListOfLists import com.vitorpamplona.amethyst.ui.actions.toImmutableListOfLists
import com.vitorpamplona.amethyst.ui.components.CreateTextWithEmoji import com.vitorpamplona.amethyst.ui.components.CreateTextWithEmoji
import com.vitorpamplona.amethyst.ui.theme.StdButtonSizeModifier
import com.vitorpamplona.amethyst.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.theme.placeholderText
@Composable @Composable
@@ -57,9 +56,6 @@ private fun UserNameDisplay(
tags: ImmutableListOfLists<String>?, tags: ImmutableListOfLists<String>?,
modifier: Modifier modifier: Modifier
) { ) {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
if (bestUserName != null && bestDisplayName != null) { if (bestUserName != null && bestDisplayName != null) {
CreateTextWithEmoji( CreateTextWithEmoji(
text = bestDisplayName, text = bestDisplayName,
@@ -74,17 +70,7 @@ private fun UserNameDisplay(
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
modifier = modifier modifier = modifier
) )
IconButton( DrawPlayName(bestDisplayName)
onClick = { speak(bestDisplayName, context, lifecycleOwner) },
modifier = Modifier.size(20.dp)
) {
Icon(
imageVector = Icons.Outlined.PlayCircle,
contentDescription = null,
modifier = Modifier.size(20.dp),
tint = MaterialTheme.colors.placeholderText
)
}
} else if (bestDisplayName != null) { } else if (bestDisplayName != null) {
CreateTextWithEmoji( CreateTextWithEmoji(
text = bestDisplayName, text = bestDisplayName,
@@ -94,17 +80,7 @@ private fun UserNameDisplay(
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
modifier = modifier modifier = modifier
) )
IconButton( DrawPlayName(bestDisplayName)
onClick = { speak(bestDisplayName, context, lifecycleOwner) },
modifier = Modifier.size(20.dp)
) {
Icon(
imageVector = Icons.Outlined.PlayCircle,
contentDescription = null,
modifier = Modifier.size(20.dp),
tint = MaterialTheme.colors.placeholderText
)
}
} else if (bestUserName != null) { } else if (bestUserName != null) {
CreateTextWithEmoji( CreateTextWithEmoji(
text = remember { "@$bestUserName" }, text = remember { "@$bestUserName" },
@@ -114,17 +90,7 @@ private fun UserNameDisplay(
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
modifier = modifier modifier = modifier
) )
IconButton( DrawPlayName(bestUserName)
onClick = { speak(bestUserName, context, lifecycleOwner) },
modifier = Modifier.size(20.dp)
) {
Icon(
imageVector = Icons.Outlined.PlayCircle,
contentDescription = null,
modifier = Modifier.size(20.dp),
tint = MaterialTheme.colors.placeholderText
)
}
} else { } else {
Text( Text(
npubDisplay, npubDisplay,
@@ -136,6 +102,24 @@ private fun UserNameDisplay(
} }
} }
@Composable
fun DrawPlayName(name: String) {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
IconButton(
onClick = { speak(name, context, lifecycleOwner) },
modifier = StdButtonSizeModifier
) {
Icon(
imageVector = Icons.Outlined.PlayCircle,
contentDescription = null,
modifier = StdButtonSizeModifier,
tint = MaterialTheme.colors.placeholderText
)
}
}
private fun speak( private fun speak(
message: String, message: String,
context: Context, context: Context,

View File

@@ -1,7 +1,10 @@
package com.vitorpamplona.amethyst.ui.theme package com.vitorpamplona.amethyst.ui.theme
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Shapes import androidx.compose.material.Shapes
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
val Shapes = Shapes( val Shapes = Shapes(
@@ -15,3 +18,6 @@ val ButtonBorder = RoundedCornerShape(20.dp)
val ChatBubbleShapeMe = RoundedCornerShape(15.dp, 15.dp, 3.dp, 15.dp) val ChatBubbleShapeMe = RoundedCornerShape(15.dp, 15.dp, 3.dp, 15.dp)
val ChatBubbleShapeThem = RoundedCornerShape(3.dp, 15.dp, 15.dp, 15.dp) val ChatBubbleShapeThem = RoundedCornerShape(3.dp, 15.dp, 15.dp, 15.dp)
val StdButtonSizeModifier = Modifier.size(20.dp)
val StdHorzSpacer = Modifier.width(5.dp)