mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 22:55:46 +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
|
private var active = false
|
||||||
lateinit var binding: TrashbinActivityBinding
|
lateinit var binding: TrashbinActivityBinding
|
||||||
|
|
||||||
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
|
override fun handleOnBackPressed() {
|
||||||
|
trashbinPresenter?.navigateUp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -181,11 +187,7 @@ class TrashbinActivity :
|
||||||
private fun handleOnBackPressed() {
|
private fun handleOnBackPressed() {
|
||||||
onBackPressedDispatcher.addCallback(
|
onBackPressedDispatcher.addCallback(
|
||||||
this,
|
this,
|
||||||
object : OnBackPressedCallback(true) {
|
onBackPressedCallback
|
||||||
override fun handleOnBackPressed() {
|
|
||||||
trashbinPresenter?.navigateUp()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +209,7 @@ class TrashbinActivity :
|
||||||
if (itemId == android.R.id.home) {
|
if (itemId == android.R.id.home) {
|
||||||
if (isDrawerOpen) {
|
if (isDrawerOpen) {
|
||||||
closeDrawer()
|
closeDrawer()
|
||||||
} else if (trashbinPresenter?.isRoot == true) {
|
} else if (trashbinPresenter?.isRoot == false) {
|
||||||
trashbinPresenter?.navigateUp()
|
trashbinPresenter?.navigateUp()
|
||||||
} else {
|
} else {
|
||||||
openDrawer()
|
openDrawer()
|
||||||
|
@ -233,7 +235,6 @@ class TrashbinActivity :
|
||||||
override fun onItemClicked(file: TrashbinFile) {
|
override fun onItemClicked(file: TrashbinFile) {
|
||||||
if (file.isFolder) {
|
if (file.isFolder) {
|
||||||
trashbinPresenter?.enterFolder(file.remotePath)
|
trashbinPresenter?.enterFolder(file.remotePath)
|
||||||
mDrawerToggle.isDrawerIndicatorEnabled = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,8 +257,9 @@ class TrashbinActivity :
|
||||||
trashbinPresenter?.navigateUp()
|
trashbinPresenter?.navigateUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setDrawerIndicatorEnabled(bool: Boolean) {
|
override fun atRoot(isRoot: Boolean) {
|
||||||
mDrawerToggle.isDrawerIndicatorEnabled = bool
|
mDrawerToggle.isDrawerIndicatorEnabled = isRoot
|
||||||
|
onBackPressedCallback.isEnabled = !isRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSortingOrderChosen(sortOrder: FileSortOrder?) {
|
override fun onSortingOrderChosen(sortOrder: FileSortOrder?) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ interface TrashbinContract {
|
||||||
fun removeFile(file: TrashbinFile?)
|
fun removeFile(file: TrashbinFile?)
|
||||||
fun removeAllFiles()
|
fun removeAllFiles()
|
||||||
fun close()
|
fun close()
|
||||||
fun setDrawerIndicatorEnabled(bool: Boolean)
|
fun atRoot(isRoot: Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Presenter {
|
interface Presenter {
|
||||||
|
|
|
@ -43,10 +43,10 @@ class TrashbinPresenter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isRoot: Boolean
|
override val isRoot: Boolean
|
||||||
get() = OCFile.ROOT_PATH != currentPath
|
get() = OCFile.ROOT_PATH == currentPath
|
||||||
|
|
||||||
override fun navigateUp() {
|
override fun navigateUp() {
|
||||||
if (OCFile.ROOT_PATH == currentPath) {
|
if (isRoot) {
|
||||||
trashbinView.close()
|
trashbinView.close()
|
||||||
} else {
|
} else {
|
||||||
currentPath?.let {
|
currentPath?.let {
|
||||||
|
@ -54,8 +54,6 @@ class TrashbinPresenter(
|
||||||
loadFolder()
|
loadFolder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trashbinView.setDrawerIndicatorEnabled(OCFile.ROOT_PATH == currentPath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadFolder() {
|
override fun loadFolder() {
|
||||||
|
@ -71,6 +69,7 @@ class TrashbinPresenter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
trashbinView.atRoot(isRoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun restoreTrashbinFile(file: TrashbinFile?) {
|
override fun restoreTrashbinFile(file: TrashbinFile?) {
|
||||||
|
|
Loading…
Reference in a new issue