diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt index 97d8e193db..d987e4b5ff 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt @@ -246,8 +246,8 @@ fun LocalImageView( } val ratio = remember(content) { content.dim?.aspectRatio() ?: MediaAspectRatioCache.get(content.localFile.toString()) } - CrossfadeIfEnabled(targetState = showImage.value, contentAlignment = Alignment.Center, accountViewModel = accountViewModel) { - if (it) { + CrossfadeIfEnabled(targetState = showImage.value, contentAlignment = Alignment.Center, accountViewModel = accountViewModel) { imageVisible -> + if (imageVisible) { SubcomposeAsyncImage( model = content.localFile, contentDescription = content.description, @@ -552,11 +552,7 @@ fun ShowHash(content: MediaUrlContent) { } @Composable -fun WaitAndDisplay( - content: - @Composable() - (AnimatedVisibilityScope.() -> Unit), -) { +fun WaitAndDisplay(content: @Composable (AnimatedVisibilityScope.() -> Unit)) { val visible = remember { mutableStateOf(false) } LaunchedEffect(Unit) { @@ -939,7 +935,11 @@ private suspend fun shareVideoFile( // GlobalScope is intentional: cleanup must survive after share UI is dismissed. GlobalScope.launch(Dispatchers.IO) { delay(SHARED_VIDEO_CLEANUP_DELAY_MS) - sharedFile?.delete() + sharedFile?.let { file -> + if (!file.delete()) { + Log.w("ZoomableContentView", "Failed to delete shared file: ${file.path}") + } + } } withContext(Dispatchers.Main) { @@ -950,8 +950,14 @@ private suspend fun shareVideoFile( Log.w("ZoomableContentView", "Failed to share video: $videoUrl", e) // Clean up temp file on error - tempFile.delete() - sharedFile?.delete() + if (!tempFile.delete()) { + Log.w("ZoomableContentView", "Failed to delete temp file: ${tempFile.path}") + } + sharedFile?.let { file -> + if (!file.delete()) { + Log.w("ZoomableContentView", "Failed to delete shared file: ${file.path}") + } + } withContext(Dispatchers.Main) { Toast diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt index 5e4fc7b209..0be396cdae 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt @@ -128,6 +128,8 @@ import kotlinx.collections.immutable.toImmutableList import kotlin.contracts.ExperimentalContracts import kotlin.contracts.contract +private const val HTTPS_PREFIX = "https://" + @Composable fun RelayInformationScreen( relayUrl: String, @@ -434,7 +436,7 @@ fun FeesCard( } payUrl?.let { val uri = LocalUriHandler.current - ClickableInfoRow(Icons.Default.Payment, stringRes(R.string.payments_url), it.removePrefix("https://")) { + ClickableInfoRow(Icons.Default.Payment, stringRes(R.string.payments_url), it.removePrefix(HTTPS_PREFIX)) { runCatching { uri.openUri(it) } @@ -583,8 +585,8 @@ fun SoftwareCard(relayInfo: Nip11RelayInformation) { Column(modifier = Modifier.padding(16.dp)) { val uri = LocalUriHandler.current relayInfo.software?.let { - if (it.contains("https://")) { - ClickableInfoRow(Icons.Default.Code, stringRes(R.string.software), it.removePrefix("git+https://").removePrefix("https://")) { + if (it.contains(HTTPS_PREFIX)) { + ClickableInfoRow(Icons.Default.Code, stringRes(R.string.software), it.removePrefix("git+https://").removePrefix(HTTPS_PREFIX)) { runCatching { uri.openUri(it.removePrefix("git+")) } @@ -809,7 +811,7 @@ fun PoliciesCard(relay: Nip11RelayInformation) { val pp = relay.privacy_policy if (pp != null) { - ClickableInfoRow(Icons.Default.PrivacyTip, stringRes(R.string.privacy_policy), pp.removePrefix("https://")) { + ClickableInfoRow(Icons.Default.PrivacyTip, stringRes(R.string.privacy_policy), pp.removePrefix(HTTPS_PREFIX)) { runCatching { uri.openUri(pp) } @@ -820,7 +822,7 @@ fun PoliciesCard(relay: Nip11RelayInformation) { val ts = relay.terms_of_service if (ts != null) { - ClickableInfoRow(Icons.Default.Gavel, stringRes(R.string.terms_and_conditions), ts.removePrefix("https://")) { + ClickableInfoRow(Icons.Default.Gavel, stringRes(R.string.terms_and_conditions), ts.removePrefix(HTTPS_PREFIX)) { runCatching { uri.openUri(ts) }