diff --git a/wear/build.gradle.kts b/wear/build.gradle.kts index 16b73259..12cf5534 100644 --- a/wear/build.gradle.kts +++ b/wear/build.gradle.kts @@ -30,6 +30,9 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) + // Sign with the debug key so release builds can be installed over the + // debug app during development (same signature = seamless upgrade). + signingConfig = signingConfigs.getByName("debug") } } diff --git a/wear/proguard-rules.pro b/wear/proguard-rules.pro new file mode 100644 index 00000000..001b0a09 --- /dev/null +++ b/wear/proguard-rules.pro @@ -0,0 +1,13 @@ +# Gson reflection targets in the shared bitchat sources (persisted state payloads). +-keep class com.bitchat.android.favorites.** { *; } +-keep class com.bitchat.android.services.SeenMessageStore$* { *; } +-keepclassmembers class * { + @com.google.gson.annotations.SerializedName ; +} + +# Kotlin metadata needed by reflection-based serialization. +-keepattributes Signature, InnerClasses, EnclosingMethod + +# Tink references JSR-305 annotations not present on Android. +-dontwarn javax.annotation.Nullable +-dontwarn javax.annotation.concurrent.GuardedBy diff --git a/wear/src/main/java/com/bitchat/watch/ui/ChatScreen.kt b/wear/src/main/java/com/bitchat/watch/ui/ChatScreen.kt index b9aa013d..7ead1fc4 100644 --- a/wear/src/main/java/com/bitchat/watch/ui/ChatScreen.kt +++ b/wear/src/main/java/com/bitchat/watch/ui/ChatScreen.kt @@ -221,10 +221,12 @@ fun MessageItem( onOpen = onOpenImage ) BitchatMessageType.Audio -> VoiceNoteItem(path = message.content.trim()) - BitchatMessageType.File -> FileMessageChip( - name = File(message.content.trim()).name, - sizeBytes = File(message.content.trim()).length() - ) + BitchatMessageType.File -> { + val path = message.content.trim() + val file = remember(path) { File(path) } + val sizeBytes = remember(path) { file.length() } + FileMessageChip(name = file.name, sizeBytes = sizeBytes) + } BitchatMessageType.Message -> Text( text = message.content, style = ChatVisualTokens.MessageBodyStyle, @@ -235,5 +237,6 @@ fun MessageItem( } } -private fun formatTime(date: Date): String = - SimpleDateFormat("HH:mm", Locale.getDefault()).format(date) +private val timeFormat = SimpleDateFormat("HH:mm", Locale.getDefault()) + +private fun formatTime(date: Date): String = timeFormat.format(date)