Pure white light theme

This commit is contained in:
arkon 2020-03-14 13:18:34 -04:00
parent 738f776d36
commit e41edc1fb7
17 changed files with 133 additions and 39 deletions

View File

@ -26,7 +26,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/Theme.Tachiyomi">
android:theme="@style/Theme.Tachiyomi.Light">
<activity
android:name=".ui.main.MainActivity"
android:launchMode="singleTop"

View File

@ -7,6 +7,8 @@ object PreferenceKeys {
const val themeMode = "pref_theme_mode_key"
const val themeLight = "pref_theme_light_key"
const val themeDark = "pref_theme_dark_key"
const val rotation = "pref_rotation_type_key"

View File

@ -9,6 +9,9 @@ object PreferenceValues {
const val THEME_MODE_DARK = "dark"
const val THEME_MODE_SYSTEM = "system"
const val THEME_LIGHT_DEFAULT = "default"
const val THEME_LIGHT_BLUE = "blue"
const val THEME_DARK_DEFAULT = "default"
const val THEME_DARK_BLUE = "blue"
const val THEME_DARK_AMOLED = "amoled"

View File

@ -65,7 +65,9 @@ class PreferencesHelper(val context: Context) {
fun themeMode() = rxPrefs.getString(Keys.themeMode, Values.THEME_MODE_SYSTEM)
fun themeDark() = prefs.getString(Keys.themeDark, Values.THEME_DARK_DEFAULT)
fun themeLight() = prefs.getString(Keys.themeLight, Values.THEME_DARK_DEFAULT)
fun themeDark() = prefs.getString(Keys.themeDark, Values.THEME_LIGHT_DEFAULT)
fun rotation() = rxPrefs.getInteger(Keys.rotation, 1)

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.base.activity
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import eu.kanade.tachiyomi.R
@ -18,11 +19,33 @@ abstract class BaseActivity : AppCompatActivity() {
@Suppress("LeakingThis")
private val secureActivityDelegate = SecureActivityDelegate(this)
private val lightTheme: Int by lazy {
when (preferences.themeLight()) {
Values.THEME_LIGHT_BLUE -> R.style.Theme_Tachiyomi_LightBlue
else -> {
when {
// Light status + navigation bar
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 -> {
R.style.Theme_Tachiyomi_Light_Api27
}
// Light status bar + fallback gray navigation bar
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
R.style.Theme_Tachiyomi_Light_Api23
}
// Fallback gray status + navigation bar
else -> {
R.style.Theme_Tachiyomi_Light
}
}
}
}
}
private val darkTheme: Int by lazy {
when (preferences.themeDark()) {
Values.THEME_DARK_DEFAULT -> R.style.Theme_Tachiyomi_Dark
Values.THEME_DARK_BLUE -> R.style.Theme_Tachiyomi_DarkBlue
Values.THEME_DARK_AMOLED -> R.style.Theme_Tachiyomi_Amoled
else -> R.style.Theme_Tachiyomi_DarkBlue
else -> R.style.Theme_Tachiyomi_Dark
}
}
@ -33,15 +56,15 @@ abstract class BaseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(when (preferences.themeMode().getOrDefault()) {
Values.THEME_MODE_DARK -> darkTheme
Values.THEME_MODE_SYSTEM -> {
if (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES) {
darkTheme
} else {
R.style.Theme_Tachiyomi
lightTheme
}
}
else -> R.style.Theme_Tachiyomi
Values.THEME_MODE_DARK -> darkTheme
else -> lightTheme
})
super.onCreate(savedInstanceState)

View File

@ -118,6 +118,28 @@ class SettingsGeneralController : SettingsController() {
true
}
}
listPreference {
key = Keys.themeLight
titleRes = R.string.pref_theme_light
entriesRes = arrayOf(
R.string.theme_light_default,
R.string.theme_light_blue)
entryValues = arrayOf(
Values.THEME_LIGHT_DEFAULT,
Values.THEME_LIGHT_BLUE)
defaultValue = Values.THEME_LIGHT_DEFAULT
summary = "%s"
preferences.themeMode().asObservable()
.subscribeUntilDestroy { isVisible = it != Values.THEME_MODE_DARK }
onChange {
if (preferences.themeMode().getOrDefault() == Values.THEME_MODE_LIGHT) {
activity?.recreate()
}
true
}
}
listPreference {
key = Keys.themeDark
titleRes = R.string.pref_theme_dark

View File

@ -10,7 +10,7 @@
android:id="@+id/title_background"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall"
android:background="?colorPrimary"
android:background="?attr/colorPrimary"
android:elevation="2dp"
android:gravity="center_vertical"
android:orientation="horizontal"
@ -25,7 +25,7 @@
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@color/textColorPrimaryDark"
android:textColor="?attr/colorOnPrimary"
tools:text="Title" />
</LinearLayout>

View File

@ -12,7 +12,7 @@
android:layout_height="match_parent"
android:background="@drawable/list_item_selector"
android:padding="8dp"
android:tint="?colorAccent"
android:tint="?attr/colorAccent"
app:srcCompat="@drawable/ic_chevron_left_double_black_24dp" />
<androidx.appcompat.widget.AppCompatImageButton
@ -21,7 +21,7 @@
android:layout_height="match_parent"
android:background="@drawable/list_item_selector"
android:padding="8dp"
android:tint="?colorAccent"
android:tint="?attr/colorAccent"
app:srcCompat="@drawable/ic_chevron_left_black_24dp" />
<EditText
@ -39,7 +39,7 @@
android:layout_height="match_parent"
android:background="@drawable/list_item_selector"
android:padding="8dp"
android:tint="?colorAccent"
android:tint="?attr/colorAccent"
app:srcCompat="@drawable/ic_chevron_right_black_24dp" />
<androidx.appcompat.widget.AppCompatImageButton
@ -48,7 +48,7 @@
android:layout_height="match_parent"
android:background="@drawable/list_item_selector"
android:padding="8dp"
android:tint="?colorAccent"
android:tint="?attr/colorAccent"
app:srcCompat="@drawable/ic_chevron_right_double_black_24dp" />
</LinearLayout>

View File

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall"
android:background="?colorPrimary"
android:background="?attr/colorPrimary"
android:elevation="2dp"
android:gravity="center_vertical"
android:orientation="horizontal"
@ -18,7 +18,7 @@
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="@color/textColorPrimaryDark"
android:textColor="?attr/colorOnPrimary"
tools:text="Header" />
<ImageView

View File

@ -52,14 +52,14 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?colorPrimary" />
android:background="?attr/colorPrimary" />
<LinearLayout
android:id="@+id/reader_menu_bottom"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:background="?colorPrimary"
android:background="?attr/colorPrimary"
android:descendantFocusability="blocksDescendants"
android:gravity="center"
android:orientation="horizontal">

View File

@ -14,6 +14,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1" />
android:maxLines="1"
android:textColor="?attr/colorOnPrimary" />
</FrameLayout>

View File

@ -4,7 +4,7 @@
<!--===============-->
<!-- Launch Screen -->
<!--===============-->
<style name="Theme.Splash" parent="Theme.Tachiyomi">
<style name="Theme.Splash" parent="Theme.Tachiyomi.Dark">
<item name="colorBackgroundSplash">@color/backgroundDark</item>
<item name="android:windowBackground">@drawable/splash_background</item>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Tachiyomi.Light.Api23">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Tachiyomi.Light.Api27">
<item name="android:statusBarColor">@color/md_white_1000</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:navigationBarColor">@color/md_white_1000</item>
<item name="android:windowLightNavigationBar">true</item>
</style>
</resources>

View File

@ -38,7 +38,8 @@
<color name="pageNumberBackgroundLight">@color/md_grey_50_75</color>
<color name="pageNumberBackgroundDark">@color/md_grey_900_75</color>
<color name="filterColor">#FFEE07</color>
<color name="filterColorLight">#FFC107</color>
<color name="filterColorDark">#FFEB3B</color>
<!-- Text Colors -->
<color name="md_black_1000_87">#DE000000</color>

View File

@ -125,6 +125,9 @@
<string name="theme_light">Light</string>
<string name="theme_dark">Dark</string>
<string name="theme_system">Follow system</string>
<string name="pref_theme_light">Light theme variant</string>
<string name="theme_light_default">Default</string>
<string name="theme_light_blue">Light blue</string>
<string name="pref_theme_dark">Dark theme variant</string>
<string name="theme_dark_default">Default</string>
<string name="theme_dark_blue">Dark blue</string>

View File

@ -15,11 +15,11 @@
<item name="windowNoTitle">true</item>
<!-- Theme colors -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/textColorPrimaryDark</item>
<item name="colorPrimaryDark">@color/colorPrimary</item>
<item name="colorPrimary">@color/md_white_1000</item>
<item name="colorOnPrimary">@color/md_black_1000</item>
<item name="colorPrimaryDark">@color/md_white_1000</item>
<item name="colorSecondary">@color/colorAccentLight</item>
<item name="colorOnSecondary">@color/textColorPrimaryDark</item>
<item name="colorOnSecondary">@color/md_white_1000</item>
<item name="colorSurface">@color/dialogLight</item>
<item name="colorOnSurface">@color/textColorPrimaryLight</item>
<item name="colorOnBackground">@color/textColorPrimaryLight</item>
@ -43,31 +43,41 @@
<item name="android:textDirection">locale</item>
<!-- Themes -->
<item name="android:forceDarkAllowed">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionBarTheme">@style/Theme.ActionBar.Light</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.MaterialComponents</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
<item name="dialogTheme">@style/Theme.AlertDialog.Light</item>
<item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
<!-- Intentially using default snackbar background in light theme -->
<!-- <item name="snackbarStyle">@style/Theme.Widget.Snackbar</item> -->
<item name="snackbarButtonStyle">@style/Theme.Widget.Button.Borderless</item>
<item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item>
<item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
<!-- Custom Attributes-->
<item name="selectable_library_drawable">@drawable/library_item_selector_light</item>
<item name="colorFilterActive">@color/filterColor</item>
<item name="colorFilterActive">@color/filterColorDark</item>
</style>
<!--===========-->
<!-- Main Theme-->
<!--===========-->
<style name="Theme.Tachiyomi" parent="Theme.Base">
<style name="Theme.Tachiyomi.Light" parent="Theme.Base">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/md_black_1000_54</item>
<item name="android:navigationBarColor">@color/md_black_1000_54</item>
<item name="colorFilterActive">@color/filterColorLight</item>
</style>
<style name="Theme.Tachiyomi.LightBlue" parent="Theme.Base">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@color/colorPrimary</item>
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/textColorPrimaryDark</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="actionBarTheme">@style/Theme.ActionBar.Light</item>
</style>
<!--=============-->
@ -107,14 +117,12 @@
<item name="android:navigationBarColor">@color/colorDarkPrimary</item>
<!-- Themes -->
<item name="android:forceDarkAllowed">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionBarTheme">@style/ThemeOverlay.MaterialComponents.Dark.ActionBar</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.MaterialComponents</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
<item name="dialogTheme">@style/Theme.AlertDialog.Dark</item>
<item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
<item name="snackbarStyle">@style/Theme.Widget.Snackbar</item>
<item name="snackbarButtonStyle">@style/Theme.Widget.Button.Borderless</item>
<item name="textAppearanceButton">@style/TextAppearance.Widget.Button</item>
<item name="android:itemTextAppearance">@style/TextAppearance.Widget.Menu</item>
@ -123,7 +131,7 @@
<!-- Custom Attributes-->
<item name="selectable_library_drawable">@drawable/library_item_selector_dark</item>
<item name="colorFilterActive">@color/filterColor</item>
<item name="colorFilterActive">@color/filterColorDark</item>
</style>
<style name="Theme.Tachiyomi.Dark" parent="Theme.Base.Dark">
@ -150,6 +158,8 @@
<item name="android:navigationBarColor">@android:color/transparent</item>
<!-- Themes -->
<!-- Surface-colored snackbar -->
<item name="snackbarStyle">@style/Theme.Widget.Snackbar</item>
<item name="md_background_color">@color/colorAmoledPrimary</item>
<!-- Custom Attributes-->
@ -166,21 +176,27 @@
<style name="Theme.Base.Reader.Dark" parent="Theme.Base.Dark">
<item name="colorPrimary">@color/readerColorDarkPrimary</item>
<item name="colorPrimaryDark">@color/readerColorDarkPrimary</item>
<item name="colorSurface">@android:color/black</item>
<item name="colorSurface">@color/md_black_1000</item>
<item name="android:colorBackground">@android:color/black</item>
<item name="android:colorBackground">@color/md_black_1000</item>
<item name="android:statusBarColor">?attr/colorPrimaryDark</item>
<item name="android:navigationBarColor">?attr/colorPrimaryDark</item>
<item name="actionBarTheme">@style/ThemeOverlay.MaterialComponents.Dark.ActionBar</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.MaterialComponents</item>
</style>
<style name="Theme.Base.Reader.Light" parent="Theme.Base">
<item name="colorPrimary">@color/readerColorDarkPrimary</item>
<item name="colorPrimaryDark">@color/readerColorDarkPrimary</item>
<item name="colorSurface">@android:color/white</item>
<item name="colorSurface">@color/md_white_1000</item>
<item name="android:colorBackground">@android:color/white</item>
<item name="android:colorBackground">@color/md_white_1000</item>
<item name="android:statusBarColor">?attr/colorPrimaryDark</item>
<item name="android:navigationBarColor">?attr/colorPrimaryDark</item>
<item name="actionBarTheme">@style/ThemeOverlay.MaterialComponents.Dark.ActionBar</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.MaterialComponents</item>
</style>
<style name="Theme.Reader" parent="Theme.Base.Reader.Dark">
@ -195,7 +211,7 @@
<!--===============-->
<!-- Launch Screen -->
<!--===============-->
<style name="Theme.Splash" parent="Theme.Tachiyomi">
<style name="Theme.Splash" parent="Theme.Tachiyomi.LightBlue">
<item name="colorBackgroundSplash">@color/colorPrimary</item>
<item name="android:windowBackground">@drawable/splash_background</item>