diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt index 29f658510f..7fa302d408 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt @@ -16,7 +16,6 @@ import eu.kanade.tachiyomi.databinding.WebviewActivityBinding import eu.kanade.tachiyomi.ui.base.activity.BaseActivity import eu.kanade.tachiyomi.util.system.getPrefTheme import eu.kanade.tachiyomi.util.system.getResourceColor -import eu.kanade.tachiyomi.util.system.isBottomTappable import eu.kanade.tachiyomi.util.system.isInNightMode import eu.kanade.tachiyomi.util.system.setDefaultSettings import eu.kanade.tachiyomi.util.view.invisible @@ -89,18 +88,9 @@ open class BaseWebViewActivity : BaseActivity() { window.statusBarColor = Color.BLACK else window.statusBarColor = getResourceColor(R.attr.colorPrimary)*/ window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { - val colorPrimary = getResourceColor(R.attr.colorPrimaryVariant) - if (colorPrimary == Color.WHITE) Color.BLACK - else getResourceColor(android.R.attr.colorPrimary) - } - // if the android q+ device has gesture nav, transparent nav bar - else if (v.rootWindowInsets.isBottomTappable()) { - getColor(android.R.color.transparent) + Color.BLACK } else { - ColorUtils.setAlphaComponent( - getResourceColor(R.attr.colorPrimaryVariant), - 179 - ) + getResourceColor(R.attr.colorPrimaryVariant) } v.setPadding( insets.systemWindowInsetLeft, @@ -130,8 +120,9 @@ open class BaseWebViewActivity : BaseActivity() { } } val marginB = binding.webview.marginBottom - binding.webview.setOnApplyWindowInsetsListener { v, insets -> + binding.swipeRefresh.setOnApplyWindowInsetsListener { v, insets -> val bottomInset = insets.systemWindowInsetBottom +// v.updatePaddingRelative(bottom = bottomInset) v.updateLayoutParams { bottomMargin = marginB + bottomInset } @@ -168,24 +159,41 @@ open class BaseWebViewActivity : BaseActivity() { binding.toolbar.overflowIcon?.setTint(tintColor) binding.swipeRefresh.setStyle() - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { - window.navigationBarColor = getResourceColor(R.attr.colorPrimaryVariant) - } else if (window.navigationBarColor != getColor(android.R.color.transparent)) { - window.navigationBarColor = getResourceColor(android.R.attr.colorBackground) - } + window.navigationBarColor = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) getResourceColor(R.attr.colorPrimaryVariant) + else Color.BLACK binding.webLinearLayout.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && lightMode) { - binding.webLinearLayout.systemUiVisibility = binding.webLinearLayout.systemUiVisibility.or( - View - .SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR - ) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val lightNav = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + val typedValue = TypedValue() + theme.resolveAttribute( + android.R.attr.windowLightNavigationBar, + typedValue, + true + ) + typedValue.data == -1 + } else { + lightMode + } + if (lightNav) { + window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.or( + View + .SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR + ) + } else { + window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.rem( + View + .SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR + ) + } } + val typedValue = TypedValue() theme.resolveAttribute(android.R.attr.windowLightStatusBar, typedValue, true) - if (typedValue.data == -1) { window.decorView.systemUiVisibility = window.decorView.systemUiVisibility .or(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) 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 a57342085f..1415b29bd7 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 @@ -69,10 +69,7 @@ open class WebViewActivity : BaseWebViewActivity() { invalidateOptionsMenu() title = view?.title binding.swipeRefresh.isEnabled = true - binding.swipeRefresh?.isRefreshing = false - view?.evaluateJavascript("getComputedStyle(document.querySelector('body')).backgroundColor") { - binding.nestedView.setBackgroundColor(parseHTMLColor(it)) - } + binding.swipeRefresh.isRefreshing = false } override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { diff --git a/app/src/main/res/layout/webview_activity.xml b/app/src/main/res/layout/webview_activity.xml index db7a0bb3c2..5b539e8ba1 100644 --- a/app/src/main/res/layout/webview_activity.xml +++ b/app/src/main/res/layout/webview_activity.xml @@ -1,6 +1,6 @@ - - - + + android:layout_height="match_parent" > - - - + \ No newline at end of file