SuperTux / supertux

SuperTux source code
https://supertux.org
GNU General Public License v3.0
2.54k stars 491 forks source link

SuperTux for Android TV #2107

Open pelya opened 2 years ago

pelya commented 2 years ago

SuperTux version: 0.6.3 System information: Android

Expected behavior

SuperTux was published for Android TV up to version 0.5.1

Actual behavior

SuperTux 0.6.3 is not available for Android TV

Steps to reproduce actual behavior

Try to install SuperTux onto any smart TV with Android

Additional debugging information

Android TV apps are manually reviewed. SuperTux mostly satisfies TV requirements, but following changes should be implemented:

  1. Back button must exit current screen. Pressing Back button 10 times must close the game, from any screen or dialog.

Right now Back button opens and closes the Pause menu, but does not close the level or the worldmap. Back button generates keypress SDL_SCANCODE_AC_BACK on SDL2, and you need to call SDL_SetHint(SDL_HINT_ANDROID_TRAP_BACK_BUTTON, "1"); to receive the keypress.

  1. Do not display any text or information like coins counter near the screen edge, because some TVs cover the edges and it won't be shown. It's usually easier to shrink the whole video output than to re-layout all text elements.

The required margin is 5% for all screen edges, that is, shrink the game screen to 90% size and add borders to the edges. My app was rejected when I've added plain black borders, but it was accepted with this border graphics: https://github.com/pelya/commandergenius/blob/sdl_android/project/res/drawable/tv_border_top.jpg

  1. Call SDL_DisableScreenSaver() after creating SDL window.

You can check whether the app is running on Android TV like this: if (getenv("ANDROID_TV")) { ... }

You will also need to add following lines to your AndroidManifest.xml:

<application
  ...
  android:banner="@drawable/banner"
  android:isGame="true"
  ... >
    <activity ... >
      <intent-filter>
      ...
      <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
      ...
      </intent-filter>

Beware, it is overwritten each time you run changeAppSettings.sh. You can add these changes to the patch project/jni/application/supertux/project.diff which is applied by changeAppSettings.sh automatically. The default AndroidManifest.xml comes directly from SDL2 repository, and it is missing all this stuff and also INTERNET permission, go open an issue in their github repo so they stop slacking with Android support.

More info about Android TV: https://developer.android.com/training/tv

pelya commented 2 years ago

And now that I have transferred Android app, implementing all this stuff is someone else's headache 👍 sorry Semphriss

It is practically guaranteed that Android TV app will be rejected after the first review, sometimes doing some trivial change and submitting the same app would allow me to pass the review, and they usually explain why they rejected the app.

Android TV section in Play Console can be found here: https://i.stack.imgur.com/ACigj.jpg