PaulsCode Forum

Mupen64Plus AE => General Discussion => Topic started by: fzurita on July 10, 2015, 11:54:57 PM

Title: Adding auto Big Screen mode to Android TV
Post by: fzurita 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?
Title: Re: Adding auto Big Screen mode to Android TV
Post by: littleguy 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
Title: Re: Adding auto Big Screen mode to Android TV
Post by: fzurita on July 11, 2015, 07:34:55 PM
OK, will do.