Skip to content

Commit 3bc3264

Browse files
authored
Merge pull request #250 from chrisws/12_29
12 29
2 parents a7fc68c + 4fbdec5 commit 3bc3264

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ do
3535
xxd -n img_${imageFile} -i ${imageFile}.png >> keypad_icons.h
3636
done
3737

38-
mv keypad_icons.h ../../src/ui
38+
mv keypad_icons.h ../src/ui
3939

src/platform/android/app/src/main/java/net/sourceforge/smallbasic/MainActivity.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ public int getWindowHeight() {
429429
return rect.height();
430430
}
431431

432+
public boolean isPredictiveBack() {
433+
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU;
434+
}
435+
432436
public boolean loadModules() {
433437
Log.i(TAG, "loadModules: " + getActivity());
434438
boolean result;
@@ -1063,7 +1067,7 @@ private void setImmersiveMode() {
10631067
// Hook into Predictive Back (Android 13+)
10641068
//
10651069
private void setupPredictiveBack() {
1066-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
1070+
if (isPredictiveBack()) {
10671071
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
10681072
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
10691073
new OnBackInvokedCallback() {

src/platform/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
mavenCentral()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:8.11.1'
8+
classpath 'com.android.tools.build:gradle:8.12.0'
99
}
1010
}
1111

src/platform/android/jni/runtime.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Runtime *runtime = nullptr;
3333
// Pipe file descriptors: g_backPipe[0] is read-end, g_backPipe[1] is write-end
3434
static int g_backPipe[2] = {-1, -1};
3535

36+
// whether native back key handling is active
37+
static bool g_predictiveBack = false;
38+
3639
// the sensorTypes corresponding to _sensors[] positions
3740
constexpr int SENSOR_TYPES[MAX_SENSORS] = {
3841
ASENSOR_TYPE_ACCELEROMETER,
@@ -159,7 +162,7 @@ static void process_input(android_app *app, android_poll_source *source) {
159162
AKeyEvent_getKeyCode(event) == AKEYCODE_BACK) {
160163
// prevent AInputQueue_preDispatchEvent from attempting to close
161164
// the keypad here to avoid a crash in android 4.2 + 4.3.
162-
if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN && runtime->isActive()) {
165+
if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN && runtime->isActive() && !g_predictiveBack) {
163166
pushBackEvent();
164167
}
165168
AInputQueue_finishEvent(app->inputQueue, event, true);
@@ -287,7 +290,10 @@ Runtime::Runtime(android_app *app) :
287290
_looper = ALooper_forThread();
288291
_sensorManager = ASensorManager_getInstance();
289292
memset(&_sensors, 0, sizeof(_sensors));
290-
setupBackWakePipe(_looper);
293+
g_predictiveBack = getBoolean("isPredictiveBack");
294+
if (g_predictiveBack) {
295+
setupBackWakePipe(_looper);
296+
}
291297
}
292298

293299
Runtime::~Runtime() {

src/platform/teensy/src/serial.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This file is part of SmallBASIC
2+
//
3+
// Copyright(C) 2001-2025 Chris Warren-Smith.
4+
// Copyright(C) 2000 Nicholas Christopoulos
5+
//
6+
// This program is distributed under the terms of the GPL v2.0 or later
7+
// Download the GNU Public License (GPL) from www.gnu.org
8+
//
9+
10+
#pragma once
11+
12+
void serial_init();

0 commit comments

Comments
 (0)