Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.py text
*.rb text
*.sh text
*.bat text eol=crlf

# external sources
tests/doctest.h -diff linguist-vendored
Expand Down
22 changes: 11 additions & 11 deletions builds/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand All @@ -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);
Expand Down Expand Up @@ -150,26 +155,24 @@ 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) {
getWindow().getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsets onApplyWindowInsets(@NonNull View view, @NonNull WindowInsets insets) {
Insets systemInsets = insets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars());
topInset = systemInsets.top;
showInputLayout();
return insets;
}
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

/**
Expand Down
20 changes: 2 additions & 18 deletions builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand All @@ -421,9 +414,7 @@ public void onClick(DialogInterface dialog,int id) {
} catch(Exception ignored) {
}

/* EasyRPG modification: overwrite layout
setContentView(mLayout);
*/

setWindowStyle(false);

Expand Down Expand Up @@ -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();

Expand Down
5 changes: 3 additions & 2 deletions builds/android/app/src/main/res/layout/activity_init.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
android:padding="10dp"
tools:context=".InitActivity"
android:orientation="vertical"
android:gravity="center">
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:gravity="center">
<Button
android:id="@+id/set_games_folder"
android:layout_width="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion builds/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.7.3'
classpath 'com.android.tools.build:gradle:8.13.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Binary file modified builds/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion builds/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
8 changes: 5 additions & 3 deletions builds/android/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions builds/android/gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading