1

I already tryed to contact the support with no success (through report of the build and the getHelp page https://support.google.com/googleplay/android-developer/gethelp, i got no reply or the same reply "Missing dpad f...") and read this thread React Native Android TV - DPad Functionality missing and tryed the solution proposed. Nothing worked for me. My app is fully navigable expect for things out of my domain. For example i reproduce youtube video and when you pause the video the share button of youtube is visible but not navigable, could it be an issue? What can i do now?

Edit:

I'll try to explain in detail how i managed the dpad in every screen and attach screenshot of the app. In the HomeScreen i haven't managed Dpad programmatically but let the job to Android. I only blocked some bad behaviour through xml, for example limitating the nextFocus of the top button Search (android:nextFocus...)

Excluding the SplashScreen the first screen is the HomeScreen (not using BrowseSupportFragment): HomeScreen Top

Still in Home Screen going down to the the HorizontalGridView of Leanback library. The cards of the live row only have a changing dimension effect. In the following rows the card is focused with a white border and the name of the progam too. Here the dpad is handled automatically by the HorizontalGridView. HorizontalGridView with focus handling

Concluding, the HomeScreen is entirely contained in a custom ScrollView where i added these few lines to manually manage the scroll when a row is focused(smoothScrollTo) .

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_DPAD_CENTER:
            return super.dispatchKeyEvent(event);
    }
    return false;
}

The program detail screen act the same.

For the search screen i used the SearchSupportFragment of Android Leanback: enter image description here

For the playback screen of youtube video i used a this library: https://github.com/PierfrancescoSoffritti/android-youtube-player and made my own custom playback ui.

enter image description here

Here is the code that handles the dpad:

    override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
        val action = event!!.action
        when (event.keyCode) {
            KeyEvent.KEYCODE_ENTER, KeyEvent.KEYCODE_DPAD_CENTER -> {
                if (action == KeyEvent.ACTION_DOWN) {
                    Toast.makeText(this, "Clicked Enter", Toast.LENGTH_SHORT).show()
                    customPlayerYoutube.playPauseVideo()
                }
            }
            KeyEvent.KEYCODE_DPAD_RIGHT-> {
                if (action == KeyEvent.ACTION_DOWN) {
                    Log.i("CUSTOM","dpad right clicked")
                    Log.d(TAG,"Down time is" + event.getDownTime()+"with action:" + event.getAction()+ "with repeat count"+ event.getRepeatCount()+"with long press"+ event.isLongPress());
                    val time = SystemClock.uptimeMillis()
                    if (event.downTime - mLastKeyDownTime <= mPressedDelta) {
                        Log.i("CUSTOM","skip 180")
                        Toast.makeText(this, "Skipping 180 seconds", Toast.LENGTH_SHORT).show()
                        customPlayerYoutube.skipSeconds(180f)
                    } else {
                        Log.i("CUSTOM","skip 10")
                        Toast.makeText(this, "Skipping 10 seconds", Toast.LENGTH_SHORT).show()
                        customPlayerYoutube.skipSeconds(10f)
                    }
                    mLastKeyDownTime = event.downTime
                }
            }
            KeyEvent.KEYCODE_DPAD_LEFT -> {
                if (action == KeyEvent.ACTION_DOWN) {
                    Log.d(TAG,"Down time is" + event.getDownTime()+"with action:" + event.getAction()+ "with repeat count"+ event.getRepeatCount()+"with long press"+ event.isLongPress());
                    val time = SystemClock.uptimeMillis()
                    if (event.downTime - mLastKeyDownTime <= mPressedDelta) {
                        Toast.makeText(this, "Go back 180 seconds", Toast.LENGTH_SHORT).show()
                        customPlayerYoutube.goBackSeconds(180f)
                    } else {
                        Toast.makeText(this, "Go back 10 seconds", Toast.LENGTH_SHORT).show()
                        customPlayerYoutube.goBackSeconds(10f)
                    }
                    mLastKeyDownTime = event.downTime
                }
            }
            KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> {
                if (action == KeyEvent.ACTION_DOWN) {
                    Toast.makeText(this, "Play pause video", Toast.LENGTH_SHORT).show()
                    customPlayerYoutube.playPauseVideo()
                }
            }
            KeyEvent.KEYCODE_MEDIA_PLAY -> {
                if (action == KeyEvent.ACTION_DOWN) {
                    Toast.makeText(this, "Play video", Toast.LENGTH_SHORT).show()
                    customPlayerYoutube.playVideo()
                }
            }
            KeyEvent.KEYCODE_MEDIA_PAUSE -> {
                if (action == KeyEvent.ACTION_DOWN) {
                    Toast.makeText(this, "Pause video", Toast.LENGTH_SHORT).show()
                    customPlayerYoutube.pauseVideo()
                }
            }
            KeyEvent.KEYCODE_DPAD_UP -> {
                if (action == KeyEvent.ACTION_DOWN) {
                    Toast.makeText(this, "Clicked up...", Toast.LENGTH_SHORT).show()
                }
            }
            KeyEvent.KEYCODE_DPAD_DOWN -> {
                if (action == KeyEvent.ACTION_DOWN) {
                    Toast.makeText(this, "Clicked down...", Toast.LENGTH_SHORT).show()
                }
            }
            else -> return super.dispatchKeyEvent(event)
        }
        return true
    }

In this screen nothing is focusable (as i wanted to be) all commands are instant, if the user tap Dpad Enter the video stops or play (and the image in the middle change) and so on. After the first reject i added the Toast to make sure google didnt think there was no feedback for up and down dpad click but nothing changed (app still rejected).

If you need more details or certain code just ask i really need to figure this out.

  • You haven't shared any code so we can't help you with any dpad code you have. And we can't read google's minds so we have no more details on what may have caused their rejection than you do. Unless you can give us more details, there's not really anything we can do outside of vague wild guesses. – Gabe Sechan Oct 17 '22 at 15:36
  • Thanks for the feedback @GabeSechan i edited the question with screenshot and code. – Edoardo Maioli Oct 19 '22 at 13:28

0 Answers0