Dark Theme based on system
This commit is contained in:
parent
b4b78e0f6b
commit
c0e4b9bb38
@ -3,12 +3,18 @@ package eu.kanade.tachiyomi.ui.main
|
||||
import android.animation.ObjectAnimator
|
||||
import android.app.SearchManager
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.support.v4.view.GravityCompat
|
||||
import android.support.v4.widget.DrawerLayout
|
||||
import android.support.v7.app.AppCompatDelegate
|
||||
import android.support.v7.app.AppCompatDelegate.*
|
||||
import android.support.v7.graphics.drawable.DrawerArrowDrawable
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowInsets
|
||||
import android.widget.LinearLayout
|
||||
import com.bluelinelabs.conductor.*
|
||||
import eu.kanade.tachiyomi.Migrations
|
||||
import eu.kanade.tachiyomi.R
|
||||
@ -50,10 +56,14 @@ class MainActivity : BaseActivity() {
|
||||
lateinit var tabAnimator: TabsAnimator
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDefaultNightMode(when (preferences.theme()) {
|
||||
1 -> MODE_NIGHT_NO
|
||||
2, 3, 4 -> MODE_NIGHT_YES
|
||||
else -> MODE_NIGHT_FOLLOW_SYSTEM
|
||||
})
|
||||
setTheme(when (preferences.theme()) {
|
||||
2 -> R.style.Theme_Tachiyomi_Dark
|
||||
3 -> R.style.Theme_Tachiyomi_Amoled
|
||||
4 -> R.style.Theme_Tachiyomi_DarkBlue
|
||||
3, 6 -> R.style.Theme_Tachiyomi_Amoled
|
||||
4, 7 -> R.style.Theme_Tachiyomi_DarkBlue
|
||||
else -> R.style.Theme_Tachiyomi
|
||||
})
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -63,7 +73,7 @@ class MainActivity : BaseActivity() {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
//AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO)
|
||||
setContentView(R.layout.main_activity)
|
||||
|
||||
setSupportActionBar(toolbar)
|
||||
@ -103,6 +113,15 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
val container: ViewGroup = findViewById(R.id.controller_container)
|
||||
|
||||
val content: LinearLayout = findViewById(R.id.main_content)
|
||||
container.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
content.setOnApplyWindowInsetsListener(NoopWindowInsetsListener)
|
||||
|
||||
router = Conductor.attachRouter(this, container, savedInstanceState)
|
||||
if (!router.hasRootController()) {
|
||||
// Set start screen
|
||||
@ -280,3 +299,17 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
object NoopWindowInsetsListener : View.OnApplyWindowInsetsListener {
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||
v.setPadding(0,insets.systemWindowInsetTop,0,0)
|
||||
return insets
|
||||
}
|
||||
}
|
||||
|
||||
object NoopWindowInsetsListener2 : View.OnApplyWindowInsetsListener {
|
||||
override fun onApplyWindowInsets(v: View, insets: WindowInsets): WindowInsets {
|
||||
v.setPadding(0,0,0,insets.systemWindowInsetBottom)
|
||||
return insets
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.support.v7.app.AppCompatDelegate
|
||||
import android.support.v7.preference.PreferenceScreen
|
||||
import android.view.View
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
@ -53,12 +55,18 @@ class SettingsGeneralController : SettingsController() {
|
||||
key = Keys.theme
|
||||
titleRes = R.string.pref_theme
|
||||
entriesRes = arrayOf(R.string.light_theme, R.string.dark_theme,
|
||||
R.string.amoled_theme, R.string.darkblue_theme)
|
||||
entryValues = arrayOf("1", "2", "3", "4")
|
||||
defaultValue = "1"
|
||||
R.string.amoled_theme, R.string.darkblue_theme,
|
||||
R.string.system_theme, R.string.system_amoled_theme, R.string.system_darkblue_theme)
|
||||
entryValues = arrayOf("1", "2", "3", "4", "5", "6", "7")
|
||||
defaultValue = "5"
|
||||
summary = "%s"
|
||||
|
||||
onChange {
|
||||
onChange {newValue ->
|
||||
AppCompatDelegate.setDefaultNightMode(when (newValue) {
|
||||
"1" -> AppCompatDelegate.MODE_NIGHT_NO
|
||||
"2", "3", "4" -> AppCompatDelegate.MODE_NIGHT_YES
|
||||
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
})
|
||||
activity?.recreate()
|
||||
true
|
||||
}
|
||||
|
@ -178,13 +178,14 @@ object ImageUtil {
|
||||
darkBG = false
|
||||
if (topIsBlackStreak && bottomIsBlackStreak)
|
||||
darkBG = true
|
||||
val whiteColor = android.R.attr.colorBackground
|
||||
if (darkBG) {
|
||||
if (isWhite(image.getPixel(left, bot)) && isWhite(image.getPixel(right, bot)))
|
||||
return GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(blackPixel, blackPixel, Color.WHITE, Color.WHITE))
|
||||
intArrayOf(blackPixel, blackPixel, whiteColor, whiteColor))
|
||||
else if (isWhite(image.getPixel(left, top)) && isWhite(image.getPixel(right, top)))
|
||||
return GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(Color.WHITE, Color.WHITE, blackPixel, blackPixel))
|
||||
intArrayOf(whiteColor, whiteColor, blackPixel, blackPixel))
|
||||
else
|
||||
return ColorDrawable(blackPixel)
|
||||
}
|
||||
@ -192,13 +193,13 @@ object ImageUtil {
|
||||
&& isDark(image.getPixel(left - offsetX, top)) && isDark(image.getPixel(right + offsetX, top))
|
||||
&& (topMidIsDark || overallBlackPixels > 9)))
|
||||
return GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(blackPixel, blackPixel, Color.WHITE, Color.WHITE))
|
||||
intArrayOf(blackPixel, blackPixel, whiteColor, whiteColor))
|
||||
else if (bottomIsBlackStreak || (botLeftIsDark && botRightIsDark
|
||||
&& isDark(image.getPixel(left - offsetX, bot)) && isDark(image.getPixel(right + offsetX, bot))
|
||||
&& (isDark(image.getPixel(midX, bot)) || overallBlackPixels > 9)))
|
||||
return GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM,
|
||||
intArrayOf(Color.WHITE, Color.WHITE, blackPixel, blackPixel))
|
||||
return ColorDrawable(Color.WHITE)
|
||||
intArrayOf(whiteColor, whiteColor, blackPixel, blackPixel))
|
||||
return ColorDrawable(whiteColor)
|
||||
}
|
||||
|
||||
fun Boolean.toInt() = if (this) 1 else 0
|
||||
|
@ -11,6 +11,7 @@
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<eu.kanade.tachiyomi.widget.ElevationAppBarLayout
|
||||
|
71
app/src/main/res/values-night/themes.xml
Normal file
71
app/src/main/res/values-night/themes.xml
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.Base" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorDarkPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccentDark</item>
|
||||
<item name="android:textColorPrimary">@color/textColorPrimaryDark</item>
|
||||
<item name="android:textColorSecondary">@color/textColorSecondaryDark</item>
|
||||
<item name="android:textColorHint">@color/textColorHintDark</item>
|
||||
<item name="android:textColorPrimaryInverse">@color/textColorPrimaryLight</item>
|
||||
<item name="android:textColorSecondaryInverse">@color/textColorSecondaryLight</item>
|
||||
<item name="android:textColorHintInverse">@color/textColorHintLight</item>
|
||||
<item name="android:colorBackground">@color/backgroundDark</item>
|
||||
<item name="android:listSelector">?colorAccent</item>
|
||||
<item name="android:divider">@color/dividerDark</item>
|
||||
<item name="android:listDivider">@drawable/line_divider_dark</item>
|
||||
|
||||
<!-- Themes -->
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
||||
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.Material</item>
|
||||
<item name="md_background_color">@color/dialogDark</item>
|
||||
<item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
|
||||
|
||||
|
||||
<!-- Custom Attributes-->
|
||||
<item name="navigation_view_theme">@style/Theme.Widget.NavigationView.Dark</item>
|
||||
<item name="selectable_list_drawable">@drawable/list_item_selector_dark</item>
|
||||
<item name="selectable_library_drawable">@drawable/library_item_selector_dark</item>
|
||||
<item name="text_color_primary">@color/textColorPrimaryDark</item>
|
||||
<item name="background_card">@color/dialogDark</item>
|
||||
<item name="icon_color">@color/iconColorDark</item>
|
||||
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@color/colorDarkPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi" parent="Theme.Base">
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@color/colorDarkPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Base.Reader.Light" parent="Theme.Base">
|
||||
<item name="colorPrimary">@color/colorDarkPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimaryDark</item>
|
||||
<item name="android:colorBackground">@color/backgroundDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<!--==============-->
|
||||
<!-- Amoled Theme -->
|
||||
<!--==============-->
|
||||
<style name="Theme.Base.Amoled" parent="Theme.Base">
|
||||
<item name="colorPrimary">@color/colorAmoledPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorAmoledPrimary</item>
|
||||
<item name="android:colorBackground">@color/md_black_1000</item>
|
||||
|
||||
<!-- Custom Attributes-->
|
||||
<item name="selectable_list_drawable">@drawable/list_item_selector_amoled</item>
|
||||
<item name="selectable_library_drawable">@drawable/library_item_selector_amoled</item>
|
||||
<item name="background_card">@color/dialog_amoled</item>
|
||||
</style>
|
||||
</resources>
|
@ -10,17 +10,7 @@
|
||||
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<!--=============-->
|
||||
<!-- Dark Themes -->
|
||||
<!--=============-->
|
||||
<style name="Theme.Tachiyomi.Dark" parent="Theme.Base.Dark">
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@color/colorDarkPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base.Dark">
|
||||
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
|
||||
|
28
app/src/main/res/values-v29/themes.xml
Normal file
28
app/src/main/res/values-v29/themes.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- values-v29/themes.xml -->
|
||||
<style name="Theme.Tachiyomi" parent="Theme.Base">
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<!--==============-->
|
||||
<!-- Amoled Theme -->
|
||||
<!--==============-->
|
||||
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Base.Amoled">
|
||||
<!-- Attributes specific for SDK 21 and up -->
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
</resources>
|
@ -143,6 +143,9 @@
|
||||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="amoled_theme">AMOLED theme</string>
|
||||
<string name="darkblue_theme">Dark blue</string>
|
||||
<string name="system_theme">System default</string>
|
||||
<string name="system_amoled_theme">System default (AMOLED)</string>
|
||||
<string name="system_darkblue_theme">System default (Dark blue)</string>
|
||||
<string name="pref_start_screen">Start screen</string>
|
||||
<string name="pref_language">Language</string>
|
||||
<string name="system_default">System default</string>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<!--==============-->
|
||||
<!-- Light Themes -->
|
||||
<!--=======-======-->
|
||||
<style name="Theme.Base" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<style name="Theme.Base" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccentLight</item>
|
||||
@ -43,73 +43,10 @@
|
||||
<!-- Attributes specific for SDK 16 to SDK 20 -->
|
||||
</style>
|
||||
|
||||
<!--=============-->
|
||||
<!-- Dark Themes -->
|
||||
<!--=============-->
|
||||
<style name="Theme.Base.Dark" parent="Theme.AppCompat.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorDarkPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccentDark</item>
|
||||
<item name="android:textColorPrimary">@color/textColorPrimaryDark</item>
|
||||
<item name="android:textColorSecondary">@color/textColorSecondaryDark</item>
|
||||
<item name="android:textColorHint">@color/textColorHintDark</item>
|
||||
<item name="android:textColorPrimaryInverse">@color/textColorPrimaryLight</item>
|
||||
<item name="android:textColorSecondaryInverse">@color/textColorSecondaryLight</item>
|
||||
<item name="android:textColorHintInverse">@color/textColorHintLight</item>
|
||||
<item name="android:colorBackground">@color/backgroundDark</item>
|
||||
<item name="android:listSelector">?colorAccent</item>
|
||||
<item name="android:divider">@color/dividerDark</item>
|
||||
<item name="android:listDivider">@drawable/line_divider_dark</item>
|
||||
|
||||
<!-- Themes -->
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
||||
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay.Material</item>
|
||||
<item name="md_background_color">@color/dialogDark</item>
|
||||
<item name="alertDialogTheme">@style/Theme.AlertDialog.Dark</item>
|
||||
|
||||
|
||||
<!-- Custom Attributes-->
|
||||
<item name="navigation_view_theme">@style/Theme.Widget.NavigationView.Dark</item>
|
||||
<item name="selectable_list_drawable">@drawable/list_item_selector_dark</item>
|
||||
<item name="selectable_library_drawable">@drawable/library_item_selector_dark</item>
|
||||
<item name="text_color_primary">@color/textColorPrimaryDark</item>
|
||||
<item name="background_card">@color/dialogDark</item>
|
||||
<item name="icon_color">@color/iconColorDark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi.Dark" parent="Theme.Base.Dark">
|
||||
<!-- Attributes specific for SDK 16 to SDK 20 -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi.DarkBlue" parent="Theme.Base.Dark">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<!--==============-->
|
||||
<!-- Amoled Theme -->
|
||||
<!--==============-->
|
||||
<style name="Theme.Base.Amoled" parent="Theme.Base.Dark">
|
||||
<item name="colorPrimary">@color/colorAmoledPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorAmoledPrimary</item>
|
||||
<item name="android:colorBackground">@color/md_black_1000</item>
|
||||
|
||||
<!-- Custom Attributes-->
|
||||
<item name="selectable_list_drawable">@drawable/list_item_selector_amoled</item>
|
||||
<item name="selectable_library_drawable">@drawable/library_item_selector_amoled</item>
|
||||
<item name="background_card">@color/dialog_amoled</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Base.Amoled">
|
||||
<!-- Attributes specific for SDK 16 to SDK 20 -->
|
||||
</style>
|
||||
|
||||
<!--==============-->
|
||||
<!-- Reader Theme -->
|
||||
<!--==============-->
|
||||
<style name="Theme.Base.Reader.Dark" parent="Theme.Base.Dark">
|
||||
<style name="Theme.Base.Reader.Dark" parent="Theme.Base">
|
||||
<item name="colorPrimary">@color/colorDarkPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorDarkPrimaryDark</item>
|
||||
<item name="android:colorBackground">@android:color/black</item>
|
||||
|
Loading…
Reference in New Issue
Block a user