Skip to content

Commit

Permalink
screen rotate opti
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Jiaxin committed Oct 16, 2024
1 parent aa3e083 commit 229a16c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ private static String getMimeType(File file) {
public final void attachInfo(Context context, ProviderInfo info) {
super.attachInfo(context, info);
this.pkgName = Objects.requireNonNull(getContext()).getPackageName();
this.dataDir = Objects.requireNonNull(context.getFilesDir());
// this.dataDir = Objects.requireNonNull(context.getFilesDir().getParentFile());
this.dataDir = Objects.requireNonNull(context.getFilesDir().getParentFile());
// String path = dataDir.getPath();
// if (path.startsWith("/data/user/"))
// this.userDataDir = new File("/data/user_de/" + path.substring("/data/user/".length()));
Expand Down Expand Up @@ -299,8 +298,8 @@ private void includeFile(MatrixCursor result, String docId, File file) throws Fi
//once private directory
String path = file.getPath();
if (path.equals(this.dataDir.getPath())) {
// displayName = "data";
displayName = file.getName();
displayName = "data";
// displayName = file.getName();
} /*else if (androidDataDir != null && path.equals(androidDataDir.getPath())) {
displayName = "android_data";
} else if (androidObbDir != null && path.equals(androidObbDir.getPath())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public CursorLocker(LorieView xServer) {
this.xServer = xServer;
maxDistance = (short)(xServer.screenInfo.width * 0.05f);
Timer timer = new Timer();
timer.scheduleAtFixedRate(this, 0, 1000 / 60);
timer.schedule(this, 0, 1000 / 60);
}

public short getMaxDistance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public int flag() {
}
}

private static final float EPSILON = 0.001f;
public static final byte MAX_BUTTONS = 8;
private final ArrayList<OnPointerMotionListener> onPointerMotionListeners = new ArrayList<>();
private final Bitmask buttonMask = new Bitmask();
Expand Down Expand Up @@ -46,10 +47,16 @@ public Pointer(LorieView xServer) {
}

public void setX(int x) {
if (screenPointLiesOutsideImageBoundaryX(x)){
return;
}
this.x = (short) x;
}

public void setY(int y) {
if (screenPointLiesOutsideImageBoundaryY(y)){
return;
}
this.y = (short) y;
}

Expand All @@ -70,13 +77,25 @@ public short getClampedY() {
}

public void moveTo(int x, int y) {
if (xServer.screenInfo.setCursorPosition(x,y)){
// setX(x);
// setY(y);
if (xServer.screenInfo.setCursorPosition(x, y)) {
setX(x);
setY(y);
triggerOnPointerMove(this.x, this.y);
}
}

private boolean screenPointLiesOutsideImageBoundaryX(float screenX) {
float scaledX = screenX * xServer.screenInfo.scale.x;
float imageWidth = (float) xServer.screenInfo.imageWidth + EPSILON;
return scaledX < -EPSILON || scaledX > imageWidth;
}

private boolean screenPointLiesOutsideImageBoundaryY(float screenY) {
float scaledY = screenY * xServer.screenInfo.scale.y;
float imageHeight = (float) xServer.screenInfo.imageHeight + EPSILON;
return scaledY < -EPSILON || scaledY > imageHeight;
}

public Bitmask getButtonMask() {
return buttonMask;
}
Expand Down

0 comments on commit 229a16c

Please sign in to comment.