mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:55:11 +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.ui.base.activity.BaseActivity
|
||||||
import eu.kanade.tachiyomi.util.system.getPrefTheme
|
import eu.kanade.tachiyomi.util.system.getPrefTheme
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
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.isInNightMode
|
||||||
import eu.kanade.tachiyomi.util.system.setDefaultSettings
|
import eu.kanade.tachiyomi.util.system.setDefaultSettings
|
||||||
import eu.kanade.tachiyomi.util.view.invisible
|
import eu.kanade.tachiyomi.util.view.invisible
|
||||||
@ -89,18 +88,9 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||||||
window.statusBarColor = Color.BLACK
|
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) {
|
window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
val colorPrimary = getResourceColor(R.attr.colorPrimaryVariant)
|
Color.BLACK
|
||||||
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)
|
|
||||||
} else {
|
} else {
|
||||||
ColorUtils.setAlphaComponent(
|
getResourceColor(R.attr.colorPrimaryVariant)
|
||||||
getResourceColor(R.attr.colorPrimaryVariant),
|
|
||||||
179
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
v.setPadding(
|
v.setPadding(
|
||||||
insets.systemWindowInsetLeft,
|
insets.systemWindowInsetLeft,
|
||||||
@ -130,8 +120,9 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val marginB = binding.webview.marginBottom
|
val marginB = binding.webview.marginBottom
|
||||||
binding.webview.setOnApplyWindowInsetsListener { v, insets ->
|
binding.swipeRefresh.setOnApplyWindowInsetsListener { v, insets ->
|
||||||
val bottomInset = insets.systemWindowInsetBottom
|
val bottomInset = insets.systemWindowInsetBottom
|
||||||
|
// v.updatePaddingRelative(bottom = bottomInset)
|
||||||
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = marginB + bottomInset
|
bottomMargin = marginB + bottomInset
|
||||||
}
|
}
|
||||||
@ -168,24 +159,41 @@ open class BaseWebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||||||
binding.toolbar.overflowIcon?.setTint(tintColor)
|
binding.toolbar.overflowIcon?.setTint(tintColor)
|
||||||
binding.swipeRefresh.setStyle()
|
binding.swipeRefresh.setStyle()
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
window.navigationBarColor =
|
||||||
window.navigationBarColor = getResourceColor(R.attr.colorPrimaryVariant)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) getResourceColor(R.attr.colorPrimaryVariant)
|
||||||
} else if (window.navigationBarColor != getColor(android.R.color.transparent)) {
|
else Color.BLACK
|
||||||
window.navigationBarColor = getResourceColor(android.R.attr.colorBackground)
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.webLinearLayout.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
binding.webLinearLayout.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && lightMode) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
binding.webLinearLayout.systemUiVisibility = binding.webLinearLayout.systemUiVisibility.or(
|
val lightNav =
|
||||||
View
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||||
.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
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()
|
val typedValue = TypedValue()
|
||||||
theme.resolveAttribute(android.R.attr.windowLightStatusBar, typedValue, true)
|
theme.resolveAttribute(android.R.attr.windowLightStatusBar, typedValue, true)
|
||||||
|
|
||||||
if (typedValue.data == -1) {
|
if (typedValue.data == -1) {
|
||||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility
|
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility
|
||||||
.or(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
|
.or(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
|
||||||
|
@ -69,10 +69,7 @@ open class WebViewActivity : BaseWebViewActivity() {
|
|||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
title = view?.title
|
title = view?.title
|
||||||
binding.swipeRefresh.isEnabled = true
|
binding.swipeRefresh.isEnabled = true
|
||||||
binding.swipeRefresh?.isRefreshing = false
|
binding.swipeRefresh.isRefreshing = false
|
||||||
view?.evaluateJavascript("getComputedStyle(document.querySelector('body')).backgroundColor") {
|
|
||||||
binding.nestedView.setBackgroundColor(parseHTMLColor(it))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/web_view_layout"
|
android:id="@+id/web_view_layout"
|
||||||
@ -31,18 +31,13 @@
|
|||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@id/swipe_refresh"
|
android:id="@id/swipe_refresh"
|
||||||
android:layout_width="match_parent"
|
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">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<WebView
|
<WebView
|
||||||
android:id="@+id/webview"
|
android:id="@+id/webview"
|
||||||
android:nestedScrollingEnabled="true"
|
android:nestedScrollingEnabled="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
@ -54,8 +49,6 @@
|
|||||||
/>
|
/>
|
||||||
</WebView>
|
</WebView>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user