maui icon indicating copy to clipboard operation
maui copied to clipboard

Android Platform App Theme does not automatically update when switching themes

Open Chandrakalavaprani opened this issue 1 year ago • 10 comments

          Hi @drasticactions. 

We use Visual Studio Professional and this is still an issue for android , Could you please guide and confirm if this is also resolved for Visual Studio Professional

Chandrakalavaprani avatar Apr 11 '24 07:04 Chandrakalavaprani

I confirm that this is regression after migration to MAUI 8.0.20 from MAUI 8.0.14, theme switching is broken

LeDahu22 avatar Apr 11 '24 07:04 LeDahu22

Could you please provide a bit more detail here? What is the code that you are using? What isn't working any more? Are there other parts that are still working? Could you please provide a reproduction project that shows what was working before and now doesn't?

Does this only happen on Android or also other platforms?

jfversluis avatar Apr 11 '24 08:04 jfversluis

@Chandrakalavaprani @LeDahu22 I've ran a few tests by changing the app theme on the device and changing it via the userapptheme property and both scenarios are working for me

If you have any specifics here that would be very helpful.

PureWeen avatar Apr 11 '24 16:04 PureWeen

@PureWeen

I am using Application.Current.RequestedTheme to get the System theme.

Steps to reproduce

  1. Run the App in Dark mode
  2. Kill the app
  3. Change the System settings to Light Mode
  4. Open the APP Bug here :- Application.Current.RequestedTheme is still Dark Kill the app again and open now the Application.Current.RequestedTheme gets correct value

My APP was initially in on .net7 framework , I switched to .net8 for this particular issue I am using Visual Studio Professional 17.9.5 Version

Chandrakalavaprani avatar Apr 11 '24 17:04 Chandrakalavaprani

@PureWeen

I am using Application.Current.RequestedTheme to get the System theme.

Steps to reproduce

  1. Run the App in Dark mode
  2. Kill the app
  3. Change the System settings to Light Mode
  4. Open the APP Bug here :- Application.Current.RequestedTheme is still Dark Kill the app again and open now the Application.Current.RequestedTheme gets correct value

My APP was initially in on .net7 framework , I switched to .net8 for this particular issue I am using Visual Studio Professional 17.9.5 Version

what version of MAUI are you on? did you update to 8.0.20? or are you just using the version that was installed with VS?

  1. Can you give me specifics on what device you are testing with and if possible a recording?

PureWeen avatar Apr 11 '24 18:04 PureWeen

Hi @PureWeen

I managed to reproduced the issue in a sample project i created : Public repo

I'm running on a physical device, using Android 11 (API 29), with VS 17.9.6.

The sample project currently uses MAUI 8.0.14, with .Net 8.0.4 (in order to demonstrate the regression)

Set system theme to dark mode first.

Steps to reproduce : 1 - Start debug 2 - Click on "Navigate to options" button 3 - Click on "Go to third page" button 4 - Go back to MainPage 5 - Use the button to change app theme 6 - Go back to third page 7 - Everything is fine !

Now, stop debug, make sure to clean your solution (or "git clean -fdx"), change both MAUI Nuget version to 8.0.20 in .csproj file and rebuild. Repeat steps 1 to 6 and see the result (all label in white theme don't switch to black, they remain in white.)

I don't know if it's a dependency injection related issue, but what was working with MAUI 8.0.14 is now broken with 8.0.20.

With 8.0.14 : image

With 8.0.20 : image

Thanks.

LeDahu22 avatar Apr 12 '24 08:04 LeDahu22

@PureWeen

Attaching here with maui workloads version installed on my machine

mauiworkloadsversion

Testing with Samsung Galaxy A53 5G, Has Android OS Version 14,

Chandrakalavaprani avatar Apr 12 '24 11:04 Chandrakalavaprani

@StephaneDelcroix

Since this is an issue , Do you know any alternative solution for it?

Chandrakalavaprani avatar Apr 15 '24 10:04 Chandrakalavaprani

note to self: it's quite strange that DynamicResource keep working, and AppTheme does not

StephaneDelcroix avatar Apr 16 '24 09:04 StephaneDelcroix

I can repro @LeDahu22 issue, not sure the one reported by @Chandrakalavaprani is the same...

StephaneDelcroix avatar Apr 16 '24 15:04 StephaneDelcroix

a potential fix for @LeDahu22 issue si here: #21879 but I wasn't able to produce a unit test (because reasons)

StephaneDelcroix avatar Apr 17 '24 13:04 StephaneDelcroix