Fix webview height issue

Collapsing toolbar doesn't work currently.
This commit is contained in:
arkon 2020-06-13 15:56:40 -04:00
parent 526e029ebb
commit e9fbdb660b
2 changed files with 19 additions and 33 deletions

View file

@ -98,6 +98,11 @@ class WebViewActivity : BaseActivity<WebviewActivityBinding>() {
return true return true
} }
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
invalidateOptionsMenu()
}
override fun onPageFinished(view: WebView?, url: String?) { override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url) super.onPageFinished(view, url)
invalidateOptionsMenu() invalidateOptionsMenu()
@ -105,18 +110,9 @@ class WebViewActivity : BaseActivity<WebviewActivityBinding>() {
supportActionBar?.subtitle = url supportActionBar?.subtitle = url
binding.swipeRefresh.isEnabled = true binding.swipeRefresh.isEnabled = true
binding.swipeRefresh.isRefreshing = false binding.swipeRefresh.isRefreshing = false
}
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
invalidateOptionsMenu()
}
override fun onPageCommitVisible(view: WebView, url: String) {
super.onPageCommitVisible(view, url)
// Reset to top when page refreshes // Reset to top when page refreshes
binding.nestedView.scrollTo(0, 0) view?.scrollTo(0, 0)
} }
} }

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout 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:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -15,7 +15,6 @@
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:theme="?attr/actionBarTheme" android:theme="?attr/actionBarTheme"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:navigationIcon="@drawable/ic_close_24dp" /> app:navigationIcon="@drawable/ic_close_24dp" />
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
@ -23,32 +22,23 @@
<eu.kanade.tachiyomi.widget.ThemedSwipeRefreshLayout <eu.kanade.tachiyomi.widget.ThemedSwipeRefreshLayout
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" android:layout_height="match_parent">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.core.widget.NestedScrollView <WebView
android:id="@+id/nested_view" android:id="@+id/webview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView <ProgressBar
android:id="@+id/webview" android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="2dp"
android:progressBackgroundTint="@color/colorPrimary"
android:progressTint="@color/colorPrimary" />
<ProgressBar </WebView>
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="2dp"
android:progressBackgroundTint="@color/colorPrimary"
android:progressTint="@color/colorPrimary" />
</WebView>
</androidx.core.widget.NestedScrollView>
</eu.kanade.tachiyomi.widget.ThemedSwipeRefreshLayout> </eu.kanade.tachiyomi.widget.ThemedSwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </LinearLayout>