Prevent popup menu from covering bottom items in the media overview screen.

This commit is contained in:
Greyson Parrelli 2022-07-28 17:15:50 -04:00
parent f50bf3e9c2
commit 26bb52fd60
2 changed files with 24 additions and 0 deletions

View file

@ -40,6 +40,7 @@ import org.thoughtcrime.securesms.database.loaders.GroupedThreadMediaLoader;
import org.thoughtcrime.securesms.database.loaders.MediaLoader;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.mms.PartAuthority;
import org.thoughtcrime.securesms.util.BottomOffsetDecoration;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
@ -130,6 +131,7 @@ public final class MediaOverviewPageFragment extends Fragment
this.recyclerView.setLayoutManager(gridManager);
this.recyclerView.setHasFixedSize(true);
this.recyclerView.addItemDecoration(new MediaGridDividerDecoration(spans, ViewUtil.dpToPx(4), adapter));
this.recyclerView.addItemDecoration(new BottomOffsetDecoration(ViewUtil.dpToPx(160)));
MediaOverviewViewModel viewModel = MediaOverviewViewModel.getMediaOverviewViewModel(requireActivity());

View file

@ -0,0 +1,22 @@
package org.thoughtcrime.securesms.util
import android.graphics.Rect
import android.view.View
import androidx.annotation.Px
import androidx.recyclerview.widget.RecyclerView
/**
* Adds some empty space to the bottom of a recyclerview. Useful if you need some "dead space" at the bottom of the list to account for floating menus that may
* otherwise cover up the bottom entries of the list.
*/
class BottomOffsetDecoration(@Px private val bottomOffset: Int) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
super.getItemOffsets(outRect, view, parent, state)
if (parent.getChildAdapterPosition(view) == state.itemCount - 1) {
outRect.set(0, 0, 0, bottomOffset)
} else {
outRect.set(0, 0, 0, 0)
}
}
}