[Scummvm-git-logs] scummvm master -> 7650456a0e6e20fc7c529e0bab1bdab48cb86441

lephilousophe noreply at scummvm.org
Sun Nov 2 08:13:19 UTC 2025


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
066b88a661 ANDROID: Make keyboardWithoutTextInputShown non static
7650456a0e ANDROID: Introduce back long-press on back button handling


Commit: 066b88a661487caa6e00f3eb3bea40f9fe619989
    https://github.com/scummvm/scummvm/commit/066b88a661487caa6e00f3eb3bea40f9fe619989
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-11-02T09:13:16+01:00

Commit Message:
ANDROID: Make keyboardWithoutTextInputShown non static

And use the proper accessor to read it.

Changed paths:
    backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
    backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java


diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index b39a8426246..7f5b304adfb 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -126,7 +126,7 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 	private int _layoutOrientation;
 
 	public View _screenKeyboard = null;
-	static boolean keyboardWithoutTextInputShown = false;
+	private boolean keyboardWithoutTextInputShown = false;
 
 //	boolean _isPaused = false;
 	private InputMethodManager _inputManager = null;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
index 7093dfd215f..04445b58c68 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -373,7 +373,7 @@ public class ScummVMEvents implements
 				}
 			}
 
-			if (ScummVMActivity.keyboardWithoutTextInputShown ) {
+			if (_activity.isKeyboardOverlayShown()) {
 				if (action == KeyEvent.ACTION_DOWN) {
 					return true;
 				} else if (action == KeyEvent.ACTION_UP) {
@@ -643,7 +643,7 @@ public class ScummVMEvents implements
 //			Log.d(ScummVM.LOG_TAG,prefixDBGMsg + "Single touch event:: x: " + xPos + " y: " + yPos);
 //		}
 
-		if (ScummVMActivity.keyboardWithoutTextInputShown
+		if (_activity.isKeyboardOverlayShown()
 		    && _activity.isScreenKeyboardShown()
 		    && _activity.getScreenKeyboard().getY() <= event.getY() ) {
 			event.offsetLocation(-_activity.getScreenKeyboard().getX(), -_activity.getScreenKeyboard().getY());


Commit: 7650456a0e6e20fc7c529e0bab1bdab48cb86441
    https://github.com/scummvm/scummvm/commit/7650456a0e6e20fc7c529e0bab1bdab48cb86441
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-11-02T09:13:16+01:00

Commit Message:
ANDROID: Introduce back long-press on back button handling

This allows to display the system menu.
It needs Android 14 so we can't set enableOnBackInvokedCallback to true
because we would get an incomplete behaviour on Android 13.
In this case, the feature is only enabled starting with Android 16, so
don't register our handler before.

Changed paths:
    backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
    dists/android/AndroidManifest.xml


diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
index 04445b58c68..45df86e2363 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -12,7 +12,8 @@ import android.view.InputDevice;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewConfiguration;
-import android.window.OnBackInvokedCallback;
+import android.window.BackEvent;
+import android.window.OnBackAnimationCallback;
 import android.window.OnBackInvokedDispatcher;
 
 import androidx.annotation.NonNull;
@@ -130,13 +131,40 @@ public class ScummVMEvents implements
 		}
 	}
 
-	@RequiresApi(android.os.Build.VERSION_CODES.TIRAMISU)
-	private class OnBackInvoked implements OnBackInvokedCallback {
+	@RequiresApi(android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
+	private class OnBackInvoked implements OnBackAnimationCallback {
+		@Override
+		public void onBackStarted(@NonNull BackEvent backEvent) {
+			final int typeOfLongPressMessage = MSG_SBACK_LONG_PRESS;
+			final boolean fired = !_handler.hasMessages(typeOfLongPressMessage);
+			_handler.removeMessages(typeOfLongPressMessage);
+			_handler.sendMessageDelayed(_handler.obtainMessage(typeOfLongPressMessage), _longPressTimeout);
+		}
+
+		@Override
+		public void onBackCancelled() {
+			_handler.removeMessages(MSG_SBACK_LONG_PRESS);
+		}
+
 		@Override
 		public void onBackInvoked() {
+			if (_activity.isKeyboardOverlayShown() &&
+				_activity.isScreenKeyboardShown()) {
+				_activity.hideScreenKeyboard();
+				return;
+			}
+
+			final int typeOfLongPressMessage = MSG_SBACK_LONG_PRESS;
+			final boolean fired = !_handler.hasMessages(typeOfLongPressMessage);
+			_handler.removeMessages(typeOfLongPressMessage);
+
+			if (fired) {
+				return;
+			}
+
 			//Log.d(ScummVM.LOG_TAG,"Sending back key");
 			ScummVMEvents.this._scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK,
-					0, 0, 0, 0);
+				0, 0, 0, 0);
 			ScummVMEvents.this._scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK,
 					0, 0, 0, 0);
 		}
@@ -169,8 +197,15 @@ public class ScummVMEvents implements
 		_doubleTapMode = false;
 		_longPressTimeout = ViewConfiguration.getLongPressTimeout();
 
-		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
-			activity.getOnBackInvokedDispatcher().registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_DEFAULT, new OnBackInvoked());
+		/*
+		 * Register our OnBackInvokedCallback starting with Baklava
+		 * Before, it's not enabled by default.
+		 * We don't want to get it too soon, because OnBackAnimationCallback (which we require to
+		 * handle the long press on back) is not available in Tiramisu when the feature was introduced.
+		 */
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA) {
+			activity.getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
+				OnBackInvokedDispatcher.PRIORITY_DEFAULT, new OnBackInvoked());
 		}
 	}
 
diff --git a/dists/android/AndroidManifest.xml b/dists/android/AndroidManifest.xml
index d4e40808636..8b9c4124210 100644
--- a/dists/android/AndroidManifest.xml
+++ b/dists/android/AndroidManifest.xml
@@ -41,7 +41,6 @@
 		android:allowBackup="true"
 		android:appCategory="game"
 		android:description="@string/app_desc"
-		android:enableOnBackInvokedCallback="true"
 		android:icon="@mipmap/scummvm"
 		android:intentMatchingFlags="enforceIntentFilter"
 		android:label="@string/app_name${nameSuffix}"




More information about the Scummvm-git-logs mailing list