Browse Source

Restore transparent status bars, allow WebView app bar to scroll away

arkon 5 years ago
parent
commit
57595988f5

+ 5 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt

@@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.source.SourceManager
 import eu.kanade.tachiyomi.source.online.HttpSource
 import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
 import eu.kanade.tachiyomi.util.WebViewClientCompat
+import eu.kanade.tachiyomi.util.getResourceColor
 import kotlinx.android.synthetic.main.webview_activity.toolbar
 import kotlinx.android.synthetic.main.webview_activity.webview
 import uy.kohesive.injekt.injectLazy
@@ -29,6 +30,10 @@ class WebViewActivity : BaseActivity() {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.webview_activity)
 
+        // Manually override status bar color since it's normally transparent with the app themes
+        // This is needed to hide the app bar when it scrolls up
+        window.statusBarColor = getResourceColor(R.attr.colorPrimaryDark)
+
         title = intent.extras?.getString(TITLE_KEY)
         setSupportActionBar(toolbar)
         supportActionBar?.setDisplayHomeAsUpEnabled(true)

+ 14 - 6
app/src/main/res/layout/webview_activity.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
+<androidx.coordinatorlayout.widget.CoordinatorLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
@@ -17,13 +17,21 @@
             android:layout_height="?attr/actionBarSize"
             android:background="?attr/colorPrimary"
             android:theme="?attr/actionBarTheme"
-            app:navigationIcon="@drawable/ic_close_white_24dp" />
+            app:navigationIcon="@drawable/ic_close_white_24dp"
+            app:layout_scrollFlags="scroll|enterAlways|snap" />
 
     </com.google.android.material.appbar.AppBarLayout>
 
-    <WebView
-        android:id="@+id/webview"
+    <androidx.core.widget.NestedScrollView
         android:layout_width="match_parent"
-        android:layout_height="match_parent" />
+        android:layout_height="match_parent"
+        app:layout_behavior="@string/appbar_scrolling_view_behavior">
 
-</LinearLayout>
+        <WebView
+            android:id="@+id/webview"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
+
+    </androidx.core.widget.NestedScrollView>
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout>

+ 3 - 3
app/src/main/res/values/themes.xml

@@ -44,7 +44,7 @@
     <!--===========-->
     <style name="Theme.Tachiyomi" parent="Theme.Base">
         <item name="android:windowDrawsSystemBarBackgrounds">true</item>
-        <item name="android:statusBarColor">@color/colorPrimaryDark</item>
+        <item name="android:statusBarColor">@android:color/transparent</item>
         <item name="android:navigationBarColor">@color/colorPrimaryDark</item>
     </style>
 
@@ -67,7 +67,7 @@
         <item name="android:listDivider">@drawable/line_divider_dark</item>
 
         <item name="android:windowDrawsSystemBarBackgrounds">true</item>
-        <item name="android:statusBarColor">@color/colorDarkPrimaryDark</item>
+        <item name="android:statusBarColor">@android:color/transparent</item>
         <item name="android:navigationBarColor">@color/colorDarkPrimaryDark</item>
 
         <!-- Themes -->
@@ -97,7 +97,7 @@
         <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
 
         <item name="android:windowDrawsSystemBarBackgrounds">true</item>
-        <item name="android:statusBarColor">@color/colorPrimaryDark</item>
+        <item name="android:statusBarColor">@android:color/transparent</item>
         <item name="android:navigationBarColor">@color/colorDarkPrimaryDark</item>
     </style>