diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt index b83e66d6e..7a99f8034 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt @@ -99,10 +99,8 @@ class AndroidKeyPackageBundleStore( withContext(Dispatchers.IO) { mutex.withLock { val file = stateFile() - if (file.exists()) { - if (!file.delete()) { - Log.w(TAG) { "delete(): failed to remove ${file.absolutePath}" } - } + if (file.exists() && !file.delete()) { + Log.w(TAG) { "delete(): failed to remove ${file.absolutePath}" } } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt index fdcf5334a..01d9ee9cc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt @@ -108,10 +108,8 @@ class AndroidMarmotMessageStore( withContext(Dispatchers.IO) { writeMutex.withLock { val file = messagesFile(nostrGroupId) - if (file.exists()) { - if (!file.delete()) { - Log.w(TAG) { "delete($nostrGroupId): failed to remove ${file.absolutePath}" } - } + if (file.exists() && !file.delete()) { + Log.w(TAG) { "delete($nostrGroupId): failed to remove ${file.absolutePath}" } } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/FileServerSelectionRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/FileServerSelectionRow.kt index 2239d0b94..19b85ad26 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/FileServerSelectionRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/FileServerSelectionRow.kt @@ -26,7 +26,6 @@ import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.ui.components.TextSpinner import com.vitorpamplona.amethyst.ui.components.TitleExplainer import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsRow -import com.vitorpamplona.amethyst.ui.stringRes import kotlinx.collections.immutable.toImmutableList @Composable @@ -35,8 +34,6 @@ fun FileServerSelectionRow( selectedServer: ServerName?, onSelect: (ServerName) -> Unit, ) { - val nip95description = stringRes(id = R.string.upload_server_relays_nip95) - val fileServerOptions = remember(fileServers) { fileServers diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt index 57144390c..de503573f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentDialog.kt @@ -382,59 +382,59 @@ private fun DialogContent( } } - if (myContent is MediaUrlImage || myContent is MediaLocalImage || myContent is MediaUrlPdf) { - if (myContent !is MediaUrlContent || !isLiveStreaming(myContent.url)) { - val localContext = LocalContext.current + val isPdfOrStaticImage = myContent is MediaUrlImage || myContent is MediaLocalImage || myContent is MediaUrlPdf + val isNotLiveStream = myContent !is MediaUrlContent || !isLiveStreaming(myContent.url) + if (isPdfOrStaticImage && isNotLiveStream) { + val localContext = LocalContext.current - val scope = rememberCoroutineScope() + val scope = rememberCoroutineScope() - val writeStoragePermissionState = - rememberPermissionState(Manifest.permission.WRITE_EXTERNAL_STORAGE) { isGranted -> - if (isGranted) { - scope.launch { - saveMediaToGallery(myContent, localContext, accountViewModel) - } - scope.launch { - Toast - .makeText( - localContext, - stringRes(localContext, R.string.media_download_has_started_toast), - Toast.LENGTH_SHORT, - ).show() - } + val writeStoragePermissionState = + rememberPermissionState(Manifest.permission.WRITE_EXTERNAL_STORAGE) { isGranted -> + if (isGranted) { + scope.launch { + saveMediaToGallery(myContent, localContext, accountViewModel) + } + scope.launch { + Toast + .makeText( + localContext, + stringRes(localContext, R.string.media_download_has_started_toast), + Toast.LENGTH_SHORT, + ).show() } } - - OutlinedButton( - onClick = { - if ( - Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q || - writeStoragePermissionState.status.isGranted - ) { - scope.launch(Dispatchers.IO) { - saveMediaToGallery(myContent, localContext, accountViewModel) - } - scope.launch { - Toast - .makeText( - localContext, - stringRes(localContext, R.string.media_download_has_started_toast), - Toast.LENGTH_SHORT, - ).show() - } - } else { - writeStoragePermissionState.launchPermissionRequest() - } - }, - contentPadding = PaddingValues(horizontal = Size5dp), - colors = ButtonDefaults.outlinedButtonColors().copy(containerColor = MaterialTheme.colorScheme.background), - ) { - Icon( - symbol = MaterialSymbols.Download, - modifier = Size20Modifier, - contentDescription = stringRes(R.string.download_to_phone), - ) } + + OutlinedButton( + onClick = { + if ( + Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q || + writeStoragePermissionState.status.isGranted + ) { + scope.launch(Dispatchers.IO) { + saveMediaToGallery(myContent, localContext, accountViewModel) + } + scope.launch { + Toast + .makeText( + localContext, + stringRes(localContext, R.string.media_download_has_started_toast), + Toast.LENGTH_SHORT, + ).show() + } + } else { + writeStoragePermissionState.launchPermissionRequest() + } + }, + contentPadding = PaddingValues(horizontal = Size5dp), + colors = ButtonDefaults.outlinedButtonColors().copy(containerColor = MaterialTheme.colorScheme.background), + ) { + Icon( + symbol = MaterialSymbols.Download, + modifier = Size20Modifier, + contentDescription = stringRes(R.string.download_to_phone), + ) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/uploads/ImageVideoDescription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/uploads/ImageVideoDescription.kt index 603b499f8..4f75143de 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/uploads/ImageVideoDescription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/uploads/ImageVideoDescription.kt @@ -438,7 +438,7 @@ fun ImageVideoDescription( .padding(vertical = 10.dp), enabled = !isUploading, onClick = { - val effectiveStripMetadata = if (isVideoWithCompression) false else stripMetadata + val effectiveStripMetadata = !isVideoWithCompression && stripMetadata onAdd(message, selectedServer, sensitiveContent, mediaQualitySlider, useH265Codec, effectiveStripMetadata, convertGifToMp4) }, shape = QuoteBorder,