More theme fixes

Also Empty categories now hide with a filter on
This commit is contained in:
Jay 2020-03-22 13:51:34 -04:00
parent 30925053ab
commit ba30882291
8 changed files with 40 additions and 57 deletions

View File

@ -157,11 +157,18 @@ class LibraryPresenter(
val filterTracked = preferences.filterTracked().getOrDefault()
val filterMangaType by lazy { preferences.filterMangaType().getOrDefault() }
val filterMangaType = preferences.filterMangaType().getOrDefault()
val filterTrackers = FilterBottomSheet.FILTER_TRACKER
val filterFn: (LibraryItem) -> Boolean = f@{ item ->
if (item.manga.isBlank()) {
return@f filterDownloaded == 0 &&
filterUnread == 0 &&
filterCompleted == 0 &&
filterTracked == 0 &&
filterMangaType == 0
}
// Filter when there isn't unread chapters.
if (filterUnread == STATE_INCLUDE &&
(item.manga.unread == 0 || db.getChapters(item.manga).executeAsBlocking()

View File

@ -199,17 +199,13 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
supportActionBar?.setDisplayShowCustomEnabled(true)
content.setOnApplyWindowInsetsListener { v, insets ->
// if device doesn't support light nav bar
window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) {
// basically if in landscape on a phone
// For lollipop, draw opaque nav bar
if (v.rootWindowInsets.systemWindowInsetLeft > 0 || v.rootWindowInsets.systemWindowInsetRight > 0)
Color.BLACK
else Color.argb(179, 0, 0, 0)
}
/*else {
getColor(android.R.color.transparent)
}*/
// if the android q+ device has gesture nav, transparent nav bar
// this is here in case some crazy with a notch uses landscape
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && (v.rootWindowInsets.systemWindowInsetBottom != v.rootWindowInsets.tappableElementInsets.bottom)) {
@ -240,16 +236,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
)
bottom_nav.updatePadding(bottom = insets.systemWindowInsetBottom)
/*controller_container.updateLayoutParams<ConstraintLayout.LayoutParams> {
val attrsArray = intArrayOf(android.R.attr.actionBarSize)
val array = v.context.obtainStyledAttributes(attrsArray)
topMargin = insets.systemWindowInsetTop + array.getDimensionPixelSize(0, 0)
array.recycle()
}*/
/*nav_bar_scrim.updateLayoutParams<ViewGroup.MarginLayoutParams> {
height = 0//insets.systemWindowInsetBottom
}*/
insets.replaceSystemWindowInsets(
0, insets.systemWindowInsetTop, 0, insets.systemWindowInsetBottom
)
@ -257,12 +243,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
insets
}
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO && preferences.theme() >= 8) {
content.systemUiVisibility = content.systemUiVisibility.or(
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
)
}
// val drawerContainer: FrameLayout = findViewById(R.id.drawer_container)
router = Conductor.attachRouter(this, container, savedInstanceState)
if (!router.hasRootController()) {

View File

@ -23,8 +23,8 @@ import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.manga_header_item.*
import java.util.Locale
import kotlinx.android.synthetic.main.manga_header_item.*
class MangaHeaderHolder(
private val view: View,

View File

@ -7,6 +7,7 @@ import android.graphics.Bitmap
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.util.TypedValue
import android.view.Menu
import android.view.MenuItem
import android.view.View
@ -70,12 +71,8 @@ class WebViewActivity : BaseActivity() {
val container: ViewGroup = findViewById(R.id.web_view_layout)
val content: LinearLayout = findViewById(R.id.web_linear_layout)
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
container.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
container.setOnApplyWindowInsetsListener { v, insets ->
val contextView = window?.decorView?.findViewById<View>(R.id.action_mode_bar)
@ -98,11 +95,14 @@ class WebViewActivity : BaseActivity() {
refreshPage()
}
window.statusBarColor = ColorUtils.setAlphaComponent(getResourceColor(R.attr
.colorOnPrimary), 255)
content.setOnApplyWindowInsetsListener { v, insets ->
// if pure white theme on a device that does not support dark status bar
if (getResourceColor(android.R.attr.statusBarColor) != Color.TRANSPARENT)
/*if (getResourceColor(android.R.attr.statusBarColor) != Color.TRANSPARENT)
window.statusBarColor = Color.BLACK
else window.statusBarColor = getResourceColor(R.attr.colorPrimary)
else window.statusBarColor = getResourceColor(R.attr.colorPrimary)*/
window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
val colorPrimary = getResourceColor(android.R.attr.colorPrimary)
if (colorPrimary == Color.WHITE) Color.BLACK
@ -121,8 +121,6 @@ class WebViewActivity : BaseActivity() {
if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO) {
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
}
if (currentNightMode == Configuration.UI_MODE_NIGHT_NO && preferences.theme() >= 8)
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
insets
}
@ -192,8 +190,9 @@ class WebViewActivity : BaseActivity() {
super.onConfigurationChanged(newConfig)
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
val lightMode = currentNightMode == Configuration.UI_MODE_NIGHT_NO
window.statusBarColor = getResourceColor(R.attr.colorPrimary)
toolbar.setBackgroundColor(getResourceColor(R.attr.colorPrimary))
window.statusBarColor = ColorUtils.setAlphaComponent(getResourceColor(R.attr
.colorOnPrimary), 255)
toolbar.setBackgroundColor(getResourceColor(R.attr.colorOnPrimary))
toolbar.popupTheme = if (lightMode) R.style.ThemeOverlay_MaterialComponents else R
.style.ThemeOverlay_MaterialComponents_Dark
val tintColor = getResourceColor(R.attr.actionBarTintColor)
@ -214,9 +213,15 @@ class WebViewActivity : BaseActivity() {
web_linear_layout.systemUiVisibility = web_linear_layout.systemUiVisibility.or(View
.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR)
}
if (lightMode && preferences.theme() >= 8)
val typedValue = TypedValue()
theme.resolveAttribute(android.R.attr.windowLightStatusBar, typedValue, true)
if (typedValue.data == -1)
web_linear_layout.systemUiVisibility = web_linear_layout.systemUiVisibility
.or(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
else
web_linear_layout.systemUiVisibility = web_linear_layout.systemUiVisibility
.rem(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
invalidateOptionsMenu()
}

View File

@ -19,7 +19,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:background="?attr/colorOnPrimary"
android:theme="?attr/actionBarTheme"
app:navigationIcon="@drawable/ic_close_white_24dp"
app:layout_scrollFlags="scroll|enterAlways|snap" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.Tachiyomi" parent="Theme.Base">
<item name="android:windowLightStatusBar">false</item>
@ -39,11 +39,4 @@
<item name="md_background_color">@color/colorAmoledPrimary</item>
<item name="md_corner_radius">16dp</item>
</style>
<style name="Theme.Splash" parent="Theme.Tachiyomi">
<item name="android:windowBackground">@drawable/splash_background</item>
<item name="android:statusBarColor">@color/splashBackground</item>
<item name="android:navigationBarColor">@color/splashBackground</item>
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Tachiyomi" parent="Theme.Base">
<item name="android:navigationBarColor">@color/oldNavBarBackground</item>
</style>
</resources>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<!--============-->
<!-- Base Theme -->
@ -7,7 +7,7 @@
<style name="Theme"/>
<style name="Theme.Base" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:forceDarkAllowed">false</item>
<item name="android:forceDarkAllowed" tools:targetApi="29">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/background</item>
@ -59,6 +59,7 @@
<item name="md_button_casing">literal</item>
<item name="md_corner_radius">16dp</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
</style>
<style name="Theme.Tachiyomi" parent="Theme.Base"/>
@ -72,13 +73,14 @@
<item name="actionBarTintColor">@color/md_white_1000</item>
<item name="actionBarTheme">@style/Theme.ActionBar.Dark.DayNight</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
</style>
<style name="Theme.Tachiyomi.Amoled" parent="Theme.Tachiyomi"/>
<!--==============-->
<!-- Reader Theme -->
<!--==============-->
<style name="Theme.Base.Reader" parent="Theme.Base">
<item name="android:forceDarkAllowed">false</item>
<item name="android:forceDarkAllowed" tools:targetApi="29">false</item>
<item name="colorPrimary">@color/darkPrimaryTranslucent</item>
<item name="colorPrimaryDark">@color/darkPrimaryTranslucent</item>
<item name="android:colorBackground">@android:color/white</item>
@ -87,10 +89,11 @@
<item name="android:statusBarColor">?colorPrimaryDark</item>
<item name="android:navigationBarColor">?colorPrimaryDark</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
</style>
<style name="Theme.Base.Reader.Dark" parent="Theme.MaterialComponents.NoActionBar">
<item name="android:forceDarkAllowed">false</item>
<item name="android:forceDarkAllowed" tools:targetApi="29">false</item>
<item name="colorPrimary">@color/darkPrimaryTranslucent</item>
<item name="colorPrimaryDark">@color/darkPrimaryTranslucent</item>
<item name="android:colorBackground">@android:color/black</item>
@ -129,7 +132,7 @@
</style>
<style name="Theme.Base.Reader.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:forceDarkAllowed">false</item>
<item name="android:forceDarkAllowed" tools:targetApi="29">false</item>
<item name="colorPrimary">@color/darkPrimaryTranslucent</item>
<item name="colorPrimaryDark">@color/darkPrimaryTranslucent</item>
<item name="android:colorBackground">@android:color/white</item>
@ -171,6 +174,7 @@
<item name="android:windowBackground">@drawable/splash_background</item>
<item name="android:statusBarColor">@color/splashBackground</item>
<item name="android:navigationBarColor">@color/splashBackground</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
</style>
</resources>