From 7c9920a761f86d04af1c61a423976125420a9bb8 Mon Sep 17 00:00:00 2001 From: Unpublished Date: Sun, 14 Apr 2024 15:37:12 +0200 Subject: [PATCH] Show snackbar above FAB Signed-off-by: Unpublished --- .../com/owncloud/android/utils/DisplayUtils.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java index 3b49cdc5014c..150d0e39d26b 100644 --- a/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -650,10 +650,22 @@ public static Snackbar showSnackMessage(Activity activity, @StringRes int messag */ public static Snackbar showSnackMessage(Activity activity, String message) { final Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), message, Snackbar.LENGTH_LONG); + var fab = findFABView(activity); + if (fab != null && fab.getVisibility() == View.VISIBLE) { + snackbar.setAnchorView(fab); + } snackbar.show(); return snackbar; } + private static View findFABView(Activity activity) { + return activity.findViewById(R.id.fab_main); + } + + private static View findFABView(View view) { + return view.findViewById(R.id.fab_main); + } + /** * Show a temporary message in a {@link Snackbar} bound to the given view. * @@ -663,6 +675,10 @@ public static Snackbar showSnackMessage(Activity activity, String message) { */ public static Snackbar showSnackMessage(View view, @StringRes int messageResource) { final Snackbar snackbar = Snackbar.make(view, messageResource, Snackbar.LENGTH_LONG); + var fab = findFABView(view.getRootView()); + if (fab != null && fab.getVisibility() == View.VISIBLE) { + snackbar.setAnchorView(fab); + } snackbar.show(); return snackbar; }