|
|
@ -16,12 +16,12 @@ public final class ScreenInfo {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Device rotation, related to the natural device orientation (0, 1, 2 or 3)
|
|
|
|
* Device rotation, related to the natural device orientation (0, 1, 2 or 3)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private final int rotation;
|
|
|
|
private final int deviceRotation;
|
|
|
|
|
|
|
|
|
|
|
|
public ScreenInfo(Rect contentRect, Size videoSize, int rotation) {
|
|
|
|
public ScreenInfo(Rect contentRect, Size videoSize, int deviceRotation) {
|
|
|
|
this.contentRect = contentRect;
|
|
|
|
this.contentRect = contentRect;
|
|
|
|
this.videoSize = videoSize;
|
|
|
|
this.videoSize = videoSize;
|
|
|
|
this.rotation = rotation;
|
|
|
|
this.deviceRotation = deviceRotation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Rect getContentRect() {
|
|
|
|
public Rect getContentRect() {
|
|
|
@ -32,16 +32,16 @@ public final class ScreenInfo {
|
|
|
|
return videoSize;
|
|
|
|
return videoSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getRotation() {
|
|
|
|
public int getDeviceRotation() {
|
|
|
|
return rotation;
|
|
|
|
return deviceRotation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ScreenInfo withRotation(int newRotation) {
|
|
|
|
public ScreenInfo withDeviceRotation(int newDeviceRotation) {
|
|
|
|
if (newRotation == rotation) {
|
|
|
|
if (newDeviceRotation == deviceRotation) {
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// true if changed between portrait and landscape
|
|
|
|
// true if changed between portrait and landscape
|
|
|
|
boolean orientationChanged = (rotation + newRotation) % 2 != 0;
|
|
|
|
boolean orientationChanged = (deviceRotation + newDeviceRotation) % 2 != 0;
|
|
|
|
Rect newContentRect;
|
|
|
|
Rect newContentRect;
|
|
|
|
Size newVideoSize;
|
|
|
|
Size newVideoSize;
|
|
|
|
if (orientationChanged) {
|
|
|
|
if (orientationChanged) {
|
|
|
@ -51,7 +51,7 @@ public final class ScreenInfo {
|
|
|
|
newContentRect = contentRect;
|
|
|
|
newContentRect = contentRect;
|
|
|
|
newVideoSize = videoSize;
|
|
|
|
newVideoSize = videoSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new ScreenInfo(newContentRect, newVideoSize, newRotation);
|
|
|
|
return new ScreenInfo(newContentRect, newVideoSize, newDeviceRotation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ScreenInfo computeScreenInfo(DisplayInfo displayInfo, Rect crop, int maxSize) {
|
|
|
|
public static ScreenInfo computeScreenInfo(DisplayInfo displayInfo, Rect crop, int maxSize) {
|
|
|
|