Yuito-app-android/app/src/main/res/layout
mcclure 70725fd75b
Regularize show/hide logic for video player scrub/play controls (fixes #4073) (#4117)
When viewing a video in Tusky, there is a top toolbar where the
description is shown and the bottom toolbar where play, forward,
backward, and scrub controls are found. In both Tusky 23 and the new
media3 video player code, the logic for showing these toolbars is
*unrelated*; Tusky catches tap events and shows and hides the
description, and the Android media library separately catches tap events
and shows and hides the bottom toolbar. Meanwhile, Tusky and the Android
media library each separately manage a set of logic for auto-hiding
their respective toolbars after a certain number of seconds has passed.
This all results in several problems:

- The top and bottom toolbars can desync, so that one is visible and the
other is not, and tapping to show/hide after this will only swap which
one is visible. This happens *every* time you switch to another
application then back to Tusky while the video player is up.
- You can also desync the top and bottom toolbars in this way by simply
tapping very rapidly.
- The autohide logic was difficult for us to control or customize,
because it was partially hidden inside the Android libraries (relevant
because under media3, the autohide delay increased from 3 to something
like 5 or 6 seconds).

In this patch, I disabled all auto- and tap-based show/hide logic in
media3 and set the Tusky-side show/hide to directly control the media3
toolbar. I then audited the code with printfs until I understood the
state machine of show/hide, and removed anything irrational (some code
was either unreachable, or redundant; either these lines were broken in
the media3 transition, or they never worked).¹

While doing this, I made two policy changes:

- As discussed on Matrix, the autohide delay is now 4 seconds. (In
discussions with users on Mastodon, some complained the previous 3
seconds was too short; but in my opinion and [I think?] charlag's, the
new 5 seconds is too long).
- In the pre-existing code, if the user has hidden the controls, and
they switch to another app and back, the controls display for 4 seconds
then re-hide themselves, just like if the video had been presented for
the first time. I think this is good and kept it— *however* I made a
decision if the user intentionally taps to display the controls, *then*
switches to another app and back, the controls should *not* auto-hide,
because the user most recently requested those controls be shown.

Tests I performed on the final PR (successfully):

- Start video. Expect: toolbar+description hides after 4 seconds.
- Start video. Pause. Resume. Expect: t+d hides after 4 seconds.
- Start video. Wait 4 seconds until t+d hide. Switch to other app.
Switch back. Expect: t+d reappears, then hides after 4 seconds.
- Start video. Wait 4 seconds until t+d hide. Tap to show t+d. Switch to
other app. Switch back. Expect: t+d appear, do NOT autohide.
- Start video. Before 4 seconds up, switch to other app. Switch back.
Expect: t+d reappears, then hides after 4 seconds.
- Start video. Pause. Resume. Before 4 seconds up, switch to other app.
Switch back. Expect: t+d reappears, then hides after 4 seconds.
- Start video. Wait 4 seconds until t+d hide. Tap rapidly over and over
for many seconds. Expect: Nothing weird
- Start *audio*. Expect: At no point does controller autohide, not even
if I switch to another app and back, but I can hide it by manually
tapping

These tests were performed on Android 13. There is an entirely separate
`Build.VERSION.SDK_INT <= 23` path I did not test, but Android Studio
says this is dead code (I think it thinks our minimum SDK is higher than
that?)

---

<small>¹ Incidentally, the underlying cause of #4073 (the show/resume
part of it anyway) turned out to be that the STATE_READY event was being
received not just on video load but also a second time on app resume,
causing certain parts of the initialization code to run a second time
although the fragment had already been fully initialized.</small>
2023-11-23 08:32:01 +01:00
..
activity_about.xml Show additional bug report info in AboutActivity (#3802) 2023-08-03 12:20:35 +02:00
activity_account.xml don't cut off names on profiles (#4052) 2023-10-09 15:43:02 +02:00
activity_account_list.xml Make links in bios of follow request and follow notifications work (#3646) 2023-05-13 15:32:56 +02:00
activity_announcements.xml Officially rename error elephant to errorphant (#3922) 2023-08-05 15:39:07 +02:00
activity_compose.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
activity_drafts.xml Officially rename error elephant to errorphant (#3922) 2023-08-05 15:39:07 +02:00
activity_edit_filter.xml Add delete button to edit filter activity. (#3553) 2023-06-11 19:59:26 +02: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 3503: SwipeRefreshLayout must be higher level (#3504) 2023-04-20 19:36:29 +02:00
activity_followed_tags.xml Adjust list UX for platform consistency (#3142) 2023-06-29 18:36:19 +02:00
activity_license.xml update licenses (#2315) 2022-02-04 21:59:42 +01:00
activity_lists.xml 3503: SwipeRefreshLayout must be higher level (#3504) 2023-04-20 19:36:29 +02: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 2512: Set style properly 2023-10-11 21:00:59 +02: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 Officially rename error elephant to errorphant (#3922) 2023-08-05 15:39:07 +02:00
activity_search.xml Adjust list UX for platform consistency (#3142) 2023-06-29 18:36:19 +02:00
activity_statuslist.xml merge ModalTimelineActivity & ViewTagActivity into StatusListActivity (#2332) 2022-02-25 18:57:31 +01:00
activity_tab_preference.xml 2512: Allow more than 5 tabs (#4051) 2023-10-11 09:54:01 +02:00
activity_trending.xml Add trending tags (#3149) 2023-02-14 19:52:11 +01:00
activity_view_media.xml Theme refactoring (#1656) 2020-01-30 21:37:28 +01:00
activity_view_thread.xml Add "Refresh" accessibility menu (#3121) 2023-03-01 19:58:18 +01: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 Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
dialog_focus.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
dialog_follow_hashtag.xml Add FAB to follow new hashtags from FollowedTagsActivity (#3275) 2023-02-20 20:14:16 +01:00
dialog_image_description.xml 4063: Make dialog size more stable (#4066) 2023-10-25 11:59:59 +02:00
dialog_list.xml Support "replies policy" for lists (#4072) 2023-10-26 11:21:04 +02:00
dialog_mute_account.xml migrating to ViewBinding part 1: Dialogs + Views (#2091) 2021-03-07 19:04:22 +01:00
exo_player_control_view.xml Exoplayer: Increase space between rewind, pause, ffwd buttons (#4077) 2023-11-01 09:21:43 +01:00
fragment_account_list.xml 3503: SwipeRefreshLayout must be higher level (#3504) 2023-04-20 19:36:29 +02:00
fragment_accounts_in_list.xml Officially rename error elephant to errorphant (#3922) 2023-08-05 15:39:07 +02:00
fragment_domain_blocks.xml ui improvements 2023-07-05 20:11:12 +02:00
fragment_lists_for_account.xml Officially rename error elephant to errorphant (#3922) 2023-08-05 15:39:07 +02:00
fragment_report_done.xml Redesign report activity (#1295) 2019-06-09 16:55:34 +02:00
fragment_report_note.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02: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 3503: SwipeRefreshLayout must be higher level (#3504) 2023-04-20 19:36:29 +02:00
fragment_timeline_notifications.xml Add the special appbar for the notifications again (#4022) 2023-09-13 09:21:08 +02:00
fragment_trending_tags.xml Rename "Trending" to "TrendingTags" or similar where necessary (#3906) 2023-08-19 12:54:35 +02:00
fragment_view_edits.xml Remove ReplacementSpan, display diffs using CharacterStyle (#3431) 2023-06-11 19:12:05 +02:00
fragment_view_image.xml Fix image zoom / pan / scroll / swipe (#3894) 2023-07-31 12:44:01 +02:00
fragment_view_thread.xml Set statusView width/height to match_parent (#3844) 2023-07-13 17:26:12 +02:00
fragment_view_video.xml Regularize show/hide logic for video player scrub/play controls (fixes #4073) (#4117) 2023-11-23 08:32:01 +01:00
item_account.xml Clean up Account adapters (#3202) 2023-02-04 20:29:13 +01:00
item_account_field.xml By explicit about the `firstStrong` text direction on UGC (#3328) 2023-03-02 18:30:26 +01:00
item_account_media.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +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 Displayed the date of each announcement. (#4041) 2023-10-10 19:17:06 +02: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_domain.xml rename item_muted_domain to item_blocked_domain 2023-07-05 19:23:04 +02:00
item_blocked_user.xml Clean up Account adapters (#3202) 2023-02-04 20:29:13 +01:00
item_conversation.xml Meet accessibility guidelines for clickable spans (#3382) 2023-03-18 08:57:39 +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_follow.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
item_follow_request.xml Make links in bios of follow request and follow notifications work (#3646) 2023-05-13 15:32:56 +02: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 Adjust list UX for platform consistency (#3142) 2023-06-29 18:36:19 +02: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 Adjust list UX for platform consistency (#3142) 2023-06-29 18:36:19 +02: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 Adjust list UX for platform consistency (#3142) 2023-06-29 18:36:19 +02:00
item_media_preview.xml Add background to sensitive media button (#3939) 2023-08-08 23:08:35 +02:00
item_muted_user.xml Clean up Account adapters (#3202) 2023-02-04 20:29:13 +01:00
item_network_state.xml Tab customization & direct messages tab (#1012) 2019-02-12 19:22:37 +01:00
item_notifications_load_state_footer_view.xml Convert NotificationsFragment and related code to Kotlin, use the Paging library (#3159) 2023-03-10 20:12:33 +01:00
item_poll.xml Allow multiline polls (this time for real) (#3608) 2023-05-03 09:05:05 +02:00
item_poll_preview_option.xml remove ThemeUtils.getTintedDrawable (#2015) 2020-12-09 19:08:16 +01:00
item_removable.xml Support the mastodon 4 filter api (#3188) 2023-03-11 13:12:50 +01:00
item_report_notification.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
item_report_status.xml Add background to sensitive media button (#3939) 2023-08-08 23:08:35 +02:00
item_scheduled_status.xml New emoji picker (#2395) 2022-04-26 18:50:58 +02:00
item_status.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02: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 Make CW description selectable (#3926) 2023-08-07 20:32:17 +02:00
item_status_edit.xml Remove ReplacementSpan, display diffs using CharacterStyle (#3431) 2023-06-11 19:12:05 +02:00
item_status_filtered.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
item_status_notification.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
item_status_placeholder.xml 3311 load more more prominent (#3376) 2023-02-27 11:33:11 +01:00
item_status_wrapper.xml Support the mastodon 4 filter api (#3188) 2023-03-11 13:12:50 +01:00
item_tab_preference.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
item_tab_preference_small.xml Adjust list UX for platform consistency (#3142) 2023-06-29 18:36:19 +02:00
item_trending_cell.xml Fix trending tags being cut off (#3745) 2023-06-15 11:27:57 +02:00
item_trending_date.xml Add trending tags (#3149) 2023-02-14 19:52:11 +01:00
material_drawer_header.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00
notifications_filter.xml Resets the paging3 changes of 3159 back to the (java) fragment code before. 2023-09-09 21:29:24 +02:00
pref_slider.xml Provide a preference to scale all UI text (#3248) 2023-06-29 18:34:56 +02:00
search_view.xml Upgrade to AndroidX, move to MaterialComponents theme (#953) 2018-12-17 15:25:35 +01:00
simple_list_item_1.xml Convert NotificationsFragment and related code to Kotlin, use the Paging library (#3159) 2023-03-10 20:12:33 +01:00
toolbar_basic.xml Drafts v2 (#2032) 2021-01-21 18:57:09 +01:00
view_background_message.xml Officially rename error elephant to errorphant (#3922) 2023-08-05 15:39:07 +02:00
view_compose_options.xml simplify ComposeOptionsView (#1734) 2020-03-24 21:07:10 +01:00
view_compose_schedule.xml Use colorPrimary for the "edit" schedule icon (#3917) 2023-08-04 13:37:31 +02:00
view_poll_preview.xml Fix lint warnings (#4019) 2023-09-13 09:20:53 +02:00