GoogleChrome / android-browser-helper

The Android Browser Helper library helps developers use Custom Tabs and Trusted Web Activities on top of the AndroidX browser support library.
Apache License 2.0
694 stars 288 forks source link

Broken caching behavior in `SplashImageTransferTask` on dark / light mode switches #461

Open uwolfer opened 7 months ago

uwolfer commented 7 months ago

In case you provide both normal (light) and dark (night) mode resources for your slash screen,SplashImageTransferTask does not work as expected: it keeps the splash screen for the previous mode. The only workaround is reinstalling the app.

To Reproduce

  1. Add a folder res/drawable-night next to the existing res/drawable folder with a splash.png file.
  2. Toggle the device color schema mode (light / dark).
  3. The splash displayed shows still the "old" splash image.

I think I was able to find the cause of this issue: https://github.com/GoogleChrome/android-browser-helper/blob/main/androidbrowserhelper/src/main/java/com/google/androidbrowserhelper/trusted/splashscreens/SplashImageTransferTask.java#L107 checks the last app update time, and compares it with the persisted time when the splash got last cached (PREF_LAST_UPDATE_TIME). That means for the case when you update the color schema of your device, but you do not reinstall the app, it will take the shortcut and use the already cached splash setup.

Expected behavior Whenever the user changes color schema of their device, the proper splash should be rendered.