mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:25:10 +01:00
Removing Edge to Edge for webview
it was nice but it breaks too many sites for it
This commit is contained in:
parent
f1cc4a35dc
commit
e028c3395c
@ -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<WebviewActivityBinding>() {
|
||||
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<WebviewActivityBinding>() {
|
||||
}
|
||||
}
|
||||
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<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = marginB + bottomInset
|
||||
}
|
||||
@ -168,24 +159,41 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
||||
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)
|
||||
|
@ -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?) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/web_view_layout"
|
||||
@ -31,18 +31,13 @@
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nested_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webview"
|
||||
android:nestedScrollingEnabled="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
@ -54,8 +49,6 @@
|
||||
/>
|
||||
</WebView>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user