diff options
author | Fredia Huya-Kouadio <fhuyakou@gmail.com> | 2022-04-04 02:22:51 -0700 |
---|---|---|
committer | Fredia Huya-Kouadio <fhuyakou@gmail.com> | 2022-04-04 09:23:43 -0700 |
commit | 8eabf77f5403e7d7aff770f73a9b7906b424149a (patch) | |
tree | ed83fef086d1e03b9a4c999d8cc95258665deb52 /platform/android/java | |
parent | 10d9e479491c25a350a8ed191987dd36ed43c073 (diff) |
Update the editor display scale based on the device's scaled density
Diffstat (limited to 'platform/android/java')
3 files changed, 22 insertions, 1 deletions
diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.java b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.java index b3a340cc64..8a6bf88267 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.java +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.java @@ -107,4 +107,18 @@ public class GodotEditor extends FullScreenGodotApp { Intent newInstance = new Intent(this, targetClass).putExtra(COMMAND_LINE_PARAMS, args); startActivity(newInstance); } + + @Override + public void setRequestedOrientation(int requestedOrientation) { + if (!overrideOrientationRequest()) { + super.setRequestedOrientation(requestedOrientation); + } + } + + /** + * The Godot Android Editor sets its own orientation via its AndroidManifest + */ + protected boolean overrideOrientationRequest() { + return true; + } } diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.java b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.java index 5a0be391cf..12766775a8 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.java +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.java @@ -34,4 +34,7 @@ package org.godotengine.editor; * Drives the 'run project' window of the Godot Editor. */ public class GodotGame extends GodotEditor { + protected boolean overrideOrientationRequest() { + return false; + } } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java index b151e7eec1..e8e292df5d 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java @@ -222,10 +222,14 @@ public class GodotIO { } public int getScreenDPI() { - DisplayMetrics metrics = activity.getApplicationContext().getResources().getDisplayMetrics(); + DisplayMetrics metrics = activity.getResources().getDisplayMetrics(); return (int)(metrics.density * 160f); } + public float getScaledDensity() { + return activity.getResources().getDisplayMetrics().scaledDensity; + } + public double getScreenRefreshRate(double fallback) { Display display = activity.getWindowManager().getDefaultDisplay(); if (display != null) { |