diff --git a/.gitattributes b/.gitattributes index e102958589..282be498c8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,6 +6,7 @@ *.py text *.rb text *.sh text +*.bat text eol=crlf # external sources tests/doctest.h -diff linguist-vendored diff --git a/builds/android/app/build.gradle b/builds/android/app/build.gradle index 92b7694abe..48dd2db6e2 100644 --- a/builds/android/app/build.gradle +++ b/builds/android/app/build.gradle @@ -5,8 +5,8 @@ android { assetPacks = [":assets"] defaultConfig { applicationId "org.easyrpg.player" - compileSdk 36 - minSdkVersion 21 + compileSdkVersion 36 + minSdkVersion 23 targetSdkVersion 36 versionName VERSION_NAME versionCode Integer.parseInt(VERSION_CODE) @@ -42,11 +42,11 @@ android { version "3.22.1" } } - lint { - abortOnError false - disable 'MissingTranslation' - } - defaultConfig { + lint { + abortOnError false + disable 'MissingTranslation' + } + defaultConfig { externalNativeBuild { cmake { arguments "-DPLAYER_GRADLE_BUILD=ON", @@ -76,12 +76,12 @@ allprojects { } dependencies { - implementation 'androidx.appcompat:appcompat:1.7.0' - implementation "androidx.activity:activity:1.10.1" - implementation 'com.google.android.material:material:1.12.0' + implementation 'androidx.appcompat:appcompat:1.7.1' + implementation "androidx.activity:activity:1.13.0" + implementation 'com.google.android.material:material:1.13.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.2.1' - implementation 'androidx.documentfile:documentfile:1.0.1' + implementation 'androidx.documentfile:documentfile:1.1.0' implementation 'org.ini4j:ini4j:0.5.4' } diff --git a/builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java b/builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java index dbc861ba50..4e2671e3ba 100644 --- a/builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java +++ b/builds/android/app/src/main/java/org/easyrpg/player/game_browser/GameBrowserActivity.java @@ -248,7 +248,6 @@ public void displayGamesList() { getLayoutInflater().inflate(R.layout.browser_games_grid, content_layout); gamesGridRecyclerView = findViewById(R.id.games_grid_recycle_view); - gamesGridRecyclerView.setHasFixedSize(true); setGamesGridSize(); reorderGameList(); diff --git a/builds/android/app/src/main/java/org/easyrpg/player/player/EasyRpgPlayerActivity.java b/builds/android/app/src/main/java/org/easyrpg/player/player/EasyRpgPlayerActivity.java index b735783eeb..71973b1d70 100644 --- a/builds/android/app/src/main/java/org/easyrpg/player/player/EasyRpgPlayerActivity.java +++ b/builds/android/app/src/main/java/org/easyrpg/player/player/EasyRpgPlayerActivity.java @@ -31,6 +31,7 @@ import android.content.Intent; import android.content.res.AssetManager; import android.content.res.Configuration; +import android.graphics.Insets; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -39,17 +40,17 @@ import android.text.method.LinkMovementMethod; import android.text.util.Linkify; import android.util.Log; +import android.view.KeyEvent; import android.view.MenuItem; import android.view.MotionEvent; -import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; import android.widget.TextView; +import android.window.OnBackInvokedDispatcher; -import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.core.content.FileProvider; import androidx.core.view.GravityCompat; @@ -90,7 +91,8 @@ public class EasyRpgPlayerActivity extends SDLActivity implements NavigationView DrawerLayout drawer; InputLayout inputLayout; private boolean uiVisible = true; - SurfaceView surface; + + private int topInset = 0; @Override protected String[] getLibraries() { @@ -114,6 +116,9 @@ protected void onCreate(Bundle savedInstanceState) { SettingsManager.init(getApplicationContext()); + // Load our custom activity layout + setContentView(R.layout.activity_player); + // Menu configuration this.drawer = findViewById(R.id.drawer_layout); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); @@ -150,19 +155,15 @@ public void onDrawerStateChanged(int newState) { this.setOrientationBis(0, 0, false, "LandscapeRight|LandscapeLeft"); } - // Hardware acceleration - try { - // Api > 11: FLAG_HARDWARE_ACCELERATED - // TODO : Is it still useful? - getWindow().setFlags(0x01000000, 0x01000000); - } catch (Exception e) { - e.printStackTrace(); - } - // Put the gameScreen - surface = mSurface; mLayout = findViewById(R.id.main_layout); - mLayout.addView(surface); + + ViewGroup parent = (ViewGroup) mSurface.getParent(); + if (parent != null) { + parent.removeView(mSurface); + } + mLayout.addView(mSurface); + updateScreenPosition(); if (Build.VERSION.SDK_INT >= 35) { @@ -170,6 +171,8 @@ public void onDrawerStateChanged(int newState) { @NonNull @Override public WindowInsets onApplyWindowInsets(@NonNull View view, @NonNull WindowInsets insets) { + Insets systemInsets = insets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()); + topInset = systemInsets.top; showInputLayout(); return insets; } @@ -178,13 +181,14 @@ public WindowInsets onApplyWindowInsets(@NonNull View view, @NonNull WindowInset showInputLayout(); } - OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) { - @Override - public void handleOnBackPressed() { - backPressed(); - } - }; - getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback); + if (Build.VERSION.SDK_INT >= 33) { + getOnBackInvokedDispatcher().registerOnBackInvokedCallback( + OnBackInvokedDispatcher.PRIORITY_DEFAULT, + () -> { + backPressed(); + } + ); + } } @Override @@ -333,6 +337,22 @@ public void backPressed() { openOrCloseMenu(); } + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + if (Build.VERSION.SDK_INT >= 33) { + // Uses OnBackInvokedDispatcher + return super.dispatchKeyEvent(event); + } + + // Handle back button on older Androids + if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { + backPressed(); + return false; + } + + return super.dispatchKeyEvent(event); + } + @Override public void setOrientationBis(int w, int h, boolean resizable, String hint) { // Filter orientation events generated by SDL (hint is empty) @@ -468,11 +488,11 @@ public void updateScreenPosition() { // Determine the multiplier int screenWidth = getWindowManager().getDefaultDisplay().getWidth(); - params.topMargin = 0; + params.topMargin = topInset; params.leftMargin = 0; params.width = screenWidth; params.height = (int)(screenWidth * 0.75); - surface.setLayoutParams(params); + mSurface.setLayoutParams(params); } /** diff --git a/builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java index 7987d57c26..b2fd9cd5ee 100644 --- a/builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -54,18 +54,16 @@ import java.util.Locale; // EasyRPG additions -import org.easyrpg.player.R; import androidx.appcompat.app.AppCompatActivity; /** SDL Activity */ -// EasyRPG modification: extends AppCompatActivity -public class SDLActivity extends AppCompatActivity implements View.OnSystemUiVisibilityChangeListener { +public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener { private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 32; - private static final int SDL_MICRO_VERSION = 6; + private static final int SDL_MICRO_VERSION = 10; /* // Display InputType.SOURCE/CLASS of events and devices // @@ -334,9 +332,6 @@ protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "modify thread properties failed " + e.toString()); } - // EasyRPG modification: overwrite layout - setContentView(R.layout.activity_player); - // Load shared libraries String errorMsgBrokenLib = ""; try { @@ -402,10 +397,8 @@ public void onClick(DialogInterface dialog,int id) { // Set up the surface mSurface = createSDLSurface(this); - /* EasyRPG modification: overwrite layout mLayout = new RelativeLayout(this); mLayout.addView(mSurface); - */ // Get our current screen orientation and pass it down. mCurrentOrientation = SDLActivity.getCurrentOrientation(); @@ -421,9 +414,7 @@ public void onClick(DialogInterface dialog,int id) { } catch(Exception ignored) { } - /* EasyRPG modification: overwrite layout setContentView(mLayout); - */ setWindowStyle(false); @@ -1323,13 +1314,6 @@ public static boolean isTextInputEvent(KeyEvent event) { } public static boolean handleKeyEvent(View v, int keyCode, KeyEvent event, InputConnection ic) { - // EasyRPG addition: handle back button on Xperia - if (event.getKeyCode() == KeyEvent.KEYCODE_MENU || - ((keyCode == KeyEvent.KEYCODE_BACK) && (!event.isAltPressed()))) { - return false; - } - // End of EasyRPG addition - int deviceId = event.getDeviceId(); int source = event.getSource(); diff --git a/builds/android/app/src/main/res/layout/activity_init.xml b/builds/android/app/src/main/res/layout/activity_init.xml index 0134e220b7..0edd075460 100644 --- a/builds/android/app/src/main/res/layout/activity_init.xml +++ b/builds/android/app/src/main/res/layout/activity_init.xml @@ -8,11 +8,12 @@ android:padding="10dp" tools:context=".InitActivity" android:orientation="vertical" - android:gravity="center"> + android:fillViewport="true"> + android:orientation="vertical" + android:gravity="center">