persist Skip Delete Confirmation in the whole app launch session

This commit is contained in:
tibbi 2018-05-25 20:04:07 +02:00
parent 1bc335b29d
commit 2c2334dea3
6 changed files with 11 additions and 6 deletions

View file

@ -188,6 +188,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
override fun onDestroy() {
super.onDestroy()
config.temporarilyShowHidden = false
config.tempSkipDeleteConfirmation = false
mTempShowHiddenHandler.removeCallbacksAndMessages(null)
removeTempFolder()
if (!isChangingConfigurations) {

View file

@ -175,6 +175,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
super.onDestroy()
if (config.showAll) {
config.temporarilyShowHidden = false
config.tempSkipDeleteConfirmation = false
}
mTempShowHiddenHandler.removeCallbacksAndMessages(null)

View file

@ -58,7 +58,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private var mPos = -1
private var mShowAll = false
private var mIsSlideshowActive = false
private var mSkipConfirmationDialog = false
private var mRotationDegrees = 0
private var mPrevHashcode = 0
@ -728,7 +727,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
private fun checkDeleteConfirmation() {
if (mSkipConfirmationDialog || config.skipDeleteConfirmation) {
if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
deleteConfirmed()
} else {
askConfirmDelete()
@ -737,7 +736,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun askConfirmDelete() {
DeleteWithRememberDialog(this, getString(R.string.proceed_with_deletion)) {
mSkipConfirmationDialog = it
config.tempSkipDeleteConfirmation = it
deleteConfirmed()
}
}

View file

@ -31,7 +31,6 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
private val config = activity.config
private val isListViewType = config.viewTypeFiles == VIEW_TYPE_LIST
private var skipConfirmationDialog = false
private var visibleItemPaths = ArrayList<String>()
private var loadImageInstantly = false
private var delayHandler = Handler(Looper.getMainLooper())
@ -202,7 +201,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
}
private fun checkDeleteConfirmation() {
if (skipConfirmationDialog || config.skipDeleteConfirmation) {
if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
deleteFiles()
} else {
askConfirmDelete()
@ -213,7 +212,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
val items = resources.getQuantityString(R.plurals.delete_items, selectedPositions.size, selectedPositions.size)
val question = String.format(resources.getString(R.string.deletion_confirmation), items)
DeleteWithRememberDialog(activity, question) {
skipConfirmationDialog = it
config.tempSkipDeleteConfirmation = it
deleteFiles()
}
}

View file

@ -318,4 +318,8 @@ class Config(context: Context) : BaseConfig(context) {
var wasOTGHandled: Boolean
get() = prefs.getBoolean(WAS_OTG_HANDLED, false)
set(wasOTGHandled) = prefs.edit().putBoolean(WAS_OTG_HANDLED, wasOTGHandled).apply()
var tempSkipDeleteConfirmation: Boolean
get() = prefs.getBoolean(TEMP_SKIP_DELETE_CONFIRMATION, false)
set(tempSkipDeleteConfirmation) = prefs.edit().putBoolean(TEMP_SKIP_DELETE_CONFIRMATION, tempSkipDeleteConfirmation).apply()
}

View file

@ -48,6 +48,7 @@ const val DO_EXTRA_CHECK = "do_extra_check"
const val WAS_NEW_APP_SHOWN = "was_new_app_shown_clock"
const val LAST_FILEPICKER_PATH = "last_filepicker_path"
const val WAS_OTG_HANDLED = "was_otg_handled"
const val TEMP_SKIP_DELETE_CONFIRMATION = "temp_skip_delete_confirmation"
// slideshow
const val SLIDESHOW_INTERVAL = "slideshow_interval"