From 692b02cac8eba3898b7614a91c7bf5caa2cecda6 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 25 Nov 2024 12:36:23 +0100 Subject: [PATCH] Apply insets to full screen message view --- .../email/FragmentDialogOpenFull.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogOpenFull.java b/app/src/main/java/eu/faircode/email/FragmentDialogOpenFull.java index a2a4f8fa5a..d7cea9f624 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogOpenFull.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogOpenFull.java @@ -31,6 +31,9 @@ import android.webkit.WebSettings; import android.webkit.WebView; import androidx.annotation.Nullable; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.fragment.app.DialogFragment; import androidx.webkit.WebSettingsCompat; import androidx.webkit.WebViewFeature; @@ -63,6 +66,38 @@ public class FragmentDialogOpenFull extends FragmentDialogBase { final Context context = getContext(); View view = inflater.inflate(R.layout.fragment_open_full, container, false); + + ViewCompat.setOnApplyWindowInsetsListener(view, (v, windowInsets) -> { + try { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + + boolean changed = false; + ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); + if (mlp.leftMargin != insets.left) { + changed = true; + mlp.leftMargin = insets.left; + } + if (mlp.topMargin != insets.top) { + changed = true; + mlp.topMargin = insets.top; + } + if (mlp.rightMargin != insets.right) { + changed = true; + mlp.rightMargin = insets.right; + } + if (mlp.bottomMargin != insets.bottom) { + changed = true; + mlp.bottomMargin = insets.bottom; + } + if (changed) + v.setLayoutParams(mlp); + } catch (Throwable ex) { + Log.e(ex); + } + + return WindowInsetsCompat.CONSUMED; + }); + WebView wv = view.findViewById(R.id.wv); WebSettings settings = wv.getSettings();