mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-01-23 21:53:39 +01:00
skip the save/discard prompt at Customization activity if user spams Back
This commit is contained in:
parent
d7210a7780
commit
e0ed4b981e
@ -51,5 +51,5 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.16.18'
|
implementation 'com.simplemobiletools:commons:5.17.0'
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
|
|||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
|
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
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.FAQItem
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
@ -53,6 +54,7 @@ class MainActivity : SimpleActivity(), CanvasListener {
|
|||||||
private var color = 0
|
private var color = 0
|
||||||
private var brushSize = 0f
|
private var brushSize = 0f
|
||||||
private var savedPathsHash = 0L
|
private var savedPathsHash = 0L
|
||||||
|
private var lastSavePromptTS = 0L
|
||||||
private var isEraserOn = false
|
private var isEraserOn = false
|
||||||
private var isImageCaptureIntent = false
|
private var isImageCaptureIntent = false
|
||||||
private var isEditIntent = false
|
private var isEditIntent = false
|
||||||
@ -144,7 +146,8 @@ class MainActivity : SimpleActivity(), CanvasListener {
|
|||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val hasUnsavedChanges = savedPathsHash != my_canvas.getDrawingHashCode()
|
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) {
|
ConfirmationAdvancedDialog(this, "", R.string.save_before_closing, R.string.save, R.string.discard) {
|
||||||
if (it) {
|
if (it) {
|
||||||
trySaveImage()
|
trySaveImage()
|
||||||
|
Loading…
Reference in New Issue
Block a user