mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
Removed the deprecated FLAG_FULLSCREEN, FLAG_FORCE_NOT_FULLSCREEN.
We have removed the usage of deprecated flags FLAG_FULLSCREEN and FLAG_FORCE_NOT_FULLSCREEN. Instead, we are now using the updated API `WindowCompat.setDecorFitsSystemWindows` to handle fullscreen mode. This API automatically takes care of handling fullscreen behavior for both older and newer API levels.
This commit is contained in:
parent
35ff151e9b
commit
d2662c1aa4
@ -49,7 +49,6 @@ import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.webkit.WebBackForwardList
|
||||
import android.webkit.WebView
|
||||
@ -70,6 +69,9 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.widget.ContentLoadingProgressBar
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
@ -1288,10 +1290,13 @@ abstract class CoreReaderFragment :
|
||||
bottomToolbar?.visibility = View.GONE
|
||||
exitFullscreenButton?.visibility = View.VISIBLE
|
||||
exitFullscreenButton?.background?.alpha = 153
|
||||
val fullScreenFlag = WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||
val classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
|
||||
requireActivity().window.addFlags(fullScreenFlag)
|
||||
requireActivity().window.clearFlags(classicScreenFlag)
|
||||
val window = requireActivity().window
|
||||
WindowCompat.setDecorFitsSystemWindows(window, true)
|
||||
WindowInsetsControllerCompat(window, window.decorView.rootView).apply {
|
||||
hide(WindowInsetsCompat.Type.systemBars())
|
||||
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
window.decorView.rootView.requestLayout()
|
||||
}
|
||||
getCurrentWebView()?.apply {
|
||||
requestLayout()
|
||||
translationY = 0f
|
||||
@ -1306,10 +1311,12 @@ abstract class CoreReaderFragment :
|
||||
updateBottomToolbarVisibility()
|
||||
exitFullscreenButton?.visibility = View.GONE
|
||||
exitFullscreenButton?.background?.alpha = 255
|
||||
val fullScreenFlag = WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||
val classicScreenFlag = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
|
||||
requireActivity().window.clearFlags(fullScreenFlag)
|
||||
requireActivity().window.addFlags(classicScreenFlag)
|
||||
val window = requireActivity().window
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
WindowInsetsControllerCompat(window, window.decorView.rootView).apply {
|
||||
show(WindowInsetsCompat.Type.systemBars())
|
||||
window.decorView.rootView.requestLayout()
|
||||
}
|
||||
getCurrentWebView()?.requestLayout()
|
||||
sharedPreferenceUtil?.putPrefFullScreen(false)
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.ContextMenu
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN
|
||||
import android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||
import android.webkit.WebView
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
@ -73,13 +71,9 @@ open class KiwixWebView @SuppressLint("SetJavaScriptEnabled") constructor(
|
||||
if (isFullScreen) {
|
||||
hide(WindowInsetsCompat.Type.systemBars())
|
||||
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
window.clearFlags(FLAG_FULLSCREEN)
|
||||
window.addFlags(FLAG_FULLSCREEN)
|
||||
window.decorView.rootView.requestLayout()
|
||||
} else {
|
||||
show(WindowInsetsCompat.Type.systemBars())
|
||||
window.clearFlags(FLAG_FULLSCREEN)
|
||||
window.addFlags(FLAG_FORCE_NOT_FULLSCREEN)
|
||||
window.decorView.rootView.requestLayout()
|
||||
}
|
||||
}
|
||||
@ -99,6 +93,7 @@ open class KiwixWebView @SuppressLint("SetJavaScriptEnabled") constructor(
|
||||
useWideViewPort = true
|
||||
builtInZoomControls = true
|
||||
displayZoomControls = false
|
||||
@Suppress("DEPRECATION")
|
||||
allowUniversalAccessFromFileURLs = true
|
||||
}
|
||||
setInitialScale(INITIAL_SCALE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user