Skip to content

Commit

Permalink
Notify missing saving folder (#120)
Browse files Browse the repository at this point in the history
* Notify missing saving folder

* Resolve conflicts
  • Loading branch information
shubertm authored Mar 17, 2024
1 parent 571b555 commit 053cbf8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import dev.arkbuilders.arkretouch.presentation.theme.Gray
import dev.arkbuilders.arkretouch.presentation.utils.askWritePermissions
import dev.arkbuilders.arkretouch.presentation.utils.getActivity
import dev.arkbuilders.arkretouch.presentation.utils.isWritePermGranted
import dev.arkbuilders.arkretouch.presentation.utils.toast
import java.nio.file.Path

@Composable
Expand Down Expand Up @@ -365,13 +364,9 @@ private fun BoxScope.TopMenu(
SavePathDialog(
initialImagePath = imagePath,
fragmentManager = fragmentManager,
onEmptyFileName = {
context.toast(R.string.ark_retouch_file_name_missing)
},
onDismissClick = { viewModel.showSavePathDialog = false },
onPositiveClick = { savePath ->
viewModel.saveImage(context, savePath)
viewModel.showSavePathDialog = false
}
)
if (viewModel.showMoreOptionsPopup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class EditViewModel(
) { _, _ -> }
imageSaved = true
isSavingImage = false
showSavePathDialog = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ fun NewImageOptionsDialog(
isVisible = false
}
) {
Text("Ok")
Text(stringResource(R.string.ok))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import kotlin.io.path.name
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.runtime.key
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.platform.LocalContext
import dev.arkbuilders.arkretouch.presentation.utils.toast
import java.nio.file.Files
import kotlin.streams.toList

Expand All @@ -52,7 +54,6 @@ import kotlin.streams.toList
fun SavePathDialog(
initialImagePath: Path?,
fragmentManager: FragmentManager,
onEmptyFileName: () -> Unit,
onDismissClick: () -> Unit,
onPositiveClick: (Path) -> Unit
) {
Expand All @@ -70,6 +71,8 @@ fun SavePathDialog(

val lifecycleOwner = LocalLifecycleOwner.current

val context = LocalContext.current

LaunchedEffect(overwriteOriginalPath) {
if (overwriteOriginalPath) {
imagePath?.let {
Expand Down Expand Up @@ -130,7 +133,9 @@ fun SavePathDialog(
onValueChange = {
name = it
if (name.isEmpty()) {
onEmptyFileName()
context.toast(
R.string.ark_retouch_notify_missing_file_name
)
return@OutlinedTextField
}
currentPath?.let { path ->
Expand Down Expand Up @@ -181,11 +186,18 @@ fun SavePathDialog(
modifier = Modifier.padding(5.dp),
onClick = {
if (name.isEmpty()) {
onEmptyFileName()
context.toast(
R.string.ark_retouch_notify_missing_file_name
)
return@Button
}
if (currentPath == null) {
context.toast(
R.string.ark_retouch_notify_choose_folder
)
return@Button
}
if (currentPath != null)
onPositiveClick(currentPath!!.resolve(name))
onPositiveClick(currentPath?.resolve(name)!!)
}
) {
Text(text = stringResource(R.string.ok))
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<string name="height_empty">Please enter height</string>
<string name="blur_intensity">Intensity</string>
<string name="blur_size">Size</string>
<string name="ark_retouch_file_name_missing">Please provide file name</string>
<string name="ark_retouch_notify_choose_folder">Please pick folder to save image</string>
<string name="ark_retouch_notify_missing_file_name">Please provide file name</string>
</resources>

0 comments on commit 053cbf8

Please sign in to comment.