Fix forward sheet weirdness in full screen activities.
This commit is contained in:
parent
aae888f5af
commit
3c0c5478b5
4 changed files with 47 additions and 6 deletions
|
@ -45,6 +45,7 @@ import org.thoughtcrime.securesms.stories.settings.create.CreateStoryWithViewers
|
|||
import org.thoughtcrime.securesms.stories.settings.hide.HideStoryFromDialogFragment
|
||||
import org.thoughtcrime.securesms.util.BottomSheetUtil
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.FullscreenHelper
|
||||
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.thoughtcrime.securesms.util.fragments.findListener
|
||||
|
@ -125,14 +126,19 @@ class MultiselectForwardFragment :
|
|||
|
||||
val container = callback.getContainer()
|
||||
val title: TextView? = container.findViewById(R.id.title)
|
||||
val bottomBar = LayoutInflater.from(requireContext()).inflate(R.layout.multiselect_forward_fragment_bottom_bar, container, false)
|
||||
val bottomBarAndSpacer = LayoutInflater.from(requireContext()).inflate(R.layout.multiselect_forward_fragment_bottom_bar_and_spacer, container, false)
|
||||
val bottomBar: ViewGroup = bottomBarAndSpacer.findViewById(R.id.bottom_bar)
|
||||
val bottomBarSpacer: View = bottomBarAndSpacer.findViewById(R.id.bottom_bar_spacer)
|
||||
val shareSelectionRecycler: RecyclerView = bottomBar.findViewById(R.id.selected_list)
|
||||
val shareSelectionAdapter = ShareSelectionAdapter()
|
||||
val sendButtonFrame: View = bottomBar.findViewById(R.id.share_confirm_frame)
|
||||
val sendButton: View = bottomBar.findViewById(R.id.share_confirm)
|
||||
val backgroundHelper: View = bottomBar.findViewById(R.id.background_helper)
|
||||
|
||||
FullscreenHelper.configureBottomBarLayout(requireActivity(), bottomBarSpacer, bottomBar)
|
||||
|
||||
backgroundHelper.setBackgroundColor(callback.getDialogBackgroundColor())
|
||||
bottomBarSpacer.setBackgroundColor(callback.getDialogBackgroundColor())
|
||||
|
||||
title?.setText(requireArguments().getInt(ARG_TITLE))
|
||||
|
||||
|
@ -171,7 +177,7 @@ class MultiselectForwardFragment :
|
|||
|
||||
bottomBar.visible = false
|
||||
|
||||
container.addView(bottomBar)
|
||||
container.addView(bottomBarAndSpacer)
|
||||
|
||||
contactSearchMediator.getSelectionState().observe(viewLifecycleOwner) { contactSelection ->
|
||||
shareSelectionAdapter.submitList(contactSelection.mapIndexed { index, key -> ShareSelectionMappingModel(key.requireShareContact(), index == 0) })
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class FullscreenHelper {
|
|||
public void configureToolbarLayout(@NonNull View spacer, @NonNull View toolbar) {
|
||||
if (Build.VERSION.SDK_INT == 19) {
|
||||
setSpacerHeight(spacer, ViewUtil.getStatusBarHeight(spacer));
|
||||
int[] padding = makePaddingValuesForAPI19();
|
||||
int[] padding = makePaddingValuesForAPI19(activity);
|
||||
toolbar.setPadding(padding[0], 0, padding[1], 0);
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +56,27 @@ public final class FullscreenHelper {
|
|||
});
|
||||
}
|
||||
|
||||
private void setSpacerHeight(@NonNull View spacer, int height) {
|
||||
public static void configureBottomBarLayout(@NonNull Activity activity, @NonNull View spacer, @NonNull View bottomBar) {
|
||||
if (Build.VERSION.SDK_INT == 19) {
|
||||
setSpacerHeight(spacer, ViewUtil.getNavigationBarHeight(spacer));
|
||||
int[] padding = makePaddingValuesForAPI19(activity);
|
||||
bottomBar.setPadding(padding[0], 0, padding[1], 0);
|
||||
return;
|
||||
}
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(spacer, (view, insets) -> {
|
||||
setSpacerHeight(view, insets.getSystemWindowInsetBottom());
|
||||
return insets;
|
||||
});
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(bottomBar, (view, insets) -> {
|
||||
int[] padding = makePaddingValues(insets);
|
||||
bottomBar.setPadding(padding[0], 0, padding[1], 0);
|
||||
return insets;
|
||||
});
|
||||
}
|
||||
|
||||
private static void setSpacerHeight(@NonNull View spacer, int height) {
|
||||
ViewGroup.LayoutParams params = spacer.getLayoutParams();
|
||||
|
||||
params.height = height;
|
||||
|
@ -66,7 +86,7 @@ public final class FullscreenHelper {
|
|||
}
|
||||
|
||||
@SuppressLint("SwitchIntDef")
|
||||
private int[] makePaddingValuesForAPI19() {
|
||||
private static int[] makePaddingValuesForAPI19(@NonNull Activity activity) {
|
||||
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
|
||||
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
|
||||
return new int[]{0, 0};
|
||||
|
@ -88,7 +108,7 @@ public final class FullscreenHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private int[] makePaddingValues(WindowInsetsCompat insets) {
|
||||
private static int[] makePaddingValues(WindowInsetsCompat insets) {
|
||||
Insets tappable = insets.getTappableElementInsets();
|
||||
DisplayCutoutCompat cutout = insets.getDisplayCutout();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/bottom_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom">
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<include layout="@layout/multiselect_forward_fragment_bottom_bar" />
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_bar_spacer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp" />
|
||||
</LinearLayout>
|
Loading…
Add table
Reference in a new issue