From ba30882291aa21c90f78605ed37f2cb3878f289d Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 22 Mar 2020 13:51:34 -0400 Subject: [PATCH] More theme fixes Also Empty categories now hide with a filter on --- .../tachiyomi/ui/library/LibraryPresenter.kt | 9 +++++- .../kanade/tachiyomi/ui/main/MainActivity.kt | 22 +------------ .../tachiyomi/ui/manga/MangaHeaderHolder.kt | 2 +- .../tachiyomi/ui/webview/WebViewActivity.kt | 31 +++++++++++-------- app/src/main/res/layout/webview_activity.xml | 2 +- app/src/main/res/values-night/themes.xml | 9 +----- app/src/main/res/values-v26/themes.xml | 6 ---- app/src/main/res/values/themes.xml | 16 ++++++---- 8 files changed, 40 insertions(+), 57 deletions(-) delete mode 100644 app/src/main/res/values-v26/themes.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index e22477ba3a..4c5a019df4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -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() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 67bb6a83ef..d94b501eeb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -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 { - 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 { - 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()) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt index 543db576a4..9e1224b641 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt @@ -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, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt index e2c7376c90..6441831746 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt @@ -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(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() } diff --git a/app/src/main/res/layout/webview_activity.xml b/app/src/main/res/layout/webview_activity.xml index 01ffdab448..c51eda76ea 100644 --- a/app/src/main/res/layout/webview_activity.xml +++ b/app/src/main/res/layout/webview_activity.xml @@ -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" /> diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index ecdd16fafd..f48c0d0da8 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,5 +1,5 @@ - + - - \ No newline at end of file diff --git a/app/src/main/res/values-v26/themes.xml b/app/src/main/res/values-v26/themes.xml deleted file mode 100644 index 566da8539c..0000000000 --- a/app/src/main/res/values-v26/themes.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index ea0aa36dac..e8f8408c50 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@