Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

FLAG_FULLSCREEN deprecation in API 30

Open david-allison opened this issue 4 years ago • 11 comments

[!IMPORTANT] This issue is to be included in a research study, and should not be worked on

  • FLAG_FULLSCREEN
    • Use WindowInsetsController.hide(int) with WindowInsets.Type.statusBars() instead.
    • Only the usage in AnkiActivity needs to be fixed. The usage in Reviewer.kt doesn't need to be fixed because the screen is deprecated

The deprecations below don't need to be fixed because the screen that uses it is deprecated and will be eventually removed.

  • ~~View.setOnSystemUiVisibilityChangeListener~~
    • ~~Use WindowInsets.isVisible(int) to find out about system bar visibilities by setting a View.OnApplyWindowInsetsListener on this view~~
  • ~~View.getSystemUiVisibility()~~
    • ~~SystemUiVisibility flags are deprecated. Use WindowInsetsController instead.~~

david-allison avatar Jul 29 '21 20:07 david-allison

Hello, I would like to work on this issue.

noahwe145 avatar Aug 09 '21 09:08 noahwe145

Sounds good to me!

david-allison avatar Aug 09 '21 14:08 david-allison

I replaced all mentioned functions. I am unsure about reviewer.java lines 1168-1177:

// Set appropriate flags to enable Sticky Immersive mode. a.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE //| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // temporarily disabled due to #5245 | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_IMMERSIVE );

it is not explicit asked, but setSystemUiVisibility() seems deprecated (same as getSystemUiVisibility()) and it is using flags, so should I open a pull request or should i replace lines 1168-1177 as well?

noahwe145 avatar Aug 13 '21 13:08 noahwe145

If it's deprecated, and you're in there + understand the deprecation / necessary forward-port because you're in there, then please do replace it as well! And thank you in advance - it's a never-ending job keeping up with deprecation but is vital to project continuity, I really do appreciate it

mikehardy avatar Aug 13 '21 14:08 mikehardy

Hi, I would like to work on this issue.

entropyconquers avatar Sep 02 '21 21:09 entropyconquers

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] avatar Nov 01 '21 22:11 github-actions[bot]

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] avatar Jan 01 '22 00:01 github-actions[bot]

I would like to work on this issue.

n1snt avatar Jun 03 '22 20:06 n1snt

please be my guest! good luck :-)

mikehardy avatar Jun 03 '22 20:06 mikehardy

is this closed? or else i wanna try

soCallmeAdityaKumar avatar Jan 08 '23 07:01 soCallmeAdityaKumar

I've been trying to tackle this issue and this is the code that I came up with

override fun hideSystemBars(
        window: Window?,
        toolbar: View?,
        answerButtons: View?,
        topBar: View?,
        fullScreenMode: FullScreenMode
    ) {
        if (window == null) {
            return
        }
        WindowInsetsControllerCompat(window, window.decorView).let { controller ->
            controller.hide(WindowInsetsCompat.Type.systemBars())
            controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
        }

        window.decorView.setOnApplyWindowInsetsListener { _, windowInsets ->
            if (toolbar == null || topBar == null || answerButtons == null) {
                return@setOnApplyWindowInsetsListener windowInsets
            }
            val visible = WindowInsetsCompat.toWindowInsetsCompat(windowInsets).isVisible(WindowInsetsCompat.Type.systemBars())
            if (visible) {
                showViewWithAnimation(toolbar)
                WindowCompat.setDecorFitsSystemWindows(window, true)
                if (fullScreenMode == FullScreenMode.BUTTONS_AND_MENU) {
                    showViewWithAnimation(topBar)
                    showViewWithAnimation(answerButtons)
                }
            } else {
                hideViewWithAnimation(toolbar)
                WindowCompat.setDecorFitsSystemWindows(window, false)
                if (fullScreenMode == FullScreenMode.FULLSCREEN_ALL_GONE) {
                    hideViewWithAnimation(topBar)
                    hideViewWithAnimation(answerButtons)
                }
            }
            return@setOnApplyWindowInsetsListener windowInsets
        }
    }

but WindowInsetsCompat.toWindowInsetsCompat(windowInsets).isVisible(WindowInsetsCompat.Type.systemBars()) always returns false I tried controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE so the full system bars show up but that way was also really buggy, like the system bars would appear when I tapped on the review screen

hai265 avatar Jun 03 '23 20:06 hai265