Skip to content

Commit

Permalink
Merge pull request #3262 from Ghabry/android
Browse files Browse the repository at this point in the history
Android: fix version bump, improve title encoding detection
  • Loading branch information
fdelapena authored Sep 2, 2024
2 parents fb5d659 + d274f13 commit f83c0fa
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ else()
CONDITION PLAYER_WITH_NLOHMANN_JSON
DEFINITION HAVE_NLOHMANN_JSON
TARGET nlohmann_json::nlohmann_json
ONLY_CONFIG
)
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,18 @@ Java_org_easyrpg_player_game_1browser_Game_reencodeTitle(JNIEnv *env, jobject th
jstring jencoding = (jstring)env->CallObjectMethod(thiz, jget_encoding_method);
std::string encoding = jstring_to_string(env, jencoding);
if (encoding == "auto") {
lcf::Encoder enc(lcf::ReaderUtil::DetectEncoding(title));
enc.Encode(title);
auto det_encodings = lcf::ReaderUtil::DetectEncodings(title);
for (auto &det_enc: det_encodings) {
if (det_enc == "UTF-16BE" || det_enc == "UTF-16LE") {
// Skip obviously wrong title encodings
continue;
}

if (lcf::Encoder encoder(det_enc); encoder.IsOk()) {
encoder.Encode(title);
break;
}
}
} else {
lcf::Encoder enc(encoding);
enc.Encode(title);
Expand Down
1 change: 0 additions & 1 deletion builds/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.easyrpg.player"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
Expand Down
12 changes: 6 additions & 6 deletions builds/android/app/src/main/java/org/libsdl/app/SDLActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
private static final String TAG = "SDL";
private static final int SDL_MAJOR_VERSION = 2;
private static final int SDL_MINOR_VERSION = 30;
private static final int SDL_MICRO_VERSION = 1;
private static final int SDL_MICRO_VERSION = 6;
/*
// Display InputType.SOURCE/CLASS of events and devices
//
Expand Down Expand Up @@ -283,7 +283,7 @@ protected String[] getLibraries() {
// Load the .so
public void loadLibraries() {
for (String lib : getLibraries()) {
SDL.loadLibrary(lib);
SDL.loadLibrary(lib, this);
}
}

Expand Down Expand Up @@ -1004,8 +1004,8 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint)
/* No valid hint, nothing is explicitly allowed */
if (!is_portrait_allowed && !is_landscape_allowed) {
if (resizable) {
/* All orientations are allowed */
req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
/* All orientations are allowed, respecting user orientation lock setting */
req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER;
} else {
/* Fixed window and nothing specified. Get orientation from w/h of created window */
req = (w > h ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
Expand All @@ -1014,8 +1014,8 @@ public void setOrientationBis(int w, int h, boolean resizable, String hint)
/* At least one orientation is allowed */
if (resizable) {
if (is_portrait_allowed && is_landscape_allowed) {
/* hint allows both landscape and portrait, promote to full sensor */
req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
/* hint allows both landscape and portrait, promote to full user */
req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER;
} else {
/* Use the only one allowed "orientation" */
req = (is_landscape_allowed ? orientation_landscape : orientation_portrait);
Expand Down
26 changes: 22 additions & 4 deletions builds/cmake/Modules/PlayerFindPackage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Name of the library to search. The name must match FindNAME.cmake.
# ``TARGET`` (list of string)
# Targets to import when the library was found.
# Searching ends when any of the targets is found.
# Searching ends when any of the targets is found.
#
# Optional Arguments
# ^^^^^^^^^^^^^^^^^^
Expand All @@ -27,8 +27,13 @@
# ``VERSION`` (String)
# Specifies required version of the library.
# ``CONFIG_BROKEN`` (without arguments)
# Indicates that the config file of the library is known to be broken on certain systems.
# Indicates that the config file of the library is known to be broken on
# certain systems.
# Uses bundled FindXXX.cmake instead.
# ``ONLY_CONFIG`` (without arguments)
# Use this for libraries that only have a config file and no find-module.
# This silences a huge warning emitted by CMake in that case and replaces it
# with a one-liner.
#
# Return variables
# ^^^^^^^^^^^^^^^^
Expand All @@ -37,7 +42,7 @@
#

function(player_find_package)
cmake_parse_arguments(PARSE_ARGV 0 PLAYER_FIND_PACKAGE "REQUIRED;CONFIG_BROKEN" "NAME;CONDITION;DEFINITION;TARGET;VERSION" "")
cmake_parse_arguments(PARSE_ARGV 0 PLAYER_FIND_PACKAGE "REQUIRED;CONFIG_BROKEN;ONLY_CONFIG" "NAME;CONDITION;DEFINITION;TARGET;VERSION" "")

set(IS_REQUIRED "")
if(PLAYER_FIND_PACKAGE_REQUIRED)
Expand All @@ -49,11 +54,20 @@ function(player_find_package)
set(MODULE "MODULE")
endif()

set(ONLY_CONFIG_QUIET "")
if(PLAYER_FIND_PACKAGE_ONLY_CONFIG)
set(ONLY_CONFIG_QUIET "QUIET")
endif()

# Assume "true" when Condition is empty, otherwise dereference the condition variable
if((NOT PLAYER_FIND_PACKAGE_CONDITION) OR (${PLAYER_FIND_PACKAGE_CONDITION}))
find_package(${PLAYER_FIND_PACKAGE_NAME} ${PLAYER_FIND_PACKAGE_VERSION} ${IS_REQUIRED} ${MODULE})
find_package(${PLAYER_FIND_PACKAGE_NAME} ${PLAYER_FIND_PACKAGE_VERSION} ${IS_REQUIRED} ${MODULE} ${ONLY_CONFIG_QUIET})
set(DEP_FOUND FALSE)

foreach(TARGET_ITEM ${PLAYER_FIND_PACKAGE_TARGET})
if (TARGET ${TARGET_ITEM})
set(DEP_FOUND TRUE)

if(${PLAYER_FIND_PACKAGE_NAME}_DIR)
message(STATUS "Found ${PLAYER_FIND_PACKAGE_NAME}: ${${PLAYER_FIND_PACKAGE_NAME}_DIR} (${TARGET_ITEM})")
endif()
Expand All @@ -66,5 +80,9 @@ function(player_find_package)
break()
endif()
endforeach()

if (PLAYER_FIND_PACKAGE_ONLY_CONFIG AND NOT DEP_FOUND)
message(STATUS "Could NOT find ${PLAYER_FIND_PACKAGE_NAME} (missing: ${PLAYER_FIND_PACKAGE_NAME}Config.cmake)")
endif()
endif()
endfunction()

0 comments on commit f83c0fa

Please sign in to comment.