From ccf20998f49299eeb1c71e66cdaed36373cf38ab Mon Sep 17 00:00:00 2001 From: Maksym H Date: Wed, 7 Dec 2022 16:29:25 +0200 Subject: [PATCH] Android: move project files from build folder (#112) --- .github/workflows/android.yml | 10 +- {build/android => Android}/.gitignore | 0 {build/android => Android}/app/build.gradle | 8 +- .../app/src/main/AndroidManifest.xml | 0 .../com/multicraft/game/CustomEditText.kt | 0 .../java/com/multicraft/game/GameActivity.kt | 3 +- .../java/com/multicraft/game/MainActivity.kt | 4 +- .../multicraft/game/helpers/ApiLevelHelper.kt | 0 .../game/helpers/PreferenceHelper.kt | 0 .../game/helpers/UsefulExtensions.kt | 0 .../game/workmanager/UnzipWorker.kt | 0 .../game/workmanager/WorkerViewModel.kt | 0 .../workmanager/WorkerViewModelFactory.kt | 0 .../main/java/org/libsdl/app/HIDDevice.java | 0 .../app/HIDDeviceBLESteamController.java | 0 .../java/org/libsdl/app/HIDDeviceManager.java | 0 .../java/org/libsdl/app/HIDDeviceUSB.java | 0 .../app/src/main/java/org/libsdl/app/SDL.java | 0 .../main/java/org/libsdl/app/SDLActivity.java | 709 +++++------------- .../java/org/libsdl/app/SDLAudioManager.java | 0 .../org/libsdl/app/SDLControllerManager.java | 0 .../main/java/org/libsdl/app/SDLSurface.java | 405 ++++++++++ .../src/main/res/drawable-night/bg_input.xml | 0 .../app/src/main/res/drawable/background.png | Bin .../app/src/main/res/drawable/bg.xml | 0 .../app/src/main/res/drawable/bg_common.9.png | Bin .../app/src/main/res/drawable/bg_input.xml | 0 .../main/res/drawable/custom_progress_bar.xml | 0 .../main/res/drawable/ic_baseline_send.xml | 0 .../app/src/main/res/drawable/progress.xml | 0 .../src/main/res/drawable/progress_bar.webp | Bin .../main/res/drawable/progress_bar_bg.webp | Bin .../src/main/res/drawable/progress_bar_fg.png | Bin .../app/src/main/res/drawable/sad.png | Bin .../app/src/main/res/drawable/update.png | Bin .../app/src/main/res/font/multicraftfont.ttf | Bin .../app/src/main/res/layout/activity_main.xml | 0 .../app/src/main/res/layout/conn_dialog.xml | 0 .../app/src/main/res/layout/input_text.xml | 0 .../src/main/res/layout/multiline_input.xml | 0 .../src/main/res/layout/restart_dialog.xml | 0 .../res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../mipmap-anydpi-v26/ic_launcher_round.xml | 0 .../ic_launcher_foreground.png | Bin .../main/res/mipmap-v25/ic_launcher_round.png | Bin .../ic_launcher_foreground.png | Bin .../ic_launcher_foreground.png | Bin .../ic_launcher_foreground.png | Bin .../app/src/main/res/mipmap/ic_launcher.png | Bin .../app/src/main/res/values-ru/strings.xml | 0 .../app/src/main/res/values-sw600dp/attrs.xml | 0 .../app/src/main/res/values/attrs.xml | 0 .../app/src/main/res/values/colors.xml | 0 .../app/src/main/res/values/strings.xml | 0 .../app/src/main/res/values/styles.xml | 0 .../app/src/main/res/xml/backup_rules.xml | 0 .../main/res/xml/data_extraction_rules.xml | 0 {build/android => Android}/build.gradle | 6 +- {build/android => Android}/gradle.properties | 0 .../gradle/wrapper/gradle-wrapper.jar | Bin .../gradle/wrapper/gradle-wrapper.properties | 4 +- {build/android => Android}/gradlew | 0 {build/android => Android}/gradlew.bat | 0 {build/android => Android}/icons/aux_btn.svg | 0 .../icons/chat_hide_btn.svg | 0 .../icons/chat_show_btn.svg | 0 .../icons/checkbox_tick.svg | 0 .../android => Android}/icons/debug_btn.svg | 0 {build/android => Android}/icons/fast_btn.svg | 0 {build/android => Android}/icons/fly_btn.svg | 0 .../android => Android}/icons/gear_icon.svg | 0 .../icons/inventory_btn.svg | 0 .../android => Android}/icons/noclip_btn.svg | 0 .../icons/rare_controls.svg | 0 {build/android => Android}/icons/zoom.svg | 0 .../android => Android}/native/build.gradle | 13 +- Android/native/jni/Android.mk | 265 +++++++ .../native/jni/Application.mk | 8 +- .../native/src/main/AndroidManifest.xml | 0 {build/android => Android}/settings.gradle | 0 build/android/native/jni/Android.mk | 265 ------- 81 files changed, 866 insertions(+), 834 deletions(-) rename {build/android => Android}/.gitignore (100%) rename {build/android => Android}/app/build.gradle (92%) rename {build/android => Android}/app/src/main/AndroidManifest.xml (100%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/CustomEditText.kt (100%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/GameActivity.kt (99%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/MainActivity.kt (97%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt (100%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt (100%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt (100%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt (100%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt (100%) rename {build/android => Android}/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt (100%) rename {build/android => Android}/app/src/main/java/org/libsdl/app/HIDDevice.java (100%) rename {build/android => Android}/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java (100%) rename {build/android => Android}/app/src/main/java/org/libsdl/app/HIDDeviceManager.java (100%) rename {build/android => Android}/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java (100%) rename {build/android => Android}/app/src/main/java/org/libsdl/app/SDL.java (100%) rename {build/android => Android}/app/src/main/java/org/libsdl/app/SDLActivity.java (80%) rename {build/android => Android}/app/src/main/java/org/libsdl/app/SDLAudioManager.java (100%) rename {build/android => Android}/app/src/main/java/org/libsdl/app/SDLControllerManager.java (100%) create mode 100644 Android/app/src/main/java/org/libsdl/app/SDLSurface.java rename {build/android => Android}/app/src/main/res/drawable-night/bg_input.xml (100%) rename {build/android => Android}/app/src/main/res/drawable/background.png (100%) rename {build/android => Android}/app/src/main/res/drawable/bg.xml (100%) rename {build/android => Android}/app/src/main/res/drawable/bg_common.9.png (100%) rename {build/android => Android}/app/src/main/res/drawable/bg_input.xml (100%) rename {build/android => Android}/app/src/main/res/drawable/custom_progress_bar.xml (100%) rename {build/android => Android}/app/src/main/res/drawable/ic_baseline_send.xml (100%) rename {build/android => Android}/app/src/main/res/drawable/progress.xml (100%) rename {build/android => Android}/app/src/main/res/drawable/progress_bar.webp (100%) rename {build/android => Android}/app/src/main/res/drawable/progress_bar_bg.webp (100%) rename {build/android => Android}/app/src/main/res/drawable/progress_bar_fg.png (100%) rename {build/android => Android}/app/src/main/res/drawable/sad.png (100%) rename {build/android => Android}/app/src/main/res/drawable/update.png (100%) rename {build/android => Android}/app/src/main/res/font/multicraftfont.ttf (100%) rename {build/android => Android}/app/src/main/res/layout/activity_main.xml (100%) rename {build/android => Android}/app/src/main/res/layout/conn_dialog.xml (100%) rename {build/android => Android}/app/src/main/res/layout/input_text.xml (100%) rename {build/android => Android}/app/src/main/res/layout/multiline_input.xml (100%) rename {build/android => Android}/app/src/main/res/layout/restart_dialog.xml (100%) rename {build/android => Android}/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename {build/android => Android}/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml (100%) rename {build/android => Android}/app/src/main/res/mipmap-hdpi-v26/ic_launcher_foreground.png (100%) rename {build/android => Android}/app/src/main/res/mipmap-v25/ic_launcher_round.png (100%) rename {build/android => Android}/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png (100%) rename {build/android => Android}/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png (100%) rename {build/android => Android}/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png (100%) rename {build/android => Android}/app/src/main/res/mipmap/ic_launcher.png (100%) rename {build/android => Android}/app/src/main/res/values-ru/strings.xml (100%) rename {build/android => Android}/app/src/main/res/values-sw600dp/attrs.xml (100%) rename {build/android => Android}/app/src/main/res/values/attrs.xml (100%) rename {build/android => Android}/app/src/main/res/values/colors.xml (100%) rename {build/android => Android}/app/src/main/res/values/strings.xml (100%) rename {build/android => Android}/app/src/main/res/values/styles.xml (100%) rename {build/android => Android}/app/src/main/res/xml/backup_rules.xml (100%) rename {build/android => Android}/app/src/main/res/xml/data_extraction_rules.xml (100%) rename {build/android => Android}/build.gradle (86%) rename {build/android => Android}/gradle.properties (100%) rename {build/android => Android}/gradle/wrapper/gradle-wrapper.jar (100%) rename {build/android => Android}/gradle/wrapper/gradle-wrapper.properties (79%) rename {build/android => Android}/gradlew (100%) rename {build/android => Android}/gradlew.bat (100%) rename {build/android => Android}/icons/aux_btn.svg (100%) rename {build/android => Android}/icons/chat_hide_btn.svg (100%) rename {build/android => Android}/icons/chat_show_btn.svg (100%) rename {build/android => Android}/icons/checkbox_tick.svg (100%) rename {build/android => Android}/icons/debug_btn.svg (100%) rename {build/android => Android}/icons/fast_btn.svg (100%) rename {build/android => Android}/icons/fly_btn.svg (100%) rename {build/android => Android}/icons/gear_icon.svg (100%) rename {build/android => Android}/icons/inventory_btn.svg (100%) rename {build/android => Android}/icons/noclip_btn.svg (100%) rename {build/android => Android}/icons/rare_controls.svg (100%) rename {build/android => Android}/icons/zoom.svg (100%) rename {build/android => Android}/native/build.gradle (85%) create mode 100644 Android/native/jni/Android.mk rename {build/android => Android}/native/jni/Application.mk (69%) rename {build/android => Android}/native/src/main/AndroidManifest.xml (100%) rename {build/android => Android}/settings.gradle (100%) delete mode 100644 build/android/native/jni/Android.mk diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 628b36f03..95b5dd420 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -8,7 +8,7 @@ on: - 'lib/**.cpp' - 'src/**.[ch]' - 'src/**.cpp' - - 'build/android/**' + - 'Android/**' - '.github/workflows/android.yml' pull_request: paths: @@ -16,7 +16,7 @@ on: - 'lib/**.cpp' - 'src/**.[ch]' - 'src/**.cpp' - - 'build/android/**' + - 'Android/**' - '.github/workflows/android.yml' jobs: @@ -32,14 +32,14 @@ jobs: - name: Install GNU gettext run: sudo apt install gettext - name: Build with Gradle - run: cd build/android; ./gradlew assemblerelease + run: cd Android; ./gradlew assemblerelease - name: Save armeabi artifact uses: actions/upload-artifact@v3 with: name: MultiCraft-armeabi-v7a.apk - path: build/android/app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned.apk + path: Android/app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned.apk - name: Save arm64 artifact uses: actions/upload-artifact@v3 with: name: MultiCraft-arm64-v8a.apk - path: build/android/app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk + path: Android/app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk diff --git a/build/android/.gitignore b/Android/.gitignore similarity index 100% rename from build/android/.gitignore rename to Android/.gitignore diff --git a/build/android/app/build.gradle b/Android/app/build.gradle similarity index 92% rename from build/android/app/build.gradle rename to Android/app/build.gradle index cfd35b6fa..977dde90e 100644 --- a/build/android/app/build.gradle +++ b/Android/app/build.gradle @@ -47,7 +47,7 @@ android { abi { enable true reset() - include 'armeabi-v7a', 'arm64-v8a' + include 'armeabi-v7a', 'arm64-v8a', 'x86_64' } } @@ -66,7 +66,7 @@ import org.apache.tools.ant.taskdefs.condition.Os task prepareAssetsFiles() { def assetsFolder = "build/assets/Files" - def projRoot = "../../.." + def projRoot = "../.." copy { from "${projRoot}/builtin" into "${assetsFolder}/builtin" exclude '*.txt' @@ -75,7 +75,7 @@ task prepareAssetsFiles() { from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders" } copy { - from "../native/deps/Android/Irrlicht/shaders" into "${assetsFolder}/client/shaders/Irrlicht" + from "../native/deps/irrlicht/shaders" into "${assetsFolder}/client/shaders/Irrlicht" } copy { from "${projRoot}/fonts/MultiCraftFont.ttf" into "${assetsFolder}/fonts" @@ -104,7 +104,7 @@ task prepareAssetsFiles() { preBuild.dependsOn zipAssetsFiles // Map for the version code that gives each ABI a value. -def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1] +def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1, 'x86_64': 2] android.applicationVariants.all { variant -> variant.outputs.each { output -> diff --git a/build/android/app/src/main/AndroidManifest.xml b/Android/app/src/main/AndroidManifest.xml similarity index 100% rename from build/android/app/src/main/AndroidManifest.xml rename to Android/app/src/main/AndroidManifest.xml diff --git a/build/android/app/src/main/java/com/multicraft/game/CustomEditText.kt b/Android/app/src/main/java/com/multicraft/game/CustomEditText.kt similarity index 100% rename from build/android/app/src/main/java/com/multicraft/game/CustomEditText.kt rename to Android/app/src/main/java/com/multicraft/game/CustomEditText.kt diff --git a/build/android/app/src/main/java/com/multicraft/game/GameActivity.kt b/Android/app/src/main/java/com/multicraft/game/GameActivity.kt similarity index 99% rename from build/android/app/src/main/java/com/multicraft/game/GameActivity.kt rename to Android/app/src/main/java/com/multicraft/game/GameActivity.kt index d859c1ac0..27c98241d 100644 --- a/build/android/app/src/main/java/com/multicraft/game/GameActivity.kt +++ b/Android/app/src/main/java/com/multicraft/game/GameActivity.kt @@ -70,7 +70,6 @@ class GameActivity : SDLActivity() { super.onCreate(savedInstanceState) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) hasKeyboard = resources.configuration.hardKeyboardHidden == HARDKEYBOARDHIDDEN_NO - keyboardEvent(hasKeyboard) } override fun onWindowFocusChanged(hasFocus: Boolean) { @@ -90,6 +89,8 @@ class GameActivity : SDLActivity() { override fun onResume() { super.onResume() + if (hasKeyboard) + keyboardEvent(hasKeyboard) window.makeFullScreen() } diff --git a/build/android/app/src/main/java/com/multicraft/game/MainActivity.kt b/Android/app/src/main/java/com/multicraft/game/MainActivity.kt similarity index 97% rename from build/android/app/src/main/java/com/multicraft/game/MainActivity.kt rename to Android/app/src/main/java/com/multicraft/game/MainActivity.kt index 02ddf8aa6..3845ddb14 100644 --- a/build/android/app/src/main/java/com/multicraft/game/MainActivity.kt +++ b/Android/app/src/main/java/com/multicraft/game/MainActivity.kt @@ -134,7 +134,9 @@ class MainActivity : AppCompatActivity() { val initLua = File(filesDir, "builtin${sep}mainmenu${sep}init.lua") if (initLua.exists() && initLua.canRead()) { val intent = Intent(this, GameActivity::class.java) - intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) startActivity(intent) } else { prefs[TAG_BUILD_VER] = "0" diff --git a/build/android/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt b/Android/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt similarity index 100% rename from build/android/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt rename to Android/app/src/main/java/com/multicraft/game/helpers/ApiLevelHelper.kt diff --git a/build/android/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt b/Android/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt similarity index 100% rename from build/android/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt rename to Android/app/src/main/java/com/multicraft/game/helpers/PreferenceHelper.kt diff --git a/build/android/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt b/Android/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt similarity index 100% rename from build/android/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt rename to Android/app/src/main/java/com/multicraft/game/helpers/UsefulExtensions.kt diff --git a/build/android/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt b/Android/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt similarity index 100% rename from build/android/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt rename to Android/app/src/main/java/com/multicraft/game/workmanager/UnzipWorker.kt diff --git a/build/android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt b/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt similarity index 100% rename from build/android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt rename to Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModel.kt diff --git a/build/android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt b/Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt similarity index 100% rename from build/android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt rename to Android/app/src/main/java/com/multicraft/game/workmanager/WorkerViewModelFactory.kt diff --git a/build/android/app/src/main/java/org/libsdl/app/HIDDevice.java b/Android/app/src/main/java/org/libsdl/app/HIDDevice.java similarity index 100% rename from build/android/app/src/main/java/org/libsdl/app/HIDDevice.java rename to Android/app/src/main/java/org/libsdl/app/HIDDevice.java diff --git a/build/android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java b/Android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java similarity index 100% rename from build/android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java rename to Android/app/src/main/java/org/libsdl/app/HIDDeviceBLESteamController.java diff --git a/build/android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/Android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java similarity index 100% rename from build/android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java rename to Android/app/src/main/java/org/libsdl/app/HIDDeviceManager.java diff --git a/build/android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java b/Android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java similarity index 100% rename from build/android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java rename to Android/app/src/main/java/org/libsdl/app/HIDDeviceUSB.java diff --git a/build/android/app/src/main/java/org/libsdl/app/SDL.java b/Android/app/src/main/java/org/libsdl/app/SDL.java similarity index 100% rename from build/android/app/src/main/java/org/libsdl/app/SDL.java rename to Android/app/src/main/java/org/libsdl/app/SDL.java diff --git a/build/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/Android/app/src/main/java/org/libsdl/app/SDLActivity.java similarity index 80% rename from build/android/app/src/main/java/org/libsdl/app/SDLActivity.java rename to Android/app/src/main/java/org/libsdl/app/SDLActivity.java index eee04db84..4e5501084 100644 --- a/build/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/Android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -15,13 +15,9 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Color; -import android.graphics.PixelFormat; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -37,11 +33,8 @@ import android.view.Display; import android.view.Gravity; import android.view.InputDevice; import android.view.KeyEvent; -import android.view.MotionEvent; import android.view.PointerIcon; import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; import android.view.Window; @@ -51,6 +44,7 @@ import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.Button; +import android.widget.EditText; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; @@ -65,6 +59,9 @@ import java.util.Locale; */ 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 = 26; + private static final int SDL_MICRO_VERSION = 1; /* // Display InputType.SOURCE/CLASS of events and devices // @@ -213,7 +210,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh // Main components protected static SDLActivity mSingleton; protected static SDLSurface mSurface; - protected static View mTextEdit; + protected static DummyEdit mTextEdit; protected static boolean mScreenKeyboardShown; protected static ViewGroup mLayout; protected static SDLClipboardHandler mClipboardHandler; @@ -315,6 +312,10 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh mCurrentNativeState = NativeState.INIT; } + protected SDLSurface createSDLSurface(Context context) { + return new SDLSurface(context); + } + // Setup @Override protected void onCreate(Bundle savedInstanceState) { @@ -344,8 +345,18 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh errorMsgBrokenLib = e.getMessage(); } - if (mBrokenLibraries) - { + if (!mBrokenLibraries) { + String expected_version = String.valueOf(SDL_MAJOR_VERSION) + "." + + String.valueOf(SDL_MINOR_VERSION) + "." + + String.valueOf(SDL_MICRO_VERSION); + String version = nativeGetVersion(); + if (!version.equals(expected_version)) { + mBrokenLibraries = true; + errorMsgBrokenLib = "SDL C/Java version mismatch (expected " + expected_version + ", got " + version + ")"; + } + } + + if (mBrokenLibraries) { mSingleton = this; AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this); dlgAlert.setMessage("An error occurred while trying to start the application. Please try again and/or reinstall." @@ -382,7 +393,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh mHIDDeviceManager = HIDDeviceManager.acquire(this); // Set up the surface - mSurface = new SDLSurface(getApplication()); + mSurface = createSDLSurface(getApplication()); mLayout = new RelativeLayout(this); mLayout.addView(mSurface); @@ -533,7 +544,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh nativeFocusChanged(true); } else { - //nativeFocusChanged(false); // CHANGED! + //nativeFocusChanged(false); // CHANGED! if (!mHasMultiWindow) { mNextNativeState = NativeState.PAUSED; SDLActivity.handleNativeState(); @@ -886,6 +897,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh } // C functions we call + public static native String nativeGetVersion(); public static native int nativeSetupJNI(); public static native int nativeRunMain(String library, String function, Object arguments); public static native void nativeLowMemory(); @@ -1220,8 +1232,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh } // This method is called by SDLControllerManager's API 26 Generic Motion Handler. - public static View getContentView() - { + public static View getContentView() { return mLayout; } @@ -1292,6 +1303,77 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh return event.isPrintingKey() || event.getKeyCode() == KeyEvent.KEYCODE_SPACE; } + public static boolean handleKeyEvent(View v, int keyCode, KeyEvent event, InputConnection ic) { + int deviceId = event.getDeviceId(); + int source = event.getSource(); + + if (source == InputDevice.SOURCE_UNKNOWN) { + InputDevice device = InputDevice.getDevice(deviceId); + if (device != null) { + source = device.getSources(); + } + } + +// if (event.getAction() == KeyEvent.ACTION_DOWN) { +// Log.v("SDL", "key down: " + keyCode + ", deviceId = " + deviceId + ", source = " + source); +// } else if (event.getAction() == KeyEvent.ACTION_UP) { +// Log.v("SDL", "key up: " + keyCode + ", deviceId = " + deviceId + ", source = " + source); +// } + + // Dispatch the different events depending on where they come from + // Some SOURCE_JOYSTICK, SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD + // So, we try to process them as JOYSTICK/DPAD/GAMEPAD events first, if that fails we try them as KEYBOARD + // + // Furthermore, it's possible a game controller has SOURCE_KEYBOARD and + // SOURCE_JOYSTICK, while its key events arrive from the keyboard source + // So, retrieve the device itself and check all of its sources + if (SDLControllerManager.isDeviceSDLJoystick(deviceId)) { + // Note that we process events with specific key codes here + if (event.getAction() == KeyEvent.ACTION_DOWN) { + if (SDLControllerManager.onNativePadDown(deviceId, keyCode) == 0) { + return true; + } + } else if (event.getAction() == KeyEvent.ACTION_UP) { + if (SDLControllerManager.onNativePadUp(deviceId, keyCode) == 0) { + return true; + } + } + } + + if ((source & InputDevice.SOURCE_KEYBOARD) == InputDevice.SOURCE_KEYBOARD) { + if (event.getAction() == KeyEvent.ACTION_DOWN) { + if (isTextInputEvent(event)) { + if (ic != null) { + ic.commitText(String.valueOf((char) event.getUnicodeChar()), 1); + } else { + SDLInputConnection.nativeCommitText(String.valueOf((char) event.getUnicodeChar()), 1); + } + } + onNativeKeyDown(keyCode); + return true; + } else if (event.getAction() == KeyEvent.ACTION_UP) { + onNativeKeyUp(keyCode); + return true; + } + } + + if ((source & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) { + // on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses + // they are ignored here because sending them as mouse input to SDL is messy + if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) { + switch (event.getAction()) { + case KeyEvent.ACTION_DOWN: + case KeyEvent.ACTION_UP: + // mark the event as handled or it will be handled by system + // handling KEYCODE_BACK by system will call onBackPressed() + return true; + } + } + } + + return false; + } + /** * This method is called by SDL using JNI. */ @@ -1809,455 +1891,6 @@ class SDLMain implements Runnable { } } - -/** - SDLSurface. This is what we draw on, so we need to know when it's created - in order to do anything useful. - - Because of this, that's where we set up the SDL thread -*/ -class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, - View.OnKeyListener, View.OnTouchListener, SensorEventListener { - - // Sensors - protected SensorManager mSensorManager; - protected Display mDisplay; - - // Keep track of the surface size to normalize touch events - protected float mWidth, mHeight; - - // Is SurfaceView ready for rendering - public boolean mIsSurfaceReady; - - // Startup - public SDLSurface(Context context) { - super(context); - getHolder().addCallback(this); - - setFocusable(true); - setFocusableInTouchMode(true); - requestFocus(); - setOnKeyListener(this); - setOnTouchListener(this); - - mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); - mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); - - setOnGenericMotionListener(SDLActivity.getMotionListener()); - - // Some arbitrary defaults to avoid a potential division by zero - mWidth = 1.0f; - mHeight = 1.0f; - - mIsSurfaceReady = false; - } - - public void handlePause() { - enableSensor(Sensor.TYPE_ACCELEROMETER, false); - } - - public void handleResume() { - setFocusable(true); - setFocusableInTouchMode(true); - requestFocus(); - setOnKeyListener(this); - setOnTouchListener(this); - enableSensor(Sensor.TYPE_ACCELEROMETER, true); - } - - public Surface getNativeSurface() { - return getHolder().getSurface(); - } - - // Called when we have a valid drawing surface - @Override - public void surfaceCreated(SurfaceHolder holder) { - Log.v("SDL", "surfaceCreated()"); - SDLActivity.onNativeSurfaceCreated(); - } - - // Called when we lose the surface - @Override - public void surfaceDestroyed(SurfaceHolder holder) { - Log.v("SDL", "surfaceDestroyed()"); - - // Transition to pause, if needed - SDLActivity.mNextNativeState = SDLActivity.NativeState.PAUSED; - SDLActivity.handleNativeState(); - - mIsSurfaceReady = false; - SDLActivity.onNativeSurfaceDestroyed(); - } - - // Called when the surface is resized - @Override - public void surfaceChanged(SurfaceHolder holder, - int format, int width, int height) { - Log.v("SDL", "surfaceChanged()"); - - if (SDLActivity.mSingleton == null) { - return; - } - - mWidth = width; - mHeight = height; - int nDeviceWidth = width; - int nDeviceHeight = height; - try - { - if (Build.VERSION.SDK_INT >= 17) { - DisplayMetrics realMetrics = new DisplayMetrics(); - mDisplay.getRealMetrics( realMetrics ); - nDeviceWidth = realMetrics.widthPixels; - nDeviceHeight = realMetrics.heightPixels; - } - } catch(Exception ignored) { - } - - synchronized(SDLActivity.getContext()) { - // In case we're waiting on a size change after going fullscreen, send a notification. - SDLActivity.getContext().notifyAll(); - } - - Log.v("SDL", "Window size: " + width + "x" + height); - Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight); - SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, mDisplay.getRefreshRate()); - SDLActivity.onNativeResize(); - - // Prevent a screen distortion glitch, - // for instance when the device is in Landscape and a Portrait App is resumed. - boolean skip = false; - int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation(); - - if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { - if (mWidth > mHeight) { - skip = true; - } - } else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { - if (mWidth < mHeight) { - skip = true; - } - } - - // Special Patch for Square Resolution: Black Berry Passport - if (skip) { - double min = Math.min(mWidth, mHeight); - double max = Math.max(mWidth, mHeight); - - if (max / min < 1.20) { - Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution."); - skip = false; - } - } - - // Don't skip in MultiWindow. - if (skip) { - if (Build.VERSION.SDK_INT >= 24) { - if (SDLActivity.mSingleton.isInMultiWindowMode()) { - Log.v("SDL", "Don't skip in Multi-Window"); - skip = false; - } - } - } - - if (skip) { - Log.v("SDL", "Skip .. Surface is not ready."); - mIsSurfaceReady = false; - return; - } - - /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ - SDLActivity.onNativeSurfaceChanged(); - - /* Surface is ready */ - mIsSurfaceReady = true; - - SDLActivity.mNextNativeState = SDLActivity.NativeState.RESUMED; - SDLActivity.handleNativeState(); - } - - // Key events - @Override - public boolean onKey(View v, int keyCode, KeyEvent event) { - - int deviceId = event.getDeviceId(); - int source = event.getSource(); - - if (source == InputDevice.SOURCE_UNKNOWN) { - InputDevice device = InputDevice.getDevice(deviceId); - if (device != null) { - source = device.getSources(); - } - } - -// if (event.getAction() == KeyEvent.ACTION_DOWN) { -// Log.v("SDL", "key down: " + keyCode + ", deviceId = " + deviceId + ", source = " + source); -// } else if (event.getAction() == KeyEvent.ACTION_UP) { -// Log.v("SDL", "key up: " + keyCode + ", deviceId = " + deviceId + ", source = " + source); -// } - - // Dispatch the different events depending on where they come from - // Some SOURCE_JOYSTICK, SOURCE_DPAD or SOURCE_GAMEPAD are also SOURCE_KEYBOARD - // So, we try to process them as JOYSTICK/DPAD/GAMEPAD events first, if that fails we try them as KEYBOARD - // - // Furthermore, it's possible a game controller has SOURCE_KEYBOARD and - // SOURCE_JOYSTICK, while its key events arrive from the keyboard source - // So, retrieve the device itself and check all of its sources - if (SDLControllerManager.isDeviceSDLJoystick(deviceId)) { - // Note that we process events with specific key codes here - if (event.getAction() == KeyEvent.ACTION_DOWN) { - if (SDLControllerManager.onNativePadDown(deviceId, keyCode) == 0) { - return true; - } - } else if (event.getAction() == KeyEvent.ACTION_UP) { - if (SDLControllerManager.onNativePadUp(deviceId, keyCode) == 0) { - return true; - } - } - } - - if ((source & InputDevice.SOURCE_KEYBOARD) == InputDevice.SOURCE_KEYBOARD) { - if (event.getAction() == KeyEvent.ACTION_DOWN) { - if (SDLActivity.isTextInputEvent(event)) { - SDLInputConnection.nativeCommitText(String.valueOf((char) event.getUnicodeChar()), 1); - } - SDLActivity.onNativeKeyDown(keyCode); - return true; - } else if (event.getAction() == KeyEvent.ACTION_UP) { - SDLActivity.onNativeKeyUp(keyCode); - return true; - } - } - - if ((source & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) { - // on some devices key events are sent for mouse BUTTON_BACK/FORWARD presses - // they are ignored here because sending them as mouse input to SDL is messy - if ((keyCode == KeyEvent.KEYCODE_BACK) || (keyCode == KeyEvent.KEYCODE_FORWARD)) { - switch (event.getAction()) { - case KeyEvent.ACTION_DOWN: - case KeyEvent.ACTION_UP: - // mark the event as handled or it will be handled by system - // handling KEYCODE_BACK by system will call onBackPressed() - return true; - } - } - } - - return false; - } - - // Touch events - @Override - public boolean onTouch(View v, MotionEvent event) { - /* Ref: http://developer.android.com/training/gestures/multi.html */ - int touchDevId = event.getDeviceId(); - final int pointerCount = event.getPointerCount(); - int action = event.getActionMasked(); - int pointerFingerId; - int i = -1; - float x,y,p; - - /* - * Prevent id to be -1, since it's used in SDL internal for synthetic events - * Appears when using Android emulator, eg: - * adb shell input mouse tap 100 100 - * adb shell input touchscreen tap 100 100 - */ - if (touchDevId < 0) { - touchDevId -= 1; - } - - // 12290 = Samsung DeX mode desktop mouse - // 12290 = 0x3002 = 0x2002 | 0x1002 = SOURCE_MOUSE | SOURCE_TOUCHSCREEN - // 0x2 = SOURCE_CLASS_POINTER - if (event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == (InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN)) { - int mouseButton = 1; - try { - Object object = event.getClass().getMethod("getButtonState").invoke(event); - if (object != null) { - mouseButton = (Integer) object; - } - } catch(Exception ignored) { - } - - // We need to check if we're in relative mouse mode and get the axis offset rather than the x/y values - // if we are. We'll leverage our existing mouse motion listener - SDLGenericMotionListener_API12 motionListener = SDLActivity.getMotionListener(); - x = motionListener.getEventX(event); - y = motionListener.getEventY(event); - - SDLActivity.onNativeMouse(mouseButton, action, x, y, motionListener.inRelativeMode()); - } else { - switch(action) { - case MotionEvent.ACTION_MOVE: - for (i = 0; i < pointerCount; i++) { - pointerFingerId = event.getPointerId(i); - x = event.getX(i) / mWidth; - y = event.getY(i) / mHeight; - p = event.getPressure(i); - if (p > 1.0f) { - // may be larger than 1.0f on some devices - // see the documentation of getPressure(i) - p = 1.0f; - } - SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); - } - break; - - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_DOWN: - // Primary pointer up/down, the index is always zero - i = 0; - /* fallthrough */ - case MotionEvent.ACTION_POINTER_UP: - case MotionEvent.ACTION_POINTER_DOWN: - // Non primary pointer up/down - if (i == -1) { - i = event.getActionIndex(); - } - - pointerFingerId = event.getPointerId(i); - x = event.getX(i) / mWidth; - y = event.getY(i) / mHeight; - p = event.getPressure(i); - if (p > 1.0f) { - // may be larger than 1.0f on some devices - // see the documentation of getPressure(i) - p = 1.0f; - } - SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); - break; - - case MotionEvent.ACTION_CANCEL: - for (i = 0; i < pointerCount; i++) { - pointerFingerId = event.getPointerId(i); - x = event.getX(i) / mWidth; - y = event.getY(i) / mHeight; - p = event.getPressure(i); - if (p > 1.0f) { - // may be larger than 1.0f on some devices - // see the documentation of getPressure(i) - p = 1.0f; - } - SDLActivity.onNativeTouch(touchDevId, pointerFingerId, MotionEvent.ACTION_UP, x, y, p); - } - break; - - default: - break; - } - } - - return true; - } - - // Sensor events - public void enableSensor(int sensortype, boolean enabled) { - // TODO: This uses getDefaultSensor - what if we have >1 accels? - if (enabled) { - mSensorManager.registerListener(this, - mSensorManager.getDefaultSensor(sensortype), - SensorManager.SENSOR_DELAY_GAME, null); - } else { - mSensorManager.unregisterListener(this, - mSensorManager.getDefaultSensor(sensortype)); - } - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - // TODO - } - - @Override - public void onSensorChanged(SensorEvent event) { - if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { - - // Since we may have an orientation set, we won't receive onConfigurationChanged events. - // We thus should check here. - int newOrientation; - - float x, y; - switch (mDisplay.getRotation()) { - case Surface.ROTATION_90: - x = -event.values[1]; - y = event.values[0]; - newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE; - break; - case Surface.ROTATION_270: - x = event.values[1]; - y = -event.values[0]; - newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE_FLIPPED; - break; - case Surface.ROTATION_180: - x = -event.values[0]; - y = -event.values[1]; - newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT_FLIPPED; - break; - case Surface.ROTATION_0: - default: - x = event.values[0]; - y = event.values[1]; - newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT; - break; - } - - if (newOrientation != SDLActivity.mCurrentOrientation) { - SDLActivity.mCurrentOrientation = newOrientation; - SDLActivity.onNativeOrientationChanged(newOrientation); - } - - SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH, - y / SensorManager.GRAVITY_EARTH, - event.values[2] / SensorManager.GRAVITY_EARTH); - - - } - } - - // Captured pointer events for API 26. - public boolean onCapturedPointerEvent(MotionEvent event) - { - int action = event.getActionMasked(); - - float x, y; - switch (action) { - case MotionEvent.ACTION_SCROLL: - x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0); - y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0); - SDLActivity.onNativeMouse(0, action, x, y, false); - return true; - - case MotionEvent.ACTION_HOVER_MOVE: - case MotionEvent.ACTION_MOVE: - x = event.getX(0); - y = event.getY(0); - SDLActivity.onNativeMouse(0, action, x, y, true); - return true; - - case MotionEvent.ACTION_BUTTON_PRESS: - case MotionEvent.ACTION_BUTTON_RELEASE: - - // Change our action value to what SDL's code expects. - if (action == MotionEvent.ACTION_BUTTON_PRESS) { - action = MotionEvent.ACTION_DOWN; - } else { /* MotionEvent.ACTION_BUTTON_RELEASE */ - action = MotionEvent.ACTION_UP; - } - - x = event.getX(0); - y = event.getY(0); - int button = event.getButtonState(); - - SDLActivity.onNativeMouse(button, action, x, y, true); - return true; - } - - return false; - } - -} - /* This is a fake invisible editor view that receives the input and defines the * pan&scan region */ @@ -2278,21 +1911,7 @@ class DummyEdit extends View implements View.OnKeyListener { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { - /* - * This handles the hardware keyboard input - */ - if (event.getAction() == KeyEvent.ACTION_DOWN) { - if (SDLActivity.isTextInputEvent(event)) { - ic.commitText(String.valueOf((char) event.getUnicodeChar()), 1); - return true; - } - SDLActivity.onNativeKeyDown(keyCode); - return true; - } else if (event.getAction() == KeyEvent.ACTION_UP) { - SDLActivity.onNativeKeyUp(keyCode); - return true; - } - return false; + return SDLActivity.handleKeyEvent(v, keyCode, event, ic); } // @@ -2316,9 +1935,10 @@ class DummyEdit extends View implements View.OnKeyListener { public InputConnection onCreateInputConnection(EditorInfo outAttrs) { ic = new SDLInputConnection(this, true); - outAttrs.inputType = InputType.TYPE_CLASS_TEXT; - outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI - | EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */; + outAttrs.inputType = InputType.TYPE_CLASS_TEXT | + InputType.TYPE_TEXT_FLAG_MULTI_LINE; + outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI | + EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */; return ic; } @@ -2326,9 +1946,17 @@ class DummyEdit extends View implements View.OnKeyListener { class SDLInputConnection extends BaseInputConnection { + protected EditText mEditText; + protected String mCommittedText = ""; + public SDLInputConnection(View targetView, boolean fullEditor) { super(targetView, fullEditor); + mEditText = new EditText(SDL.getContext()); + } + @Override + public Editable getEditable() { + return mEditText.getEditableText(); } @Override @@ -2351,79 +1979,84 @@ class SDLInputConnection extends BaseInputConnection { } } - return super.sendKeyEvent(event); } @Override public boolean commitText(CharSequence text, int newCursorPosition) { - - /* Generate backspaces for the text we're going to replace */ - final Editable content = getEditable(); - if (content != null) { - int a = getComposingSpanStart(content); - int b = getComposingSpanEnd(content); - if (a == -1 || b == -1) { - a = Selection.getSelectionStart(content); - b = Selection.getSelectionEnd(content); - } - if (a < 0) a = 0; - if (b < 0) b = 0; - if (b < a) { - int tmp = a; - a = b; - b = tmp; - } - int backspaces = (b - a); - - for (int i = 0; i < backspaces; i++) { - nativeGenerateScancodeForUnichar('\b'); - } + if (!super.commitText(text, newCursorPosition)) { + return false; } - - for (int i = 0; i < text.length(); i++) { - char c = text.charAt(i); - if (c == '\n') { - if (SDLActivity.onNativeSoftReturnKey()) { - return true; - } - } - nativeGenerateScancodeForUnichar(c); - } - - SDLInputConnection.nativeCommitText(text.toString(), newCursorPosition); - - return super.commitText(text, newCursorPosition); + updateText(); + return true; } @Override public boolean setComposingText(CharSequence text, int newCursorPosition) { + if (!super.setComposingText(text, newCursorPosition)) { + return false; + } + updateText(); + return true; + } - nativeSetComposingText(text.toString(), newCursorPosition); + @Override + public boolean deleteSurroundingText(int beforeLength, int afterLength) { + if (!super.deleteSurroundingText(beforeLength, afterLength)) { + return false; + } + updateText(); + return true; + } - return super.setComposingText(text, newCursorPosition); + protected void updateText() { + final Editable content = getEditable(); + if (content == null) { + return; + } + + String text = content.toString(); + int compareLength = Math.min(text.length(), mCommittedText.length()); + int matchLength, offset; + + /* Backspace over characters that are no longer in the string */ + for (matchLength = 0; matchLength < compareLength; ) { + int codePoint = mCommittedText.codePointAt(matchLength); + if (codePoint != text.codePointAt(matchLength)) { + break; + } + matchLength += Character.charCount(codePoint); + } + /* FIXME: This doesn't handle graphemes, like '🌬️' */ + for (offset = matchLength; offset < mCommittedText.length(); ) { + int codePoint = mCommittedText.codePointAt(offset); + nativeGenerateScancodeForUnichar('\b'); + offset += Character.charCount(codePoint); + } + + if (matchLength < text.length()) { + String pendingText = text.subSequence(matchLength, text.length()).toString(); + for (offset = 0; offset < pendingText.length(); ) { + int codePoint = pendingText.codePointAt(offset); + if (codePoint == '\n') { + if (SDLActivity.onNativeSoftReturnKey()) { + return; + } + } + /* Higher code points don't generate simulated scancodes */ + if (codePoint < 128) { + nativeGenerateScancodeForUnichar((char)codePoint); + } + offset += Character.charCount(codePoint); + } + SDLInputConnection.nativeCommitText(pendingText, 0); + } + mCommittedText = text; } public static native void nativeCommitText(String text, int newCursorPosition); - public native void nativeGenerateScancodeForUnichar(char c); - - public native void nativeSetComposingText(String text, int newCursorPosition); - - @Override - public boolean deleteSurroundingText(int beforeLength, int afterLength) { - // Workaround to capture backspace key. Ref: http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection - // and https://bugzilla.libsdl.org/show_bug.cgi?id=2265 - if (beforeLength > 0 && afterLength == 0) { - // backspace(s) - while (beforeLength-- > 0) { - nativeGenerateScancodeForUnichar('\b'); - } - return true; - } - - return super.deleteSurroundingText(beforeLength, afterLength); - } + public static native void nativeGenerateScancodeForUnichar(char c); } class SDLClipboardHandler implements diff --git a/build/android/app/src/main/java/org/libsdl/app/SDLAudioManager.java b/Android/app/src/main/java/org/libsdl/app/SDLAudioManager.java similarity index 100% rename from build/android/app/src/main/java/org/libsdl/app/SDLAudioManager.java rename to Android/app/src/main/java/org/libsdl/app/SDLAudioManager.java diff --git a/build/android/app/src/main/java/org/libsdl/app/SDLControllerManager.java b/Android/app/src/main/java/org/libsdl/app/SDLControllerManager.java similarity index 100% rename from build/android/app/src/main/java/org/libsdl/app/SDLControllerManager.java rename to Android/app/src/main/java/org/libsdl/app/SDLControllerManager.java diff --git a/Android/app/src/main/java/org/libsdl/app/SDLSurface.java b/Android/app/src/main/java/org/libsdl/app/SDLSurface.java new file mode 100644 index 000000000..dcd26d495 --- /dev/null +++ b/Android/app/src/main/java/org/libsdl/app/SDLSurface.java @@ -0,0 +1,405 @@ +package org.libsdl.app; + + +import android.content.Context; +import android.content.pm.ActivityInfo; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; +import android.os.Build; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.Display; +import android.view.InputDevice; +import android.view.KeyEvent; +import android.view.MotionEvent; +import android.view.Surface; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.View; +import android.view.WindowManager; + + +/** + SDLSurface. This is what we draw on, so we need to know when it's created + in order to do anything useful. + + Because of this, that's where we set up the SDL thread +*/ +public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, + View.OnKeyListener, View.OnTouchListener, SensorEventListener { + + // Sensors + protected SensorManager mSensorManager; + protected Display mDisplay; + + // Keep track of the surface size to normalize touch events + protected float mWidth, mHeight; + + // Is SurfaceView ready for rendering + public boolean mIsSurfaceReady; + + // Startup + public SDLSurface(Context context) { + super(context); + getHolder().addCallback(this); + + setFocusable(true); + setFocusableInTouchMode(true); + requestFocus(); + setOnKeyListener(this); + setOnTouchListener(this); + + mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); + mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); + + setOnGenericMotionListener(SDLActivity.getMotionListener()); + + // Some arbitrary defaults to avoid a potential division by zero + mWidth = 1.0f; + mHeight = 1.0f; + + mIsSurfaceReady = false; + } + + public void handlePause() { + enableSensor(Sensor.TYPE_ACCELEROMETER, false); + } + + public void handleResume() { + setFocusable(true); + setFocusableInTouchMode(true); + requestFocus(); + setOnKeyListener(this); + setOnTouchListener(this); + enableSensor(Sensor.TYPE_ACCELEROMETER, true); + } + + public Surface getNativeSurface() { + return getHolder().getSurface(); + } + + // Called when we have a valid drawing surface + @Override + public void surfaceCreated(SurfaceHolder holder) { + Log.v("SDL", "surfaceCreated()"); + SDLActivity.onNativeSurfaceCreated(); + } + + // Called when we lose the surface + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + Log.v("SDL", "surfaceDestroyed()"); + + // Transition to pause, if needed + SDLActivity.mNextNativeState = SDLActivity.NativeState.PAUSED; + SDLActivity.handleNativeState(); + + mIsSurfaceReady = false; + SDLActivity.onNativeSurfaceDestroyed(); + } + + // Called when the surface is resized + @Override + public void surfaceChanged(SurfaceHolder holder, + int format, int width, int height) { + Log.v("SDL", "surfaceChanged()"); + + if (SDLActivity.mSingleton == null) { + return; + } + + mWidth = width; + mHeight = height; + int nDeviceWidth = width; + int nDeviceHeight = height; + try + { + if (Build.VERSION.SDK_INT >= 17) { + DisplayMetrics realMetrics = new DisplayMetrics(); + mDisplay.getRealMetrics( realMetrics ); + nDeviceWidth = realMetrics.widthPixels; + nDeviceHeight = realMetrics.heightPixels; + } + } catch(Exception ignored) { + } + + synchronized(SDLActivity.getContext()) { + // In case we're waiting on a size change after going fullscreen, send a notification. + SDLActivity.getContext().notifyAll(); + } + + Log.v("SDL", "Window size: " + width + "x" + height); + Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight); + SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, mDisplay.getRefreshRate()); + SDLActivity.onNativeResize(); + + // Prevent a screen distortion glitch, + // for instance when the device is in Landscape and a Portrait App is resumed. + boolean skip = false; + int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation(); + + if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { + if (mWidth > mHeight) { + skip = true; + } + } else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { + if (mWidth < mHeight) { + skip = true; + } + } + + // Special Patch for Square Resolution: Black Berry Passport + if (skip) { + double min = Math.min(mWidth, mHeight); + double max = Math.max(mWidth, mHeight); + + if (max / min < 1.20) { + Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution."); + skip = false; + } + } + + // Don't skip in MultiWindow. + if (skip) { + if (Build.VERSION.SDK_INT >= 24) { + if (SDLActivity.mSingleton.isInMultiWindowMode()) { + Log.v("SDL", "Don't skip in Multi-Window"); + skip = false; + } + } + } + + if (skip) { + Log.v("SDL", "Skip .. Surface is not ready."); + mIsSurfaceReady = false; + return; + } + + /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ + SDLActivity.onNativeSurfaceChanged(); + + /* Surface is ready */ + mIsSurfaceReady = true; + + SDLActivity.mNextNativeState = SDLActivity.NativeState.RESUMED; + SDLActivity.handleNativeState(); + } + + // Key events + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + return SDLActivity.handleKeyEvent(v, keyCode, event, null); + } + + // Touch events + @Override + public boolean onTouch(View v, MotionEvent event) { + /* Ref: http://developer.android.com/training/gestures/multi.html */ + int touchDevId = event.getDeviceId(); + final int pointerCount = event.getPointerCount(); + int action = event.getActionMasked(); + int pointerFingerId; + int i = -1; + float x,y,p; + + /* + * Prevent id to be -1, since it's used in SDL internal for synthetic events + * Appears when using Android emulator, eg: + * adb shell input mouse tap 100 100 + * adb shell input touchscreen tap 100 100 + */ + if (touchDevId < 0) { + touchDevId -= 1; + } + + // 12290 = Samsung DeX mode desktop mouse + // 12290 = 0x3002 = 0x2002 | 0x1002 = SOURCE_MOUSE | SOURCE_TOUCHSCREEN + // 0x2 = SOURCE_CLASS_POINTER + if (event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == (InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN)) { + int mouseButton = 1; + try { + Object object = event.getClass().getMethod("getButtonState").invoke(event); + if (object != null) { + mouseButton = (Integer) object; + } + } catch(Exception ignored) { + } + + // We need to check if we're in relative mouse mode and get the axis offset rather than the x/y values + // if we are. We'll leverage our existing mouse motion listener + SDLGenericMotionListener_API12 motionListener = SDLActivity.getMotionListener(); + x = motionListener.getEventX(event); + y = motionListener.getEventY(event); + + SDLActivity.onNativeMouse(mouseButton, action, x, y, motionListener.inRelativeMode()); + } else { + switch(action) { + case MotionEvent.ACTION_MOVE: + for (i = 0; i < pointerCount; i++) { + pointerFingerId = event.getPointerId(i); + x = event.getX(i) / mWidth; + y = event.getY(i) / mHeight; + p = event.getPressure(i); + if (p > 1.0f) { + // may be larger than 1.0f on some devices + // see the documentation of getPressure(i) + p = 1.0f; + } + SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); + } + break; + + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_DOWN: + // Primary pointer up/down, the index is always zero + i = 0; + /* fallthrough */ + case MotionEvent.ACTION_POINTER_UP: + case MotionEvent.ACTION_POINTER_DOWN: + // Non primary pointer up/down + if (i == -1) { + i = event.getActionIndex(); + } + + pointerFingerId = event.getPointerId(i); + x = event.getX(i) / mWidth; + y = event.getY(i) / mHeight; + p = event.getPressure(i); + if (p > 1.0f) { + // may be larger than 1.0f on some devices + // see the documentation of getPressure(i) + p = 1.0f; + } + SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); + break; + + case MotionEvent.ACTION_CANCEL: + for (i = 0; i < pointerCount; i++) { + pointerFingerId = event.getPointerId(i); + x = event.getX(i) / mWidth; + y = event.getY(i) / mHeight; + p = event.getPressure(i); + if (p > 1.0f) { + // may be larger than 1.0f on some devices + // see the documentation of getPressure(i) + p = 1.0f; + } + SDLActivity.onNativeTouch(touchDevId, pointerFingerId, MotionEvent.ACTION_UP, x, y, p); + } + break; + + default: + break; + } + } + + return true; + } + + // Sensor events + public void enableSensor(int sensortype, boolean enabled) { + // TODO: This uses getDefaultSensor - what if we have >1 accels? + if (enabled) { + mSensorManager.registerListener(this, + mSensorManager.getDefaultSensor(sensortype), + SensorManager.SENSOR_DELAY_GAME, null); + } else { + mSensorManager.unregisterListener(this, + mSensorManager.getDefaultSensor(sensortype)); + } + } + + @Override + public void onAccuracyChanged(Sensor sensor, int accuracy) { + // TODO + } + + @Override + public void onSensorChanged(SensorEvent event) { + if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { + + // Since we may have an orientation set, we won't receive onConfigurationChanged events. + // We thus should check here. + int newOrientation; + + float x, y; + switch (mDisplay.getRotation()) { + case Surface.ROTATION_90: + x = -event.values[1]; + y = event.values[0]; + newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE; + break; + case Surface.ROTATION_270: + x = event.values[1]; + y = -event.values[0]; + newOrientation = SDLActivity.SDL_ORIENTATION_LANDSCAPE_FLIPPED; + break; + case Surface.ROTATION_180: + x = -event.values[0]; + y = -event.values[1]; + newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT_FLIPPED; + break; + case Surface.ROTATION_0: + default: + x = event.values[0]; + y = event.values[1]; + newOrientation = SDLActivity.SDL_ORIENTATION_PORTRAIT; + break; + } + + if (newOrientation != SDLActivity.mCurrentOrientation) { + SDLActivity.mCurrentOrientation = newOrientation; + SDLActivity.onNativeOrientationChanged(newOrientation); + } + + SDLActivity.onNativeAccel(-x / SensorManager.GRAVITY_EARTH, + y / SensorManager.GRAVITY_EARTH, + event.values[2] / SensorManager.GRAVITY_EARTH); + + + } + } + + // Captured pointer events for API 26. + public boolean onCapturedPointerEvent(MotionEvent event) + { + int action = event.getActionMasked(); + + float x, y; + switch (action) { + case MotionEvent.ACTION_SCROLL: + x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0); + y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0); + SDLActivity.onNativeMouse(0, action, x, y, false); + return true; + + case MotionEvent.ACTION_HOVER_MOVE: + case MotionEvent.ACTION_MOVE: + x = event.getX(0); + y = event.getY(0); + SDLActivity.onNativeMouse(0, action, x, y, true); + return true; + + case MotionEvent.ACTION_BUTTON_PRESS: + case MotionEvent.ACTION_BUTTON_RELEASE: + + // Change our action value to what SDL's code expects. + if (action == MotionEvent.ACTION_BUTTON_PRESS) { + action = MotionEvent.ACTION_DOWN; + } else { /* MotionEvent.ACTION_BUTTON_RELEASE */ + action = MotionEvent.ACTION_UP; + } + + x = event.getX(0); + y = event.getY(0); + int button = event.getButtonState(); + + SDLActivity.onNativeMouse(button, action, x, y, true); + return true; + } + + return false; + } +} diff --git a/build/android/app/src/main/res/drawable-night/bg_input.xml b/Android/app/src/main/res/drawable-night/bg_input.xml similarity index 100% rename from build/android/app/src/main/res/drawable-night/bg_input.xml rename to Android/app/src/main/res/drawable-night/bg_input.xml diff --git a/build/android/app/src/main/res/drawable/background.png b/Android/app/src/main/res/drawable/background.png similarity index 100% rename from build/android/app/src/main/res/drawable/background.png rename to Android/app/src/main/res/drawable/background.png diff --git a/build/android/app/src/main/res/drawable/bg.xml b/Android/app/src/main/res/drawable/bg.xml similarity index 100% rename from build/android/app/src/main/res/drawable/bg.xml rename to Android/app/src/main/res/drawable/bg.xml diff --git a/build/android/app/src/main/res/drawable/bg_common.9.png b/Android/app/src/main/res/drawable/bg_common.9.png similarity index 100% rename from build/android/app/src/main/res/drawable/bg_common.9.png rename to Android/app/src/main/res/drawable/bg_common.9.png diff --git a/build/android/app/src/main/res/drawable/bg_input.xml b/Android/app/src/main/res/drawable/bg_input.xml similarity index 100% rename from build/android/app/src/main/res/drawable/bg_input.xml rename to Android/app/src/main/res/drawable/bg_input.xml diff --git a/build/android/app/src/main/res/drawable/custom_progress_bar.xml b/Android/app/src/main/res/drawable/custom_progress_bar.xml similarity index 100% rename from build/android/app/src/main/res/drawable/custom_progress_bar.xml rename to Android/app/src/main/res/drawable/custom_progress_bar.xml diff --git a/build/android/app/src/main/res/drawable/ic_baseline_send.xml b/Android/app/src/main/res/drawable/ic_baseline_send.xml similarity index 100% rename from build/android/app/src/main/res/drawable/ic_baseline_send.xml rename to Android/app/src/main/res/drawable/ic_baseline_send.xml diff --git a/build/android/app/src/main/res/drawable/progress.xml b/Android/app/src/main/res/drawable/progress.xml similarity index 100% rename from build/android/app/src/main/res/drawable/progress.xml rename to Android/app/src/main/res/drawable/progress.xml diff --git a/build/android/app/src/main/res/drawable/progress_bar.webp b/Android/app/src/main/res/drawable/progress_bar.webp similarity index 100% rename from build/android/app/src/main/res/drawable/progress_bar.webp rename to Android/app/src/main/res/drawable/progress_bar.webp diff --git a/build/android/app/src/main/res/drawable/progress_bar_bg.webp b/Android/app/src/main/res/drawable/progress_bar_bg.webp similarity index 100% rename from build/android/app/src/main/res/drawable/progress_bar_bg.webp rename to Android/app/src/main/res/drawable/progress_bar_bg.webp diff --git a/build/android/app/src/main/res/drawable/progress_bar_fg.png b/Android/app/src/main/res/drawable/progress_bar_fg.png similarity index 100% rename from build/android/app/src/main/res/drawable/progress_bar_fg.png rename to Android/app/src/main/res/drawable/progress_bar_fg.png diff --git a/build/android/app/src/main/res/drawable/sad.png b/Android/app/src/main/res/drawable/sad.png similarity index 100% rename from build/android/app/src/main/res/drawable/sad.png rename to Android/app/src/main/res/drawable/sad.png diff --git a/build/android/app/src/main/res/drawable/update.png b/Android/app/src/main/res/drawable/update.png similarity index 100% rename from build/android/app/src/main/res/drawable/update.png rename to Android/app/src/main/res/drawable/update.png diff --git a/build/android/app/src/main/res/font/multicraftfont.ttf b/Android/app/src/main/res/font/multicraftfont.ttf similarity index 100% rename from build/android/app/src/main/res/font/multicraftfont.ttf rename to Android/app/src/main/res/font/multicraftfont.ttf diff --git a/build/android/app/src/main/res/layout/activity_main.xml b/Android/app/src/main/res/layout/activity_main.xml similarity index 100% rename from build/android/app/src/main/res/layout/activity_main.xml rename to Android/app/src/main/res/layout/activity_main.xml diff --git a/build/android/app/src/main/res/layout/conn_dialog.xml b/Android/app/src/main/res/layout/conn_dialog.xml similarity index 100% rename from build/android/app/src/main/res/layout/conn_dialog.xml rename to Android/app/src/main/res/layout/conn_dialog.xml diff --git a/build/android/app/src/main/res/layout/input_text.xml b/Android/app/src/main/res/layout/input_text.xml similarity index 100% rename from build/android/app/src/main/res/layout/input_text.xml rename to Android/app/src/main/res/layout/input_text.xml diff --git a/build/android/app/src/main/res/layout/multiline_input.xml b/Android/app/src/main/res/layout/multiline_input.xml similarity index 100% rename from build/android/app/src/main/res/layout/multiline_input.xml rename to Android/app/src/main/res/layout/multiline_input.xml diff --git a/build/android/app/src/main/res/layout/restart_dialog.xml b/Android/app/src/main/res/layout/restart_dialog.xml similarity index 100% rename from build/android/app/src/main/res/layout/restart_dialog.xml rename to Android/app/src/main/res/layout/restart_dialog.xml diff --git a/build/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from build/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/build/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from build/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to Android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/build/android/app/src/main/res/mipmap-hdpi-v26/ic_launcher_foreground.png b/Android/app/src/main/res/mipmap-hdpi-v26/ic_launcher_foreground.png similarity index 100% rename from build/android/app/src/main/res/mipmap-hdpi-v26/ic_launcher_foreground.png rename to Android/app/src/main/res/mipmap-hdpi-v26/ic_launcher_foreground.png diff --git a/build/android/app/src/main/res/mipmap-v25/ic_launcher_round.png b/Android/app/src/main/res/mipmap-v25/ic_launcher_round.png similarity index 100% rename from build/android/app/src/main/res/mipmap-v25/ic_launcher_round.png rename to Android/app/src/main/res/mipmap-v25/ic_launcher_round.png diff --git a/build/android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png b/Android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png similarity index 100% rename from build/android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png rename to Android/app/src/main/res/mipmap-xhdpi-v26/ic_launcher_foreground.png diff --git a/build/android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png b/Android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png similarity index 100% rename from build/android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png rename to Android/app/src/main/res/mipmap-xxhdpi-v26/ic_launcher_foreground.png diff --git a/build/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png b/Android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png similarity index 100% rename from build/android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png rename to Android/app/src/main/res/mipmap-xxxhdpi-v26/ic_launcher_foreground.png diff --git a/build/android/app/src/main/res/mipmap/ic_launcher.png b/Android/app/src/main/res/mipmap/ic_launcher.png similarity index 100% rename from build/android/app/src/main/res/mipmap/ic_launcher.png rename to Android/app/src/main/res/mipmap/ic_launcher.png diff --git a/build/android/app/src/main/res/values-ru/strings.xml b/Android/app/src/main/res/values-ru/strings.xml similarity index 100% rename from build/android/app/src/main/res/values-ru/strings.xml rename to Android/app/src/main/res/values-ru/strings.xml diff --git a/build/android/app/src/main/res/values-sw600dp/attrs.xml b/Android/app/src/main/res/values-sw600dp/attrs.xml similarity index 100% rename from build/android/app/src/main/res/values-sw600dp/attrs.xml rename to Android/app/src/main/res/values-sw600dp/attrs.xml diff --git a/build/android/app/src/main/res/values/attrs.xml b/Android/app/src/main/res/values/attrs.xml similarity index 100% rename from build/android/app/src/main/res/values/attrs.xml rename to Android/app/src/main/res/values/attrs.xml diff --git a/build/android/app/src/main/res/values/colors.xml b/Android/app/src/main/res/values/colors.xml similarity index 100% rename from build/android/app/src/main/res/values/colors.xml rename to Android/app/src/main/res/values/colors.xml diff --git a/build/android/app/src/main/res/values/strings.xml b/Android/app/src/main/res/values/strings.xml similarity index 100% rename from build/android/app/src/main/res/values/strings.xml rename to Android/app/src/main/res/values/strings.xml diff --git a/build/android/app/src/main/res/values/styles.xml b/Android/app/src/main/res/values/styles.xml similarity index 100% rename from build/android/app/src/main/res/values/styles.xml rename to Android/app/src/main/res/values/styles.xml diff --git a/build/android/app/src/main/res/xml/backup_rules.xml b/Android/app/src/main/res/xml/backup_rules.xml similarity index 100% rename from build/android/app/src/main/res/xml/backup_rules.xml rename to Android/app/src/main/res/xml/backup_rules.xml diff --git a/build/android/app/src/main/res/xml/data_extraction_rules.xml b/Android/app/src/main/res/xml/data_extraction_rules.xml similarity index 100% rename from build/android/app/src/main/res/xml/data_extraction_rules.xml rename to Android/app/src/main/res/xml/data_extraction_rules.xml diff --git a/build/android/build.gradle b/Android/build.gradle similarity index 86% rename from build/android/build.gradle rename to Android/build.gradle index 828ed12ec..d74656c62 100644 --- a/build/android/build.gradle +++ b/Android/build.gradle @@ -6,8 +6,8 @@ project.ext.set("versionPatch", 3) // Version Patch project.ext.set("versionExtra", "") // Version Extra project.ext.set("versionCode", 100) // Android Version Code project.ext.set("developmentBuild", 0) // Whether it is a development build, or a release -// NOTE: +2 after each release! -// +1 for ARM and +1 for ARM64 APK's, because +// NOTE: +3 after each release! +// +1 for ARM, +1 for ARM64 and +1 for x86_64 APK's, because // each APK must have a larger `versionCode` than the previous buildscript { @@ -19,7 +19,7 @@ buildscript { classpath 'com.android.tools.build:gradle:7.3.1' //noinspection GradleDependency classpath 'de.undercouch:gradle-download-task:4.1.2' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/build/android/gradle.properties b/Android/gradle.properties similarity index 100% rename from build/android/gradle.properties rename to Android/gradle.properties diff --git a/build/android/gradle/wrapper/gradle-wrapper.jar b/Android/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from build/android/gradle/wrapper/gradle-wrapper.jar rename to Android/gradle/wrapper/gradle-wrapper.jar diff --git a/build/android/gradle/wrapper/gradle-wrapper.properties b/Android/gradle/wrapper/gradle-wrapper.properties similarity index 79% rename from build/android/gradle/wrapper/gradle-wrapper.properties rename to Android/gradle/wrapper/gradle-wrapper.properties index f01a8c175..e3e6a280d 100644 --- a/build/android/gradle/wrapper/gradle-wrapper.properties +++ b/Android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Sep 16 10:25:17 CEST 2022 +#Mon Dec 05 18:33:37 EET 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/build/android/gradlew b/Android/gradlew similarity index 100% rename from build/android/gradlew rename to Android/gradlew diff --git a/build/android/gradlew.bat b/Android/gradlew.bat similarity index 100% rename from build/android/gradlew.bat rename to Android/gradlew.bat diff --git a/build/android/icons/aux_btn.svg b/Android/icons/aux_btn.svg similarity index 100% rename from build/android/icons/aux_btn.svg rename to Android/icons/aux_btn.svg diff --git a/build/android/icons/chat_hide_btn.svg b/Android/icons/chat_hide_btn.svg similarity index 100% rename from build/android/icons/chat_hide_btn.svg rename to Android/icons/chat_hide_btn.svg diff --git a/build/android/icons/chat_show_btn.svg b/Android/icons/chat_show_btn.svg similarity index 100% rename from build/android/icons/chat_show_btn.svg rename to Android/icons/chat_show_btn.svg diff --git a/build/android/icons/checkbox_tick.svg b/Android/icons/checkbox_tick.svg similarity index 100% rename from build/android/icons/checkbox_tick.svg rename to Android/icons/checkbox_tick.svg diff --git a/build/android/icons/debug_btn.svg b/Android/icons/debug_btn.svg similarity index 100% rename from build/android/icons/debug_btn.svg rename to Android/icons/debug_btn.svg diff --git a/build/android/icons/fast_btn.svg b/Android/icons/fast_btn.svg similarity index 100% rename from build/android/icons/fast_btn.svg rename to Android/icons/fast_btn.svg diff --git a/build/android/icons/fly_btn.svg b/Android/icons/fly_btn.svg similarity index 100% rename from build/android/icons/fly_btn.svg rename to Android/icons/fly_btn.svg diff --git a/build/android/icons/gear_icon.svg b/Android/icons/gear_icon.svg similarity index 100% rename from build/android/icons/gear_icon.svg rename to Android/icons/gear_icon.svg diff --git a/build/android/icons/inventory_btn.svg b/Android/icons/inventory_btn.svg similarity index 100% rename from build/android/icons/inventory_btn.svg rename to Android/icons/inventory_btn.svg diff --git a/build/android/icons/noclip_btn.svg b/Android/icons/noclip_btn.svg similarity index 100% rename from build/android/icons/noclip_btn.svg rename to Android/icons/noclip_btn.svg diff --git a/build/android/icons/rare_controls.svg b/Android/icons/rare_controls.svg similarity index 100% rename from build/android/icons/rare_controls.svg rename to Android/icons/rare_controls.svg diff --git a/build/android/icons/zoom.svg b/Android/icons/zoom.svg similarity index 100% rename from build/android/icons/zoom.svg rename to Android/icons/zoom.svg diff --git a/build/android/native/build.gradle b/Android/native/build.gradle similarity index 85% rename from build/android/native/build.gradle rename to Android/native/build.gradle index 711306c96..4b0c6b2bd 100644 --- a/build/android/native/build.gradle +++ b/Android/native/build.gradle @@ -32,7 +32,7 @@ android { abi { enable true reset() - include 'armeabi-v7a', 'arm64-v8a'//, 'x86' + include 'armeabi-v7a', 'arm64-v8a', 'x86_64' } } @@ -50,22 +50,19 @@ android { // get precompiled deps task downloadDeps(type: Download) { - src 'https://github.com/MultiCraft/deps/archive/master.zip' + def VERSION = "05122022" + src "https://github.com/MultiCraft/deps_android/releases/download/$VERSION/deps_android.zip" dest new File(buildDir, 'deps.zip') overwrite false } task getDeps(dependsOn: downloadDeps, type: Copy) { def deps = file('deps') - def f = file("$buildDir/deps-master") + def f = file("$buildDir/deps_android") if (!f.exists()) { from zipTree(downloadDeps.dest) - into buildDir - } - - doLast { - file(f).renameTo(file(deps)) + into deps } } diff --git a/Android/native/jni/Android.mk b/Android/native/jni/Android.mk new file mode 100644 index 000000000..08b4b9faf --- /dev/null +++ b/Android/native/jni/Android.mk @@ -0,0 +1,265 @@ +LOCAL_PATH := $(call my-dir)/.. + +#LOCAL_ADDRESS_SANITIZER:=true + +include $(CLEAR_VARS) +LOCAL_MODULE := Curl +LOCAL_SRC_FILES := deps/libcurl/lib/$(APP_ABI)/libcurl.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Gettext +LOCAL_SRC_FILES := deps/gettext/lib/$(APP_ABI)/libintl.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Freetype +LOCAL_SRC_FILES := deps/freetype/lib/$(APP_ABI)/libfreetype.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Irrlicht +LOCAL_SRC_FILES := deps/irrlicht/lib/$(APP_ABI)/libIrrlicht.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libpng +LOCAL_SRC_FILES := deps/libpng/lib/$(APP_ABI)/libpng.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libjpeg +LOCAL_SRC_FILES := deps/libjpeg/lib/$(APP_ABI)/libjpeg.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := SDL2 +LOCAL_SRC_FILES := deps/sdl2/lib/$(APP_ABI)/libSDL2.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := LevelDB +LOCAL_SRC_FILES := deps/leveldb/lib/$(APP_ABI)/libleveldb.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := LuaJIT +LOCAL_SRC_FILES := deps/luajit/lib/$(APP_ABI)/libluajit.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := mbedTLS +LOCAL_SRC_FILES := deps/mbedtls/lib/$(APP_ABI)/libmbedtls.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := mbedx509 +LOCAL_SRC_FILES := deps/mbedtls/lib/$(APP_ABI)/libmbedx509.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := mbedcrypto +LOCAL_SRC_FILES := deps/mbedtls/lib/$(APP_ABI)/libmbedcrypto.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := OpenAL +LOCAL_SRC_FILES := deps/openal/lib/$(APP_ABI)/libopenal.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Vorbis +LOCAL_SRC_FILES := deps/vorbis/lib/$(APP_ABI)/libvorbis.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := MultiCraft + +LOCAL_CFLAGS += \ + -DJSONCPP_NO_LOCALE_SUPPORT \ + -DHAVE_TOUCHSCREENGUI \ + -DENABLE_GLES=1 \ + -DUSE_CURL=1 \ + -DUSE_SOUND=1 \ + -DUSE_FREETYPE=1 \ + -DUSE_LEVELDB=1 \ + -DUSE_SQLITE=0 \ + -DUSE_LUAJIT=1 \ + -DUSE_GETTEXT=1 \ + -D_IRR_COMPILE_WITH_SDL_DEVICE_ \ + -DVERSION_MAJOR=${versionMajor} \ + -DVERSION_MINOR=${versionMinor} \ + -DVERSION_PATCH=${versionPatch} \ + -DVERSION_EXTRA=${versionExtra} \ + -DDEVELOPMENT_BUILD=${developmentBuild} \ + $(GPROF_DEF) + +ifdef NDEBUG + LOCAL_CFLAGS += -DNDEBUG=1 +endif + +ifdef GPROF + GPROF_DEF := -DGPROF + PROFILER_LIBS := android-ndk-profiler + LOCAL_CFLAGS += -pg +endif + +LOCAL_C_INCLUDES := \ + ../../src \ + ../../src/script \ + ../../lib/gmp \ + ../../lib/jsoncpp \ + deps/freetype/include \ + deps/gettext/include \ + deps/irrlicht/include \ + deps/libpng/include \ + deps/libjpeg/include \ + deps/sdl2/include \ + deps/leveldb/include \ + deps/libcurl/include \ + deps/luajit/include \ + deps/openal/include \ + deps/vorbis/include + +LOCAL_SRC_FILES := \ + $(wildcard ../../src/client/*.cpp) \ + $(wildcard ../../src/client/*/*.cpp) \ + $(wildcard ../../src/content/*.cpp) \ + ../../src/database/database.cpp \ + ../../src/database/database-dummy.cpp \ + ../../src/database/database-files.cpp \ + ../../src/database/database-leveldb.cpp \ + $(wildcard ../../src/gui/*.cpp) \ + $(wildcard ../../src/irrlicht_changes/*.cpp) \ + $(wildcard ../../src/mapgen/*.cpp) \ + $(wildcard ../../src/network/*.cpp) \ + $(wildcard ../../src/script/*.cpp) \ + $(wildcard ../../src/script/common/*.cpp) \ + $(wildcard ../../src/script/cpp_api/*.cpp) \ + ../../src/script/lua_api/l_areastore.cpp \ + ../../src/script/lua_api/l_auth.cpp \ + ../../src/script/lua_api/l_base.cpp \ + ../../src/script/lua_api/l_camera.cpp \ + ../../src/script/lua_api/l_craft.cpp \ + ../../src/script/lua_api/l_client.cpp \ + ../../src/script/lua_api/l_env.cpp \ + ../../src/script/lua_api/l_http.cpp \ + ../../src/script/lua_api/l_inventory.cpp \ + ../../src/script/lua_api/l_item.cpp \ + ../../src/script/lua_api/l_itemstackmeta.cpp \ + ../../src/script/lua_api/l_localplayer.cpp \ + ../../src/script/lua_api/l_mainmenu.cpp \ + ../../src/script/lua_api/l_mapgen.cpp \ + ../../src/script/lua_api/l_metadata.cpp \ + ../../src/script/lua_api/l_minimap.cpp \ + ../../src/script/lua_api/l_modchannels.cpp \ + ../../src/script/lua_api/l_nodemeta.cpp \ + ../../src/script/lua_api/l_nodetimer.cpp \ + ../../src/script/lua_api/l_noise.cpp \ + ../../src/script/lua_api/l_object.cpp \ + ../../src/script/lua_api/l_particles.cpp \ + ../../src/script/lua_api/l_particles_local.cpp \ + ../../src/script/lua_api/l_playermeta.cpp \ + ../../src/script/lua_api/l_server.cpp \ + ../../src/script/lua_api/l_settings.cpp \ + ../../src/script/lua_api/l_sound.cpp \ + ../../src/script/lua_api/l_storage.cpp \ + ../../src/script/lua_api/l_util.cpp \ + ../../src/script/lua_api/l_vmanip.cpp \ + $(wildcard ../../src/server/*.cpp) \ + $(wildcard ../../src/threading/*.cpp) \ + $(wildcard ../../src/util/*.c) \ + $(wildcard ../../src/util/*.cpp) \ + ../../src/ban.cpp \ + ../../src/chat.cpp \ + ../../src/clientiface.cpp \ + ../../src/collision.cpp \ + ../../src/content_mapnode.cpp \ + ../../src/content_nodemeta.cpp \ + ../../src/convert_json.cpp \ + ../../src/craftdef.cpp \ + ../../src/debug.cpp \ + ../../src/defaultsettings.cpp \ + ../../src/emerge.cpp \ + ../../src/environment.cpp \ + ../../src/face_position_cache.cpp \ + ../../src/filesys.cpp \ + ../../src/gettext.cpp \ + ../../src/httpfetch.cpp \ + ../../src/hud.cpp \ + ../../src/inventory.cpp \ + ../../src/inventorymanager.cpp \ + ../../src/itemdef.cpp \ + ../../src/itemstackmetadata.cpp \ + ../../src/light.cpp \ + ../../src/log.cpp \ + ../../src/main.cpp \ + ../../src/map.cpp \ + ../../src/map_settings_manager.cpp \ + ../../src/mapblock.cpp \ + ../../src/mapnode.cpp \ + ../../src/mapsector.cpp \ + ../../src/metadata.cpp \ + ../../src/modchannels.cpp \ + ../../src/nameidmapping.cpp \ + ../../src/nodedef.cpp \ + ../../src/nodemetadata.cpp \ + ../../src/nodetimer.cpp \ + ../../src/noise.cpp \ + ../../src/objdef.cpp \ + ../../src/object_properties.cpp \ + ../../src/particles.cpp \ + ../../src/pathfinder.cpp \ + ../../src/player.cpp \ + ../../src/porting.cpp \ + ../../src/porting_android.cpp \ + ../../src/profiler.cpp \ + ../../src/raycast.cpp \ + ../../src/reflowscan.cpp \ + ../../src/remoteplayer.cpp \ + ../../src/serialization.cpp \ + ../../src/server.cpp \ + ../../src/serverenvironment.cpp \ + ../../src/serverlist.cpp \ + ../../src/settings.cpp \ + ../../src/staticobject.cpp \ + ../../src/texture_override.cpp \ + ../../src/tileanimation.cpp \ + ../../src/tool.cpp \ + ../../src/translation.cpp \ + ../../src/version.cpp \ + ../../src/voxel.cpp \ + ../../src/voxelalgorithms.cpp + + +# GMP +LOCAL_SRC_FILES += ../../lib/gmp/mini-gmp.c + +# JSONCPP +LOCAL_SRC_FILES += ../../lib/jsoncpp/jsoncpp.cpp + +# Lua UTF-8 Lib +LOCAL_SRC_FILES += ../../lib/luautf8/lutf8lib.c + +# Lua ChaCha Lib +LOCAL_SRC_FILES += $(wildcard ../../lib/luachacha/*.c) + +LOCAL_STATIC_LIBRARIES += \ + Curl mbedTLS mbedx509 mbedcrypto \ + Freetype \ + OpenAL \ + Gettext \ + Irrlicht libpng libjpeg SDL2 \ + LevelDB \ + Vorbis \ + LuaJIT + +LOCAL_STATIC_LIBRARIES += $(PROFILER_LIBS) + +LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES -lz -llog + +include $(BUILD_SHARED_LIBRARY) + +ifdef GPROF +$(call import-module,android-ndk-profiler) +endif diff --git a/build/android/native/jni/Application.mk b/Android/native/jni/Application.mk similarity index 69% rename from build/android/native/jni/Application.mk rename to Android/native/jni/Application.mk index 2eedda1a6..b4489807d 100644 --- a/build/android/native/jni/Application.mk +++ b/Android/native/jni/Application.mk @@ -4,14 +4,8 @@ APP_STL := c++_static APP_SHORT_COMMANDS := true APP_MODULES := MultiCraft -APP_CFLAGS := -Ofast -fvisibility=hidden -Wno-extra-tokens - -#ifeq ($(APP_ABI),x86) -#APP_CFLAGS += -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -funroll-loops -#endif - ifdef NDEBUG -APP_CFLAGS += -D__FILE__=__FILE_NAME__ -Wno-builtin-macro-redefined +APP_CFLAGS := -Ofast -fvisibility=hidden -Wno-extra-tokens -D__FILE__=__FILE_NAME__ -Wno-builtin-macro-redefined else APP_CFLAGS := -g -D_DEBUG -O0 -fno-omit-frame-pointer endif diff --git a/build/android/native/src/main/AndroidManifest.xml b/Android/native/src/main/AndroidManifest.xml similarity index 100% rename from build/android/native/src/main/AndroidManifest.xml rename to Android/native/src/main/AndroidManifest.xml diff --git a/build/android/settings.gradle b/Android/settings.gradle similarity index 100% rename from build/android/settings.gradle rename to Android/settings.gradle diff --git a/build/android/native/jni/Android.mk b/build/android/native/jni/Android.mk deleted file mode 100644 index 5397f3121..000000000 --- a/build/android/native/jni/Android.mk +++ /dev/null @@ -1,265 +0,0 @@ -LOCAL_PATH := $(call my-dir)/.. - -#LOCAL_ADDRESS_SANITIZER:=true - -include $(CLEAR_VARS) -LOCAL_MODULE := Curl -LOCAL_SRC_FILES := deps/Android/Curl/clang/$(APP_ABI)/libcurl.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := Freetype -LOCAL_SRC_FILES := deps/Android/Freetype/clang/$(APP_ABI)/libfreetype.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := Irrlicht -LOCAL_SRC_FILES := deps/Android/Irrlicht/clang/$(APP_ABI)/libIrrlicht.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libpng -LOCAL_SRC_FILES := deps/Android/libpng/clang/$(APP_ABI)/libpng.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libjpeg -LOCAL_SRC_FILES := deps/Android/libjpeg/clang/$(APP_ABI)/libjpeg.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := SDL2 -LOCAL_SRC_FILES := deps/Android/SDL2/clang/$(APP_ABI)/libSDL2.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := LevelDB -LOCAL_SRC_FILES := deps/Android/LevelDB/clang/$(APP_ABI)/libleveldb.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := LuaJIT -LOCAL_SRC_FILES := deps/Android/LuaJIT/clang/$(APP_ABI)/libluajit.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := mbedTLS -LOCAL_SRC_FILES := deps/Android/mbedTLS/clang/$(APP_ABI)/libmbedtls.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := mbedx509 -LOCAL_SRC_FILES := deps/Android/mbedTLS/clang/$(APP_ABI)/libmbedx509.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := mbedcrypto -LOCAL_SRC_FILES := deps/Android/mbedTLS/clang/$(APP_ABI)/libmbedcrypto.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := OpenAL -LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/clang/$(APP_ABI)/libopenal.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := Gettext -LOCAL_SRC_FILES := deps/Android/Gettext/clang/$(APP_ABI)/libintl.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := Vorbis -LOCAL_SRC_FILES := deps/Android/Vorbis/clang/$(APP_ABI)/libvorbis.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := MultiCraft - -LOCAL_CFLAGS += \ - -DJSONCPP_NO_LOCALE_SUPPORT \ - -DHAVE_TOUCHSCREENGUI \ - -DENABLE_GLES=1 \ - -DUSE_CURL=1 \ - -DUSE_SOUND=1 \ - -DUSE_FREETYPE=1 \ - -DUSE_LEVELDB=1 \ - -DUSE_SQLITE=0 \ - -DUSE_LUAJIT=1 \ - -DUSE_GETTEXT=1 \ - -D_IRR_COMPILE_WITH_SDL_DEVICE_ \ - -DVERSION_MAJOR=${versionMajor} \ - -DVERSION_MINOR=${versionMinor} \ - -DVERSION_PATCH=${versionPatch} \ - -DVERSION_EXTRA=${versionExtra} \ - -DDEVELOPMENT_BUILD=${developmentBuild} \ - $(GPROF_DEF) - -ifdef NDEBUG - LOCAL_CFLAGS += -DNDEBUG=1 -endif - -ifdef GPROF - GPROF_DEF := -DGPROF - PROFILER_LIBS := android-ndk-profiler - LOCAL_CFLAGS += -pg -endif - -LOCAL_C_INCLUDES := \ - ../../../src \ - ../../../src/script \ - ../../../lib/gmp \ - ../../../lib/jsoncpp \ - deps/Android/Curl/include \ - deps/Android/Freetype/include \ - deps/Android/Irrlicht/include \ - deps/Android/libpng/include \ - deps/Android/libjpeg/include \ - deps/Android/SDL2/include \ - deps/Android/LevelDB/include \ - deps/Android/Gettext/include \ - deps/Android/LuaJIT/src \ - deps/Android/OpenAL-Soft/include \ - deps/Android/Vorbis/include - -LOCAL_SRC_FILES := \ - $(wildcard ../../../src/client/*.cpp) \ - $(wildcard ../../../src/client/*/*.cpp) \ - $(wildcard ../../../src/content/*.cpp) \ - ../../../src/database/database.cpp \ - ../../../src/database/database-dummy.cpp \ - ../../../src/database/database-files.cpp \ - ../../../src/database/database-leveldb.cpp \ - $(wildcard ../../../src/gui/*.cpp) \ - $(wildcard ../../../src/irrlicht_changes/*.cpp) \ - $(wildcard ../../../src/mapgen/*.cpp) \ - $(wildcard ../../../src/network/*.cpp) \ - $(wildcard ../../../src/script/*.cpp) \ - $(wildcard ../../../src/script/common/*.cpp) \ - $(wildcard ../../../src/script/cpp_api/*.cpp) \ - ../../../src/script/lua_api/l_areastore.cpp \ - ../../../src/script/lua_api/l_auth.cpp \ - ../../../src/script/lua_api/l_base.cpp \ - ../../../src/script/lua_api/l_camera.cpp \ - ../../../src/script/lua_api/l_craft.cpp \ - ../../../src/script/lua_api/l_client.cpp \ - ../../../src/script/lua_api/l_env.cpp \ - ../../../src/script/lua_api/l_http.cpp \ - ../../../src/script/lua_api/l_inventory.cpp \ - ../../../src/script/lua_api/l_item.cpp \ - ../../../src/script/lua_api/l_itemstackmeta.cpp \ - ../../../src/script/lua_api/l_localplayer.cpp \ - ../../../src/script/lua_api/l_mainmenu.cpp \ - ../../../src/script/lua_api/l_mapgen.cpp \ - ../../../src/script/lua_api/l_metadata.cpp \ - ../../../src/script/lua_api/l_minimap.cpp \ - ../../../src/script/lua_api/l_modchannels.cpp \ - ../../../src/script/lua_api/l_nodemeta.cpp \ - ../../../src/script/lua_api/l_nodetimer.cpp \ - ../../../src/script/lua_api/l_noise.cpp \ - ../../../src/script/lua_api/l_object.cpp \ - ../../../src/script/lua_api/l_particles.cpp \ - ../../../src/script/lua_api/l_particles_local.cpp \ - ../../../src/script/lua_api/l_playermeta.cpp \ - ../../../src/script/lua_api/l_server.cpp \ - ../../../src/script/lua_api/l_settings.cpp \ - ../../../src/script/lua_api/l_sound.cpp \ - ../../../src/script/lua_api/l_storage.cpp \ - ../../../src/script/lua_api/l_util.cpp \ - ../../../src/script/lua_api/l_vmanip.cpp \ - $(wildcard ../../../src/server/*.cpp) \ - $(wildcard ../../../src/threading/*.cpp) \ - $(wildcard ../../../src/util/*.c) \ - $(wildcard ../../../src/util/*.cpp) \ - ../../../src/ban.cpp \ - ../../../src/chat.cpp \ - ../../../src/clientiface.cpp \ - ../../../src/collision.cpp \ - ../../../src/content_mapnode.cpp \ - ../../../src/content_nodemeta.cpp \ - ../../../src/convert_json.cpp \ - ../../../src/craftdef.cpp \ - ../../../src/debug.cpp \ - ../../../src/defaultsettings.cpp \ - ../../../src/emerge.cpp \ - ../../../src/environment.cpp \ - ../../../src/face_position_cache.cpp \ - ../../../src/filesys.cpp \ - ../../../src/gettext.cpp \ - ../../../src/httpfetch.cpp \ - ../../../src/hud.cpp \ - ../../../src/inventory.cpp \ - ../../../src/inventorymanager.cpp \ - ../../../src/itemdef.cpp \ - ../../../src/itemstackmetadata.cpp \ - ../../../src/light.cpp \ - ../../../src/log.cpp \ - ../../../src/main.cpp \ - ../../../src/map.cpp \ - ../../../src/map_settings_manager.cpp \ - ../../../src/mapblock.cpp \ - ../../../src/mapnode.cpp \ - ../../../src/mapsector.cpp \ - ../../../src/metadata.cpp \ - ../../../src/modchannels.cpp \ - ../../../src/nameidmapping.cpp \ - ../../../src/nodedef.cpp \ - ../../../src/nodemetadata.cpp \ - ../../../src/nodetimer.cpp \ - ../../../src/noise.cpp \ - ../../../src/objdef.cpp \ - ../../../src/object_properties.cpp \ - ../../../src/particles.cpp \ - ../../../src/pathfinder.cpp \ - ../../../src/player.cpp \ - ../../../src/porting.cpp \ - ../../../src/porting_android.cpp \ - ../../../src/profiler.cpp \ - ../../../src/raycast.cpp \ - ../../../src/reflowscan.cpp \ - ../../../src/remoteplayer.cpp \ - ../../../src/serialization.cpp \ - ../../../src/server.cpp \ - ../../../src/serverenvironment.cpp \ - ../../../src/serverlist.cpp \ - ../../../src/settings.cpp \ - ../../../src/staticobject.cpp \ - ../../../src/texture_override.cpp \ - ../../../src/tileanimation.cpp \ - ../../../src/tool.cpp \ - ../../../src/translation.cpp \ - ../../../src/version.cpp \ - ../../../src/voxel.cpp \ - ../../../src/voxelalgorithms.cpp - - -# GMP -LOCAL_SRC_FILES += ../../../lib/gmp/mini-gmp.c - -# JSONCPP -LOCAL_SRC_FILES += ../../../lib/jsoncpp/jsoncpp.cpp - -# Lua UTF-8 Lib -LOCAL_SRC_FILES += ../../../lib/luautf8/lutf8lib.c - -# Lua ChaCha Lib -LOCAL_SRC_FILES += $(wildcard ../../../lib/luachacha/*.c) - -LOCAL_STATIC_LIBRARIES += \ - Curl mbedTLS mbedx509 mbedcrypto \ - Freetype \ - OpenAL \ - Gettext \ - Irrlicht libpng libjpeg SDL2 \ - LevelDB \ - Vorbis \ - LuaJIT - -LOCAL_STATIC_LIBRARIES += $(PROFILER_LIBS) - -LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES -lz -llog - -include $(BUILD_SHARED_LIBRARY) - -ifdef GPROF -$(call import-module,android-ndk-profiler) -endif