Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify missing saving folder #120

Merged
merged 3 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ private fun BoxScope.TopMenu(
onDismissClick = { viewModel.showSavePathDialog = false },
onPositiveClick = { savePath ->
viewModel.saveImage(savePath)
viewModel.showSavePathDialog = false
}
)
if (viewModel.showMoreOptionsPopup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class EditViewModel(
}
imageSaved = true
isSavingImage = false
showSavePathDialog = false
}

fun shareImage(context: Context) =
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 Down Expand Up @@ -166,6 +168,7 @@ fun SavePathDialog(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End
) {
val context = LocalContext.current
TextButton(
modifier = Modifier.padding(5.dp),
onClick = onDismissClick
Expand All @@ -175,8 +178,17 @@ fun SavePathDialog(
Button(
modifier = Modifier.padding(5.dp),
onClick = {
if (currentPath != null && name != null)
onPositiveClick(currentPath!!.resolve(name))
if (currentPath == null) {
with(context) {
toast(
getString(
R.string.ark_retouch_notify_choose_folder
)
)
}
return@Button
}
onPositiveClick(currentPath?.resolve(name)!!)
}
) {
Text(text = stringResource(R.string.ok))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.Settings
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.PointerEvent
Expand Down Expand Up @@ -98,3 +99,7 @@ fun PointerEvent.calculateRotationFromOneFingerGesture(
}
return angleDelta.toFloat()
}

fun Context.toast(string: String) {
Toast.makeText(this, string, Toast.LENGTH_SHORT).show()
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +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_notify_choose_folder">Please pick folder to save image</string>
<string name="ark_retouch_notify_missing_file_name">Please provide file name</string>
</resources>
Loading