mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
Merge pull request #12619 from nextcloud/TBBB
Fix back button in trash bin
This commit is contained in:
commit
74bb22bf22
3 changed files with 15 additions and 14 deletions
|
@ -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?) {
|
||||
|
|
|
@ -33,7 +33,7 @@ interface TrashbinContract {
|
|||
fun removeFile(file: TrashbinFile?)
|
||||
fun removeAllFiles()
|
||||
fun close()
|
||||
fun setDrawerIndicatorEnabled(bool: Boolean)
|
||||
fun atRoot(isRoot: Boolean)
|
||||
}
|
||||
|
||||
interface Presenter {
|
||||
|
|
|
@ -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?) {
|
||||
|
|
Loading…
Reference in a new issue