pachli-android/core/navigation
Nik Clayton 6bef6f2fae
feat: Simplify adding/removing timelines from tabs (#587)
Previously, modifying any tabs meant opening the left-side nav, opening
Account preferences > Tabs, and then adding / removing tabs. This is
time consuming, and difficult for new users to discover.

In addition, it was possible to remove the Home tab, and there was a
hardcoded minimum of at least two tabs.

Fix this.

When viewing a timeline that is not already in a tab an "Add to tab"
menu item is enabled, which appends the timeline to the list of existing
tabs.

When viewing a timeline in a tab (that is not the Home timeline) a
"Remove tab" menu item is enabled, which removes the tab from the list
of existing tabs.

If the user removes the active tab (either with this menu item, or
through preferences) the tab to the left of the active tab becomes the
new active tab.

A new "Manage tabs" menu item is also provided, as a shortcut to the
existing Account preferences > Tabs screen.

When managing tabs the Home timeline can not be removed; the button to
remove it is removed, and swiping is disabled on that list item. The
restriction of "at least two tabs" has also been removed.

`NotificationsActivity` has been removed, as `TimelineActivity` can
display `NotificationsFragment`.

To make the three "Trending" types (hashtags, links, and posts) more
visually distinct add two new icons for links (ic_newspaper) and posts
(ic_whatshot).

Fixes #572, #584, #585, #569
2024-04-03 00:10:09 +02:00
..
src/main feat: Simplify adding/removing timelines from tabs (#587) 2024-04-03 00:10:09 +02:00
README.md refactor: Rename `StatusListActivity` to `TimelineActivity` (#577) 2024-03-30 23:48:04 +01:00
build.gradle.kts refactor: Remove `TabData` type (#576) 2024-03-30 23:27:25 +01:00
lint-baseline.xml refactor: Break navigation dependency cycles with :core:navigation (#305) 2023-12-07 18:36:00 +01:00

README.md

:core:navigation

package app.pachli.core.navigation

Intents for starting activities to break circular dependencies.

A common approach for surfacing type-safe (ish) intents to start activities is for the activity-to-be-launched to provide a method in a companion object that returns the relevant intent, possibly taking additional parameters that will be included in the intent as extras.

E.g., if A wants to start B, B provides the method that returns the intent.

This introduces a dependency between A and B.

This is worse if B also wants to start A.

For example, if A is TimelineActivity and B isViewThreadActivity. The user might click a status in TimelineActivity to view the thread, starting ViewThreadActivity. But from the thread they might click a hashtag to view the list of statuses with that hashtag. Now TimelineActivity and ViewThreadActivity have a circular dependency.

Even if that doesn't happen the dependency means that any changes to B will trigger a rebuild of A, even if the changes to B are not relevant.

This package contains Intent subclasses that should be used instead. The quadrant plugin is used to generate constants that can be used to launch activities by name instead of by class, breaking the dependency chain.

If the activity's intent requires specific extras those are passed via the constructor, with companion object methods to extract them from the intent.

Using the intent classes from this package is enforced by a lint IntentDetector which will warn if any intents are created using a class literal.