0.1.0-2-beta.1.fix.3
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
// file: Android/common/src/main/java/com/sasedev/games/common/NativeBridge.java
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
package com.sasedev.games.common;
|
||||
|
||||
/** Stable Java/JNI platform bridge contract shared by Android game applications. */
|
||||
public final class NativeBridge {
|
||||
private static final int CONTRACT_VERSION = 1;
|
||||
private static final int CONTRACT_VERSION = 2;
|
||||
|
||||
private NativeBridge() {
|
||||
}
|
||||
@@ -26,6 +26,9 @@ public final class NativeBridge {
|
||||
*/
|
||||
public static native int nativeContractVersion();
|
||||
|
||||
/** Sends a platform-native Back request to the Rust SDL runtime. */
|
||||
private static native void nativeRequestPlatformBack();
|
||||
|
||||
/** Verifies that the loaded native bridge matches the Java contract. */
|
||||
public static void requireCompatibleContract() {
|
||||
final int nativeVersion = nativeContractVersion();
|
||||
@@ -34,4 +37,9 @@ public final class NativeBridge {
|
||||
"Native bridge contract mismatch: java=" + CONTRACT_VERSION + ", native=" + nativeVersion);
|
||||
}
|
||||
}
|
||||
|
||||
/** Requests Back through the common Rust engine quit policy. */
|
||||
public static void requestPlatformBack() {
|
||||
nativeRequestPlatformBack();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// file: Android/common/src/main/java/com/sasedev/games/common/SaseGameActivity.java
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
package com.sasedev.games.common;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
@@ -17,6 +18,16 @@ public abstract class SaseGameActivity extends org.libsdl.app.SDLActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
NativeBridge.requireCompatibleContract();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
Api33BackHandler.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
NativeBridge.requestPlatformBack();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -31,4 +42,16 @@ public abstract class SaseGameActivity extends org.libsdl.app.SDLActivity {
|
||||
* @return game identifier
|
||||
*/
|
||||
public abstract String gameId();
|
||||
|
||||
/** API 33+ predictive Back bridge isolated from pre-33 class loading. */
|
||||
private static final class Api33BackHandler {
|
||||
private Api33BackHandler() {
|
||||
}
|
||||
|
||||
static void register(SaseGameActivity activity) {
|
||||
activity.getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
|
||||
android.window.OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||
NativeBridge::requestPlatformBack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: Android/game-reflex-poc/build.gradle
|
||||
// version: 19
|
||||
// version: 20
|
||||
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
@@ -18,7 +18,7 @@ android {
|
||||
minSdk 21
|
||||
targetSdk 36
|
||||
versionCode 1
|
||||
versionName '0.1.0-2-beta.1.fix.2'
|
||||
versionName '0.1.0-2-beta.1.fix.3'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: Android/game-snake-poc/build.gradle
|
||||
// version: 19
|
||||
// version: 20
|
||||
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
@@ -18,7 +18,7 @@ android {
|
||||
minSdk 21
|
||||
targetSdk 36
|
||||
versionCode 1
|
||||
versionName '0.1.0-2-beta.1.fix.2'
|
||||
versionName '0.1.0-2-beta.1.fix.3'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
||||
Reference in New Issue
Block a user