From f63c662275699d7069feb6a95364bb2376e34c5f Mon Sep 17 00:00:00 2001 From: UlrichKu Date: Wed, 13 Sep 2023 09:21:08 +0200 Subject: [PATCH] Add the special appbar for the notifications again (#4022) --- .../tusky/fragment/NotificationsFragment.java | 35 ++++++++++------ .../fragment_timeline_notifications.xml | 42 +++++++++++++++++++ .../main/res/menu/fragment_notifications.xml | 7 +--- app/src/main/res/values/strings.xml | 4 +- 4 files changed, 67 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index da9d89025..f6df6a855 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -275,6 +275,9 @@ public class NotificationsFragment extends SFragment implements updateAdapter(); + binding.buttonClear.setOnClickListener(v -> confirmClearNotifications()); + binding.buttonFilter.setOnClickListener(v -> showFilterMenu()); + if (notifications.isEmpty()) { binding.swipeRefreshLayout.setEnabled(false); sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1); @@ -306,25 +309,31 @@ public class NotificationsFragment extends SFragment implements binding.swipeRefreshLayout.setRefreshing(true); onRefresh(); return true; + } else if (menuItem.getItemId() == R.id.action_edit_notification_filter) { + showFilterMenu(); + return true; + } else if (menuItem.getItemId() == R.id.action_clear_notifications) { + confirmClearNotifications(); + return true; } return false; } private void updateFilterVisibility() { -// CoordinatorLayout.LayoutParams params = -// (CoordinatorLayout.LayoutParams) binding.swipeRefreshLayout.getLayoutParams(); -// if (showNotificationsFilter && !showingError) { -// binding.appBarOptions.setExpanded(true, false); -// binding.appBarOptions.setVisibility(View.VISIBLE); -// // Set content behaviour to hide filter on scroll -// params.setBehavior(new AppBarLayout.ScrollingViewBehavior()); -// } else { -// binding.appBarOptions.setExpanded(false, false); -// binding.appBarOptions.setVisibility(View.GONE); -// // Clear behaviour to hide app bar -// params.setBehavior(null); -// } + CoordinatorLayout.LayoutParams params = + (CoordinatorLayout.LayoutParams) binding.swipeRefreshLayout.getLayoutParams(); + if (showNotificationsFilter && !showingError) { + binding.appBarOptions.setExpanded(true, false); + binding.appBarOptions.setVisibility(View.VISIBLE); + // Set content behaviour to hide filter on scroll + params.setBehavior(new AppBarLayout.ScrollingViewBehavior()); + } else { + binding.appBarOptions.setExpanded(false, false); + binding.appBarOptions.setVisibility(View.GONE); + // Clear behaviour to hide app bar + params.setBehavior(null); + } } private void confirmClearNotifications() { diff --git a/app/src/main/res/layout/fragment_timeline_notifications.xml b/app/src/main/res/layout/fragment_timeline_notifications.xml index 4d139b155..40c1a7522 100644 --- a/app/src/main/res/layout/fragment_timeline_notifications.xml +++ b/app/src/main/res/layout/fragment_timeline_notifications.xml @@ -22,6 +22,48 @@ android:layout_height="match_parent" android:background="?android:attr/colorBackground"> + + + + +