mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-24 01:06:39 +00:00
Restore TV-specific padding (but slightly less)
This commit is contained in:
@@ -2,6 +2,8 @@ package com.limelight.utils;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.UiModeManager;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -19,6 +21,9 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class UiHelper {
|
public class UiHelper {
|
||||||
|
|
||||||
|
private static final int TV_VERTICAL_PADDING_DP = 15;
|
||||||
|
private static final int TV_HORIZONTAL_PADDING_DP = 15;
|
||||||
|
|
||||||
public static void setLocale(Activity activity)
|
public static void setLocale(Activity activity)
|
||||||
{
|
{
|
||||||
String locale = PreferenceConfiguration.readPreferences(activity).language;
|
String locale = PreferenceConfiguration.readPreferences(activity).language;
|
||||||
@@ -60,6 +65,20 @@ public class UiHelper {
|
|||||||
|
|
||||||
public static void notifyNewRootView(final Activity activity)
|
public static void notifyNewRootView(final Activity activity)
|
||||||
{
|
{
|
||||||
|
View rootView = activity.findViewById(android.R.id.content);
|
||||||
|
UiModeManager modeMgr = (UiModeManager) activity.getSystemService(Context.UI_MODE_SERVICE);
|
||||||
|
|
||||||
|
if (modeMgr.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION)
|
||||||
|
{
|
||||||
|
// Increase view padding on TVs
|
||||||
|
float scale = activity.getResources().getDisplayMetrics().density;
|
||||||
|
int verticalPaddingPixels = (int) (TV_VERTICAL_PADDING_DP*scale + 0.5f);
|
||||||
|
int horizontalPaddingPixels = (int) (TV_HORIZONTAL_PADDING_DP*scale + 0.5f);
|
||||||
|
|
||||||
|
rootView.setPadding(horizontalPaddingPixels, verticalPaddingPixels,
|
||||||
|
horizontalPaddingPixels, verticalPaddingPixels);
|
||||||
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
// Allow this non-streaming activity to layout under notches.
|
// Allow this non-streaming activity to layout under notches.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user