diff options
| author | Zae <zaevi@live.com> | 2023-09-26 11:00:04 +0800 |
|---|---|---|
| committer | Zae <zaevi@live.com> | 2023-09-26 11:00:04 +0800 |
| commit | 428eb1309aaadf3cf2d01e4e6cbfda16ad85bf6a (patch) | |
| tree | 339e7cfbe85b440f0618aa70bb15e4815a4ba747 /platform/android/java/lib | |
| parent | c12d63556b5c1da03a00dd4c45c40e60bd8d68c2 (diff) | |
| download | redot-engine-428eb1309aaadf3cf2d01e4e6cbfda16ad85bf6a.tar.gz | |
Support dark mode on Android and iOS.
Diffstat (limited to 'platform/android/java/lib')
| -rw-r--r-- | platform/android/java/lib/src/org/godotengine/godot/Godot.kt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt index e115494cfd..0e111d5247 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt @@ -35,6 +35,7 @@ import android.app.Activity import android.app.AlertDialog import android.content.* import android.content.pm.PackageManager +import android.content.res.Configuration import android.content.res.Resources import android.graphics.Rect import android.hardware.Sensor @@ -694,6 +695,25 @@ class Godot(private val context: Context) : SensorEventListener { } } + /** + * Returns true if dark mode is supported, false otherwise. + */ + @Keep + private fun isDarkModeSupported(): Boolean { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q + } + + /** + * Returns true if dark mode is supported and enabled, false otherwise. + */ + @Keep + private fun isDarkMode(): Boolean { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + return context.resources?.configuration?.uiMode?.and(Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES + } + return false + } + fun hasClipboard(): Boolean { return mClipboard.hasPrimaryClip() } |
