request an overwrite confirmation when replacing the original image with edited

This commit is contained in:
tibbi 2017-05-29 20:06:56 +02:00
parent 630e4e11b8
commit ee44432665
2 changed files with 12 additions and 3 deletions

View file

@ -32,7 +32,7 @@ android {
} }
dependencies { dependencies {
compile 'com.simplemobiletools:commons:2.18.8' compile 'com.simplemobiletools:commons:2.18.9'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0' compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0' compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'

View file

@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.dialogs
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.WindowManager import android.view.WindowManager
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
@ -62,8 +63,16 @@ class SaveAsDialog(val activity: SimpleActivity, val path: String, val callback:
return@setOnClickListener return@setOnClickListener
} }
if (newFile.exists()) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
ConfirmationDialog(activity, title) {
callback.invoke(newFile.absolutePath) callback.invoke(newFile.absolutePath)
dismiss() dismiss()
}
} else {
callback.invoke(newFile.absolutePath)
dismiss()
}
}) })
} }
} }