feat(autojs): requestScreenCapture() supports changing orientation automatically and dynamically

This commit is contained in:
hyb1996
2018-06-03 11:12:01 +08:00
parent 28a551324a
commit 35a5abed6a
3 changed files with 90 additions and 40 deletions

View File

@@ -1,6 +1,7 @@
package com.stardust.util;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.Point;
import android.util.DisplayMetrics;
import android.view.Display;
@@ -44,6 +45,22 @@ public class ScreenMetrics {
return deviceScreenDensity;
}
public static int getOrientationAwareScreenWidth(int orientation) {
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return getDeviceScreenHeight();
} else {
return getDeviceScreenWidth();
}
}
public static int getOrientationAwareScreenHeight(int orientation) {
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return getDeviceScreenWidth();
} else {
return getDeviceScreenHeight();
}
}
public static int scaleX(int x, int width) {
if (width == 0 || !initialized)
return x;