Skip to content

Commit

Permalink
feature: mini FABs only focusable when main FAB is expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
JuancaG05 committed Jul 31, 2024
1 parent d60ea29 commit bff1c95
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,16 @@ class MainFileListFragment : Fragment(),
} else if (!currentFolder.hasAddSubdirectoriesPermission) {
binding.fabMkdir.isVisible = false
}
registerFabMainListener()
registerFabUploadListener()
registerFabMkDirListener()
registerFabNewShortcutListener()
binding.apply {
fabUpload.isFocusable = false
fabMkdir.isFocusable = false
fabNewfile.isFocusable = false
fabNewshortcut.isFocusable = false
}
}
}

Expand All @@ -844,6 +851,18 @@ class MainFileListFragment : Fragment(),
binding.fabMkdir.isVisible = shouldBeShown
}

private fun registerFabMainListener() {
binding.apply {
fabMain.findViewById<View>(R.id.fab_expand_menu_button).setOnClickListener {
fabMain.toggle()
fabUpload.isFocusable = isFabExpanded()
fabMkdir.isFocusable = isFabExpanded()
fabNewfile.isFocusable = isFabExpanded()
fabNewshortcut.isFocusable = isFabExpanded()
}
}
}

/**
* Registers [android.view.View.OnClickListener] on the 'Upload' mini FAB for the linked action.
*/
Expand Down Expand Up @@ -887,7 +906,14 @@ class MainFileListFragment : Fragment(),
}

fun collapseFab() {
binding.fabMain.collapse()
binding.apply {
fabMain.collapse()
fabUpload.isFocusable = false
fabMkdir.isFocusable = false
fabNewfile.isFocusable = false
fabNewshortcut.isFocusable = false
}

}

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

0 comments on commit bff1c95

Please sign in to comment.