Android: Set up Day/Night mode for system-compatible optional dark theme

This commit is contained in:
Parthiv Vora 2020-03-13 18:15:48 -04:00
parent bb7623e3ba
commit 5446e7b7d6
6 changed files with 19 additions and 10 deletions

View File

@ -81,7 +81,7 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
// Android TV UI libraries.
implementation 'androidx.leanback:leanback:1.0.0'

View File

@ -13,10 +13,11 @@
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_main"
android:background="?colorPrimary"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
app:popupTheme="@style/ThemeOverlay.AppCompat.DayNight"/>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs_platforms"

View File

@ -5,7 +5,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_settings"
android:background="@android:color/white"
android:background="?android:attr/colorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="FilePickerBaseTheme" parent="NNF_BaseTheme" />
</resources>

View File

@ -2,7 +2,7 @@
<resources>
<!-- Inherit from the material theme -->
<style name="DolphinBase" parent="Theme.AppCompat.Light.NoActionBar">
<style name="DolphinBase" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Main theme colors -->
<!-- Branding color for the app bar -->
<item name="colorPrimary">@color/dolphin_blue</item>
@ -19,7 +19,7 @@
</style>
<!-- Same as above, but use default action bar, and mandate margins. -->
<style name="DolphinSettingsBase" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="DolphinSettingsBase" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="colorPrimary">@color/dolphin_blue</item>
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
<item name="colorAccent">@color/dolphin_purple</item>
@ -29,7 +29,7 @@
<!-- Inherit from the Base Dolphin Dialog Theme -->
<style name="DolphinEmulationBase" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="DolphinEmulationBase" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="colorPrimary">@color/dolphin_blue</item>
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
<item name="colorAccent">@color/dolphin_purple</item>
@ -43,7 +43,7 @@
<item name="android:windowAllowReturnTransitionOverlap">true</item>
</style>
<style name="DolphinEmulationTvBase" parent="Theme.AppCompat.Light.NoActionBar">
<style name="DolphinEmulationTvBase" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="colorPrimary">@color/dolphin_blue</item>
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
<item name="colorAccent">@color/dolphin_purple</item>
@ -94,8 +94,8 @@
<item name="android:textColor">@color/button_text_color</item>
</style>
<!-- You can also inherit from NNF_BaseTheme.Light -->
<style name="FilePickerTheme" parent="NNF_BaseTheme.Light">
<!-- Inherit from a base file picker theme that handles day/night -->
<style name="FilePickerTheme" parent="FilePickerBaseTheme">
<item name="colorPrimary">@color/dolphin_blue</item>
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
<item name="colorAccent">@color/dolphin_accent_gamecube</item>
@ -111,7 +111,7 @@
<item name="nnf_toolbarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
<style name="FilePickerAlertDialogTheme" parent="Theme.AppCompat.Dialog.Alert">
<style name="FilePickerAlertDialogTheme" parent="Theme.AppCompat.DayNight.Dialog.Alert">
<item name="colorPrimary">@color/dolphin_blue</item>
<item name="colorPrimaryDark">@color/dolphin_blue_dark</item>
<item name="colorAccent">@color/dolphin_accent_gamecube</item>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="FilePickerBaseTheme" parent="NNF_BaseTheme.Light" />
</resources>