chinwag-android/app/src/main/res/layout
Nik Clayton 9cf4882f41
Keep scroll position when loading missing statuses (#3000)
* Change "Load more" to load oldest statuses first in home timeline

Previous behaviour loaded missing statuses by using "since_id" and "max_id".
This loads the most recent N statuses, looking backwards from "max_id".

Change to load the oldest statuses first, assuming the user is scrolling
up through the timeline and will want to load statuses in reverse
chronological order.

* Scroll to the bottom of new entries added by "Load more"

- Remember the position of the "Load more" placeholder
- Check the position of inserted entries
- If they match, scroll to the bottom

* Change "Load more" to load oldest statuses first in home timeline

Previous behaviour loaded missing statuses by using "since_id" and "max_id".
This loads the most recent N statuses, looking backwards from "max_id".

Change to load the oldest statuses first, assuming the user is scrolling
up through the timeline and will want to load statuses in reverse
chronological order.

* Scroll to the bottom of new entries added by "Load more"

- Remember the position of the "Load more" placeholder
- Check the position of inserted entries
- If they match, scroll to the bottom

* Ensure the user can't have two simultaneous "Load more" coroutines

Having two simultanous coroutines would break the calculation used to figure
out which item in the list to scroll to after a "Load more" in the timeline.

Do this by:

- Creating a TimelineUiState and associated flow that tracks the "Load more"
  state
- Updating this in the (Cached|Network)TimelineViewModel
- Listening for changes to it in TimelineFragment, and notifying the adapter
- The adapter will disable any placeholder views while "Load more" is active

* Revert changes that loaded the oldest statuses instead of the newest

* Be more robust about locating the status to scroll to

Weirdness with the PagingData library meant that positionStart could still be
wrong after "Load more" was clicked.

Instead, remember the position of the "Load more" item and the ID of the
status immediately after it.

When new items are added, search for the remembered status at the position of
the "Load more" item. This is quick, testing at most LOAD_AT_ONCE items in
the adapter.

If the remembered status is not visible on screen then scroll to it.

* Lint

* Add a preference to specify the reading order

Default behaviour (oldest first) is for "load more" to load statuses and
stay at the oldest of the new statuses.

Alternative behaviour (if the user is reading from top to bottom) is to
stay at the newest of the new statuses.

* Move ReadingOrder enum construction logic in to the enum

* Jump to top if swipe/refresh while preferring newest-first order

* Show a circular progress spinner during "Load more" operations

Remove a dedicated view, and use an icon on the button instead.

Adjust the placeholder attributes and styles accordingly.

* Remove the "loadMoreActive" property

Complicates the code and doesn't really achieve the desired effect. If the
user wants to tap multiple "Load more" buttons they can.

* Update comments in TimelineFragment

* Respect the user's reading order preference if it changes

* Add developer tools

This is for functionality that makes it easier for developers to interact
with the app, or get it in to a known-state.

These features are for use by users, so are only visible in debug builds.

* Adjust how content is loaded based on preferred reading order

- Add the readingOrder to TimelineViewModel so derived classes can use it.
- Update the homeTimeline API to support the `minId` parameter and update
  calls in NetworkTimelineViewModel

In CachedTimelineViewModel:
- Set the bounds of the load to be the status IDs on either side of the
  placeholder ID (update TimelineDao with a new query for this)
- Load statuses using either minId or sinceId depending on the reading order
- Is there was no overlap then insert the new placeholder at the start/end
  of the list depending on reading order

* Lint

* Rename unused dialog parameter to _

* Update API arguments in tests

* Simplify ReadingOrder preference handling

* Fix bug with Placeholder and the "expanded" property

If a status is a Placeholder the "expanded" propery is used to indicate
whether or not it is loading.

replaceStatusRange() set this property based on the old value, and the user's
alwaysOpenSpoiler preference setting.

This shouldn't have been used if the status is a Placeholder, as it can lead
to incorrect loading states.

Fix this.

While I'm here, introduce an explicit computed property for whether a
TimelineStatusEntity is a placeholder, and use that for code clarity.

* Set the "Load more" button background to transparent

* Fix typo.

* Inline spec, update comment

* Revert 1480c6aa3ac5c0c2d362fb271f47ea2259ab14e2

Turns out the behaviour is not desired.

* Remove unnecessary Log call

* Extract function

* Change default to newest first
2023-01-13 19:26:24 +01:00
..
activity_about.xml migrating to ViewBinding part 2: Activities (#2093) 2021-03-07 19:05:51 +01:00
activity_account.xml #2752: enable to copy the profile bio and its account fields (#2756) 2022-11-07 19:57:58 +01:00
activity_account_list.xml migrating to ViewBinding part 2: Activities (#2093) 2021-03-07 19:05:51 +01:00
activity_announcements.xml migrating to ViewBinding part 2: Activities (#2093) 2021-03-07 19:05:51 +01:00
activity_compose.xml 2890 show warning on missing description (#2919) 2022-12-06 19:28:44 +01:00
activity_drafts.xml Drafts v2 (#2032) 2021-01-21 18:57:09 +01:00
activity_edit_profile.xml update Android Image Cropper and get rid of deprecated onActivityResult (#2351) 2022-03-02 20:39:56 +01:00
activity_filters.xml migrating to ViewBinding part 2: Activities (#2093) 2021-03-07 19:05:51 +01:00
activity_followed_tags.xml Add view for browsing and unfollowing followed hashtags (#2794) 2022-12-01 19:24:27 +01:00
activity_license.xml update licenses (#2315) 2022-02-04 21:59:42 +01:00
activity_lists.xml migrating to ViewBinding part 2: Activities (#2093) 2021-03-07 19:05:51 +01:00
activity_login.xml Implement Login via WebView (#2371) 2022-03-08 21:22:19 +01:00
activity_login_webview.xml show rules on the login screen (#2746) 2022-11-05 17:37:20 +01:00
activity_main.xml Show Avatar next to tabs when main top bar is disabled (#2973) 2022-12-03 12:16:54 +01:00
activity_preferences.xml migrating to ViewBinding part 2: Activities (#2093) 2021-03-07 19:05:51 +01:00
activity_report.xml migrating to ViewBinding part 2: Activities (#2093) 2021-03-07 19:05:51 +01:00
activity_scheduled_status.xml Rename Toots to Posts (#2396) 2022-03-20 20:21:42 +01:00
activity_search.xml never collapse tabs in SearchActivity (#2505) 2022-05-17 19:37:09 +02:00
activity_statuslist.xml merge ModalTimelineActivity & ViewTagActivity into StatusListActivity (#2332) 2022-02-25 18:57:31 +01:00
activity_tab_preference.xml add content description to add tab button (#2910) 2022-11-23 20:06:35 +01:00
activity_view_media.xml Theme refactoring (#1656) 2020-01-30 21:37:28 +01:00
activity_view_thread.xml rewrite threads with Kotlin & coroutines (#2617) 2022-08-15 11:00:18 +02:00
card_license.xml explicitly set text colors in LicenseCard (#1910) 2020-08-26 18:46:44 +02:00
dialog_add_poll.xml Instance configuration: the easy parts (#2341) 2022-03-01 19:43:36 +01:00
dialog_filter.xml Support setting filter expirations (#2667) 2022-08-17 17:50:34 +02:00
dialog_focus.xml Add a description to the focus dialog (#2711) 2022-10-15 19:04:27 +02:00
dialog_mute_account.xml migrating to ViewBinding part 1: Dialogs + Views (#2091) 2021-03-07 19:04:22 +01:00
fragment_account_list.xml Error artwork (#1000) 2019-01-28 19:02:31 +01:00
fragment_accounts_in_list.xml fix list editing by moving account_ids from query to form param (#1690) 2020-02-18 08:45:10 +01:00
fragment_instance_list.xml Implement instance mutes (#1311) 2019-06-11 15:56:27 +02:00
fragment_lists_for_account.xml Add done button to lists dialog 2022-11-16 21:54:11 +09:00
fragment_report_done.xml Redesign report activity (#1295) 2019-06-09 16:55:34 +02:00
fragment_report_note.xml Theme refactoring (#1656) 2020-01-30 21:37:28 +01:00
fragment_report_statuses.xml Redesign report activity (#1295) 2019-06-09 16:55:34 +02:00
fragment_search.xml migrating to ViewBinding part 4: Fragments (#2108) 2021-03-13 21:27:20 +01:00
fragment_timeline.xml migrating to ViewBinding part 4: Fragments (#2108) 2021-03-13 21:27:20 +01:00
fragment_timeline_notifications.xml remove scrolling from notification options bar (#1858) 2020-07-20 11:25:36 +02:00
fragment_view_image.xml Left-align image alt text & make it selectable (#3063) 2022-12-30 11:20:25 +01:00
fragment_view_thread.xml Improve the actual and perceived speed of thread loading (#3118) 2023-01-09 21:31:31 +01:00
fragment_view_video.xml Audio caption improvements (#2220) 2021-09-17 21:55:54 +02:00
item_account.xml Convert AccountViewHolder from Java to Kotlin (#3044) 2022-12-28 19:07:43 +01:00
item_account_field.xml #2752: enable to copy the profile bio and its account fields (#2756) 2022-11-07 19:57:58 +01:00
item_account_media.xml AccountMediaFragment improvements (#2684) 2022-09-02 16:52:47 +02:00
item_add_or_remove_from_list.xml Update dialog colors 2022-11-16 20:55:36 +09:00
item_add_poll_option.xml Theme refactoring (#1656) 2020-01-30 21:37:28 +01:00
item_announcement.xml add content description to add reaction button (#2838) 2022-11-16 19:04:12 +01:00
item_autocomplete_account.xml modernize autocomplete (#2510) 2022-05-17 19:55:37 +02:00
item_autocomplete_emoji.xml modernize autocomplete (#2510) 2022-05-17 19:55:37 +02:00
item_autocomplete_hashtag.xml modernize autocomplete (#2510) 2022-05-17 19:55:37 +02:00
item_blocked_user.xml New emoji picker (#2395) 2022-04-26 18:50:58 +02:00
item_conversation.xml show status edits (#3049) 2023-01-02 14:09:18 +01:00
item_draft.xml New emoji picker (#2395) 2022-04-26 18:50:58 +02:00
item_edit_field.xml Handle even more instance defaults (#2612) 2022-07-26 20:24:50 +02:00
item_emoji_button.xml ComposeActivity improvements (#548) 2018-04-13 22:37:21 +02:00
item_emoji_pref.xml migrating to ViewBinding part 3: EmojiPreference (#2094) 2021-03-07 19:06:05 +01:00
item_follow.xml New emoji picker (#2395) 2022-04-26 18:50:58 +02:00
item_follow_request.xml Increase the size of the accept/reject follow buttons (#2987) 2022-12-05 14:44:32 +01:00
item_follow_requests_header.xml always show follow requests in main menu (#1809) 2021-04-10 20:30:44 +02:00
item_followed_hashtag.xml Add view for browsing and unfollowing followed hashtags (#2794) 2022-12-01 19:24:27 +01:00
item_footer.xml fix account list loading and clean up a lot of code (#823) 2018-08-31 21:52:09 +02:00
item_hashtag.xml migrating to ViewBinding part 4: Adapters (#2095) 2021-03-07 19:24:01 +01:00
item_image_preview_overlay.xml issue 2890: Add an "ALT" sticker to the media preview container (#2942) 2022-12-18 16:50:30 +01:00
item_list.xml Theme refactoring (#1656) 2020-01-30 21:37:28 +01:00
item_media_preview.xml issue 2890: Add an "ALT" sticker to the media preview container (#2942) 2022-12-18 16:50:30 +01:00
item_muted_domain.xml Theme refactoring (#1656) 2020-01-30 21:37:28 +01:00
item_muted_user.xml Improve muted users list (#3127) 2023-01-02 14:09:40 +01:00
item_network_state.xml Tab customization & direct messages tab (#1012) 2019-02-12 19:22:37 +01:00
item_picker_list.xml migrating to ViewBinding part 4: Adapters (#2095) 2021-03-07 19:24:01 +01:00
item_poll.xml show status edits (#3049) 2023-01-02 14:09:18 +01:00
item_poll_preview_option.xml remove ThemeUtils.getTintedDrawable (#2015) 2020-12-09 19:08:16 +01:00
item_report_notification.xml Add support for moderation report notifications (#2887) 2022-12-01 20:11:55 +01:00
item_report_status.xml New emoji picker (#2395) 2022-04-26 18:50:58 +02:00
item_scheduled_status.xml New emoji picker (#2395) 2022-04-26 18:50:58 +02:00
item_status.xml show status edits (#3049) 2023-01-02 14:09:18 +01:00
item_status_bottom_sheet.xml Upgrade to AndroidX, move to MaterialComponents theme (#953) 2018-12-17 15:25:35 +01:00
item_status_detailed.xml show status edits (#3049) 2023-01-02 14:09:18 +01:00
item_status_edit.xml show status edits (#3049) 2023-01-02 14:09:18 +01:00
item_status_notification.xml show status edits (#3049) 2023-01-02 14:09:18 +01:00
item_status_placeholder.xml Keep scroll position when loading missing statuses (#3000) 2023-01-13 19:26:24 +01:00
item_tab_preference.xml remove ThemeUtils.getTintedDrawable (#2015) 2020-12-09 19:08:16 +01:00
item_tab_preference_small.xml remove ThemeUtils.getTintedDrawable (#2015) 2020-12-09 19:08:16 +01:00
material_drawer_header.xml convert MainActivity to Kotlin and upgrade MaterialDrawer to version 8 (#1748) 2020-04-15 18:57:53 +02:00
notifications_filter.xml Ensure the "Apply" button is always visible (#3004) 2022-12-06 20:31:16 +01:00
search_view.xml Upgrade to AndroidX, move to MaterialComponents theme (#953) 2018-12-17 15:25:35 +01:00
toolbar_basic.xml Drafts v2 (#2032) 2021-01-21 18:57:09 +01:00
view_background_message.xml Make image in BackgroundMessageView adapt to the height, fix #1618 (#1649) 2020-02-25 19:57:28 +01:00
view_compose_options.xml simplify ComposeOptionsView (#1734) 2020-03-24 21:07:10 +01:00
view_compose_schedule.xml remove ThemeUtils.getTintedDrawable (#2015) 2020-12-09 19:08:16 +01:00
view_poll_preview.xml Create polls (#1452) 2019-08-22 20:30:08 +02:00