google-developer-training / basic-android-kotlin-compose-training-woof

Apache License 2.0
55 stars 87 forks source link

Material Theming: Android Basics in Compose | status bar color for API 21 & 22 is still white on white #2

Open correabuscar opened 2 years ago

correabuscar commented 2 years ago

URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-compose-material-theming?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-3-pathway-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-material-theming#7

In which task and step of the codelab can this issue be found? in 8. [Optional] Change the status bar after 8. This creates a new themes.xml file called v23/themes.xml—this file is used for API levels 23 and above.

Describe the problem The situation when the device is using API level 21 and 22 with Light Theme isn't handled, therefore the status bar will remain white text on white background because it's using values/themes.xml which still has the code <item name="android:statusBarColor">@color/grey_50</item>

Versions Android Studio version:

Android Studio Electric Eel | 2022.1.1 Canary 9
Build #AI-221.5921.22.2211.8881706, built on July 28, 2022
Runtime version: 11.0.13+0-b1751.21-8125866 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.18.16-gentoo-x86_64
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 12
Registry:
    external.system.auto.import.disabled=true
    ide.text.editor.with.preview.show.floating.toolbar=false

Current Desktop: LXQt

API version of the emulator: 31.3.10-8807927

Additional information Include screenshots if they would be useful in clarifying the problem. whitestatusbar_screen-2022-08-07-20-31-21

I wonder what the solution would be, perhaps keeping whatever purple color was there before step 2 said Delete the contents of the <resources> tag. ? Because it doesn't seem possible to keep status bar color white and still have the status bar text changed in API 21 and 22, though I haven't looked it up and I'm a newbie in Android, so it might be possible... but if it is, I really want to know how, even if it means adding kotlin code to do it :)