allow pressing OK on the renaming dialog after a failed attempt

This commit is contained in:
tibbi 2021-12-19 21:17:26 +01:00
parent 6204bcd684
commit 659d948542
3 changed files with 16 additions and 14 deletions

View file

@ -42,22 +42,22 @@ class RenameDialog(val activity: BaseSimpleActivity, val paths: ArrayList<String
}
dialog = AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel) { dialog, which -> dismissDialog() }
.create().apply {
activity.setupDialogStuff(view, this).apply {
window?.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
tabsAdapter.dialogConfirmed(useMediaFileExtension, viewPager.currentItem) {
dismissDialog()
if (it) {
activity.baseConfig.lastRenameUsed = viewPager.currentItem
callback()
}
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel) { dialog, which -> dismissDialog() }
.create().apply {
activity.setupDialogStuff(view, this).apply {
window?.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM)
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
tabsAdapter.dialogConfirmed(useMediaFileExtension, viewPager.currentItem) {
dismissDialog()
if (it) {
activity.baseConfig.lastRenameUsed = viewPager.currentItem
callback()
}
}
}
}
}
}
private fun dismissDialog() {

View file

@ -20,7 +20,7 @@ import kotlin.collections.ArrayList
class RenamePatternTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs), RenameTab {
var ignoreClicks = false
var stopLooping = false
var stopLooping = false // we should request the permission on Android 30+ for all uris at once, not one by one
var currentIncrementalNumber = 1
var numbersCnt = 0
var activity: BaseSimpleActivity? = null
@ -38,6 +38,7 @@ class RenamePatternTab(context: Context, attrs: AttributeSet) : RelativeLayout(c
}
override fun dialogConfirmed(useMediaFileExtension: Boolean, callback: (success: Boolean) -> Unit) {
stopLooping = false
if (ignoreClicks) {
return
}

View file

@ -14,7 +14,7 @@ import java.io.File
class RenameSimpleTab(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs), RenameTab {
var ignoreClicks = false
var stopLooping = false
var stopLooping = false // we should request the permission on Android 30+ for all uris at once, not one by one
var activity: BaseSimpleActivity? = null
var paths = ArrayList<String>()
@ -29,6 +29,7 @@ class RenameSimpleTab(context: Context, attrs: AttributeSet) : RelativeLayout(co
}
override fun dialogConfirmed(useMediaFileExtension: Boolean, callback: (success: Boolean) -> Unit) {
stopLooping = false
val valueToAdd = rename_simple_value.text.toString()
val append = rename_simple_radio_group.checkedRadioButtonId == rename_simple_radio_append.id