Skip to content

Commit

Permalink
Show snackbar above FAB
Browse files Browse the repository at this point in the history
Signed-off-by: Unpublished <[email protected]>
  • Loading branch information
Unpublished committed Apr 26, 2024
1 parent f2cb841 commit 7c9920a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/com/owncloud/android/utils/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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;
}
Expand Down

0 comments on commit 7c9920a

Please sign in to comment.