Yuito-app-android/app/src/main/res
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
..
anim fix some lint warnings 2019-04-21 08:24:29 +02:00
color 2512: Set style properly 2023-10-11 21:00:59 +02:00
drawable use link icon instead of emoji when showing hidden urls (#4031) 2023-09-26 21:46:05 +02:00
layout Regularize show/hide logic for video player scrub/play controls (fixes #4073) (#4117) 2023-11-23 08:32:01 +01:00
layout-land Fix trending tags being cut off (#3745) 2023-06-15 11:27:57 +02:00
layout-sw640dp Officially rename error elephant to errorphant (#3922) 2023-08-05 15:39:07 +02:00
menu Add the special appbar for the notifications again (#4022) 2023-09-13 09:21:08 +02:00
mipmap-anydpi-v26 new app icon (#2695) 2022-09-13 19:48:09 +02:00
raw Update gradle, kotlin and other dependencies (#2291) 2022-01-20 21:10:32 +01:00
values feat: Hide self-boosts (#3534) (#4101) 2023-11-13 10:04:39 +01:00
values-ar Update translation files 2023-10-25 10:27:37 +00:00
values-be Update translation files 2023-10-25 10:27:37 +00:00
values-ber Replace “status” by “post” in strings name and source values (#2405) 2022-03-27 12:23:25 +02:00
values-bg Update translation files 2023-10-25 10:27:37 +00:00
values-bn-rBD Update translation files 2023-10-11 07:29:36 +00:00
values-bn-rIN Update translation files 2023-10-11 07:29:36 +00:00
values-ca Update translation files 2023-10-11 07:29:36 +00:00
values-ckb Update translation files 2023-10-11 07:29:36 +00:00
values-cs Update translation files 2023-10-11 07:29:36 +00:00
values-cy Translated using Weblate (Welsh) 2023-11-20 04:45:00 +00:00
values-de Update translation files 2023-10-25 10:27:37 +00:00
values-el Translated using Weblate (Greek) 2023-07-29 12:53:03 +02:00
values-en-rAU Added translation using Weblate (French (Belgium)) 2023-10-25 04:45:14 +00:00
values-en-rGB revert en-gb string update 2023-02-11 13:07:14 +01:00
values-eo Update translation files 2023-10-11 07:29:36 +00:00
values-es Update translation files 2023-10-25 10:27:37 +00:00
values-eu Update translation files 2023-10-11 07:29:36 +00:00
values-fa Translated using Weblate (Persian) 2023-11-20 04:45:00 +00:00
values-fi Add support for setting a list's "exclusivity" option (#3932) 2023-08-06 20:29:34 +02:00
values-fr Update translation files 2023-10-25 10:27:37 +00:00
values-fr-rBE Added translation using Weblate (French (Belgium)) 2023-10-25 04:45:14 +00:00
values-fy Add support for setting a list's "exclusivity" option (#3932) 2023-08-06 20:29:34 +02:00
values-ga Update translation files 2023-10-11 07:29:36 +00:00
values-gd Update translation files 2023-10-25 10:27:37 +00:00
values-gl Translated using Weblate (Galician) 2023-11-09 17:27:27 +00:00
values-hi Update translation files 2023-10-11 07:29:36 +00:00
values-hu Update translation files 2023-10-25 10:27:37 +00:00
values-in Add support for setting a list's "exclusivity" option (#3932) 2023-08-06 20:29:34 +02:00
values-is Update translation files 2023-10-25 10:27:37 +00:00
values-it Translated using Weblate (Italian) 2023-11-20 04:45:00 +00:00
values-iw Added translation using Weblate (Hebrew) 2023-07-30 15:30:24 +02:00
values-ja Update translation files 2023-10-25 10:27:37 +00:00
values-kab Add support for setting a list's "exclusivity" option (#3932) 2023-08-06 20:29:34 +02:00
values-ko Update translation files 2023-10-11 07:29:36 +00:00
values-large Theme refactoring (#1656) 2020-01-30 21:37:28 +01:00
values-large-land fix compose field on landscape tablets (#2747) 2022-11-07 19:56:28 +01:00
values-lb Added translation using Weblate (French (Belgium)) 2023-10-25 04:45:14 +00:00
values-lv Update translation files 2023-10-25 10:27:37 +00:00
values-ml Spelling (#2771) 2022-11-09 19:32:39 +01:00
values-nb-rNO Update translation files 2023-10-25 10:27:37 +00:00
values-night #3178: Increase contrast for separator lines in dark themes (#3497) 2023-03-30 19:31:23 +02:00
values-nl Update translation files 2023-10-25 10:27:37 +00:00
values-oc Translated using Weblate (Occitan) 2023-11-20 04:45:01 +00:00
values-or Translated using Weblate (Odia) 2023-05-09 15:44:10 +00:00
values-pa Added translation using Weblate (French (Belgium)) 2023-10-25 04:45:14 +00:00
values-pl Update translation files 2023-10-11 07:29:36 +00:00
values-pt-rBR Update translation files 2023-10-25 10:27:37 +00:00
values-pt-rPT Update translation files 2023-10-25 10:27:37 +00:00
values-ru Update translation files 2023-10-11 07:29:36 +00:00
values-sa Update translation files 2023-10-11 07:29:36 +00:00
values-si use link icon instead of emoji when showing hidden urls 2023-09-24 16:28:53 +02:00
values-sk Spelling (#2771) 2022-11-09 19:32:39 +01:00
values-sl Update translation files 2023-10-11 07:29:36 +00:00
values-small
values-sv Translated using Weblate (Swedish) 2023-11-20 04:45:00 +00:00
values-sw380dp ComposeActivity refactor (#1541) 2019-12-19 19:09:40 +01:00
values-ta Always publish image alt text 2023-04-24 11:48:40 +02:00
values-te Added translation using Weblate (French (Belgium)) 2023-10-25 04:45:14 +00:00
values-th Update translation files 2023-10-11 07:29:36 +00:00
values-tr Translated using Weblate (Turkish) 2023-11-01 04:45:00 +00:00
values-uk Update translation files 2023-10-25 10:27:37 +00:00
values-v27 Android 12 support, update AndroidX libraries (#2367) 2022-03-09 20:50:23 +01:00
values-vi Translated using Weblate (Vietnamese) 2023-11-20 04:45:00 +00:00
values-w640dp Add trending tags (#3149) 2023-02-14 19:52:11 +01:00
values-zh-rCN Translated using Weblate (Chinese (Simplified)) 2023-10-30 04:45:00 +00:00
values-zh-rHK Update translation files 2023-10-11 07:29:36 +00:00
values-zh-rMO Update translation files 2023-10-11 07:29:36 +00:00
values-zh-rSG Update translation files 2023-10-11 07:29:36 +00:00
values-zh-rTW Update translation files 2023-10-11 07:29:36 +00:00
xml Add entry for "or" to locales_config.xml and donottranslate.xml (#3584) 2023-05-11 12:54:51 +02:00