mirror of
https://github.com/jellyfin/jellyfin-android.git
synced 2026-09-03 05:10:27 +03:00
Set system gesture exclusions for the WebView
The maximum allowed height (200dp) is excluded from system gestures at the center of the screen to allow opening the side drawer with a swipe gesture
This commit is contained in:
@@ -5,6 +5,8 @@ import android.app.Service
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.graphics.Rect
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
import android.view.OrientationEventListener
|
||||
@@ -13,6 +15,7 @@ import android.widget.FrameLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.doOnNextLayout
|
||||
import androidx.core.view.updatePadding
|
||||
import okhttp3.OkHttpClient
|
||||
import org.jellyfin.mobile.bridge.Commands.triggerInputManagerAction
|
||||
@@ -63,6 +66,13 @@ class WebappActivity : AppCompatActivity(), WebViewController {
|
||||
v.updatePadding(top = insets.systemWindowInsets.top)
|
||||
insets
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
webView.doOnNextLayout { webView ->
|
||||
val verticalCenter = webView.measuredHeight / 2
|
||||
val offset = dip(100)
|
||||
webView.systemGestureExclusionRects = listOf(Rect(0, verticalCenter - offset, dip(96), verticalCenter + offset))
|
||||
}
|
||||
}
|
||||
|
||||
// Setup WebView
|
||||
webView.initialize()
|
||||
|
||||
@@ -46,6 +46,8 @@ fun Activity.disableFullscreen(keepStableLayout: Boolean = false) {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun Context.dip(px: Int) = (px * resources.displayMetrics.density).toInt()
|
||||
|
||||
inline fun Context.toast(@StringRes text: Int, duration: Int = Toast.LENGTH_SHORT) =
|
||||
Toast.makeText(this, text, duration).show()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user