Author Topic: Adding auto Big Screen mode to Android TV  (Read 1909 times)

Offline fzurita

  • Moderator
  • double
  • *****
  • Posts: 558
    • View Profile
Adding auto Big Screen mode to Android TV
« on: July 10, 2015, 11:54:57 PM »
I'm trying to add automatic configuration of big screen mode if the current platform is Android TV. Through some google searches, I was able to determine that this is not hard to do. We can detect Android TV mode using this statement:

Code: [Select]
        UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
        isAndroidTv = uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;

I was able to get this to work on my Nexus Player without any problem. The problem that I'm having though is that this project has a minimum API level of 7, while the Configuration.UI_MODE_TYPE_TELEVISION was only added on API level 13. How do we generally handle this kind of situation with API level? I would like to push this back, but I want to make sure I'm doing it this in the expected way:

In paulscode.android.mupen64plusae.persistent.AppData I'm adding a member attribute called isAndroidTV. I'm setting this in the constructor using
Code: [Select]
        if(AppData.IS_ICE_CREAM_SANDWICH)
        {
            UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
            isAndroidTv = uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
        }
        else
        {
        isAndroidTv = false;
        }

At the same time, I'm suppressing the Target API warning using this at the top of the constructor:     
Code: [Select]
@TargetApi( 13 )

In paulscode.android.mupen64plusae.persistent.GlobalPrefs, I'm modifying

Code: [Select]
isBigScreenMode = AppData.IS_OUYA_HARDWARE ;

to

Code: [Select]
isBigScreenMode = AppData.IS_OUYA_HARDWARE || appData.isAndroidTv;

Does this sound ok?

Offline littleguy

  • Moderator
  • double
  • *****
  • Posts: 1945
    • View Profile
Re: Adding auto Big Screen mode to Android TV
« Reply #1 on: July 11, 2015, 05:48:03 PM »
Yes, this all sounds fine.  That is how we normally deal with higher-API methods.  Please open a pull request on GitHub with your changes, and I'll give it a quick review and merge it.

For future reference, you can skip the step of posting on this forum, and just open the pull request directly.  It's actually easier to review that way, saves you some typing, and the turnaround is faster.

Thanks much!  :D
2012 Nexus 7, rooted stock Lollipop
Samsung Galaxy Victory, rooted stock Jelly Bean
Xperia PLAY, stock Gingerbread
OUYA, retail version

Offline fzurita

  • Moderator
  • double
  • *****
  • Posts: 558
    • View Profile
Re: Adding auto Big Screen mode to Android TV
« Reply #2 on: July 11, 2015, 07:34:55 PM »
OK, will do.