From f2d122a275f83890c2db0746caac598e7d34d2ff Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 21 Nov 2017 20:18:28 -0800 Subject: [PATCH] Fix screen dimensions for portrait devices --- .../com/limelight/preferences/StreamSettings.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/limelight/preferences/StreamSettings.java b/app/src/main/java/com/limelight/preferences/StreamSettings.java index b71f7642..0ef2becb 100644 --- a/app/src/main/java/com/limelight/preferences/StreamSettings.java +++ b/app/src/main/java/com/limelight/preferences/StreamSettings.java @@ -124,12 +124,17 @@ public class StreamSettings extends Activity { // AVC supported width range: 64 - 384 // HEVC supported width range: 64 - 544 for (Display.Mode candidate : display.getSupportedModes()) { - if ((candidate.getPhysicalWidth() >= 3840 || candidate.getPhysicalHeight() >= 2160) && - maxSupportedResW < 3840) { + // Some devices report their dimensions in the portrait orientation + // where height > width. Normalize these to the conventional width > height + // arrangement before we process them. + + int width = Math.max(candidate.getPhysicalWidth(), candidate.getPhysicalHeight()); + int height = Math.min(candidate.getPhysicalWidth(), candidate.getPhysicalHeight()); + + if ((width >= 3840 || height >= 2160) && maxSupportedResW < 3840) { maxSupportedResW = 3840; } - else if ((candidate.getPhysicalWidth() >= 1920 || candidate.getPhysicalHeight() >= 1080) && - maxSupportedResW < 1920) { + else if ((width >= 1920 || height >= 1080) && maxSupportedResW < 1920) { maxSupportedResW = 1920; } }