I know this was discussed a bit before (i remember...
# compose
c
I know this was discussed a bit before (i remember talking about it in the dev preview) but did anything ever update from what the default theme should be for a compose only app? I currently use
Copy code
<style name="Theme.My.App" parent="android:Theme.Material.NoActionBar" />
I think Chris Banes was talking about this sort of stuff last, but yeah. Just curious if theres a way to use non-appcompat theme (so no appcompat dependency) but have a DayNight theme? because I don't want to bring in appcompat, but it looks like Theme.Material.* doesn't have any daynight variation. I think
a
Realistically, you can use v21 Material since compose is v21+, just setting up day/night resource qualifiers
c
Wouldn't that mean that my launch theme/androidx.splash screen can't adapt to day night though? right now if i launch my app, the bright white in the launch theme is blinding even though the phone is in night mode. I was able to fix that when using appcompat dayNight
So now my design team has a bug opened against my app, and im not sure what to do. 🙃
a
Create day/night resource qualifiers for that too
That’s what I’m doing anyway
Copy code
<style name="Theme.RealPage.Raul.Base" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="android:windowBackground">#FFFFFFFF</item>
        <item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
        <item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
    </style>

    <style name="Theme.RealPage.Raul" parent="Theme.RealPage.Raul.Base">
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:navigationBarColor">@android:color/transparent</item>
    </style>

    <style name="Theme.RealPage.Raul.Splash" parent="Theme.SplashScreen">
        <item name="postSplashScreenTheme">@style/Theme.RealPage.Raul</item>
        <item name="windowSplashScreenBackground">#FFFFFFFF</item>
        <item name="android:windowSplashScreenBrandingImage" tools:targetApi="s">@drawable/ui_splash_realpage_logo</item>

        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:navigationBarColor">@android:color/transparent</item>

        <item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
        <item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
    </style>
Copy code
<style name="Theme.RealPage.Raul.Base" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="android:windowBackground">#FF202737</item>
        <item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
        <item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
    </style>

    <style name="Theme.RealPage.Raul.Splash" parent="Theme.SplashScreen">
        <item name="postSplashScreenTheme">@style/Theme.RealPage.Raul</item>
        <item name="windowSplashScreenBackground">#FF202737</item>
        <item name="android:windowSplashScreenBrandingImage" tools:targetApi="s">@drawable/ui_splash_realpage_logo</item>

        <item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
        <item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
    </style>
c
But you're using AppCompat?
I don't have appCompat in my app.
a
You can swap that out for Theme.Material
c
That's what I'm saying though. Theme.Material doesn't have DayNight.
Unless Im missing something here...
a
Define your base theme in both values and values-night
And the parent will be Theme.Material.Light for normal values
And for values-night use Theme.Material
c
Ah gotcha. Lemme try to check that out when I get back to my desk.
a
Cool beans 👍🏻
c
You can also depend on the Material library for views which has DayNight themes: https://material.io/develop/android/theming/dark
Because yeah, I've seen that bright flash as well without a proper Activity theme mapped to some dark colors 😬
c
Interesting. So out of the box tho. For compose there's no daynight theme available. Maybe I'll file a bug. I kinda don't know if it's purposeful or not from the Android team I suppose
a
Compose itself is independent of the view system, so there is no theme there
You can use whatever theme you need to, tailoring it to how you need to suit your app
c
Cool. So it seems like nothing has really changed on this front.
a
Even if a DayNight theme is added now, it can only be used on Android 13+ as it must be added to Android platform itself instead of a support library.
✔️ 1
c
Ah. alright.
android:
means it comes from the platform?
has material been around that long already?
a
Yes, since Lolipop, so around 2014
c
wow. so material is around for 50% of androids lifetime roughly. insane. time flies!!!