Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

脚本获取的屏幕宽高不随屏幕旋转而变化 (Referenced) #153

Open
SuperMonster003 opened this issue Oct 12, 2023 · 2 comments
Open
Labels
Bug 🐞 故障 Confirmed bugs or reports that are very likely to be bugs Feedback Awaited 🕒 等待反馈 Waiting for the feedback from issue creater and issue will be closed if duration is over one month

Comments

@SuperMonster003
Copy link
Owner

js解决方案

let deviceClass = device.getClass();
let widthField = deviceClass.getDeclaredField("width");
let heightField = deviceClass.getDeclaredField("height");
widthField.setAccessible(true);
heightField.setAccessible(true);
widthField.setInt(device, context.getResources().getDisplayMetrics().widthPixels);
heightField.setInt(device, context.getResources().getDisplayMetrics().heightPixels);
let rotationListener = new JavaAdapter(android.view.OrientationEventListener, {
    onOrientationChanged: function (orientation) {
        widthField.setInt(device, context.getResources().getDisplayMetrics().widthPixels);
        heightField.setInt(device, context.getResources().getDisplayMetrics().heightPixels);
    }
}, context);
rotationListener.enable();

context.getResources().getDisplayMetrics().widthPixels 在AutoJs6中的结果反而是不变的, 不知道为什么.
讲道理这两个fork干脆合并算了

@SuperMonster003

Originally posted by @happyme531 in kkevsekk1/AutoX#672 (comment)


context.getResources().getDisplayMetrics().widthPixels 正常情况下应该是随屏幕方向改变而变化的.

将于下一版本修复上述问题.

@SuperMonster003 SuperMonster003 added Accepted 🌱 受理 Maintainer may be busy resolving or fixing the labeled issues Bug 🐞 故障 Confirmed bugs or reports that are very likely to be bugs labels Oct 12, 2023
@SuperMonster003
Copy link
Owner Author

6.4.0 已尝试修复上述问题, 如问题复现, 可继续反馈.

@SuperMonster003 SuperMonster003 added Feedback Awaited 🕒 等待反馈 Waiting for the feedback from issue creater and issue will be closed if duration is over one month and removed Accepted 🌱 受理 Maintainer may be busy resolving or fixing the labeled issues labels Nov 1, 2023
happyme531 added a commit to happyme531/clxTools that referenced this issue Dec 20, 2023
@happyme531
Copy link

问题已修复,感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐞 故障 Confirmed bugs or reports that are very likely to be bugs Feedback Awaited 🕒 等待反馈 Waiting for the feedback from issue creater and issue will be closed if duration is over one month
Projects
None yet
Development

No branches or pull requests

2 participants