π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
ensu android: use Rive animation while generating response
Prateek Sunal64e14739ce10
diff --git a/mobile/native/android/apps/ensu/app-ui/build.gradle.kts b/mobile/native/android/apps/ensu/app-ui/build.gradle.ktsindex 5db66167c7..7b6cee2600 100644--- a/mobile/native/android/apps/ensu/app-ui/build.gradle.kts+++ b/mobile/native/android/apps/ensu/app-ui/build.gradle.kts@@ -115,6 +115,9 @@ dependencies {implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")implementation("androidx.navigation:navigation-compose:2.7.7")implementation("com.google.accompanist:accompanist-navigation-animation:0.34.0")+ implementation("app.rive:rive-android:10.2.1") {+ exclude(group = "androidx.lifecycle", module = "lifecycle-runtime-ktx")+ }implementation(project(":domain"))implementation(project(":data"))diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatMessages.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatMessages.ktindex 84d582ca63..2c9a87fcb3 100644--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatMessages.kt+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/chat/ChatMessages.kt@@ -53,8 +53,14 @@ import androidx.compose.ui.text.AnnotatedStringimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.unit.IntOffsetimport androidx.compose.ui.unit.dp+import androidx.compose.ui.viewinterop.AndroidViewimport androidx.compose.ui.window.Popupimport androidx.compose.ui.window.PopupProperties+import app.rive.runtime.kotlin.RiveAnimationView+import app.rive.runtime.kotlin.core.Alignment as RiveAlignment+import app.rive.runtime.kotlin.core.Fit+import app.rive.runtime.kotlin.core.Loop+import io.ente.ensu.Rimport io.ente.ensu.components.BranchSwitcherimport io.ente.ensu.designsystem.EnsuColorimport io.ente.ensu.designsystem.EnsuCornerRadius@@ -679,9 +685,14 @@ private fun StreamingMessageBubble(text: String) {).padding(horizontal = EnsuSpacing.sm.dp, vertical = EnsuSpacing.md.dp)) {- if (text.isBlank()) {- LoadingDotsText()- } else {+ GeneratingAnimation(+ modifier = Modifier+ .width(92.dp)+ .height(42.dp)+ )++ if (text.isNotBlank()) {+ Spacer(modifier = Modifier.height(EnsuSpacing.xs.dp))MarkdownView(markdown = text, enableSelection = false, trailingCursor = showCursor)}}@@ -689,62 +700,23 @@ private fun StreamingMessageBubble(text: String) {}@Composable-private fun LoadingDotsText() {- var dotCount by remember { mutableStateOf(1) }- val phrase = remember { randomLoadingPhrase() }-- LaunchedEffect(Unit) {- while (true) {- delay(450)- dotCount = if (dotCount == 3) 1 else dotCount + 1+private fun GeneratingAnimation(modifier: Modifier = Modifier) {+ AndroidView(+ modifier = modifier,+ factory = { context ->+ RiveAnimationView(context).apply {+ setRiveResource(+ resId = R.raw.ensu,+ autoplay = true,+ fit = Fit.CONTAIN,+ alignment = RiveAlignment.CENTER,+ loop = Loop.LOOP+ )+ }}- }-- Text(- text = phrase + ".".repeat(dotCount),- style = EnsuTypography.message,- color = EnsuColor.textMuted())}-private fun randomLoadingPhrase(): String {- val verb = loadingPhraseVerbs.random()- val target = loadingPhraseTargets.random()- return "$verb $target"-}--private val loadingPhraseVerbs = listOf(- "Generating",- "Thinking through",- "Assembling",- "Drafting",- "Composing",- "Crunching",- "Exploring",- "Piecing together",- "Reviewing",- "Organizing",- "Synthesizing",- "Sketching",- "Refining",- "Shaping"-)--private val loadingPhraseTargets = listOf(- "your reply",- "an answer",- "ideas",- "context",- "details",- "the response",- "the next steps",- "a solution",- "the summary",- "insights",- "the draft",- "the explanation"-)-@Composableprivate fun TimestampText(timestampMillis: Long) {Text(diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.riv b/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.rivnew file mode 100644index 0000000000..35f4f64d35Binary files /dev/null and b/mobile/native/android/apps/ensu/app-ui/src/main/res/raw/ensu.riv differ