Skip to content

Commit

Permalink
OverwriteFiles setting introduced by #578
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Dec 31, 2023
1 parent 27f22a8 commit 1f7b409
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class FileControllerImpl @Inject constructor(
}

var filename = ""
var savePath = savingPath

kotlin.runCatching {
if (fileParams.copyToClipBoard) {
Expand Down Expand Up @@ -179,7 +180,9 @@ class FileControllerImpl @Inject constructor(
)
)
}.getOrNull()?.use { parcel ->
filename = DocumentFile.fromSingleUri(context, originalUri)?.name.toString()
filename = context.getFileName(originalUri).toString()
savePath = context.getString(R.string.original)

FileOutputStream(parcel.fileDescriptor).use { out ->
out.write(saveTarget.data)
copyMetadata(
Expand Down Expand Up @@ -247,7 +250,7 @@ class FileControllerImpl @Inject constructor(
if (result.isFailure) {
return SaveResult.Error.Exception(result.exceptionOrNull() ?: Throwable())
} else {
return SaveResult.Success(filename = filename, savingPath = savingPath)
return SaveResult.Success(filename = filename, savingPath = savePath)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import javax.inject.Inject
class ToggleOverwriteFilesUseCase @Inject constructor(
private val settingsRepository: SettingsRepository
) {
suspend operator fun invoke() = settingsRepository.toggleAddOriginalFilename()
suspend operator fun invoke() = settingsRepository.toggleOverwriteFiles()
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ fun CropMaskSelection(
value = cornerRadius,
title = stringResource(R.string.radius),
icon = null,
internalStateTransformation = {
it.roundToInt()
},
onValueChange = {
cornerRadius = it.roundToInt()
if (selectedItem.cropOutline is CutCornerCropShape) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun OverwriteFilesSettingItem(
enabled = !settingsState.randomizeFilename,
title = stringResource(R.string.overwrite_files),
subtitle = stringResource(R.string.overwrite_files_sub),
checked = settingsState.addSequenceNumber,
checked = settingsState.overwriteFiles,
resultModifier = Modifier.padding(
horizontal = 16.dp,
vertical = 8.dp
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@
<string name="auto_pin_sub">Automatically adds saved image to clipboard if enabled</string>
<string name="vibration">Vibration</string>
<string name="vibration_strength">Vibration Strength</string>
<string name="overwrite_file_requirements">In order to overwrite files you need to use \"Explorer\" image source, try repick images, we've changed image source to the needed one</string>
<string name="overwrite_file_requirements">In order to overwrite files you need to use \"Explorer\" image source, try repick images, we\'ve changed image source to the needed one</string>
<string name="overwrite_files">Overwrite Files</string>
<string name="overwrite_files_sub">Original file will be replaced with new one instead of saving in selected folder, this option need to image source be \"Explorer\" or GetContent, when toggling this, it will be set automatically</string>
</resources>

0 comments on commit 1f7b409

Please sign in to comment.