Merge pull request #12619 from nextcloud/TBBB

Fix back button in trash bin
This commit is contained in:
Andy Scherzinger 2024-03-20 07:43:14 +01:00 committed by GitHub
commit 74bb22bf22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 14 deletions

View file

@ -86,6 +86,12 @@ class TrashbinActivity :
private var active = false
lateinit var binding: TrashbinActivityBinding
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
trashbinPresenter?.navigateUp()
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -181,11 +187,7 @@ class TrashbinActivity :
private fun handleOnBackPressed() {
onBackPressedDispatcher.addCallback(
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
trashbinPresenter?.navigateUp()
}
}
onBackPressedCallback
)
}
@ -207,7 +209,7 @@ class TrashbinActivity :
if (itemId == android.R.id.home) {
if (isDrawerOpen) {
closeDrawer()
} else if (trashbinPresenter?.isRoot == true) {
} else if (trashbinPresenter?.isRoot == false) {
trashbinPresenter?.navigateUp()
} else {
openDrawer()
@ -233,7 +235,6 @@ class TrashbinActivity :
override fun onItemClicked(file: TrashbinFile) {
if (file.isFolder) {
trashbinPresenter?.enterFolder(file.remotePath)
mDrawerToggle.isDrawerIndicatorEnabled = false
}
}
@ -256,8 +257,9 @@ class TrashbinActivity :
trashbinPresenter?.navigateUp()
}
override fun setDrawerIndicatorEnabled(bool: Boolean) {
mDrawerToggle.isDrawerIndicatorEnabled = bool
override fun atRoot(isRoot: Boolean) {
mDrawerToggle.isDrawerIndicatorEnabled = isRoot
onBackPressedCallback.isEnabled = !isRoot
}
override fun onSortingOrderChosen(sortOrder: FileSortOrder?) {

View file

@ -33,7 +33,7 @@ interface TrashbinContract {
fun removeFile(file: TrashbinFile?)
fun removeAllFiles()
fun close()
fun setDrawerIndicatorEnabled(bool: Boolean)
fun atRoot(isRoot: Boolean)
}
interface Presenter {

View file

@ -43,10 +43,10 @@ class TrashbinPresenter(
}
override val isRoot: Boolean
get() = OCFile.ROOT_PATH != currentPath
get() = OCFile.ROOT_PATH == currentPath
override fun navigateUp() {
if (OCFile.ROOT_PATH == currentPath) {
if (isRoot) {
trashbinView.close()
} else {
currentPath?.let {
@ -54,8 +54,6 @@ class TrashbinPresenter(
loadFolder()
}
}
trashbinView.setDrawerIndicatorEnabled(OCFile.ROOT_PATH == currentPath)
}
override fun loadFolder() {
@ -71,6 +69,7 @@ class TrashbinPresenter(
}
}
)
trashbinView.atRoot(isRoot)
}
override fun restoreTrashbinFile(file: TrashbinFile?) {