mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 19:13:03 +00:00
Add support for PiP on Oreo
This commit is contained in:
parent
74ed95871b
commit
8f1d3ae04e
@ -103,7 +103,10 @@
|
|||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"
|
||||||
android:screenOrientation="sensorLandscape"
|
android:screenOrientation="sensorLandscape"
|
||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
|
android:supportsPictureInPicture="true"
|
||||||
android:resizeableActivity="true"
|
android:resizeableActivity="true"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
android:theme="@style/StreamTheme">
|
android:theme="@style/StreamTheme">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
@ -30,6 +30,7 @@ import com.limelight.utils.UiHelper;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.PictureInPictureParams;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -46,6 +47,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.util.Rational;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@ -357,6 +359,20 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
streamView.getHolder().addCallback(this);
|
streamView.getHolder().addCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUserLeaveHint() {
|
||||||
|
super.onUserLeaveHint();
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
if (prefConfig.enablePip && connected) {
|
||||||
|
enterPictureInPictureMode(
|
||||||
|
new PictureInPictureParams.Builder()
|
||||||
|
.setAspectRatio(new Rational(prefConfig.width, prefConfig.height))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
super.onWindowFocusChanged(hasFocus);
|
super.onWindowFocusChanged(hasFocus);
|
||||||
|
@ -26,6 +26,7 @@ public class PreferenceConfiguration {
|
|||||||
private static final String BATTERY_SAVER_PREF_STRING = "checkbox_battery_saver";
|
private static final String BATTERY_SAVER_PREF_STRING = "checkbox_battery_saver";
|
||||||
private static final String DISABLE_FRAME_DROP_PREF_STRING = "checkbox_disable_frame_drop";
|
private static final String DISABLE_FRAME_DROP_PREF_STRING = "checkbox_disable_frame_drop";
|
||||||
private static final String ENABLE_HDR_PREF_STRING = "checkbox_enable_hdr";
|
private static final String ENABLE_HDR_PREF_STRING = "checkbox_enable_hdr";
|
||||||
|
private static final String ENABLE_PIP_PREF_STRING = "checkbox_enable_pip";
|
||||||
|
|
||||||
private static final int BITRATE_DEFAULT_720_30 = 5;
|
private static final int BITRATE_DEFAULT_720_30 = 5;
|
||||||
private static final int BITRATE_DEFAULT_720_60 = 10;
|
private static final int BITRATE_DEFAULT_720_60 = 10;
|
||||||
@ -52,6 +53,7 @@ public class PreferenceConfiguration {
|
|||||||
private static final boolean DEFAULT_BATTERY_SAVER = false;
|
private static final boolean DEFAULT_BATTERY_SAVER = false;
|
||||||
private static final boolean DEFAULT_DISABLE_FRAME_DROP = false;
|
private static final boolean DEFAULT_DISABLE_FRAME_DROP = false;
|
||||||
private static final boolean DEFAULT_ENABLE_HDR = false;
|
private static final boolean DEFAULT_ENABLE_HDR = false;
|
||||||
|
private static final boolean DEFAULT_ENABLE_PIP = false;
|
||||||
|
|
||||||
public static final int FORCE_H265_ON = -1;
|
public static final int FORCE_H265_ON = -1;
|
||||||
public static final int AUTOSELECT_H265 = 0;
|
public static final int AUTOSELECT_H265 = 0;
|
||||||
@ -69,6 +71,7 @@ public class PreferenceConfiguration {
|
|||||||
public boolean batterySaver;
|
public boolean batterySaver;
|
||||||
public boolean disableFrameDrop;
|
public boolean disableFrameDrop;
|
||||||
public boolean enableHdr;
|
public boolean enableHdr;
|
||||||
|
public boolean enablePip;
|
||||||
|
|
||||||
public static int getDefaultBitrate(String resFpsString) {
|
public static int getDefaultBitrate(String resFpsString) {
|
||||||
if (resFpsString.equals("720p30")) {
|
if (resFpsString.equals("720p30")) {
|
||||||
@ -213,6 +216,7 @@ public class PreferenceConfiguration {
|
|||||||
config.batterySaver = prefs.getBoolean(BATTERY_SAVER_PREF_STRING, DEFAULT_BATTERY_SAVER);
|
config.batterySaver = prefs.getBoolean(BATTERY_SAVER_PREF_STRING, DEFAULT_BATTERY_SAVER);
|
||||||
config.disableFrameDrop = prefs.getBoolean(DISABLE_FRAME_DROP_PREF_STRING, DEFAULT_DISABLE_FRAME_DROP);
|
config.disableFrameDrop = prefs.getBoolean(DISABLE_FRAME_DROP_PREF_STRING, DEFAULT_DISABLE_FRAME_DROP);
|
||||||
config.enableHdr = prefs.getBoolean(ENABLE_HDR_PREF_STRING, DEFAULT_ENABLE_HDR);
|
config.enableHdr = prefs.getBoolean(ENABLE_HDR_PREF_STRING, DEFAULT_ENABLE_HDR);
|
||||||
|
config.enablePip = prefs.getBoolean(ENABLE_PIP_PREF_STRING, DEFAULT_ENABLE_PIP);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,13 @@ public class StreamSettings extends Activity {
|
|||||||
screen.removePreference(category);
|
screen.removePreference(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove PiP mode on devices pre-Oreo
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
|
PreferenceCategory category =
|
||||||
|
(PreferenceCategory) findPreference("category_basic_settings");
|
||||||
|
category.removePreference(findPreference("checkbox_enable_pip"));
|
||||||
|
}
|
||||||
|
|
||||||
// Remove HDR preference for devices below Nougat
|
// Remove HDR preference for devices below Nougat
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
LimeLog.info("Excluding HDR toggle based on OS");
|
LimeLog.info("Excluding HDR toggle based on OS");
|
||||||
|
@ -110,6 +110,8 @@
|
|||||||
<string name="summary_checkbox_disable_warnings">Disable on-screen connection warning messages while streaming</string>
|
<string name="summary_checkbox_disable_warnings">Disable on-screen connection warning messages while streaming</string>
|
||||||
<string name="title_checkbox_battery_saver">Battery saver</string>
|
<string name="title_checkbox_battery_saver">Battery saver</string>
|
||||||
<string name="summary_checkbox_battery_saver">Uses less battery, but may increase stuttering</string>
|
<string name="summary_checkbox_battery_saver">Uses less battery, but may increase stuttering</string>
|
||||||
|
<string name="title_checkbox_enable_pip">Enable Picture-in-Picture observer mode</string>
|
||||||
|
<string name="summary_checkbox_enable_pip">Allows the stream to be viewed (but not controlled) while multitasking</string>
|
||||||
|
|
||||||
<string name="category_audio_settings">Audio Settings</string>
|
<string name="category_audio_settings">Audio Settings</string>
|
||||||
<string name="title_checkbox_51_surround">Enable 5.1 surround sound</string>
|
<string name="title_checkbox_51_surround">Enable 5.1 surround sound</string>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/category_basic_settings">
|
<PreferenceCategory android:title="@string/category_basic_settings"
|
||||||
|
android:key="category_basic_settings">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="list_resolution_fps"
|
android:key="list_resolution_fps"
|
||||||
android:title="@string/title_resolution_list"
|
android:title="@string/title_resolution_list"
|
||||||
@ -25,6 +26,11 @@
|
|||||||
android:title="@string/title_checkbox_battery_saver"
|
android:title="@string/title_checkbox_battery_saver"
|
||||||
android:summary="@string/summary_checkbox_battery_saver"
|
android:summary="@string/summary_checkbox_battery_saver"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="checkbox_enable_pip"
|
||||||
|
android:title="@string/title_checkbox_enable_pip"
|
||||||
|
android:summary="@string/summary_checkbox_enable_pip"
|
||||||
|
android:defaultValue="false" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/category_audio_settings">
|
<PreferenceCategory android:title="@string/category_audio_settings">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
Loading…
x
Reference in New Issue
Block a user