Skip to content

Commit bde8dcd

Browse files
committed
android: Merge from bevy PR
This merges changes relevant to 0.18.1 from bevyengine/bevy#23491 It additionally updates targetSdk and compileSdk which I will later do in that PR.
1 parent b6e6dd2 commit bde8dcd

5 files changed

Lines changed: 46 additions & 30 deletions

File tree

mobile/android/app/build.gradle.kts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,24 @@ plugins {
1414
alias(libs.plugins.android.application)
1515
}
1616

17+
java {
18+
// https://docs.gradle.org/current/userguide/toolchains.html
19+
toolchain {
20+
languageVersion = JavaLanguageVersion.of(17)
21+
}
22+
}
23+
1724
kotlin {
25+
// https://kotlinlang.org/docs/gradle-compiler-options.html#all-compiler-options
1826
compilerOptions {
1927
languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_3
20-
jvmToolchain(8)
28+
jvmToolchain(17)
2129
}
2230
}
2331

2432
android {
2533
namespace = "dev.meinel.slimymist"
26-
compileSdk = 36
34+
compileSdk = 37
2735

2836
// https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/SigningConfig
2937
signingConfigs {
@@ -43,8 +51,9 @@ android {
4351
// https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/DefaultConfig
4452
defaultConfig {
4553
applicationId = "dev.meinel.slimymist"
46-
minSdk = 31
47-
targetSdk = 36
54+
// NOTE: `minSdk` is 26 because this is the minimum supported by `bevy_audio`
55+
minSdk = 26
56+
targetSdk = 37
4857
// NOTE: Increase by 1 on each release
4958
versionCode = 54
5059
// NOTE: Update with full semantic version on each release
@@ -86,8 +95,8 @@ android {
8695
}
8796
// https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/CompileOptions
8897
compileOptions {
89-
sourceCompatibility = JavaVersion.VERSION_1_8
90-
targetCompatibility = JavaVersion.VERSION_1_8
98+
sourceCompatibility = JavaVersion.VERSION_17
99+
targetCompatibility = JavaVersion.VERSION_17
91100
}
92101
// https://developer.android.com/reference/tools/gradle-api/9.1/com/android/build/api/dsl/BuildFeatures
93102
buildFeatures {

mobile/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:tools="http://schemas.android.com/tools">
55

6-
<application android:icon="@mipmap/ic_launcher" android:label="Slimy Mist" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/Theme.AppCompat.NoActionBar" tools:targetApi="36">
7-
<activity android:name=".MainActivity" android:configChanges="layoutDirection|locale|orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" android:exported="true" android:theme="@style/Theme.AppCompat.NoActionBar">
6+
<application android:icon="@mipmap/ic_launcher" android:label="Slimy Mist" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/Theme.AppCompat.NoActionBar" tools:targetApi="37">
7+
<activity android:name=".MainActivity" android:exported="true" android:configChanges="layoutDirection|locale|orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode" android:theme="@style/Theme.AppCompat.NoActionBar">
88
<meta-data android:name="android.app.lib_name" android:value="slimy_mist" />
99
<intent-filter>
1010
<action android:name="android.intent.action.MAIN" />

mobile/android/app/src/main/kotlin/dev/meinel/slimymist/MainActivity.kt

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,55 @@
1313

1414
package dev.meinel.slimymist
1515

16+
import android.os.Bundle
1617
import androidx.core.view.WindowCompat
1718
import androidx.core.view.WindowInsetsCompat
1819
import androidx.core.view.WindowInsetsControllerCompat
1920
import com.google.androidgamesdk.GameActivity
2021

2122
/**
22-
* Loads the rust library and handles android specific to integrate with it.
23+
* Load rust library and handle android specifics to integrate with it.
2324
*
2425
*
2526
* The library is loaded at class initialization and provided by jniLibs.
2627
*/
2728
class MainActivity : GameActivity() {
2829
/**
29-
* Called when the current Window of the activity gains or loses focus.
30+
* Enable edge to edge when the activity is starting.
3031
*
3132
*
32-
* This just hides the system UI if the app window is focused.
33+
* This is the default behavior after Android SDK 34 but is needed for backwards compatibility.
34+
*/
35+
override fun onCreate(savedInstanceState: Bundle?) {
36+
// Call parent class implementation of onCreate.
37+
super.onCreate(savedInstanceState)
38+
39+
WindowCompat.enableEdgeToEdge(window)
40+
}
41+
42+
/**
43+
* Hide system UI if the current window gains or loses focus.
3344
*/
3445
override fun onWindowFocusChanged(hasFocus: Boolean) {
35-
// Call parent class implementation of onWindowFocusChanged to make sure that we are updating correctly.
46+
// Call parent class implementation of onWindowFocusChanged.
3647
super.onWindowFocusChanged(hasFocus)
3748

38-
// If the window has focus, hide system UI.
3949
if (hasFocus) {
4050
hideSystemUi()
4151
}
4252
}
4353

4454
/**
45-
* Hides system UI.
46-
*
47-
*
48-
* This will make the app content fill the entire screen.
55+
* Hide system UI.
4956
*/
5057
private fun hideSystemUi() {
51-
val windowInsetsController =
52-
WindowCompat.getInsetsController(window, window.decorView)
53-
54-
// Show bars if swiping
55-
windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
56-
// Hide both the status bar and the navigation bar.
57-
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
58+
window.decorView.post {
59+
val controller = WindowCompat.getInsetsController(window, window.decorView)
60+
// Show bars if swiping
61+
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
62+
// Hide both the status bar and the navigation bar.
63+
controller.hide(WindowInsetsCompat.Type.systemBars())
64+
}
5865
}
5966

6067
companion object {

mobile/android/gradle/gradle-daemon-jvm.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#This file is generated by updateDaemonJvm
22
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/40b4344c056b4284246d176d9701577f/redirect
33
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/9e87f9444e29ce8efb3f66e8435d94b4/redirect
4-
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73c462e34475aeb6509ab7ba3eda218f/redirect
4+
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/40b4344c056b4284246d176d9701577f/redirect
55
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/9e87f9444e29ce8efb3f66e8435d94b4/redirect
6-
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/29c55e6bad8a0049163f0184625cecd9/redirect
7-
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/3ac7a5361c25c0b23d933f44bdb0abd9/redirect
8-
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73c462e34475aeb6509ab7ba3eda218f/redirect
6+
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1050b2216f8beaaecc1289b17d30b586/redirect
7+
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/2208feeb3d4e12f412e9a450db1a842a/redirect
8+
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/40b4344c056b4284246d176d9701577f/redirect
99
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/9e87f9444e29ce8efb3f66e8435d94b4/redirect
1010
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/dd5b582862cacd4b8e0d82037f92a53f/redirect
1111
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/69a793dd932268c7d1ae9d8b855de8ed/redirect

mobile/android/gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Heavily inspired by: https://github.com/bevyengine/bevy/tree/main/examples/mobile
22

33
[versions]
4-
agp = "9.1.0"
4+
agp = "9.1.1"
55
appcompat = "1.7.1"
66
core = "1.18.0"
7-
gamesActivity = "4.4.0"
7+
gamesActivity = "4.4.1" # Note: This must be compatible with `android-activity` crate used by bevy.
88
material = "1.13.0"
99
coreKtx = "1.18.0"
1010

0 commit comments

Comments
 (0)