BimmerGestalt / AAIdrive

Implementations of some Android Auto features as unofficial IDrive apps
MIT License
541 stars 90 forks source link

Adding text scrolling support #575

Closed Ben2356 closed 2 years ago

Ben2356 commented 2 years ago

When text is too long to fit on a line, it is often truncated as the iDrive system has no built in text scrolling support. To get around this a TextScroller object has been implemented that wraps strings which will provide basic scrolling when those strings exceed a specified max line size. The scrolling logic works in the following fashion:

  1. The original text and max line length is provided to a TextScroller which handles the state of the string
  2. The getText() method provides a way of retrieving the appropriate state of the string and is the way to advance the state of the TextScroller
  3. If the string is less than the max line length then the original string will always be returned
  4. After 6 seconds the string will begin a scroll routine, each call to getText() will return a slice of the string whose start and end indexes will increment by 3
  5. Once the end index is greater than the length of the string, the last segment of the string will be returned from a call to getText()
  6. The string returns to the beginning and a cooldown of 6 seconds is performed

The TextScroller is currently applied to the artist, album, and track title strings in the PlaybackView. Below is a demo of what this looks like when each string is to long to be displayed in its entirety (note this is a contrived example for the sake of demoing this):

scrollingTextDemo

Implements https://github.com/BimmerGestalt/AAIdrive/issues/534

codecov-commenter commented 2 years ago

Codecov Report

Merging #575 (bac0182) into main (5e37076) will decrease coverage by 7.78%. The diff coverage is 57.89%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #575      +/-   ##
============================================
- Coverage     49.46%   41.67%   -7.79%     
+ Complexity     1789     1424     -365     
============================================
  Files           249      243       -6     
  Lines         11793    11389     -404     
  Branches       2331     2270      -61     
============================================
- Hits           5833     4746    -1087     
- Misses         4827     5646     +819     
+ Partials       1133      997     -136     
Impacted Files Coverage Δ
...man/androidautoidrive/carapp/music/TextScroller.kt 22.22% <22.22%> (ø)
...droidautoidrive/carapp/music/views/PlaybackView.kt 54.92% <90.00%> (+2.57%) :arrow_up:
...droidautoidrive/phoneui/viewmodels/MapPageModel.kt 0.00% <0.00%> (-100.00%) :arrow_down:
...idautoidrive/phoneui/fragments/MapsPageFragment.kt 0.00% <0.00%> (-100.00%) :arrow_down:
...dautoidrive/phoneui/fragments/MusicPageFragment.kt 0.00% <0.00%> (-100.00%) :arrow_down:
...dautoidrive/phoneui/viewmodels/SupportPageModel.kt 0.00% <0.00%> (-100.00%) :arrow_down:
...autoidrive/phoneui/fragments/CarSummaryFragment.kt 0.00% <0.00%> (-100.00%) :arrow_down:
...utoidrive/phoneui/fragments/SupportPageFragment.kt 0.00% <0.00%> (-100.00%) :arrow_down:
...toidrive/phoneui/fragments/CalendarPageFragment.kt 0.00% <0.00%> (-100.00%) :arrow_down:
...toidrive/phoneui/fragments/OverviewPageFragment.kt 0.00% <0.00%> (-100.00%) :arrow_down:
... and 85 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5e37076...bac0182. Read the comment docs.

hufman commented 2 years ago

Did you want to continue working on this (I believe you were still interested in performance testing), or should I merge it and we can iterate forward?

Ben2356 commented 2 years ago

Did you want to continue working on this (I believe you were still interested in performance testing), or should I merge it and we can iterate forward?

We are good to merge this! I've been sidetracked working on a weird offset bug that is intermittently showing up but have been running these changes for a while and they are pretty stable in their current form. The performance testing part will come when I introduce this for the EnqueuedView track titles