Skip to content

Commit

Permalink
Make conversation text selectable; Add conversation clear button
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpv committed Jan 23, 2025
1 parent 9d56f3f commit fb2c0c8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
45 changes: 29 additions & 16 deletions mobile/src/main/java/com/swooby/alfredai/PushToTalkActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -36,6 +37,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.SelectionContainer
//noinspection UsingMaterialAndMaterial3Libraries
import androidx.compose.material.ContentAlpha
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -142,7 +144,7 @@ enum class ConversationSpeaker {
Remote,
}

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Composable
fun PushToTalkScreen(pushToTalkViewModel: PushToTalkViewModel? = null) {
@Suppress("LocalVariableName")
Expand Down Expand Up @@ -824,20 +826,31 @@ fun PushToTalkScreen(pushToTalkViewModel: PushToTalkViewModel? = null) {
.weight(1f)
.border(1.dp, Color.LightGray, shape = RoundedCornerShape(8.dp))
.fillMaxWidth()
.padding(8.dp)
,
horizontalArrangement = Arrangement.spacedBy(24.dp)
.padding(start = 8.dp, end = 8.dp, top = 0.dp, bottom = 8.dp),
horizontalArrangement = Arrangement.spacedBy(24.dp),
) {
Column {
Row {
Text(text = "Conversation:")
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
Text(
modifier = Modifier.padding(start = 4.dp),
text = "Conversation:",
)
IconButton(onClick = { conversationItems.clear() }) {
Icon(
painterResource(id = R.drawable.baseline_clear_all_24),
contentDescription = "Clear All",
)
}
}
Row {
LazyColumn(
modifier = Modifier
.border(1.dp, Color.LightGray, shape = RoundedCornerShape(8.dp))
.fillMaxSize()
,
.fillMaxSize(),
contentPadding = PaddingValues(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
state = conversationListState,
Expand Down Expand Up @@ -880,14 +893,14 @@ fun PushToTalkScreen(pushToTalkViewModel: PushToTalkViewModel? = null) {
.padding(8.dp)
,
) {
Text(
modifier = Modifier
.fillMaxWidth()
,
text = item.text,
textAlign = textAlign,

)
SelectionContainer {
Text(
modifier = Modifier
.fillMaxWidth(),
text = item.text,
textAlign = textAlign,
)
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions mobile/src/main/res/drawable/baseline_clear_all_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M5,13h14v-2L5,11v2zM3,17h14v-2L3,15v2zM7,7v2h14L21,7L7,7z"/>

</vector>

0 comments on commit fb2c0c8

Please sign in to comment.