Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import android.view.WindowManager
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
Expand Down Expand Up @@ -73,6 +74,7 @@ import eu.opencloud.android.domain.exceptions.TooEarlyException
import eu.opencloud.android.domain.files.model.FileListOption
import eu.opencloud.android.domain.files.model.FileMenuOption
import eu.opencloud.android.domain.files.model.OCFile
import eu.opencloud.android.domain.files.model.OCFile.Companion.ROOT_PARENT_ID
import eu.opencloud.android.domain.files.model.OCFile.Companion.ROOT_PATH
import eu.opencloud.android.domain.files.model.OCFileSyncInfo
import eu.opencloud.android.domain.files.model.OCFileWithSyncInfo
Expand Down Expand Up @@ -182,6 +184,17 @@ class MainFileListFragment : Fragment(),

private var isMultiPersonal = false

private val onBackPressedCallback = object : OnBackPressedCallback(false) {
override fun handleOnBackPressed() {
if (isFabExpanded()) {
collapseFab()
setFabMainContentDescription()
} else {
onBrowseUp()
}
}
}
Comment thread
wernrab marked this conversation as resolved.

private var menu: Menu? = null
private var checkedFiles: List<OCFile> = emptyList()
private var filesToRemove: List<OCFile> = emptyList()
Expand Down Expand Up @@ -328,6 +341,8 @@ class MainFileListFragment : Fragment(),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
isMultiPersonal = capabilityViewModel.checkMultiPersonal()
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, onBackPressedCallback)
updateBackPressedCallbackState()
initViews()
subscribeToViewModels()
}
Expand Down Expand Up @@ -497,8 +512,15 @@ class MainFileListFragment : Fragment(),

}

private fun updateBackPressedCallbackState() {
val parentId = mainFileListViewModel.currentFolderDisplayed.value.parentId
val isInSubfolder = parentId != null && parentId != ROOT_PARENT_ID
onBackPressedCallback.isEnabled = isFabExpanded() || isInSubfolder
}
Comment on lines +515 to +519

private fun observeCurrentFolderDisplayed() {
collectLatestLifecycleFlow(mainFileListViewModel.currentFolderDisplayed) { currentFolderDisplayed: OCFile ->
updateBackPressedCallbackState()
fileActions?.onCurrentFolderUpdated(currentFolderDisplayed, mainFileListViewModel.getSpace())
val fileListOption = mainFileListViewModel.fileListOption.value
val refreshFolderNeeded = fileListOption.isAllFiles() ||
Expand Down Expand Up @@ -1057,6 +1079,7 @@ class MainFileListFragment : Fragment(),
fabMkdir.isFocusable = isFabExpanded()
fabNewfile.isFocusable = isFabExpanded()
fabNewshortcut.isFocusable = isFabExpanded()
updateBackPressedCallbackState()
if (fabMain.isExpanded) {
binding.fabMain.findViewById<AddFloatingActionButton>(com.getbase.floatingactionbutton.R.id.fab_expand_menu_button)
.contentDescription = getString(R.string.content_description_add_new_content_expanded)
Expand Down Expand Up @@ -1128,7 +1151,7 @@ class MainFileListFragment : Fragment(),
fabNewfile.isFocusable = false
fabNewshortcut.isFocusable = false
}

updateBackPressedCallbackState()
}

fun isFabExpanded() = binding.fabMain.isExpanded
Expand Down
Loading