mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-26 22:43:05 +00:00
Fix native screen resolution on devices running Lollipop and earlier
Fixes #967
This commit is contained in:
parent
fe630e9383
commit
b3d4763ef6
@ -15,6 +15,7 @@ import android.preference.PreferenceCategory;
|
|||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Range;
|
import android.util.Range;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -28,6 +29,7 @@ import com.limelight.binding.video.MediaCodecHelper;
|
|||||||
import com.limelight.utils.Dialog;
|
import com.limelight.utils.Dialog;
|
||||||
import com.limelight.utils.UiHelper;
|
import com.limelight.utils.UiHelper;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class StreamSettings extends Activity {
|
public class StreamSettings extends Activity {
|
||||||
@ -334,12 +336,30 @@ public class StreamSettings extends Activity {
|
|||||||
// Never remove 720p
|
// Never remove 720p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||||
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
// On Android 4.2 and later, we can get the true metrics via the
|
||||||
int width = Math.max(display.getWidth(), display.getHeight());
|
// getRealMetrics() function (unlike the lies that getWidth() and getHeight()
|
||||||
int height = Math.min(display.getWidth(), display.getHeight());
|
// tell to us).
|
||||||
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
getActivity().getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
|
||||||
|
int width = Math.max(metrics.widthPixels, metrics.heightPixels);
|
||||||
|
int height = Math.min(metrics.widthPixels, metrics.heightPixels);
|
||||||
addNativeResolutionEntry(width, height);
|
addNativeResolutionEntry(width, height);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// On Android 4.1, we have to resort to reflection to invoke hidden APIs
|
||||||
|
// to get the real screen dimensions.
|
||||||
|
Display display = getActivity().getWindowManager().getDefaultDisplay();
|
||||||
|
try {
|
||||||
|
Method getRawHeightFunc = Display.class.getMethod("getRawHeight");
|
||||||
|
Method getRawWidthFunc = Display.class.getMethod("getRawWidth");
|
||||||
|
int width = (Integer) getRawWidthFunc.invoke(display);
|
||||||
|
int height = (Integer) getRawHeightFunc.invoke(display);
|
||||||
|
addNativeResolutionEntry(Math.max(width, height), Math.min(width, height));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!PreferenceConfiguration.readPreferences(this.getActivity()).unlockFps) {
|
if (!PreferenceConfiguration.readPreferences(this.getActivity()).unlockFps) {
|
||||||
// We give some extra room in case the FPS is rounded down
|
// We give some extra room in case the FPS is rounded down
|
||||||
|
Loading…
x
Reference in New Issue
Block a user