From a4812c530d1d3a915a074b8f376143d20188dbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Sch=C3=A4ttgen?= Date: Wed, 22 Jan 2025 18:33:54 +0100 Subject: [PATCH] Fix obstructing snackbar padding --- .../aegis/ui/ImportEntriesActivity.java | 36 ++++++++++++++++--- .../res/layout/activity_import_entries.xml | 1 - 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/beemdevelopment/aegis/ui/ImportEntriesActivity.java b/app/src/main/java/com/beemdevelopment/aegis/ui/ImportEntriesActivity.java index 9a5cec4083..da04bc3ca6 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/ui/ImportEntriesActivity.java +++ b/app/src/main/java/com/beemdevelopment/aegis/ui/ImportEntriesActivity.java @@ -52,6 +52,7 @@ public class ImportEntriesActivity extends AegisActivity { private View _view; private Menu _menu; + private RecyclerView _entriesView; private ImportEntriesAdapter _adapter; private FabScrollHelper _fabScrollHelper; @@ -74,8 +75,8 @@ protected void onCreate(Bundle savedInstanceState) { bar.setDisplayHomeAsUpEnabled(true); _adapter = new ImportEntriesAdapter(); - RecyclerView entriesView = findViewById(R.id.list_entries); - entriesView.addOnScrollListener(new RecyclerView.OnScrollListener() { + _entriesView = findViewById(R.id.list_entries); + _entriesView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); @@ -84,9 +85,9 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { }); LinearLayoutManager layoutManager = new LinearLayoutManager(this); - entriesView.setLayoutManager(layoutManager); - entriesView.setAdapter(_adapter); - entriesView.setNestedScrollingEnabled(false); + _entriesView.setLayoutManager(layoutManager); + _entriesView.setAdapter(_adapter); + _entriesView.setNestedScrollingEnabled(false); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(v -> { @@ -358,6 +359,31 @@ private void findDuplicates(List importEntries) { _adapter.setCheckboxStates(duplicateEntries, false); Snackbar snackbar = Snackbar.make(_view, getResources().getQuantityString(R.plurals.import_duplicate_toast, duplicateEntries.size(), duplicateEntries.size()), Snackbar.LENGTH_INDEFINITE); + snackbar.addCallback(new Snackbar.Callback() { + @Override + public void onShown(Snackbar sb) { + int snackbarHeight = sb.getView().getHeight(); + + _entriesView.setPadding( + _entriesView.getPaddingLeft(), + _entriesView.getPaddingTop(), + _entriesView.getPaddingRight(), + _entriesView.getPaddingBottom() + snackbarHeight * 2 + ); + } + + @Override + public void onDismissed(Snackbar sb, int event) { + int snackbarHeight = sb.getView().getHeight(); + + _entriesView.setPadding( + _entriesView.getPaddingLeft(), + _entriesView.getPaddingTop(), + _entriesView.getPaddingRight(), + _entriesView.getPaddingBottom() - snackbarHeight * 2 + ); + } + }); snackbar.setAction(R.string.undo, new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/res/layout/activity_import_entries.xml b/app/src/main/res/layout/activity_import_entries.xml index da32516c30..deba9ac1e0 100644 --- a/app/src/main/res/layout/activity_import_entries.xml +++ b/app/src/main/res/layout/activity_import_entries.xml @@ -23,7 +23,6 @@ android:id="@+id/list_entries" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingBottom="60dp" android:clipToPadding="false" android:scrollbars="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior"/>