nicolasbrailo / PianOli

Android baby game
GNU General Public License v3.0
59 stars 18 forks source link

Fix theme changing by reinitialising preferences each time. #86

Closed pserwylo closed 8 months ago

pserwylo commented 8 months ago

Prior to this, it was only doing so in the constructor, so when returning from the settings screen and reinitialising everything, this was omitted. Fixes theme changing.

juleskers commented 8 months ago

Interesting! Is this something you observed? Or is it a theoretical fix?

I just tried to reproduce this, but theme-changing works 'normally' for me. Is the behaviour on your phone different? If so, we're looking at different UI implementation details between android versions, always fun to debug!

  1. started PianOli with theme A ("Boomwhacker")
  2. config unlock sequence
  3. phone switches to lock-screen, enter pin
  4. arrive at settings screen, change theme to "Pastel"
  5. click settings back-button
  6. arrive at pastel-coloured Piano.

I'm running e/OS 1.17 (Android S / 12, LineageOS derived)

It's just past midnight here (go shape-of-the-world), so I don't have time for an on-device test. I'll try to squeeze that in tomorrow, or else later this week.

In principle your change looks good, but if it's Android behaviour that is handled inconsistently between devices (as my failure to reproduce seems to indicate), I really want to try it before merging, in case it, against all expectations, breaks on my phone.

pserwylo commented 8 months ago

Yeah, so this is something I observed, but this morning (like your evening) I was running out of time before the kids woke up so I didn't investigate very far, just smashed out this PR without thinking too much about it. I will test on a few devices this evening and try to narrow down the issue.

juleskers commented 8 months ago

On-device test successful on my hardware!

Now that I've looked at the change with a slightly clearer head, and less time pressure, I've convinced myself this is a safe change, so I'm merging.

When you are investigating, I'm wondering what you've observed is related to #75 .. Maybe what you are seeing is not a re-draw with the "old" theme, but rather a cached surface-rendering with the old colours. The difference in that case would be that any key-activity would trigger a redraw with the "current" theme. Do the colours "jump" when you touch a key?

I still haven't found any documentation that gives hard rules for when surfaceChanged is called, and when not. I get the impression that redrawing, and especially not redrawing, is almost completely at the discretion of the OS. (Which can suspend, unload, freeze, thaw, etc. apps in the name of holy battery-savings)