Display notification filter/clear actions as menu items (#3877)

Previously the notification filter and clear actions were shown as
buttons in the UI, with a preference that determined whether they were
displayed.

Remove this preference, and display them as menu items.

- "Filter notifications" is shown as an icon, if possible
- "Clear notifications" is only ever shown as a menu item, to reduce the
chance the user inadvertently selects it

To ensure that the options menu appears correctly, remove the code that
creates a "fake" action bar, and adjust the layouts so that there are
three toolbars;

- mainToolbar -- displays the icons, and the current "location" (Home,
Notifications, etc)
- topNav -- displays the row of tabs at the top
- bottomNav -- displays the row of tabs at the bottom

Only one of them is set as the support action bar (depending on the
user's preferences). This provides the "show a logo" and "show the
options menu" functionality as standard, without needing to re-implement
as the previous code did.
This commit is contained in:
Nik Clayton 2023-08-19 14:41:10 +02:00 committed by GitHub
commit 059352f471
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 152 additions and 304 deletions

View file

@ -99,7 +99,6 @@ abstract class NotificationsViewModelTestBase {
PrefKeys.CONFIRM_REBLOGS to true,
PrefKeys.CONFIRM_FAVOURITES to false,
PrefKeys.WELLBEING_HIDE_STATS_POSTS to false,
PrefKeys.SHOW_NOTIFICATIONS_FILTER to true,
PrefKeys.FAB_HIDE to false
)

View file

@ -35,7 +35,6 @@ class NotificationsViewModelTestUiState : NotificationsViewModelTestBase() {
private val initialUiState = UiState(
activeFilter = setOf(Notification.Type.FOLLOW),
showFilterOptions = true,
showFabWhileScrolling = true
)
@ -64,23 +63,4 @@ class NotificationsViewModelTestUiState : NotificationsViewModelTestBase() {
assertThat(expectMostRecentItem().showFabWhileScrolling).isFalse()
}
}
@Test
fun `showFilterOptions depends on SHOW_NOTIFICATIONS_FILTER preference`() = runTest {
// Prior
viewModel.uiState.test {
assertThat(expectMostRecentItem().showFilterOptions).isTrue()
}
// Given
sharedPreferencesMap[PrefKeys.SHOW_NOTIFICATIONS_FILTER] = false
// When
eventHub.dispatch(PreferenceChangedEvent(PrefKeys.SHOW_NOTIFICATIONS_FILTER))
// Then
viewModel.uiState.test {
assertThat(expectMostRecentItem().showFilterOptions).isFalse()
}
}
}