Skip to content

Commit

Permalink
Fix: Fix bottom padding for storage and bookmark directory list
Browse files Browse the repository at this point in the history
Fixes: #1200
  • Loading branch information
zhanghai committed Apr 16, 2024
1 parent f0a451b commit d03d233
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import me.zhanghai.android.files.navigation.BookmarkDirectories
import me.zhanghai.android.files.navigation.BookmarkDirectory
import me.zhanghai.android.files.navigation.EditBookmarkDirectoryDialogActivity
import me.zhanghai.android.files.navigation.EditBookmarkDirectoryDialogFragment
import me.zhanghai.android.files.ui.ScrollingViewOnApplyWindowInsetsListener
import me.zhanghai.android.files.util.createIntent
import me.zhanghai.android.files.util.fadeToVisibilityUnsafe
import me.zhanghai.android.files.util.getDrawable
Expand Down Expand Up @@ -71,6 +72,9 @@ class BookmarkDirectoryListFragment : Fragment(), BookmarkDirectoryListAdapter.L
binding.recyclerView.adapter = wrappedAdapter
binding.recyclerView.itemAnimator = DraggableItemAnimator()
dragDropManager.attachRecyclerView(binding.recyclerView)
binding.recyclerView.setOnApplyWindowInsetsListener(
ScrollingViewOnApplyWindowInsetsListener(binding.recyclerView)
)
binding.fab.setOnClickListener { onAddBookmarkDirectory() }

Settings.BOOKMARK_DIRECTORIES.observe(viewLifecycleOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropM
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
import me.zhanghai.android.files.databinding.StorageListFragmentBinding
import me.zhanghai.android.files.settings.Settings
import me.zhanghai.android.files.ui.ScrollingViewOnApplyWindowInsetsListener
import me.zhanghai.android.files.util.createIntent
import me.zhanghai.android.files.util.fadeToVisibilityUnsafe
import me.zhanghai.android.files.util.getDrawable
Expand Down Expand Up @@ -61,6 +62,9 @@ class StorageListFragment : Fragment(), StorageListAdapter.Listener {
binding.recyclerView.adapter = wrappedAdapter
binding.recyclerView.itemAnimator = DraggableItemAnimator()
dragDropManager.attachRecyclerView(binding.recyclerView)
binding.recyclerView.setOnApplyWindowInsetsListener(
ScrollingViewOnApplyWindowInsetsListener(binding.recyclerView)
)
binding.fab.setOnClickListener { onAddStorage() }

Settings.STORAGES.observe(viewLifecycleOwner) { onStorageListChanged(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import me.zhanghai.android.fastscroll.FastScroller

class ScrollingViewOnApplyWindowInsetsListener(
view: View,
private val fastScroller: FastScroller
private val fastScroller: FastScroller? = null
) : View.OnApplyWindowInsetsListener {
private val initialPadding =
Rect(view.paddingLeft, view.paddingTop, view.paddingRight, view.paddingBottom)

init {
fastScroller.setPadding(0, 0, 0, 0)
fastScroller?.setPadding(0, 0, 0, 0)
}

override fun onApplyWindowInsets(view: View, insets: WindowInsets): WindowInsets {
view.setPadding(
initialPadding.left, initialPadding.top, initialPadding.right,
initialPadding.bottom + insets.systemWindowInsetBottom
)
fastScroller.setPadding(0, 0, 0, insets.systemWindowInsetBottom)
fastScroller?.setPadding(0, 0, 0, insets.systemWindowInsetBottom)
return insets
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/layout/bookmark_directory_list_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/list_bottom_padding_with_fab"
android:clipToPadding="false"
android:fitsSystemWindows="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />

<!-- Additional layout to receive window insets as margin. -->
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/storage_list_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/list_bottom_padding_with_fab"
android:clipToPadding="false"
android:fitsSystemWindows="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />

<!-- Additional layout to receive window insets as margin. -->
Expand Down

0 comments on commit d03d233

Please sign in to comment.