From a7143c2a8c48b234d78ec666193b942ae0b62ca3 Mon Sep 17 00:00:00 2001 From: NeroBurner Date: Mon, 21 Jun 2021 21:51:42 +0200 Subject: Move build/android directory to root of project (#11283) --- .github/workflows/android.yml | 10 +- .gitignore | 1 + android/.gitignore | 11 + android/app/build.gradle | 113 +++ android/app/src/main/AndroidManifest.xml | 62 ++ .../java/net/minetest/minetest/CopyZipTask.java | 82 ++ .../java/net/minetest/minetest/CustomEditText.java | 45 ++ .../java/net/minetest/minetest/GameActivity.java | 174 ++++ .../java/net/minetest/minetest/MainActivity.java | 153 ++++ .../java/net/minetest/minetest/UnzipService.java | 157 ++++ android/app/src/main/res/drawable/background.png | Bin 0 -> 83 bytes android/app/src/main/res/drawable/bg.xml | 4 + android/app/src/main/res/layout/activity_main.xml | 30 + android/app/src/main/res/mipmap/ic_launcher.png | Bin 0 -> 5780 bytes android/app/src/main/res/values/strings.xml | 11 + android/app/src/main/res/values/styles.xml | 15 + android/build.gradle | 35 + android/gradle.properties | 11 + android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 55616 bytes android/gradle/wrapper/gradle-wrapper.properties | 6 + android/gradlew | 188 +++++ android/gradlew.bat | 100 +++ android/icons/aux1_btn.svg | 143 ++++ android/icons/camera_btn.svg | 108 +++ android/icons/chat_btn.svg | 96 +++ android/icons/chat_hide_btn.svg | 139 ++++ android/icons/chat_show_btn.svg | 133 ++++ android/icons/checkbox_tick.svg | 93 +++ android/icons/debug_btn.svg | 344 ++++++++ android/icons/down.svg | 542 +++++++++++++ android/icons/drop_btn.svg | 173 ++++ android/icons/fast_btn.svg | 190 +++++ android/icons/fly_btn.svg | 168 ++++ android/icons/gear_icon.svg | 194 +++++ android/icons/inventory_btn.svg | 509 ++++++++++++ android/icons/joystick_bg.svg | 876 ++++++++++++++++++++ android/icons/joystick_center.svg | 877 ++++++++++++++++++++ android/icons/joystick_off.svg | 882 +++++++++++++++++++++ android/icons/jump_btn.svg | 547 +++++++++++++ android/icons/minimap_btn.svg | 159 ++++ android/icons/noclip_btn.svg | 173 ++++ android/icons/rangeview_btn.svg | 456 +++++++++++ android/icons/rare_controls.svg | 521 ++++++++++++ android/icons/zoom.svg | 599 ++++++++++++++ android/keystore-minetest.jks | Bin 0 -> 2247 bytes android/native/build.gradle | 98 +++ android/native/jni/Android.mk | 206 +++++ android/native/jni/Application.mk | 32 + android/native/src/main/AndroidManifest.xml | 1 + android/settings.gradle | 2 + build/android/.gitignore | 11 - build/android/app/build.gradle | 113 --- build/android/app/src/main/AndroidManifest.xml | 62 -- .../java/net/minetest/minetest/CopyZipTask.java | 82 -- .../java/net/minetest/minetest/CustomEditText.java | 45 -- .../java/net/minetest/minetest/GameActivity.java | 174 ---- .../java/net/minetest/minetest/MainActivity.java | 153 ---- .../java/net/minetest/minetest/UnzipService.java | 157 ---- .../app/src/main/res/drawable/background.png | Bin 83 -> 0 bytes build/android/app/src/main/res/drawable/bg.xml | 4 - .../app/src/main/res/layout/activity_main.xml | 30 - .../app/src/main/res/mipmap/ic_launcher.png | Bin 5780 -> 0 bytes build/android/app/src/main/res/values/strings.xml | 11 - build/android/app/src/main/res/values/styles.xml | 15 - build/android/build.gradle | 35 - build/android/gradle.properties | 11 - build/android/gradle/wrapper/gradle-wrapper.jar | Bin 55616 -> 0 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 - build/android/gradlew | 188 ----- build/android/gradlew.bat | 100 --- build/android/icons/aux1_btn.svg | 143 ---- build/android/icons/camera_btn.svg | 108 --- build/android/icons/chat_btn.svg | 96 --- build/android/icons/chat_hide_btn.svg | 139 ---- build/android/icons/chat_show_btn.svg | 133 ---- build/android/icons/checkbox_tick.svg | 93 --- build/android/icons/debug_btn.svg | 344 -------- build/android/icons/down.svg | 542 ------------- build/android/icons/drop_btn.svg | 173 ---- build/android/icons/fast_btn.svg | 190 ----- build/android/icons/fly_btn.svg | 168 ---- build/android/icons/gear_icon.svg | 194 ----- build/android/icons/inventory_btn.svg | 509 ------------ build/android/icons/joystick_bg.svg | 876 -------------------- build/android/icons/joystick_center.svg | 877 -------------------- build/android/icons/joystick_off.svg | 882 --------------------- build/android/icons/jump_btn.svg | 547 ------------- build/android/icons/minimap_btn.svg | 159 ---- build/android/icons/noclip_btn.svg | 173 ---- build/android/icons/rangeview_btn.svg | 456 ----------- build/android/icons/rare_controls.svg | 521 ------------ build/android/icons/zoom.svg | 599 -------------- build/android/keystore-minetest.jks | Bin 2247 -> 0 bytes build/android/native/build.gradle | 98 --- build/android/native/jni/Android.mk | 206 ----- build/android/native/jni/Application.mk | 32 - build/android/native/src/main/AndroidManifest.xml | 1 - build/android/settings.gradle | 2 - doc/README.android | 2 +- util/bump_version.sh | 20 +- 100 files changed, 9475 insertions(+), 9474 deletions(-) create mode 100644 android/.gitignore create mode 100644 android/app/build.gradle create mode 100644 android/app/src/main/AndroidManifest.xml create mode 100644 android/app/src/main/java/net/minetest/minetest/CopyZipTask.java create mode 100644 android/app/src/main/java/net/minetest/minetest/CustomEditText.java create mode 100644 android/app/src/main/java/net/minetest/minetest/GameActivity.java create mode 100644 android/app/src/main/java/net/minetest/minetest/MainActivity.java create mode 100644 android/app/src/main/java/net/minetest/minetest/UnzipService.java create mode 100644 android/app/src/main/res/drawable/background.png create mode 100644 android/app/src/main/res/drawable/bg.xml create mode 100644 android/app/src/main/res/layout/activity_main.xml create mode 100644 android/app/src/main/res/mipmap/ic_launcher.png create mode 100644 android/app/src/main/res/values/strings.xml create mode 100644 android/app/src/main/res/values/styles.xml create mode 100644 android/build.gradle create mode 100644 android/gradle.properties create mode 100644 android/gradle/wrapper/gradle-wrapper.jar create mode 100644 android/gradle/wrapper/gradle-wrapper.properties create mode 100755 android/gradlew create mode 100644 android/gradlew.bat create mode 100644 android/icons/aux1_btn.svg create mode 100644 android/icons/camera_btn.svg create mode 100644 android/icons/chat_btn.svg create mode 100644 android/icons/chat_hide_btn.svg create mode 100644 android/icons/chat_show_btn.svg create mode 100644 android/icons/checkbox_tick.svg create mode 100644 android/icons/debug_btn.svg create mode 100644 android/icons/down.svg create mode 100644 android/icons/drop_btn.svg create mode 100644 android/icons/fast_btn.svg create mode 100644 android/icons/fly_btn.svg create mode 100644 android/icons/gear_icon.svg create mode 100644 android/icons/inventory_btn.svg create mode 100644 android/icons/joystick_bg.svg create mode 100644 android/icons/joystick_center.svg create mode 100644 android/icons/joystick_off.svg create mode 100644 android/icons/jump_btn.svg create mode 100644 android/icons/minimap_btn.svg create mode 100644 android/icons/noclip_btn.svg create mode 100644 android/icons/rangeview_btn.svg create mode 100644 android/icons/rare_controls.svg create mode 100644 android/icons/zoom.svg create mode 100644 android/keystore-minetest.jks create mode 100644 android/native/build.gradle create mode 100644 android/native/jni/Android.mk create mode 100644 android/native/jni/Application.mk create mode 100644 android/native/src/main/AndroidManifest.xml create mode 100644 android/settings.gradle delete mode 100644 build/android/.gitignore delete mode 100644 build/android/app/build.gradle delete mode 100644 build/android/app/src/main/AndroidManifest.xml delete mode 100644 build/android/app/src/main/java/net/minetest/minetest/CopyZipTask.java delete mode 100644 build/android/app/src/main/java/net/minetest/minetest/CustomEditText.java delete mode 100644 build/android/app/src/main/java/net/minetest/minetest/GameActivity.java delete mode 100644 build/android/app/src/main/java/net/minetest/minetest/MainActivity.java delete mode 100644 build/android/app/src/main/java/net/minetest/minetest/UnzipService.java delete mode 100644 build/android/app/src/main/res/drawable/background.png delete mode 100644 build/android/app/src/main/res/drawable/bg.xml delete mode 100644 build/android/app/src/main/res/layout/activity_main.xml delete mode 100644 build/android/app/src/main/res/mipmap/ic_launcher.png delete mode 100644 build/android/app/src/main/res/values/strings.xml delete mode 100644 build/android/app/src/main/res/values/styles.xml delete mode 100644 build/android/build.gradle delete mode 100644 build/android/gradle.properties delete mode 100644 build/android/gradle/wrapper/gradle-wrapper.jar delete mode 100644 build/android/gradle/wrapper/gradle-wrapper.properties delete mode 100755 build/android/gradlew delete mode 100644 build/android/gradlew.bat delete mode 100644 build/android/icons/aux1_btn.svg delete mode 100644 build/android/icons/camera_btn.svg delete mode 100644 build/android/icons/chat_btn.svg delete mode 100644 build/android/icons/chat_hide_btn.svg delete mode 100644 build/android/icons/chat_show_btn.svg delete mode 100644 build/android/icons/checkbox_tick.svg delete mode 100644 build/android/icons/debug_btn.svg delete mode 100644 build/android/icons/down.svg delete mode 100644 build/android/icons/drop_btn.svg delete mode 100644 build/android/icons/fast_btn.svg delete mode 100644 build/android/icons/fly_btn.svg delete mode 100644 build/android/icons/gear_icon.svg delete mode 100644 build/android/icons/inventory_btn.svg delete mode 100644 build/android/icons/joystick_bg.svg delete mode 100644 build/android/icons/joystick_center.svg delete mode 100644 build/android/icons/joystick_off.svg delete mode 100644 build/android/icons/jump_btn.svg delete mode 100644 build/android/icons/minimap_btn.svg delete mode 100644 build/android/icons/noclip_btn.svg delete mode 100644 build/android/icons/rangeview_btn.svg delete mode 100644 build/android/icons/rare_controls.svg delete mode 100644 build/android/icons/zoom.svg delete mode 100644 build/android/keystore-minetest.jks delete mode 100644 build/android/native/build.gradle delete mode 100644 build/android/native/jni/Android.mk delete mode 100644 build/android/native/jni/Application.mk delete mode 100644 build/android/native/src/main/AndroidManifest.xml delete mode 100644 build/android/settings.gradle diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 0fcfe2390..47ab64d11 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: @@ -29,14 +29,14 @@ jobs: with: java-version: 1.8 - name: Build with Gradle - run: cd build/android; ./gradlew assemblerelease + run: cd android; ./gradlew assemblerelease - name: Save armeabi artifact uses: actions/upload-artifact@v2 with: name: Minetest-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@v2 with: name: Minetest-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/.gitignore b/.gitignore index d951f2222..9db060aad 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,7 @@ doc/mkdocs/docs/*.md doc/mkdocs/mkdocs.yml ## Build files +build/ CMakeFiles Makefile cmake_install.cmake diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 000000000..e0613f8b3 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,11 @@ +*.iml +.externalNativeBuild +.gradle +app/build +app/release +app/src/main/assets +build +local.properties +native/.* +native/build +native/deps diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 000000000..b7d93ef0f --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,113 @@ +apply plugin: 'com.android.application' +android { + compileSdkVersion 29 + buildToolsVersion '30.0.3' + ndkVersion '22.0.7026061' + defaultConfig { + applicationId 'net.minetest.minetest' + minSdkVersion 16 + targetSdkVersion 29 + versionName "${versionMajor}.${versionMinor}.${versionPatch}" + versionCode project.versionCode + } + + // load properties + Properties props = new Properties() + def propfile = file('../local.properties') + if (propfile.exists()) + props.load(new FileInputStream(propfile)) + + if (props.getProperty('keystore') != null) { + signingConfigs { + release { + storeFile file(props['keystore']) + storePassword props['keystore.password'] + keyAlias props['key'] + keyPassword props['key.password'] + } + } + + buildTypes { + release { + minifyEnabled true + signingConfig signingConfigs.release + } + } + } + + // for multiple APKs + splits { + abi { + enable true + reset() + include 'armeabi-v7a', 'arm64-v8a' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +task prepareAssets() { + def assetsFolder = "build/assets" + def projRoot = "../.." + def gameToCopy = "minetest_game" + + copy { + from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into assetsFolder + } + copy { + from "${projRoot}/doc/lgpl-2.1.txt" into "${assetsFolder}" + } + copy { + from "${projRoot}/builtin" into "${assetsFolder}/builtin" + } + copy { + from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders" + } + copy { + from "../native/deps/Android/Irrlicht/shaders" into "${assetsFolder}/client/shaders/Irrlicht" + } + copy { + from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts" + } + copy { + from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}" + } + /*copy { + // ToDo: fix broken locales + from "${projRoot}/po" into "${assetsFolder}/po" + }*/ + copy { + from "${projRoot}/textures" into "${assetsFolder}/textures" + } + + file("${assetsFolder}/.nomedia").text = ""; + + task zipAssets(type: Zip) { + archiveName "Minetest.zip" + from "${assetsFolder}" + destinationDir file("src/main/assets") + } +} + +preBuild.dependsOn zipAssets + +// Map for the version code that gives each ABI a value. +import com.android.build.OutputFile + +def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1] +android.applicationVariants.all { variant -> + variant.outputs.each { + output -> + def abiName = output.getFilter(OutputFile.ABI) + output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode + } +} + +dependencies { + implementation project(':native') + implementation 'androidx.appcompat:appcompat:1.2.0' +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..fa93e7069 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/java/net/minetest/minetest/CopyZipTask.java b/android/app/src/main/java/net/minetest/minetest/CopyZipTask.java new file mode 100644 index 000000000..6d4b6ab0f --- /dev/null +++ b/android/app/src/main/java/net/minetest/minetest/CopyZipTask.java @@ -0,0 +1,82 @@ +/* +Minetest +Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2020 ubulem, Bektur Mambetov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +package net.minetest.minetest; + +import android.content.Intent; +import android.os.AsyncTask; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.ref.WeakReference; + +public class CopyZipTask extends AsyncTask { + + private final WeakReference activityRef; + + CopyZipTask(AppCompatActivity activity) { + activityRef = new WeakReference<>(activity); + } + + protected String doInBackground(String... params) { + copyAsset(params[0]); + return params[0]; + } + + @Override + protected void onPostExecute(String result) { + startUnzipService(result); + } + + private void copyAsset(String zipName) { + String filename = zipName.substring(zipName.lastIndexOf("/") + 1); + try (InputStream in = activityRef.get().getAssets().open(filename); + OutputStream out = new FileOutputStream(zipName)) { + copyFile(in, out); + } catch (IOException e) { + AppCompatActivity activity = activityRef.get(); + if (activity != null) { + activity.runOnUiThread(() -> Toast.makeText(activityRef.get(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show()); + } + cancel(true); + } + } + + private void copyFile(InputStream in, OutputStream out) throws IOException { + byte[] buffer = new byte[1024]; + int read; + while ((read = in.read(buffer)) != -1) + out.write(buffer, 0, read); + } + + private void startUnzipService(String file) { + Intent intent = new Intent(activityRef.get(), UnzipService.class); + intent.putExtra(UnzipService.EXTRA_KEY_IN_FILE, file); + AppCompatActivity activity = activityRef.get(); + if (activity != null) { + activity.startService(intent); + } + } +} diff --git a/android/app/src/main/java/net/minetest/minetest/CustomEditText.java b/android/app/src/main/java/net/minetest/minetest/CustomEditText.java new file mode 100644 index 000000000..8d0a503d0 --- /dev/null +++ b/android/app/src/main/java/net/minetest/minetest/CustomEditText.java @@ -0,0 +1,45 @@ +/* +Minetest +Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2020 ubulem, Bektur Mambetov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +package net.minetest.minetest; + +import android.content.Context; +import android.view.KeyEvent; +import android.view.inputmethod.InputMethodManager; + +import androidx.appcompat.widget.AppCompatEditText; + +import java.util.Objects; + +public class CustomEditText extends AppCompatEditText { + public CustomEditText(Context context) { + super(context); + } + + @Override + public boolean onKeyPreIme(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + InputMethodManager mgr = (InputMethodManager) + getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + Objects.requireNonNull(mgr).hideSoftInputFromWindow(this.getWindowToken(), 0); + } + return false; + } +} diff --git a/android/app/src/main/java/net/minetest/minetest/GameActivity.java b/android/app/src/main/java/net/minetest/minetest/GameActivity.java new file mode 100644 index 000000000..bdf764138 --- /dev/null +++ b/android/app/src/main/java/net/minetest/minetest/GameActivity.java @@ -0,0 +1,174 @@ +/* +Minetest +Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2020 ubulem, Bektur Mambetov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +package net.minetest.minetest; + +import android.app.NativeActivity; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.text.InputType; +import android.view.KeyEvent; +import android.view.View; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; + +import androidx.appcompat.app.AlertDialog; + +import java.util.Objects; + +public class GameActivity extends NativeActivity { + static { + System.loadLibrary("c++_shared"); + System.loadLibrary("Minetest"); + } + + private int messageReturnCode = -1; + private String messageReturnValue = ""; + + public static native void putMessageBoxResult(String text); + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } + + private void makeFullScreen() { + if (Build.VERSION.SDK_INT >= 19) + this.getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + if (hasFocus) + makeFullScreen(); + } + + @Override + protected void onResume() { + super.onResume(); + makeFullScreen(); + } + + @Override + public void onBackPressed() { + // Ignore the back press so Minetest can handle it + } + + public void showDialog(String acceptButton, String hint, String current, int editType) { + runOnUiThread(() -> showDialogUI(hint, current, editType)); + } + + private void showDialogUI(String hint, String current, int editType) { + final AlertDialog.Builder builder = new AlertDialog.Builder(this); + LinearLayout container = new LinearLayout(this); + container.setOrientation(LinearLayout.VERTICAL); + builder.setView(container); + AlertDialog alertDialog = builder.create(); + EditText editText; + // For multi-line, do not close the dialog after pressing back button + if (editType == 1) { + editText = new EditText(this); + } else { + editText = new CustomEditText(this); + } + container.addView(editText); + editText.setMaxLines(8); + editText.requestFocus(); + editText.setHint(hint); + editText.setText(current); + final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); + Objects.requireNonNull(imm).toggleSoftInput(InputMethodManager.SHOW_FORCED, + InputMethodManager.HIDE_IMPLICIT_ONLY); + if (editType == 1) + editText.setInputType(InputType.TYPE_CLASS_TEXT | + InputType.TYPE_TEXT_FLAG_MULTI_LINE); + else if (editType == 3) + editText.setInputType(InputType.TYPE_CLASS_TEXT | + InputType.TYPE_TEXT_VARIATION_PASSWORD); + else + editText.setInputType(InputType.TYPE_CLASS_TEXT); + editText.setSelection(editText.getText().length()); + editText.setOnKeyListener((view, keyCode, event) -> { + // For multi-line, do not submit the text after pressing Enter key + if (keyCode == KeyEvent.KEYCODE_ENTER && editType != 1) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + messageReturnCode = 0; + messageReturnValue = editText.getText().toString(); + alertDialog.dismiss(); + return true; + } + return false; + }); + // For multi-line, add Done button since Enter key does not submit text + if (editType == 1) { + Button doneButton = new Button(this); + container.addView(doneButton); + doneButton.setText(R.string.ime_dialog_done); + doneButton.setOnClickListener((view -> { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + messageReturnCode = 0; + messageReturnValue = editText.getText().toString(); + alertDialog.dismiss(); + })); + } + alertDialog.show(); + alertDialog.setOnCancelListener(dialog -> { + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); + messageReturnValue = current; + messageReturnCode = -1; + }); + } + + public int getDialogState() { + return messageReturnCode; + } + + public String getDialogValue() { + messageReturnCode = -1; + return messageReturnValue; + } + + public float getDensity() { + return getResources().getDisplayMetrics().density; + } + + public int getDisplayHeight() { + return getResources().getDisplayMetrics().heightPixels; + } + + public int getDisplayWidth() { + return getResources().getDisplayMetrics().widthPixels; + } + + public void openURI(String uri) { + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); + startActivity(browserIntent); + } +} diff --git a/android/app/src/main/java/net/minetest/minetest/MainActivity.java b/android/app/src/main/java/net/minetest/minetest/MainActivity.java new file mode 100644 index 000000000..2aa50d9ad --- /dev/null +++ b/android/app/src/main/java/net/minetest/minetest/MainActivity.java @@ -0,0 +1,153 @@ +/* +Minetest +Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2020 ubulem, Bektur Mambetov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +package net.minetest.minetest; + +import android.Manifest; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.os.Build; +import android.os.Bundle; +import android.view.View; +import android.widget.ProgressBar; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static net.minetest.minetest.UnzipService.ACTION_FAILURE; +import static net.minetest.minetest.UnzipService.ACTION_PROGRESS; +import static net.minetest.minetest.UnzipService.ACTION_UPDATE; +import static net.minetest.minetest.UnzipService.FAILURE; +import static net.minetest.minetest.UnzipService.SUCCESS; + +public class MainActivity extends AppCompatActivity { + private final static int versionCode = BuildConfig.VERSION_CODE; + private final static int PERMISSIONS = 1; + private static final String[] REQUIRED_SDK_PERMISSIONS = + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}; + private static final String SETTINGS = "MinetestSettings"; + private static final String TAG_VERSION_CODE = "versionCode"; + private ProgressBar mProgressBar; + private TextView mTextView; + private SharedPreferences sharedPreferences; + private final BroadcastReceiver myReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + int progress = 0; + if (intent != null) + progress = intent.getIntExtra(ACTION_PROGRESS, 0); + if (progress >= 0) { + if (mProgressBar != null) { + mProgressBar.setVisibility(View.VISIBLE); + mProgressBar.setProgress(progress); + } + mTextView.setVisibility(View.VISIBLE); + } else if (progress == FAILURE) { + Toast.makeText(MainActivity.this, intent.getStringExtra(ACTION_FAILURE), Toast.LENGTH_LONG).show(); + finish(); + } else if (progress == SUCCESS) + startNative(); + } + }; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + IntentFilter filter = new IntentFilter(ACTION_UPDATE); + registerReceiver(myReceiver, filter); + mProgressBar = findViewById(R.id.progressBar); + mTextView = findViewById(R.id.textView); + sharedPreferences = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) + checkPermission(); + else + checkAppVersion(); + } + + private void checkPermission() { + final List missingPermissions = new ArrayList<>(); + for (final String permission : REQUIRED_SDK_PERMISSIONS) { + final int result = ContextCompat.checkSelfPermission(this, permission); + if (result != PackageManager.PERMISSION_GRANTED) + missingPermissions.add(permission); + } + if (!missingPermissions.isEmpty()) { + final String[] permissions = missingPermissions + .toArray(new String[0]); + ActivityCompat.requestPermissions(this, permissions, PERMISSIONS); + } else { + final int[] grantResults = new int[REQUIRED_SDK_PERMISSIONS.length]; + Arrays.fill(grantResults, PackageManager.PERMISSION_GRANTED); + onRequestPermissionsResult(PERMISSIONS, REQUIRED_SDK_PERMISSIONS, grantResults); + } + } + + @Override + public void onRequestPermissionsResult(int requestCode, + @NonNull String[] permissions, @NonNull int[] grantResults) { + if (requestCode == PERMISSIONS) { + for (int grantResult : grantResults) { + if (grantResult != PackageManager.PERMISSION_GRANTED) { + Toast.makeText(this, R.string.not_granted, Toast.LENGTH_LONG).show(); + finish(); + } + } + checkAppVersion(); + } + } + + private void checkAppVersion() { + if (sharedPreferences.getInt(TAG_VERSION_CODE, 0) == versionCode) + startNative(); + else + new CopyZipTask(this).execute(getCacheDir() + "/Minetest.zip"); + } + + private void startNative() { + sharedPreferences.edit().putInt(TAG_VERSION_CODE, versionCode).apply(); + Intent intent = new Intent(this, GameActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK); + startActivity(intent); + } + + @Override + public void onBackPressed() { + // Prevent abrupt interruption when copy game files from assets + } + + @Override + protected void onDestroy() { + super.onDestroy(); + unregisterReceiver(myReceiver); + } +} diff --git a/android/app/src/main/java/net/minetest/minetest/UnzipService.java b/android/app/src/main/java/net/minetest/minetest/UnzipService.java new file mode 100644 index 000000000..b69f7f36e --- /dev/null +++ b/android/app/src/main/java/net/minetest/minetest/UnzipService.java @@ -0,0 +1,157 @@ +/* +Minetest +Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik +Copyright (C) 2014-2020 ubulem, Bektur Mambetov + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +package net.minetest.minetest; + +import android.app.IntentService; +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.content.Context; +import android.content.Intent; +import android.os.Build; +import android.os.Environment; +import android.widget.Toast; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; + +public class UnzipService extends IntentService { + public static final String ACTION_UPDATE = "net.minetest.minetest.UPDATE"; + public static final String ACTION_PROGRESS = "net.minetest.minetest.PROGRESS"; + public static final String ACTION_FAILURE = "net.minetest.minetest.FAILURE"; + public static final String EXTRA_KEY_IN_FILE = "file"; + public static final int SUCCESS = -1; + public static final int FAILURE = -2; + private final int id = 1; + private NotificationManager mNotifyManager; + private boolean isSuccess = true; + private String failureMessage; + + public UnzipService() { + super("net.minetest.minetest.UnzipService"); + } + + private void isDir(String dir, String location) { + File f = new File(location, dir); + if (!f.isDirectory()) + f.mkdirs(); + } + + @Override + protected void onHandleIntent(Intent intent) { + createNotification(); + unzip(intent); + } + + private void createNotification() { + String name = "net.minetest.minetest"; + String channelId = "Minetest channel"; + String description = "notifications from Minetest"; + Notification.Builder builder; + if (mNotifyManager == null) + mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + int importance = NotificationManager.IMPORTANCE_LOW; + NotificationChannel mChannel = null; + if (mNotifyManager != null) + mChannel = mNotifyManager.getNotificationChannel(channelId); + if (mChannel == null) { + mChannel = new NotificationChannel(channelId, name, importance); + mChannel.setDescription(description); + // Configure the notification channel, NO SOUND + mChannel.setSound(null, null); + mChannel.enableLights(false); + mChannel.enableVibration(false); + mNotifyManager.createNotificationChannel(mChannel); + } + builder = new Notification.Builder(this, channelId); + } else { + builder = new Notification.Builder(this); + } + builder.setContentTitle(getString(R.string.notification_title)) + .setSmallIcon(R.mipmap.ic_launcher) + .setContentText(getString(R.string.notification_description)); + mNotifyManager.notify(id, builder.build()); + } + + private void unzip(Intent intent) { + String zip = intent.getStringExtra(EXTRA_KEY_IN_FILE); + isDir("Minetest", Environment.getExternalStorageDirectory().toString()); + String location = Environment.getExternalStorageDirectory() + File.separator + "Minetest" + File.separator; + int per = 0; + int size = getSummarySize(zip); + File zipFile = new File(zip); + int readLen; + byte[] readBuffer = new byte[8192]; + try (FileInputStream fileInputStream = new FileInputStream(zipFile); + ZipInputStream zipInputStream = new ZipInputStream(fileInputStream)) { + ZipEntry ze; + while ((ze = zipInputStream.getNextEntry()) != null) { + if (ze.isDirectory()) { + ++per; + isDir(ze.getName(), location); + } else { + publishProgress(100 * ++per / size); + try (OutputStream outputStream = new FileOutputStream(location + ze.getName())) { + while ((readLen = zipInputStream.read(readBuffer)) != -1) { + outputStream.write(readBuffer, 0, readLen); + } + } + } + zipFile.delete(); + } + } catch (IOException e) { + isSuccess = false; + failureMessage = e.getLocalizedMessage(); + } + } + + private void publishProgress(int progress) { + Intent intentUpdate = new Intent(ACTION_UPDATE); + intentUpdate.putExtra(ACTION_PROGRESS, progress); + if (!isSuccess) intentUpdate.putExtra(ACTION_FAILURE, failureMessage); + sendBroadcast(intentUpdate); + } + + private int getSummarySize(String zip) { + int size = 0; + try { + ZipFile zipSize = new ZipFile(zip); + size += zipSize.size(); + } catch (IOException e) { + Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); + } + return size; + } + + @Override + public void onDestroy() { + super.onDestroy(); + mNotifyManager.cancel(id); + publishProgress(isSuccess ? SUCCESS : FAILURE); + } +} diff --git a/android/app/src/main/res/drawable/background.png b/android/app/src/main/res/drawable/background.png new file mode 100644 index 000000000..43bd6089e Binary files /dev/null and b/android/app/src/main/res/drawable/background.png differ diff --git a/android/app/src/main/res/drawable/bg.xml b/android/app/src/main/res/drawable/bg.xml new file mode 100644 index 000000000..903335ed9 --- /dev/null +++ b/android/app/src/main/res/drawable/bg.xml @@ -0,0 +1,4 @@ + + diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 000000000..e6f461f14 --- /dev/null +++ b/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,30 @@ + + + + + + + diff --git a/android/app/src/main/res/mipmap/ic_launcher.png b/android/app/src/main/res/mipmap/ic_launcher.png new file mode 100644 index 000000000..88a83782c Binary files /dev/null and b/android/app/src/main/res/mipmap/ic_launcher.png differ diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml new file mode 100644 index 000000000..85238117f --- /dev/null +++ b/android/app/src/main/res/values/strings.xml @@ -0,0 +1,11 @@ + + + + Minetest + Loading… + Required permission wasn\'t granted, Minetest can\'t run without it + Loading Minetest + Less than 1 minute… + Done + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..291a4eaf1 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 000000000..3ba51a4bb --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,35 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +project.ext.set("versionMajor", 5) // Version Major +project.ext.set("versionMinor", 5) // Version Minor +project.ext.set("versionPatch", 0) // Version Patch +project.ext.set("versionExtra", "-dev") // Version Extra +project.ext.set("versionCode", 32) // Android Version Code +// NOTE: +2 after each release! +// +1 for ARM and +1 for ARM64 APK's, because +// each APK must have a larger `versionCode` than the previous + +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:4.1.1' + classpath 'de.undercouch:gradle-download-task:4.1.1' + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir + delete 'native/deps' +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 000000000..53b475cf9 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,11 @@ +<#if isLowMemory> +org.gradle.jvmargs=-Xmx4G -XX:MaxPermSize=2G -XX:+HeapDumpOnOutOfMemoryError +<#else> +org.gradle.jvmargs=-Xmx16G -XX:MaxPermSize=8G -XX:+HeapDumpOnOutOfMemoryError + +org.gradle.daemon=true +org.gradle.parallel=true +org.gradle.parallel.threads=8 +org.gradle.configureondemand=true +android.enableJetifier=true +android.useAndroidX=true diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..5c2d1cf01 Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..7fd9307d7 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jan 08 17:52:00 UTC 2020 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip diff --git a/android/gradlew b/android/gradlew new file mode 100755 index 000000000..83f2acfdc --- /dev/null +++ b/android/gradlew @@ -0,0 +1,188 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 000000000..9618d8d96 --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,100 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/icons/aux1_btn.svg b/android/icons/aux1_btn.svg new file mode 100644 index 000000000..e0ee97c0c --- /dev/null +++ b/android/icons/aux1_btn.svg @@ -0,0 +1,143 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + Aux1 + + + diff --git a/android/icons/camera_btn.svg b/android/icons/camera_btn.svg new file mode 100644 index 000000000..a91a7fcf8 --- /dev/null +++ b/android/icons/camera_btn.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/chat_btn.svg b/android/icons/chat_btn.svg new file mode 100644 index 000000000..41dc6f8c7 --- /dev/null +++ b/android/icons/chat_btn.svg @@ -0,0 +1,96 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/android/icons/chat_hide_btn.svg b/android/icons/chat_hide_btn.svg new file mode 100644 index 000000000..6647b3097 --- /dev/null +++ b/android/icons/chat_hide_btn.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/chat_show_btn.svg b/android/icons/chat_show_btn.svg new file mode 100644 index 000000000..fce9de996 --- /dev/null +++ b/android/icons/chat_show_btn.svg @@ -0,0 +1,133 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/checkbox_tick.svg b/android/icons/checkbox_tick.svg new file mode 100644 index 000000000..6b727bb52 --- /dev/null +++ b/android/icons/checkbox_tick.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/android/icons/debug_btn.svg b/android/icons/debug_btn.svg new file mode 100644 index 000000000..2c37f142a --- /dev/null +++ b/android/icons/debug_btn.svg @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/down.svg b/android/icons/down.svg new file mode 100644 index 000000000..190e7e875 --- /dev/null +++ b/android/icons/down.svg @@ -0,0 +1,542 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/drop_btn.svg b/android/icons/drop_btn.svg new file mode 100644 index 000000000..7cb0e8532 --- /dev/null +++ b/android/icons/drop_btn.svg @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/fast_btn.svg b/android/icons/fast_btn.svg new file mode 100644 index 000000000..1436596b7 --- /dev/null +++ b/android/icons/fast_btn.svg @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/fly_btn.svg b/android/icons/fly_btn.svg new file mode 100644 index 000000000..d203842d4 --- /dev/null +++ b/android/icons/fly_btn.svg @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/gear_icon.svg b/android/icons/gear_icon.svg new file mode 100644 index 000000000..b44685ade --- /dev/null +++ b/android/icons/gear_icon.svg @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/inventory_btn.svg b/android/icons/inventory_btn.svg new file mode 100644 index 000000000..ee3dc3c17 --- /dev/null +++ b/android/icons/inventory_btn.svg @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/joystick_bg.svg b/android/icons/joystick_bg.svg new file mode 100644 index 000000000..d8836b358 --- /dev/null +++ b/android/icons/joystick_bg.svg @@ -0,0 +1,876 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/joystick_center.svg b/android/icons/joystick_center.svg new file mode 100644 index 000000000..17202290a --- /dev/null +++ b/android/icons/joystick_center.svg @@ -0,0 +1,877 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/joystick_off.svg b/android/icons/joystick_off.svg new file mode 100644 index 000000000..58e1acf22 --- /dev/null +++ b/android/icons/joystick_off.svg @@ -0,0 +1,882 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/jump_btn.svg b/android/icons/jump_btn.svg new file mode 100644 index 000000000..882c49ed7 --- /dev/null +++ b/android/icons/jump_btn.svg @@ -0,0 +1,547 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/minimap_btn.svg b/android/icons/minimap_btn.svg new file mode 100644 index 000000000..deda32717 --- /dev/null +++ b/android/icons/minimap_btn.svg @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/noclip_btn.svg b/android/icons/noclip_btn.svg new file mode 100644 index 000000000..a816edfc7 --- /dev/null +++ b/android/icons/noclip_btn.svg @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/rangeview_btn.svg b/android/icons/rangeview_btn.svg new file mode 100644 index 000000000..f9319e0b5 --- /dev/null +++ b/android/icons/rangeview_btn.svg @@ -0,0 +1,456 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/rare_controls.svg b/android/icons/rare_controls.svg new file mode 100644 index 000000000..c9991ec7a --- /dev/null +++ b/android/icons/rare_controls.svg @@ -0,0 +1,521 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/icons/zoom.svg b/android/icons/zoom.svg new file mode 100644 index 000000000..ea8dec3c5 --- /dev/null +++ b/android/icons/zoom.svg @@ -0,0 +1,599 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/keystore-minetest.jks b/android/keystore-minetest.jks new file mode 100644 index 000000000..8fce68bbb Binary files /dev/null and b/android/keystore-minetest.jks differ diff --git a/android/native/build.gradle b/android/native/build.gradle new file mode 100644 index 000000000..8ea6347b3 --- /dev/null +++ b/android/native/build.gradle @@ -0,0 +1,98 @@ +apply plugin: 'com.android.library' +apply plugin: 'de.undercouch.download' + +android { + compileSdkVersion 29 + buildToolsVersion '30.0.3' + ndkVersion '22.0.7026061' + defaultConfig { + minSdkVersion 16 + targetSdkVersion 29 + externalNativeBuild { + ndkBuild { + arguments '-j' + Runtime.getRuntime().availableProcessors(), + "versionMajor=${versionMajor}", + "versionMinor=${versionMinor}", + "versionPatch=${versionPatch}", + "versionExtra=${versionExtra}" + } + } + } + + externalNativeBuild { + ndkBuild { + path file('jni/Android.mk') + } + } + + // supported architectures + splits { + abi { + enable true + reset() + include 'armeabi-v7a', 'arm64-v8a'//, 'x86' + } + } + + buildTypes { + release { + externalNativeBuild { + ndkBuild { + arguments 'NDEBUG=1' + } + } + } + } +} + +// get precompiled deps +def folder = 'minetest_android_deps_binaries' + +task downloadDeps(type: Download) { + src 'https://github.com/minetest/' + folder + '/archive/master.zip' + dest new File(buildDir, 'deps.zip') + overwrite false +} + +task getDeps(dependsOn: downloadDeps, type: Copy) { + def deps = file('deps') + def f = file("$buildDir/" + folder + "-master") + + if (!deps.exists() && !f.exists()) { + from zipTree(downloadDeps.dest) + into buildDir + } + + doLast { + if (!deps.exists()) { + file(f).renameTo(file(deps)) + } + } +} + +// get sqlite +def sqlite_ver = '3340000' +task downloadSqlite(dependsOn: getDeps, type: Download) { + src 'https://www.sqlite.org/2020/sqlite-amalgamation-' + sqlite_ver + '.zip' + dest new File(buildDir, 'sqlite.zip') + overwrite false +} + +task getSqlite(dependsOn: downloadSqlite, type: Copy) { + def sqlite = file('deps/Android/sqlite') + def f = file("$buildDir/sqlite-amalgamation-" + sqlite_ver) + + if (!sqlite.exists() && !f.exists()) { + from zipTree(downloadSqlite.dest) + into buildDir + } + + doLast { + if (!sqlite.exists()) { + file(f).renameTo(file(sqlite)) + } + } +} + +preBuild.dependsOn getDeps +preBuild.dependsOn getSqlite diff --git a/android/native/jni/Android.mk b/android/native/jni/Android.mk new file mode 100644 index 000000000..5039f325e --- /dev/null +++ b/android/native/jni/Android.mk @@ -0,0 +1,206 @@ +LOCAL_PATH := $(call my-dir)/.. + +#LOCAL_ADDRESS_SANITIZER:=true + +include $(CLEAR_VARS) +LOCAL_MODULE := Curl +LOCAL_SRC_FILES := deps/Android/Curl/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libcurl.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Freetype +LOCAL_SRC_FILES := deps/Android/Freetype/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libfreetype.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Irrlicht +LOCAL_SRC_FILES := deps/Android/Irrlicht/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libIrrlichtMt.a +include $(PREBUILT_STATIC_LIBRARY) + +#include $(CLEAR_VARS) +#LOCAL_MODULE := LevelDB +#LOCAL_SRC_FILES := deps/Android/LevelDB/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libleveldb.a +#include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := LuaJIT +LOCAL_SRC_FILES := deps/Android/LuaJIT/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libluajit.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := mbedTLS +LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedtls.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := mbedx509 +LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedx509.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := mbedcrypto +LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedcrypto.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := OpenAL +LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libopenal.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Vorbis +LOCAL_SRC_FILES := deps/Android/Vorbis/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libvorbis.a +include $(PREBUILT_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := Minetest + +LOCAL_CFLAGS += \ + -DJSONCPP_NO_LOCALE_SUPPORT \ + -DHAVE_TOUCHSCREENGUI \ + -DENABLE_GLES=1 \ + -DUSE_CURL=1 \ + -DUSE_SOUND=1 \ + -DUSE_FREETYPE=1 \ + -DUSE_LEVELDB=0 \ + -DUSE_LUAJIT=1 \ + -DVERSION_MAJOR=${versionMajor} \ + -DVERSION_MINOR=${versionMinor} \ + -DVERSION_PATCH=${versionPatch} \ + -DVERSION_EXTRA=${versionExtra} \ + $(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/LevelDB/include \ + deps/Android/libiconv/include \ + deps/Android/libiconv/libcharset/include \ + deps/Android/LuaJIT/src \ + deps/Android/OpenAL-Soft/include \ + deps/Android/sqlite \ + 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-sqlite3.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/*/*.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/rollback.cpp \ + ../../src/rollback_interface.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 + +# LevelDB backend is disabled +# ../../src/database/database-leveldb.cpp + +# GMP +LOCAL_SRC_FILES += ../../lib/gmp/mini-gmp.c + +# JSONCPP +LOCAL_SRC_FILES += ../../lib/jsoncpp/jsoncpp.cpp + +# iconv +LOCAL_SRC_FILES += \ + deps/Android/libiconv/lib/iconv.c \ + deps/Android/libiconv/libcharset/lib/localcharset.c + +# SQLite3 +LOCAL_SRC_FILES += deps/Android/sqlite/sqlite3.c + +LOCAL_STATIC_LIBRARIES += Curl Freetype Irrlicht OpenAL mbedTLS mbedx509 mbedcrypto Vorbis LuaJIT android_native_app_glue $(PROFILER_LIBS) #LevelDB + +LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES + +include $(BUILD_SHARED_LIBRARY) + +ifdef GPROF +$(call import-module,android-ndk-profiler) +endif +$(call import-module,android/native_app_glue) diff --git a/android/native/jni/Application.mk b/android/native/jni/Application.mk new file mode 100644 index 000000000..82f0148f0 --- /dev/null +++ b/android/native/jni/Application.mk @@ -0,0 +1,32 @@ +APP_PLATFORM := ${APP_PLATFORM} +APP_ABI := ${TARGET_ABI} +APP_STL := c++_shared +NDK_TOOLCHAIN_VERSION := clang +APP_SHORT_COMMANDS := true +APP_MODULES := Minetest + +APP_CPPFLAGS := -Ofast -fvisibility=hidden -fexceptions -Wno-deprecated-declarations -Wno-extra-tokens + +ifeq ($(APP_ABI),armeabi-v7a) +APP_CPPFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb +endif + +#ifeq ($(APP_ABI),x86) +#APP_CPPFLAGS += -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -funroll-loops +#endif + +ifndef NDEBUG +APP_CPPFLAGS := -g -D_DEBUG -O0 -fno-omit-frame-pointer -fexceptions +endif + +APP_CFLAGS := $(APP_CPPFLAGS) -Wno-parentheses-equality #-Werror=shorten-64-to-32 +APP_CXXFLAGS := $(APP_CPPFLAGS) -frtti -std=gnu++17 +APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections,--icf=safe + +ifeq ($(APP_ABI),arm64-v8a) +APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections +endif + +ifndef NDEBUG +APP_LDFLAGS := +endif diff --git a/android/native/src/main/AndroidManifest.xml b/android/native/src/main/AndroidManifest.xml new file mode 100644 index 000000000..19451c7fd --- /dev/null +++ b/android/native/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 000000000..b048fca7c --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = "Minetest" +include ':app', ':native' diff --git a/build/android/.gitignore b/build/android/.gitignore deleted file mode 100644 index e0613f8b3..000000000 --- a/build/android/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -*.iml -.externalNativeBuild -.gradle -app/build -app/release -app/src/main/assets -build -local.properties -native/.* -native/build -native/deps diff --git a/build/android/app/build.gradle b/build/android/app/build.gradle deleted file mode 100644 index 7f4eba8c4..000000000 --- a/build/android/app/build.gradle +++ /dev/null @@ -1,113 +0,0 @@ -apply plugin: 'com.android.application' -android { - compileSdkVersion 29 - buildToolsVersion '30.0.3' - ndkVersion '22.0.7026061' - defaultConfig { - applicationId 'net.minetest.minetest' - minSdkVersion 16 - targetSdkVersion 29 - versionName "${versionMajor}.${versionMinor}.${versionPatch}" - versionCode project.versionCode - } - - // load properties - Properties props = new Properties() - def propfile = file('../local.properties') - if (propfile.exists()) - props.load(new FileInputStream(propfile)) - - if (props.getProperty('keystore') != null) { - signingConfigs { - release { - storeFile file(props['keystore']) - storePassword props['keystore.password'] - keyAlias props['key'] - keyPassword props['key.password'] - } - } - - buildTypes { - release { - minifyEnabled true - signingConfig signingConfigs.release - } - } - } - - // for multiple APKs - splits { - abi { - enable true - reset() - include 'armeabi-v7a', 'arm64-v8a' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -task prepareAssets() { - def assetsFolder = "build/assets" - def projRoot = "../../.." - def gameToCopy = "minetest_game" - - copy { - from "${projRoot}/minetest.conf.example", "${projRoot}/README.md" into assetsFolder - } - copy { - from "${projRoot}/doc/lgpl-2.1.txt" into "${assetsFolder}" - } - copy { - from "${projRoot}/builtin" into "${assetsFolder}/builtin" - } - copy { - from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders" - } - copy { - from "../native/deps/Android/Irrlicht/shaders" into "${assetsFolder}/client/shaders/Irrlicht" - } - copy { - from "${projRoot}/fonts" include "*.ttf" into "${assetsFolder}/fonts" - } - copy { - from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}" - } - /*copy { - // ToDo: fix broken locales - from "${projRoot}/po" into "${assetsFolder}/po" - }*/ - copy { - from "${projRoot}/textures" into "${assetsFolder}/textures" - } - - file("${assetsFolder}/.nomedia").text = ""; - - task zipAssets(type: Zip) { - archiveName "Minetest.zip" - from "${assetsFolder}" - destinationDir file("src/main/assets") - } -} - -preBuild.dependsOn zipAssets - -// Map for the version code that gives each ABI a value. -import com.android.build.OutputFile - -def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1] -android.applicationVariants.all { variant -> - variant.outputs.each { - output -> - def abiName = output.getFilter(OutputFile.ABI) - output.versionCodeOverride = abiCodes.get(abiName, 0) + variant.versionCode - } -} - -dependencies { - implementation project(':native') - implementation 'androidx.appcompat:appcompat:1.2.0' -} diff --git a/build/android/app/src/main/AndroidManifest.xml b/build/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index fa93e7069..000000000 --- a/build/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/app/src/main/java/net/minetest/minetest/CopyZipTask.java b/build/android/app/src/main/java/net/minetest/minetest/CopyZipTask.java deleted file mode 100644 index 6d4b6ab0f..000000000 --- a/build/android/app/src/main/java/net/minetest/minetest/CopyZipTask.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -Minetest -Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2020 ubulem, Bektur Mambetov - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -package net.minetest.minetest; - -import android.content.Intent; -import android.os.AsyncTask; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.ref.WeakReference; - -public class CopyZipTask extends AsyncTask { - - private final WeakReference activityRef; - - CopyZipTask(AppCompatActivity activity) { - activityRef = new WeakReference<>(activity); - } - - protected String doInBackground(String... params) { - copyAsset(params[0]); - return params[0]; - } - - @Override - protected void onPostExecute(String result) { - startUnzipService(result); - } - - private void copyAsset(String zipName) { - String filename = zipName.substring(zipName.lastIndexOf("/") + 1); - try (InputStream in = activityRef.get().getAssets().open(filename); - OutputStream out = new FileOutputStream(zipName)) { - copyFile(in, out); - } catch (IOException e) { - AppCompatActivity activity = activityRef.get(); - if (activity != null) { - activity.runOnUiThread(() -> Toast.makeText(activityRef.get(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show()); - } - cancel(true); - } - } - - private void copyFile(InputStream in, OutputStream out) throws IOException { - byte[] buffer = new byte[1024]; - int read; - while ((read = in.read(buffer)) != -1) - out.write(buffer, 0, read); - } - - private void startUnzipService(String file) { - Intent intent = new Intent(activityRef.get(), UnzipService.class); - intent.putExtra(UnzipService.EXTRA_KEY_IN_FILE, file); - AppCompatActivity activity = activityRef.get(); - if (activity != null) { - activity.startService(intent); - } - } -} diff --git a/build/android/app/src/main/java/net/minetest/minetest/CustomEditText.java b/build/android/app/src/main/java/net/minetest/minetest/CustomEditText.java deleted file mode 100644 index 8d0a503d0..000000000 --- a/build/android/app/src/main/java/net/minetest/minetest/CustomEditText.java +++ /dev/null @@ -1,45 +0,0 @@ -/* -Minetest -Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2020 ubulem, Bektur Mambetov - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -package net.minetest.minetest; - -import android.content.Context; -import android.view.KeyEvent; -import android.view.inputmethod.InputMethodManager; - -import androidx.appcompat.widget.AppCompatEditText; - -import java.util.Objects; - -public class CustomEditText extends AppCompatEditText { - public CustomEditText(Context context) { - super(context); - } - - @Override - public boolean onKeyPreIme(int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK) { - InputMethodManager mgr = (InputMethodManager) - getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - Objects.requireNonNull(mgr).hideSoftInputFromWindow(this.getWindowToken(), 0); - } - return false; - } -} diff --git a/build/android/app/src/main/java/net/minetest/minetest/GameActivity.java b/build/android/app/src/main/java/net/minetest/minetest/GameActivity.java deleted file mode 100644 index bdf764138..000000000 --- a/build/android/app/src/main/java/net/minetest/minetest/GameActivity.java +++ /dev/null @@ -1,174 +0,0 @@ -/* -Minetest -Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2020 ubulem, Bektur Mambetov - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -package net.minetest.minetest; - -import android.app.NativeActivity; -import android.content.Intent; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.text.InputType; -import android.view.KeyEvent; -import android.view.View; -import android.view.WindowManager; -import android.view.inputmethod.InputMethodManager; -import android.widget.Button; -import android.widget.EditText; -import android.widget.LinearLayout; - -import androidx.appcompat.app.AlertDialog; - -import java.util.Objects; - -public class GameActivity extends NativeActivity { - static { - System.loadLibrary("c++_shared"); - System.loadLibrary("Minetest"); - } - - private int messageReturnCode = -1; - private String messageReturnValue = ""; - - public static native void putMessageBoxResult(String text); - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - } - - private void makeFullScreen() { - if (Build.VERSION.SDK_INT >= 19) - this.getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - } - - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - if (hasFocus) - makeFullScreen(); - } - - @Override - protected void onResume() { - super.onResume(); - makeFullScreen(); - } - - @Override - public void onBackPressed() { - // Ignore the back press so Minetest can handle it - } - - public void showDialog(String acceptButton, String hint, String current, int editType) { - runOnUiThread(() -> showDialogUI(hint, current, editType)); - } - - private void showDialogUI(String hint, String current, int editType) { - final AlertDialog.Builder builder = new AlertDialog.Builder(this); - LinearLayout container = new LinearLayout(this); - container.setOrientation(LinearLayout.VERTICAL); - builder.setView(container); - AlertDialog alertDialog = builder.create(); - EditText editText; - // For multi-line, do not close the dialog after pressing back button - if (editType == 1) { - editText = new EditText(this); - } else { - editText = new CustomEditText(this); - } - container.addView(editText); - editText.setMaxLines(8); - editText.requestFocus(); - editText.setHint(hint); - editText.setText(current); - final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); - Objects.requireNonNull(imm).toggleSoftInput(InputMethodManager.SHOW_FORCED, - InputMethodManager.HIDE_IMPLICIT_ONLY); - if (editType == 1) - editText.setInputType(InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_FLAG_MULTI_LINE); - else if (editType == 3) - editText.setInputType(InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_PASSWORD); - else - editText.setInputType(InputType.TYPE_CLASS_TEXT); - editText.setSelection(editText.getText().length()); - editText.setOnKeyListener((view, keyCode, event) -> { - // For multi-line, do not submit the text after pressing Enter key - if (keyCode == KeyEvent.KEYCODE_ENTER && editType != 1) { - imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); - messageReturnCode = 0; - messageReturnValue = editText.getText().toString(); - alertDialog.dismiss(); - return true; - } - return false; - }); - // For multi-line, add Done button since Enter key does not submit text - if (editType == 1) { - Button doneButton = new Button(this); - container.addView(doneButton); - doneButton.setText(R.string.ime_dialog_done); - doneButton.setOnClickListener((view -> { - imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); - messageReturnCode = 0; - messageReturnValue = editText.getText().toString(); - alertDialog.dismiss(); - })); - } - alertDialog.show(); - alertDialog.setOnCancelListener(dialog -> { - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); - messageReturnValue = current; - messageReturnCode = -1; - }); - } - - public int getDialogState() { - return messageReturnCode; - } - - public String getDialogValue() { - messageReturnCode = -1; - return messageReturnValue; - } - - public float getDensity() { - return getResources().getDisplayMetrics().density; - } - - public int getDisplayHeight() { - return getResources().getDisplayMetrics().heightPixels; - } - - public int getDisplayWidth() { - return getResources().getDisplayMetrics().widthPixels; - } - - public void openURI(String uri) { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); - startActivity(browserIntent); - } -} diff --git a/build/android/app/src/main/java/net/minetest/minetest/MainActivity.java b/build/android/app/src/main/java/net/minetest/minetest/MainActivity.java deleted file mode 100644 index 2aa50d9ad..000000000 --- a/build/android/app/src/main/java/net/minetest/minetest/MainActivity.java +++ /dev/null @@ -1,153 +0,0 @@ -/* -Minetest -Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2020 ubulem, Bektur Mambetov - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -package net.minetest.minetest; - -import android.Manifest; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.os.Build; -import android.os.Bundle; -import android.view.View; -import android.widget.ProgressBar; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static net.minetest.minetest.UnzipService.ACTION_FAILURE; -import static net.minetest.minetest.UnzipService.ACTION_PROGRESS; -import static net.minetest.minetest.UnzipService.ACTION_UPDATE; -import static net.minetest.minetest.UnzipService.FAILURE; -import static net.minetest.minetest.UnzipService.SUCCESS; - -public class MainActivity extends AppCompatActivity { - private final static int versionCode = BuildConfig.VERSION_CODE; - private final static int PERMISSIONS = 1; - private static final String[] REQUIRED_SDK_PERMISSIONS = - new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}; - private static final String SETTINGS = "MinetestSettings"; - private static final String TAG_VERSION_CODE = "versionCode"; - private ProgressBar mProgressBar; - private TextView mTextView; - private SharedPreferences sharedPreferences; - private final BroadcastReceiver myReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - int progress = 0; - if (intent != null) - progress = intent.getIntExtra(ACTION_PROGRESS, 0); - if (progress >= 0) { - if (mProgressBar != null) { - mProgressBar.setVisibility(View.VISIBLE); - mProgressBar.setProgress(progress); - } - mTextView.setVisibility(View.VISIBLE); - } else if (progress == FAILURE) { - Toast.makeText(MainActivity.this, intent.getStringExtra(ACTION_FAILURE), Toast.LENGTH_LONG).show(); - finish(); - } else if (progress == SUCCESS) - startNative(); - } - }; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - IntentFilter filter = new IntentFilter(ACTION_UPDATE); - registerReceiver(myReceiver, filter); - mProgressBar = findViewById(R.id.progressBar); - mTextView = findViewById(R.id.textView); - sharedPreferences = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) - checkPermission(); - else - checkAppVersion(); - } - - private void checkPermission() { - final List missingPermissions = new ArrayList<>(); - for (final String permission : REQUIRED_SDK_PERMISSIONS) { - final int result = ContextCompat.checkSelfPermission(this, permission); - if (result != PackageManager.PERMISSION_GRANTED) - missingPermissions.add(permission); - } - if (!missingPermissions.isEmpty()) { - final String[] permissions = missingPermissions - .toArray(new String[0]); - ActivityCompat.requestPermissions(this, permissions, PERMISSIONS); - } else { - final int[] grantResults = new int[REQUIRED_SDK_PERMISSIONS.length]; - Arrays.fill(grantResults, PackageManager.PERMISSION_GRANTED); - onRequestPermissionsResult(PERMISSIONS, REQUIRED_SDK_PERMISSIONS, grantResults); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, - @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == PERMISSIONS) { - for (int grantResult : grantResults) { - if (grantResult != PackageManager.PERMISSION_GRANTED) { - Toast.makeText(this, R.string.not_granted, Toast.LENGTH_LONG).show(); - finish(); - } - } - checkAppVersion(); - } - } - - private void checkAppVersion() { - if (sharedPreferences.getInt(TAG_VERSION_CODE, 0) == versionCode) - startNative(); - else - new CopyZipTask(this).execute(getCacheDir() + "/Minetest.zip"); - } - - private void startNative() { - sharedPreferences.edit().putInt(TAG_VERSION_CODE, versionCode).apply(); - Intent intent = new Intent(this, GameActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK); - startActivity(intent); - } - - @Override - public void onBackPressed() { - // Prevent abrupt interruption when copy game files from assets - } - - @Override - protected void onDestroy() { - super.onDestroy(); - unregisterReceiver(myReceiver); - } -} diff --git a/build/android/app/src/main/java/net/minetest/minetest/UnzipService.java b/build/android/app/src/main/java/net/minetest/minetest/UnzipService.java deleted file mode 100644 index b69f7f36e..000000000 --- a/build/android/app/src/main/java/net/minetest/minetest/UnzipService.java +++ /dev/null @@ -1,157 +0,0 @@ -/* -Minetest -Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik -Copyright (C) 2014-2020 ubulem, Bektur Mambetov - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -package net.minetest.minetest; - -import android.app.IntentService; -import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; -import android.content.Context; -import android.content.Intent; -import android.os.Build; -import android.os.Environment; -import android.widget.Toast; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; - -public class UnzipService extends IntentService { - public static final String ACTION_UPDATE = "net.minetest.minetest.UPDATE"; - public static final String ACTION_PROGRESS = "net.minetest.minetest.PROGRESS"; - public static final String ACTION_FAILURE = "net.minetest.minetest.FAILURE"; - public static final String EXTRA_KEY_IN_FILE = "file"; - public static final int SUCCESS = -1; - public static final int FAILURE = -2; - private final int id = 1; - private NotificationManager mNotifyManager; - private boolean isSuccess = true; - private String failureMessage; - - public UnzipService() { - super("net.minetest.minetest.UnzipService"); - } - - private void isDir(String dir, String location) { - File f = new File(location, dir); - if (!f.isDirectory()) - f.mkdirs(); - } - - @Override - protected void onHandleIntent(Intent intent) { - createNotification(); - unzip(intent); - } - - private void createNotification() { - String name = "net.minetest.minetest"; - String channelId = "Minetest channel"; - String description = "notifications from Minetest"; - Notification.Builder builder; - if (mNotifyManager == null) - mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - int importance = NotificationManager.IMPORTANCE_LOW; - NotificationChannel mChannel = null; - if (mNotifyManager != null) - mChannel = mNotifyManager.getNotificationChannel(channelId); - if (mChannel == null) { - mChannel = new NotificationChannel(channelId, name, importance); - mChannel.setDescription(description); - // Configure the notification channel, NO SOUND - mChannel.setSound(null, null); - mChannel.enableLights(false); - mChannel.enableVibration(false); - mNotifyManager.createNotificationChannel(mChannel); - } - builder = new Notification.Builder(this, channelId); - } else { - builder = new Notification.Builder(this); - } - builder.setContentTitle(getString(R.string.notification_title)) - .setSmallIcon(R.mipmap.ic_launcher) - .setContentText(getString(R.string.notification_description)); - mNotifyManager.notify(id, builder.build()); - } - - private void unzip(Intent intent) { - String zip = intent.getStringExtra(EXTRA_KEY_IN_FILE); - isDir("Minetest", Environment.getExternalStorageDirectory().toString()); - String location = Environment.getExternalStorageDirectory() + File.separator + "Minetest" + File.separator; - int per = 0; - int size = getSummarySize(zip); - File zipFile = new File(zip); - int readLen; - byte[] readBuffer = new byte[8192]; - try (FileInputStream fileInputStream = new FileInputStream(zipFile); - ZipInputStream zipInputStream = new ZipInputStream(fileInputStream)) { - ZipEntry ze; - while ((ze = zipInputStream.getNextEntry()) != null) { - if (ze.isDirectory()) { - ++per; - isDir(ze.getName(), location); - } else { - publishProgress(100 * ++per / size); - try (OutputStream outputStream = new FileOutputStream(location + ze.getName())) { - while ((readLen = zipInputStream.read(readBuffer)) != -1) { - outputStream.write(readBuffer, 0, readLen); - } - } - } - zipFile.delete(); - } - } catch (IOException e) { - isSuccess = false; - failureMessage = e.getLocalizedMessage(); - } - } - - private void publishProgress(int progress) { - Intent intentUpdate = new Intent(ACTION_UPDATE); - intentUpdate.putExtra(ACTION_PROGRESS, progress); - if (!isSuccess) intentUpdate.putExtra(ACTION_FAILURE, failureMessage); - sendBroadcast(intentUpdate); - } - - private int getSummarySize(String zip) { - int size = 0; - try { - ZipFile zipSize = new ZipFile(zip); - size += zipSize.size(); - } catch (IOException e) { - Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); - } - return size; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mNotifyManager.cancel(id); - publishProgress(isSuccess ? SUCCESS : FAILURE); - } -} diff --git a/build/android/app/src/main/res/drawable/background.png b/build/android/app/src/main/res/drawable/background.png deleted file mode 100644 index 43bd6089e..000000000 Binary files a/build/android/app/src/main/res/drawable/background.png and /dev/null differ diff --git a/build/android/app/src/main/res/drawable/bg.xml b/build/android/app/src/main/res/drawable/bg.xml deleted file mode 100644 index 903335ed9..000000000 --- a/build/android/app/src/main/res/drawable/bg.xml +++ /dev/null @@ -1,4 +0,0 @@ - - diff --git a/build/android/app/src/main/res/layout/activity_main.xml b/build/android/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index e6f461f14..000000000 --- a/build/android/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - diff --git a/build/android/app/src/main/res/mipmap/ic_launcher.png b/build/android/app/src/main/res/mipmap/ic_launcher.png deleted file mode 100644 index 88a83782c..000000000 Binary files a/build/android/app/src/main/res/mipmap/ic_launcher.png and /dev/null differ diff --git a/build/android/app/src/main/res/values/strings.xml b/build/android/app/src/main/res/values/strings.xml deleted file mode 100644 index 85238117f..000000000 --- a/build/android/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Minetest - Loading… - Required permission wasn\'t granted, Minetest can\'t run without it - Loading Minetest - Less than 1 minute… - Done - - diff --git a/build/android/app/src/main/res/values/styles.xml b/build/android/app/src/main/res/values/styles.xml deleted file mode 100644 index 291a4eaf1..000000000 --- a/build/android/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - diff --git a/build/android/build.gradle b/build/android/build.gradle deleted file mode 100644 index 3ba51a4bb..000000000 --- a/build/android/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -project.ext.set("versionMajor", 5) // Version Major -project.ext.set("versionMinor", 5) // Version Minor -project.ext.set("versionPatch", 0) // Version Patch -project.ext.set("versionExtra", "-dev") // Version Extra -project.ext.set("versionCode", 32) // Android Version Code -// NOTE: +2 after each release! -// +1 for ARM and +1 for ARM64 APK's, because -// each APK must have a larger `versionCode` than the previous - -buildscript { - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:4.1.1' - classpath 'de.undercouch:gradle-download-task:4.1.1' - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir - delete 'native/deps' -} diff --git a/build/android/gradle.properties b/build/android/gradle.properties deleted file mode 100644 index 53b475cf9..000000000 --- a/build/android/gradle.properties +++ /dev/null @@ -1,11 +0,0 @@ -<#if isLowMemory> -org.gradle.jvmargs=-Xmx4G -XX:MaxPermSize=2G -XX:+HeapDumpOnOutOfMemoryError -<#else> -org.gradle.jvmargs=-Xmx16G -XX:MaxPermSize=8G -XX:+HeapDumpOnOutOfMemoryError - -org.gradle.daemon=true -org.gradle.parallel=true -org.gradle.parallel.threads=8 -org.gradle.configureondemand=true -android.enableJetifier=true -android.useAndroidX=true diff --git a/build/android/gradle/wrapper/gradle-wrapper.jar b/build/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 5c2d1cf01..000000000 Binary files a/build/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/build/android/gradle/wrapper/gradle-wrapper.properties b/build/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 7fd9307d7..000000000 --- a/build/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Jan 08 17:52:00 UTC 2020 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip diff --git a/build/android/gradlew b/build/android/gradlew deleted file mode 100755 index 83f2acfdc..000000000 --- a/build/android/gradlew +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/build/android/gradlew.bat b/build/android/gradlew.bat deleted file mode 100644 index 9618d8d96..000000000 --- a/build/android/gradlew.bat +++ /dev/null @@ -1,100 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/build/android/icons/aux1_btn.svg b/build/android/icons/aux1_btn.svg deleted file mode 100644 index e0ee97c0c..000000000 --- a/build/android/icons/aux1_btn.svg +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - Aux1 - - - diff --git a/build/android/icons/camera_btn.svg b/build/android/icons/camera_btn.svg deleted file mode 100644 index a91a7fcf8..000000000 --- a/build/android/icons/camera_btn.svg +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/chat_btn.svg b/build/android/icons/chat_btn.svg deleted file mode 100644 index 41dc6f8c7..000000000 --- a/build/android/icons/chat_btn.svg +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/chat_hide_btn.svg b/build/android/icons/chat_hide_btn.svg deleted file mode 100644 index 6647b3097..000000000 --- a/build/android/icons/chat_hide_btn.svg +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/chat_show_btn.svg b/build/android/icons/chat_show_btn.svg deleted file mode 100644 index fce9de996..000000000 --- a/build/android/icons/chat_show_btn.svg +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/checkbox_tick.svg b/build/android/icons/checkbox_tick.svg deleted file mode 100644 index 6b727bb52..000000000 --- a/build/android/icons/checkbox_tick.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/debug_btn.svg b/build/android/icons/debug_btn.svg deleted file mode 100644 index 2c37f142a..000000000 --- a/build/android/icons/debug_btn.svg +++ /dev/null @@ -1,344 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/down.svg b/build/android/icons/down.svg deleted file mode 100644 index 190e7e875..000000000 --- a/build/android/icons/down.svg +++ /dev/null @@ -1,542 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/drop_btn.svg b/build/android/icons/drop_btn.svg deleted file mode 100644 index 7cb0e8532..000000000 --- a/build/android/icons/drop_btn.svg +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/fast_btn.svg b/build/android/icons/fast_btn.svg deleted file mode 100644 index 1436596b7..000000000 --- a/build/android/icons/fast_btn.svg +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/fly_btn.svg b/build/android/icons/fly_btn.svg deleted file mode 100644 index d203842d4..000000000 --- a/build/android/icons/fly_btn.svg +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/gear_icon.svg b/build/android/icons/gear_icon.svg deleted file mode 100644 index b44685ade..000000000 --- a/build/android/icons/gear_icon.svg +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/inventory_btn.svg b/build/android/icons/inventory_btn.svg deleted file mode 100644 index ee3dc3c17..000000000 --- a/build/android/icons/inventory_btn.svg +++ /dev/null @@ -1,509 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/joystick_bg.svg b/build/android/icons/joystick_bg.svg deleted file mode 100644 index d8836b358..000000000 --- a/build/android/icons/joystick_bg.svg +++ /dev/null @@ -1,876 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/joystick_center.svg b/build/android/icons/joystick_center.svg deleted file mode 100644 index 17202290a..000000000 --- a/build/android/icons/joystick_center.svg +++ /dev/null @@ -1,877 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/joystick_off.svg b/build/android/icons/joystick_off.svg deleted file mode 100644 index 58e1acf22..000000000 --- a/build/android/icons/joystick_off.svg +++ /dev/null @@ -1,882 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/jump_btn.svg b/build/android/icons/jump_btn.svg deleted file mode 100644 index 882c49ed7..000000000 --- a/build/android/icons/jump_btn.svg +++ /dev/null @@ -1,547 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/minimap_btn.svg b/build/android/icons/minimap_btn.svg deleted file mode 100644 index deda32717..000000000 --- a/build/android/icons/minimap_btn.svg +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/noclip_btn.svg b/build/android/icons/noclip_btn.svg deleted file mode 100644 index a816edfc7..000000000 --- a/build/android/icons/noclip_btn.svg +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/rangeview_btn.svg b/build/android/icons/rangeview_btn.svg deleted file mode 100644 index f9319e0b5..000000000 --- a/build/android/icons/rangeview_btn.svg +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/rare_controls.svg b/build/android/icons/rare_controls.svg deleted file mode 100644 index c9991ec7a..000000000 --- a/build/android/icons/rare_controls.svg +++ /dev/null @@ -1,521 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/icons/zoom.svg b/build/android/icons/zoom.svg deleted file mode 100644 index ea8dec3c5..000000000 --- a/build/android/icons/zoom.svg +++ /dev/null @@ -1,599 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/android/keystore-minetest.jks b/build/android/keystore-minetest.jks deleted file mode 100644 index 8fce68bbb..000000000 Binary files a/build/android/keystore-minetest.jks and /dev/null differ diff --git a/build/android/native/build.gradle b/build/android/native/build.gradle deleted file mode 100644 index 8ea6347b3..000000000 --- a/build/android/native/build.gradle +++ /dev/null @@ -1,98 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'de.undercouch.download' - -android { - compileSdkVersion 29 - buildToolsVersion '30.0.3' - ndkVersion '22.0.7026061' - defaultConfig { - minSdkVersion 16 - targetSdkVersion 29 - externalNativeBuild { - ndkBuild { - arguments '-j' + Runtime.getRuntime().availableProcessors(), - "versionMajor=${versionMajor}", - "versionMinor=${versionMinor}", - "versionPatch=${versionPatch}", - "versionExtra=${versionExtra}" - } - } - } - - externalNativeBuild { - ndkBuild { - path file('jni/Android.mk') - } - } - - // supported architectures - splits { - abi { - enable true - reset() - include 'armeabi-v7a', 'arm64-v8a'//, 'x86' - } - } - - buildTypes { - release { - externalNativeBuild { - ndkBuild { - arguments 'NDEBUG=1' - } - } - } - } -} - -// get precompiled deps -def folder = 'minetest_android_deps_binaries' - -task downloadDeps(type: Download) { - src 'https://github.com/minetest/' + folder + '/archive/master.zip' - dest new File(buildDir, 'deps.zip') - overwrite false -} - -task getDeps(dependsOn: downloadDeps, type: Copy) { - def deps = file('deps') - def f = file("$buildDir/" + folder + "-master") - - if (!deps.exists() && !f.exists()) { - from zipTree(downloadDeps.dest) - into buildDir - } - - doLast { - if (!deps.exists()) { - file(f).renameTo(file(deps)) - } - } -} - -// get sqlite -def sqlite_ver = '3340000' -task downloadSqlite(dependsOn: getDeps, type: Download) { - src 'https://www.sqlite.org/2020/sqlite-amalgamation-' + sqlite_ver + '.zip' - dest new File(buildDir, 'sqlite.zip') - overwrite false -} - -task getSqlite(dependsOn: downloadSqlite, type: Copy) { - def sqlite = file('deps/Android/sqlite') - def f = file("$buildDir/sqlite-amalgamation-" + sqlite_ver) - - if (!sqlite.exists() && !f.exists()) { - from zipTree(downloadSqlite.dest) - into buildDir - } - - doLast { - if (!sqlite.exists()) { - file(f).renameTo(file(sqlite)) - } - } -} - -preBuild.dependsOn getDeps -preBuild.dependsOn getSqlite diff --git a/build/android/native/jni/Android.mk b/build/android/native/jni/Android.mk deleted file mode 100644 index 477392af0..000000000 --- a/build/android/native/jni/Android.mk +++ /dev/null @@ -1,206 +0,0 @@ -LOCAL_PATH := $(call my-dir)/.. - -#LOCAL_ADDRESS_SANITIZER:=true - -include $(CLEAR_VARS) -LOCAL_MODULE := Curl -LOCAL_SRC_FILES := deps/Android/Curl/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libcurl.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := Freetype -LOCAL_SRC_FILES := deps/Android/Freetype/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libfreetype.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := Irrlicht -LOCAL_SRC_FILES := deps/Android/Irrlicht/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libIrrlichtMt.a -include $(PREBUILT_STATIC_LIBRARY) - -#include $(CLEAR_VARS) -#LOCAL_MODULE := LevelDB -#LOCAL_SRC_FILES := deps/Android/LevelDB/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libleveldb.a -#include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := LuaJIT -LOCAL_SRC_FILES := deps/Android/LuaJIT/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libluajit.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := mbedTLS -LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedtls.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := mbedx509 -LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedx509.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := mbedcrypto -LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedcrypto.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := OpenAL -LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libopenal.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := Vorbis -LOCAL_SRC_FILES := deps/Android/Vorbis/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libvorbis.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := Minetest - -LOCAL_CFLAGS += \ - -DJSONCPP_NO_LOCALE_SUPPORT \ - -DHAVE_TOUCHSCREENGUI \ - -DENABLE_GLES=1 \ - -DUSE_CURL=1 \ - -DUSE_SOUND=1 \ - -DUSE_FREETYPE=1 \ - -DUSE_LEVELDB=0 \ - -DUSE_LUAJIT=1 \ - -DVERSION_MAJOR=${versionMajor} \ - -DVERSION_MINOR=${versionMinor} \ - -DVERSION_PATCH=${versionPatch} \ - -DVERSION_EXTRA=${versionExtra} \ - $(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/LevelDB/include \ - deps/Android/libiconv/include \ - deps/Android/libiconv/libcharset/include \ - deps/Android/LuaJIT/src \ - deps/Android/OpenAL-Soft/include \ - deps/Android/sqlite \ - 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-sqlite3.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/*/*.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/rollback.cpp \ - ../../../src/rollback_interface.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 - -# LevelDB backend is disabled -# ../../../src/database/database-leveldb.cpp - -# GMP -LOCAL_SRC_FILES += ../../../lib/gmp/mini-gmp.c - -# JSONCPP -LOCAL_SRC_FILES += ../../../lib/jsoncpp/jsoncpp.cpp - -# iconv -LOCAL_SRC_FILES += \ - deps/Android/libiconv/lib/iconv.c \ - deps/Android/libiconv/libcharset/lib/localcharset.c - -# SQLite3 -LOCAL_SRC_FILES += deps/Android/sqlite/sqlite3.c - -LOCAL_STATIC_LIBRARIES += Curl Freetype Irrlicht OpenAL mbedTLS mbedx509 mbedcrypto Vorbis LuaJIT android_native_app_glue $(PROFILER_LIBS) #LevelDB - -LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES - -include $(BUILD_SHARED_LIBRARY) - -ifdef GPROF -$(call import-module,android-ndk-profiler) -endif -$(call import-module,android/native_app_glue) diff --git a/build/android/native/jni/Application.mk b/build/android/native/jni/Application.mk deleted file mode 100644 index 82f0148f0..000000000 --- a/build/android/native/jni/Application.mk +++ /dev/null @@ -1,32 +0,0 @@ -APP_PLATFORM := ${APP_PLATFORM} -APP_ABI := ${TARGET_ABI} -APP_STL := c++_shared -NDK_TOOLCHAIN_VERSION := clang -APP_SHORT_COMMANDS := true -APP_MODULES := Minetest - -APP_CPPFLAGS := -Ofast -fvisibility=hidden -fexceptions -Wno-deprecated-declarations -Wno-extra-tokens - -ifeq ($(APP_ABI),armeabi-v7a) -APP_CPPFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -endif - -#ifeq ($(APP_ABI),x86) -#APP_CPPFLAGS += -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -funroll-loops -#endif - -ifndef NDEBUG -APP_CPPFLAGS := -g -D_DEBUG -O0 -fno-omit-frame-pointer -fexceptions -endif - -APP_CFLAGS := $(APP_CPPFLAGS) -Wno-parentheses-equality #-Werror=shorten-64-to-32 -APP_CXXFLAGS := $(APP_CPPFLAGS) -frtti -std=gnu++17 -APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections,--icf=safe - -ifeq ($(APP_ABI),arm64-v8a) -APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections -endif - -ifndef NDEBUG -APP_LDFLAGS := -endif diff --git a/build/android/native/src/main/AndroidManifest.xml b/build/android/native/src/main/AndroidManifest.xml deleted file mode 100644 index 19451c7fd..000000000 --- a/build/android/native/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/build/android/settings.gradle b/build/android/settings.gradle deleted file mode 100644 index b048fca7c..000000000 --- a/build/android/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = "Minetest" -include ':app', ':native' diff --git a/doc/README.android b/doc/README.android index f6b67978f..3833688b1 100644 --- a/doc/README.android +++ b/doc/README.android @@ -74,7 +74,7 @@ automatically. Or you can create a `local.properties` file and specify are different tutorials on the web explaining how to do it - choose one yourself. -* Once your keystore is setup, enter build/android subdirectory and create a new +* Once your keystore is setup, enter the android subdirectory and create a new file "ant.properties" there. Add following lines to that file: > key.store= diff --git a/util/bump_version.sh b/util/bump_version.sh index 4b12935bd..3e64bfd86 100755 --- a/util/bump_version.sh +++ b/util/bump_version.sh @@ -25,13 +25,13 @@ perform_release() { sed -i -re "s/^set\(DEVELOPMENT_BUILD TRUE\)$/set(DEVELOPMENT_BUILD FALSE)/" CMakeLists.txt - sed -i 's/project.ext.set("versionExtra", "-dev")/project.ext.set("versionExtra", "")/' build/android/build.gradle - sed -i -re "s/\"versionCode\", [0-9]+/\"versionCode\", $NEW_ANDROID_VERSION_CODE/" build/android/build.gradle + sed -i 's/project.ext.set("versionExtra", "-dev")/project.ext.set("versionExtra", "")/' android/build.gradle + sed -i -re "s/\"versionCode\", [0-9]+/\"versionCode\", $NEW_ANDROID_VERSION_CODE/" android/build.gradle sed -i '/\