@@ -109,6 +109,36 @@ class PersistentWebView(context: Context) : WebView(context) {
109109 } catch (e: Throwable ) { }
110110 }
111111
112+ override fun isShown (): Boolean {
113+ return if (allowBackgroundPlayback) true else super .isShown()
114+ }
115+
116+ override fun getVisibility (): Int {
117+ return if (allowBackgroundPlayback) View .VISIBLE else super .getVisibility()
118+ }
119+
120+ override fun getWindowVisibility (): Int {
121+ return if (allowBackgroundPlayback) View .VISIBLE else super .getWindowVisibility()
122+ }
123+
124+ override fun hasWindowFocus (): Boolean {
125+ return if (allowBackgroundPlayback) true else super .hasWindowFocus()
126+ }
127+
128+ override fun onWindowFocusChanged (hasWindowFocus : Boolean ) {
129+ try {
130+ val effectiveFocus = if (allowBackgroundPlayback) true else hasWindowFocus
131+ super .onWindowFocusChanged(effectiveFocus)
132+ } catch (e: Throwable ) { }
133+ }
134+
135+ override fun dispatchWindowFocusChanged (hasFocus : Boolean ) {
136+ try {
137+ val effectiveFocus = if (allowBackgroundPlayback) true else hasFocus
138+ super .dispatchWindowFocusChanged(effectiveFocus)
139+ } catch (e: Throwable ) { }
140+ }
141+
112142 override fun onPause () {
113143 if (! allowBackgroundPlayback) {
114144 try {
@@ -399,7 +429,8 @@ fun WebViewContainer(
399429 factory = { ctx ->
400430 val swipeRefresh = SwipeRefreshLayout (ctx).apply {
401431 isNestedScrollingEnabled = true
402- visibility = if (isActive) View .VISIBLE else View .GONE
432+ visibility = View .VISIBLE
433+ isEnabled = (customVideoView == null ) && isActive
403434 layoutParams = ViewGroup .LayoutParams (
404435 ViewGroup .LayoutParams .MATCH_PARENT ,
405436 ViewGroup .LayoutParams .MATCH_PARENT
@@ -934,7 +965,7 @@ fun WebViewContainer(
934965 },
935966 update = { swipeRefresh ->
936967 swipeRefreshRef = swipeRefresh
937- swipeRefresh.visibility = if (isActive) View .VISIBLE else View . GONE
968+ swipeRefresh.visibility = View .VISIBLE
938969 val webView = (0 until swipeRefresh.childCount)
939970 .map { swipeRefresh.getChildAt(it) }
940971 .filterIsInstance<PersistentWebView >()
@@ -946,8 +977,8 @@ fun WebViewContainer(
946977 webView.allowBackgroundPlayback = enableBackgroundPlay
947978 }
948979
949- // Pull-to-refresh enabled unless custom video view is active
950- swipeRefresh.isEnabled = (customVideoView == null )
980+ // Pull-to-refresh enabled unless custom video view is active, and only for active tab
981+ swipeRefresh.isEnabled = (customVideoView == null ) && isActive
951982
952983 val primaryColor = if (effectiveDark) android.graphics.Color .parseColor(" #80D8FF" ) else android.graphics.Color .parseColor(" #00668B" )
953984 val progressBgColor = if (effectiveDark) android.graphics.Color .parseColor(" #2C2C2C" ) else android.graphics.Color .WHITE
0 commit comments