Skip to content

Commit 8acd2e1

Browse files
authored
Merge pull request #3522 from Ghabry/android-sdl
SDL Android: Bump to 2.32.10 and preparations for SDL3
2 parents 7704c0c + c5576c9 commit 8acd2e1

File tree

11 files changed

+69
-60
lines changed

11 files changed

+69
-60
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.py text
77
*.rb text
88
*.sh text
9+
*.bat text eol=crlf
910

1011
# external sources
1112
tests/doctest.h -diff linguist-vendored

builds/android/app/build.gradle

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ android {
55
assetPacks = [":assets"]
66
defaultConfig {
77
applicationId "org.easyrpg.player"
8-
compileSdk 36
9-
minSdkVersion 21
8+
compileSdkVersion 36
9+
minSdkVersion 23
1010
targetSdkVersion 36
1111
versionName VERSION_NAME
1212
versionCode Integer.parseInt(VERSION_CODE)
@@ -42,11 +42,11 @@ android {
4242
version "3.22.1"
4343
}
4444
}
45-
lint {
46-
abortOnError false
47-
disable 'MissingTranslation'
48-
}
49-
defaultConfig {
45+
lint {
46+
abortOnError false
47+
disable 'MissingTranslation'
48+
}
49+
defaultConfig {
5050
externalNativeBuild {
5151
cmake {
5252
arguments "-DPLAYER_GRADLE_BUILD=ON",
@@ -76,12 +76,12 @@ allprojects {
7676
}
7777

7878
dependencies {
79-
implementation 'androidx.appcompat:appcompat:1.7.0'
80-
implementation "androidx.activity:activity:1.10.1"
81-
implementation 'com.google.android.material:material:1.12.0'
79+
implementation 'androidx.appcompat:appcompat:1.7.1'
80+
implementation "androidx.activity:activity:1.13.0"
81+
implementation 'com.google.android.material:material:1.13.0'
8282
implementation 'androidx.cardview:cardview:1.0.0'
8383
implementation 'androidx.recyclerview:recyclerview:1.4.0'
8484
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
85-
implementation 'androidx.documentfile:documentfile:1.0.1'
85+
implementation 'androidx.documentfile:documentfile:1.1.0'
8686
implementation 'org.ini4j:ini4j:0.5.4'
8787
}

builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ public void displayGamesList() {
248248
getLayoutInflater().inflate(R.layout.browser_games_grid, content_layout);
249249

250250
gamesGridRecyclerView = findViewById(R.id.games_grid_recycle_view);
251-
gamesGridRecyclerView.setHasFixedSize(true);
252251
setGamesGridSize();
253252

254253
reorderGameList();

builds/android/app/src/main/java/org/easyrpg/player/player/EasyRpgPlayerActivity.java

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import android.content.Intent;
3232
import android.content.res.AssetManager;
3333
import android.content.res.Configuration;
34+
import android.graphics.Insets;
3435
import android.net.Uri;
3536
import android.os.Build;
3637
import android.os.Bundle;
@@ -39,17 +40,17 @@
3940
import android.text.method.LinkMovementMethod;
4041
import android.text.util.Linkify;
4142
import android.util.Log;
43+
import android.view.KeyEvent;
4244
import android.view.MenuItem;
4345
import android.view.MotionEvent;
44-
import android.view.SurfaceView;
4546
import android.view.View;
4647
import android.view.ViewGroup;
4748
import android.view.WindowInsets;
4849
import android.widget.RelativeLayout;
4950
import android.widget.RelativeLayout.LayoutParams;
5051
import android.widget.TextView;
52+
import android.window.OnBackInvokedDispatcher;
5153

52-
import androidx.activity.OnBackPressedCallback;
5354
import androidx.annotation.NonNull;
5455
import androidx.core.content.FileProvider;
5556
import androidx.core.view.GravityCompat;
@@ -90,7 +91,8 @@ public class EasyRpgPlayerActivity extends SDLActivity implements NavigationView
9091
DrawerLayout drawer;
9192
InputLayout inputLayout;
9293
private boolean uiVisible = true;
93-
SurfaceView surface;
94+
95+
private int topInset = 0;
9496

9597
@Override
9698
protected String[] getLibraries() {
@@ -114,6 +116,9 @@ protected void onCreate(Bundle savedInstanceState) {
114116

115117
SettingsManager.init(getApplicationContext());
116118

119+
// Load our custom activity layout
120+
setContentView(R.layout.activity_player);
121+
117122
// Menu configuration
118123
this.drawer = findViewById(R.id.drawer_layout);
119124
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
@@ -150,26 +155,24 @@ public void onDrawerStateChanged(int newState) {
150155
this.setOrientationBis(0, 0, false, "LandscapeRight|LandscapeLeft");
151156
}
152157

153-
// Hardware acceleration
154-
try {
155-
// Api > 11: FLAG_HARDWARE_ACCELERATED
156-
// TODO : Is it still useful?
157-
getWindow().setFlags(0x01000000, 0x01000000);
158-
} catch (Exception e) {
159-
e.printStackTrace();
160-
}
161-
162158
// Put the gameScreen
163-
surface = mSurface;
164159
mLayout = findViewById(R.id.main_layout);
165-
mLayout.addView(surface);
160+
161+
ViewGroup parent = (ViewGroup) mSurface.getParent();
162+
if (parent != null) {
163+
parent.removeView(mSurface);
164+
}
165+
mLayout.addView(mSurface);
166+
166167
updateScreenPosition();
167168

168169
if (Build.VERSION.SDK_INT >= 35) {
169170
getWindow().getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
170171
@NonNull
171172
@Override
172173
public WindowInsets onApplyWindowInsets(@NonNull View view, @NonNull WindowInsets insets) {
174+
Insets systemInsets = insets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars());
175+
topInset = systemInsets.top;
173176
showInputLayout();
174177
return insets;
175178
}
@@ -178,13 +181,14 @@ public WindowInsets onApplyWindowInsets(@NonNull View view, @NonNull WindowInset
178181
showInputLayout();
179182
}
180183

181-
OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
182-
@Override
183-
public void handleOnBackPressed() {
184-
backPressed();
185-
}
186-
};
187-
getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);
184+
if (Build.VERSION.SDK_INT >= 33) {
185+
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
186+
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
187+
() -> {
188+
backPressed();
189+
}
190+
);
191+
}
188192
}
189193

190194
@Override
@@ -333,6 +337,22 @@ public void backPressed() {
333337
openOrCloseMenu();
334338
}
335339

340+
@Override
341+
public boolean dispatchKeyEvent(KeyEvent event) {
342+
if (Build.VERSION.SDK_INT >= 33) {
343+
// Uses OnBackInvokedDispatcher
344+
return super.dispatchKeyEvent(event);
345+
}
346+
347+
// Handle back button on older Androids
348+
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
349+
backPressed();
350+
return false;
351+
}
352+
353+
return super.dispatchKeyEvent(event);
354+
}
355+
336356
@Override
337357
public void setOrientationBis(int w, int h, boolean resizable, String hint) {
338358
// Filter orientation events generated by SDL (hint is empty)
@@ -468,11 +488,11 @@ public void updateScreenPosition() {
468488

469489
// Determine the multiplier
470490
int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
471-
params.topMargin = 0;
491+
params.topMargin = topInset;
472492
params.leftMargin = 0;
473493
params.width = screenWidth;
474494
params.height = (int)(screenWidth * 0.75);
475-
surface.setLayoutParams(params);
495+
mSurface.setLayoutParams(params);
476496
}
477497

478498
/**

builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,16 @@
5454
import java.util.Locale;
5555

5656
// EasyRPG additions
57-
import org.easyrpg.player.R;
5857
import androidx.appcompat.app.AppCompatActivity;
5958

6059
/**
6160
SDL Activity
6261
*/
63-
// EasyRPG modification: extends AppCompatActivity
64-
public class SDLActivity extends AppCompatActivity implements View.OnSystemUiVisibilityChangeListener {
62+
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
6563
private static final String TAG = "SDL";
6664
private static final int SDL_MAJOR_VERSION = 2;
6765
private static final int SDL_MINOR_VERSION = 32;
68-
private static final int SDL_MICRO_VERSION = 6;
66+
private static final int SDL_MICRO_VERSION = 10;
6967
/*
7068
// Display InputType.SOURCE/CLASS of events and devices
7169
//
@@ -334,9 +332,6 @@ protected void onCreate(Bundle savedInstanceState) {
334332
Log.v(TAG, "modify thread properties failed " + e.toString());
335333
}
336334

337-
// EasyRPG modification: overwrite layout
338-
setContentView(R.layout.activity_player);
339-
340335
// Load shared libraries
341336
String errorMsgBrokenLib = "";
342337
try {
@@ -402,10 +397,8 @@ public void onClick(DialogInterface dialog,int id) {
402397
// Set up the surface
403398
mSurface = createSDLSurface(this);
404399

405-
/* EasyRPG modification: overwrite layout
406400
mLayout = new RelativeLayout(this);
407401
mLayout.addView(mSurface);
408-
*/
409402

410403
// Get our current screen orientation and pass it down.
411404
mCurrentOrientation = SDLActivity.getCurrentOrientation();
@@ -421,9 +414,7 @@ public void onClick(DialogInterface dialog,int id) {
421414
} catch(Exception ignored) {
422415
}
423416

424-
/* EasyRPG modification: overwrite layout
425417
setContentView(mLayout);
426-
*/
427418

428419
setWindowStyle(false);
429420

@@ -1323,13 +1314,6 @@ public static boolean isTextInputEvent(KeyEvent event) {
13231314
}
13241315

13251316
public static boolean handleKeyEvent(View v, int keyCode, KeyEvent event, InputConnection ic) {
1326-
// EasyRPG addition: handle back button on Xperia
1327-
if (event.getKeyCode() == KeyEvent.KEYCODE_MENU ||
1328-
((keyCode == KeyEvent.KEYCODE_BACK) && (!event.isAltPressed()))) {
1329-
return false;
1330-
}
1331-
// End of EasyRPG addition
1332-
13331317
int deviceId = event.getDeviceId();
13341318
int source = event.getSource();
13351319

builds/android/app/src/main/res/layout/activity_init.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
android:padding="10dp"
99
tools:context=".InitActivity"
1010
android:orientation="vertical"
11-
android:gravity="center">
11+
android:fillViewport="true">
1212
<LinearLayout
1313
android:layout_width="match_parent"
1414
android:layout_height="wrap_content"
15-
android:orientation="vertical">
15+
android:orientation="vertical"
16+
android:gravity="center">
1617
<Button
1718
android:id="@+id/set_games_folder"
1819
android:layout_width="wrap_content"

builds/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
google()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:8.7.3'
9+
classpath 'com.android.tools.build:gradle:8.13.2'
1010

1111
// NOTE: Do not place your application dependencies here; they belong
1212
// in the individual module build.gradle files
243 Bytes
Binary file not shown.

builds/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

builds/android/gradlew

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)