From 30da5ecb3a8b550ddd438af1a3a422eb5efe9dad Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 28 Oct 2024 09:34:21 +0100 Subject: [PATCH] Apply insets for snackbar --- .../java/eu/faircode/email/ActivityBase.java | 19 +++++++++++++++++++ .../java/eu/faircode/email/ActivityView.java | 2 -- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index e0e2e1f965..c9268d17b8 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -152,6 +152,25 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc holder.removeView(placeholder); holder.addView(view, placeholder.getLayoutParams()); + if (edge_to_edge) + holder.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { + private boolean has = false; + + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { + try { + Snackbar.SnackbarLayout sl = Helper.findSnackbarLayout(v.getRootView()); + boolean h = (sl != null); + if (has != h) { + has = h; + v.requestApplyInsets(); + } + } catch (Throwable ex) { + Log.e(ex); + } + } + }); + int abh = Helper.getActionBarHeight(this); appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 28709b1814..9fc7edd394 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -1577,7 +1577,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB ViewGroup.MarginLayoutParams lparam = (ViewGroup.MarginLayoutParams) content.getLayoutParams(); lparam.bottomMargin = snackbar.getView().getHeight(); content.setLayoutParams(lparam); - content.requestApplyInsets(); } @Override @@ -1585,7 +1584,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB ViewGroup.MarginLayoutParams lparam = (ViewGroup.MarginLayoutParams) content.getLayoutParams(); lparam.bottomMargin = 0; content.setLayoutParams(lparam); - content.requestApplyInsets(); } });