skip the save/discard prompt at Customization activity if user spams Back

This commit is contained in:
tibbi 2019-09-02 21:46:31 +02:00
parent d7210a7780
commit e0ed4b981e
2 changed files with 5 additions and 2 deletions

View File

@ -51,5 +51,5 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.16.18'
implementation 'com.simplemobiletools:commons:5.17.0'
}

View File

@ -19,6 +19,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.SAVE_DISCARD_PROMPT_INTERVAL
import com.simplemobiletools.commons.models.FAQItem
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.commons.models.Release
@ -53,6 +54,7 @@ class MainActivity : SimpleActivity(), CanvasListener {
private var color = 0
private var brushSize = 0f
private var savedPathsHash = 0L
private var lastSavePromptTS = 0L
private var isEraserOn = false
private var isImageCaptureIntent = false
private var isEditIntent = false
@ -144,7 +146,8 @@ class MainActivity : SimpleActivity(), CanvasListener {
override fun onBackPressed() {
val hasUnsavedChanges = savedPathsHash != my_canvas.getDrawingHashCode()
if (hasUnsavedChanges) {
if (hasUnsavedChanges && System.currentTimeMillis() - lastSavePromptTS > SAVE_DISCARD_PROMPT_INTERVAL) {
lastSavePromptTS = System.currentTimeMillis()
ConfirmationAdvancedDialog(this, "", R.string.save_before_closing, R.string.save, R.string.discard) {
if (it) {
trySaveImage()