0

I have a webview-based Android app full-screen, running in COSU mode. Each time I pick a color using an HTML5 <input type="color"/>, the hidden action bars are shown again, and I can't hide them, unless I close the app and open it again.

Is there any way of avoiding the bars showing up each time I use the color picker? The only solution I came up to is using the javascript interface to call a function/method in Android to hide the bars each time the color picker is used, but seems too tricky/elaborate. There should be a better way... Or not?

Any ideas?

Thanks in advance


EDITED:

How I hide bars? I call this function I defined inside the Activity:

private fun hideBars() {
    actionBar?.hide()
    this.supportActionBar?.hide()
}

Also, use this one to set the activity to full screen

private fun setFullScreen() {
    window.decorView.systemUiVisibility =
        View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
                View.SYSTEM_UI_FLAG_FULLSCREEN or
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
}
RDM
  • 56
  • 8

1 Answers1

0

I've been waiting a few days for a response, but looks like it is not a very common problem, or there is no cleaner solution than using the javascript interface.

Finally, I opted to call to a function using the javascript interface when the <input type="color"/> is clicked. This is the function I used:

class WebAppInterface {

    private val context : Context

    ...


    constructor(context : Context) {
        this.context = context
        ...
    }

    @JavascriptInterface
    fun resetScreen() {

        val activity = context as MainActivity
        activity.runOnUiThread(Runnable {
            fun run() {
                activity.hideBars()
                activity.setFullScreen()
            }
        });

    }

}

Note I had to call the hiding bar functions using Activity.runOnUiThread(). Otherwise, Android kindly answered I was not running the code in the UI thread.

I mark this as the answer, but if someone in the future finds a cleaner way to solve this problem, I will review it. Otherwise, I hope this helps somebody

RDM
  • 56
  • 8