Skip to content
Draft
Show file tree
Hide file tree
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 @@ -1008,6 +1008,7 @@ class MainFileListFragment : Fragment(),
(newFileListOption.isSharedByLink() && currentFolder.remotePath != ROOT_PATH)
if (!isFabSupportedView || isPickingAFolder() ||
(!currentFolder.hasAddFilePermission && !currentFolder.hasAddSubdirectoriesPermission)) {
collapseFab()
toggleFabVisibility(false)
} else {
toggleFabVisibility(true)
Expand Down Expand Up @@ -1128,10 +1129,9 @@ class MainFileListFragment : Fragment(),
fabNewfile.isFocusable = false
fabNewshortcut.isFocusable = false
}

}

fun isFabExpanded() = binding.fabMain.isExpanded
fun isFabExpanded() = binding.fabMain.isVisible && binding.fabMain.isExpanded

fun setFabMainContentDescription() {
binding.fabMain.findViewById<AddFloatingActionButton>(com.getbase.floatingactionbutton.R.id.fab_expand_menu_button).contentDescription =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
Expand Down Expand Up @@ -202,6 +203,17 @@ class FileDisplayActivity : FileActivity(),
private var isLightUser = false
private var isMultiPersonal = false

private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
onBackPressed()
}
}

fun addOnBackPressedCallback() {
onBackPressedCallback.remove()
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

override fun onCreate(savedInstanceState: Bundle?) {
Timber.v("onCreate() start")

Expand Down Expand Up @@ -307,6 +319,8 @@ class FileDisplayActivity : FileActivity(),
}
}

addOnBackPressedCallback()

Timber.v("onCreate() end")
}

Expand Down Expand Up @@ -536,6 +550,7 @@ class FileDisplayActivity : FileActivity(),
transaction.replace(R.id.right_fragment_container, fragment, TAG_SECOND_FRAGMENT)
transaction.commitNow()
updateFragmentsVisibility(true)
mainFileListFragment?.collapseFab()
}

private fun showBottomNavBar(show: Boolean) {
Expand Down Expand Up @@ -747,6 +762,8 @@ class FileDisplayActivity : FileActivity(),
fileOperationsViewModel.performOperation(copyOperation)
}


// This is no longer directly called in newer Android versions, see also onBackPressedCallback.
override fun onBackPressed() {
val isFabOpen = mainFileListFragment?.isFabExpanded() ?: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.activity.OnBackPressedCallback
import androidx.annotation.StringRes
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
Expand Down Expand Up @@ -56,7 +57,16 @@ open class FolderPickerActivity : FileActivity(),

private lateinit var binding: FilesFolderPickerBinding

private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
onBackPressed()
}
}

fun addOnBackPressedCallback() {
onBackPressedCallback.remove()
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

override fun onCreate(savedInstanceState: Bundle?) {
Timber.d("onCreate() start")
Expand Down Expand Up @@ -134,6 +144,8 @@ open class FolderPickerActivity : FileActivity(),
initAndShowListOfFilesFragment()
}

addOnBackPressedCallback()

Timber.d("onCreate() end")
}

Expand Down Expand Up @@ -182,6 +194,7 @@ open class FolderPickerActivity : FileActivity(),
return super.onOptionsItemSelected(item)
}

// This is no longer directly called in newer Android versions, see also onBackPressedCallback.
override fun onBackPressed() {
val currentDirDisplayed = mainFileListFragment?.getCurrentFile()
// If current file is null (we are in the spaces list, for example), close the activity
Expand Down
Loading