Add the special appbar for the notifications again (#4022)

This commit is contained in:
UlrichKu 2023-09-13 09:21:08 +02:00 committed by GitHub
parent f99cb6d1d5
commit f63c662275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 21 deletions

View File

@ -275,6 +275,9 @@ public class NotificationsFragment extends SFragment implements
updateAdapter(); updateAdapter();
binding.buttonClear.setOnClickListener(v -> confirmClearNotifications());
binding.buttonFilter.setOnClickListener(v -> showFilterMenu());
if (notifications.isEmpty()) { if (notifications.isEmpty()) {
binding.swipeRefreshLayout.setEnabled(false); binding.swipeRefreshLayout.setEnabled(false);
sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1); sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1);
@ -306,25 +309,31 @@ public class NotificationsFragment extends SFragment implements
binding.swipeRefreshLayout.setRefreshing(true); binding.swipeRefreshLayout.setRefreshing(true);
onRefresh(); onRefresh();
return true; 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; return false;
} }
private void updateFilterVisibility() { private void updateFilterVisibility() {
// CoordinatorLayout.LayoutParams params = CoordinatorLayout.LayoutParams params =
// (CoordinatorLayout.LayoutParams) binding.swipeRefreshLayout.getLayoutParams(); (CoordinatorLayout.LayoutParams) binding.swipeRefreshLayout.getLayoutParams();
// if (showNotificationsFilter && !showingError) { if (showNotificationsFilter && !showingError) {
// binding.appBarOptions.setExpanded(true, false); binding.appBarOptions.setExpanded(true, false);
// binding.appBarOptions.setVisibility(View.VISIBLE); binding.appBarOptions.setVisibility(View.VISIBLE);
// // Set content behaviour to hide filter on scroll // Set content behaviour to hide filter on scroll
// params.setBehavior(new AppBarLayout.ScrollingViewBehavior()); params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
// } else { } else {
// binding.appBarOptions.setExpanded(false, false); binding.appBarOptions.setExpanded(false, false);
// binding.appBarOptions.setVisibility(View.GONE); binding.appBarOptions.setVisibility(View.GONE);
// // Clear behaviour to hide app bar // Clear behaviour to hide app bar
// params.setBehavior(null); params.setBehavior(null);
// } }
} }
private void confirmClearNotifications() { private void confirmClearNotifications() {

View File

@ -22,6 +22,48 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?android:attr/colorBackground"> android:background="?android:attr/colorBackground">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarOptions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
app:elevation="0dp">
<LinearLayout
android:id="@+id/topButtonsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/buttonClear"
style="@style/TuskyButton.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/notifications_clear"
android:textSize="?attr/status_text_medium" />
<Button
android:id="@+id/buttonFilter"
style="@style/TuskyButton.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/notifications_apply_filter"
android:textSize="?attr/status_text_medium" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="?android:attr/listDivider"
app:layout_scrollFlags="scroll|enterAlways" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout" android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -23,15 +23,10 @@
android:title="@string/action_refresh" android:title="@string/action_refresh"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/load_newest"
android:title="@string/load_newest_notifications"
app:showAsAction="never" />
<item <item
android:id="@+id/action_edit_notification_filter" android:id="@+id/action_edit_notification_filter"
android:title="@string/notifications_apply_filter" android:title="@string/notifications_apply_filter"
app:showAsAction="ifRoom" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_clear_notifications" android:id="@+id/action_clear_notifications"

View File

@ -613,8 +613,8 @@
<string name="error_list_load">Error loading lists</string> <string name="error_list_load">Error loading lists</string>
<string name="list_exclusive_label">Hide from the home timeline</string> <string name="list_exclusive_label">Hide from the home timeline</string>
<string name="list">List</string> <string name="list">List</string>
<string name="notifications_clear">Delete notifications</string> <string name="notifications_clear">Delete</string>
<string name="notifications_apply_filter">Filter notifications</string> <string name="notifications_apply_filter">Filter</string>
<string name="filter_apply">Apply</string> <string name="filter_apply">Apply</string>
<string name="muting_hashtag_success_format">Muting hashtag #%s as a warning</string> <string name="muting_hashtag_success_format">Muting hashtag #%s as a warning</string>