diff options
Diffstat (limited to 'android')
-rw-r--r-- | android/app/src/main/AndroidManifest.xml | 13 | ||||
-rw-r--r-- | android/app/src/main/java/net/minetest/minetest/GameActivity.java | 25 | ||||
-rw-r--r-- | android/app/src/main/res/xml/filepaths.xml | 3 | ||||
-rw-r--r-- | android/build.gradle | 7 | ||||
-rw-r--r-- | android/native/build.gradle | 3 | ||||
-rw-r--r-- | android/native/jni/Android.mk | 61 | ||||
-rw-r--r-- | android/native/jni/Application.mk | 2 |
7 files changed, 105 insertions, 9 deletions
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 6ea677cb9..11c868622 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -59,6 +59,17 @@ android:name=".UnzipService" android:enabled="true" android:exported="false" /> - </application> + + <provider + android:name="androidx.core.content.FileProvider" + android:authorities="net.minetest.minetest.fileprovider" + android:grantUriPermissions="true" + android:exported="false"> + <meta-data + android:name="android.support.FILE_PROVIDER_PATHS" + android:resource="@xml/filepaths" /> + </provider> + +</application> </manifest> diff --git a/android/app/src/main/java/net/minetest/minetest/GameActivity.java b/android/app/src/main/java/net/minetest/minetest/GameActivity.java index 46fc9b1de..f5e9fd6d0 100644 --- a/android/app/src/main/java/net/minetest/minetest/GameActivity.java +++ b/android/app/src/main/java/net/minetest/minetest/GameActivity.java @@ -26,6 +26,7 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.text.InputType; +import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.WindowManager; @@ -34,10 +35,16 @@ import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; +import androidx.annotation.Keep; import androidx.appcompat.app.AlertDialog; +import androidx.core.content.FileProvider; +import java.io.File; import java.util.Objects; +// Native code finds these methods by name (see porting_android.cpp). +// This annotation prevents the minifier/Proguard from mangling them. +@Keep public class GameActivity extends NativeActivity { static { System.loadLibrary("c++_shared"); @@ -179,4 +186,22 @@ public class GameActivity extends NativeActivity { public String getCachePath() { return Utils.getCacheDirectory(this).getAbsolutePath(); } + + public void shareFile(String path) { + File file = new File(path); + if (!file.exists()) { + Log.e("GameActivity", "File " + file.getAbsolutePath() + " doesn't exist"); + return; + } + + Uri fileUri = FileProvider.getUriForFile(this, "net.minetest.minetest.fileprovider", file); + + Intent intent = new Intent(Intent.ACTION_SEND, fileUri); + intent.setDataAndType(fileUri, getContentResolver().getType(fileUri)); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + intent.putExtra(Intent.EXTRA_STREAM, fileUri); + + Intent shareIntent = Intent.createChooser(intent, null); + startActivity(shareIntent); + } } diff --git a/android/app/src/main/res/xml/filepaths.xml b/android/app/src/main/res/xml/filepaths.xml new file mode 100644 index 000000000..2fff06908 --- /dev/null +++ b/android/app/src/main/res/xml/filepaths.xml @@ -0,0 +1,3 @@ +<paths> + <external-files-path path="Minetest/" name="minetest" /> +</paths> diff --git a/android/build.gradle b/android/build.gradle index a4c0e7535..7113dc7ad 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,16 +1,17 @@ // 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", 1) // Version Patch +project.ext.set("versionMinor", 6) // Version Minor +project.ext.set("versionPatch", 0) // Version Patch project.ext.set("versionExtra", "") // Version Extra project.ext.set("versionCode", 40) // Android Version Code +project.ext.set("developmentBuild", 0) // Whether it is a development build, or a release // NOTE: +2 after each release! // +1 for ARM and +1 for ARM64 APK's, because // each APK must have a larger `versionCode` than the previous buildscript { - ext.ndk_version = '23.0.7599858' + ext.ndk_version = '23.2.8568313' repositories { google() jcenter() diff --git a/android/native/build.gradle b/android/native/build.gradle index 2ddc77135..2254aab3a 100644 --- a/android/native/build.gradle +++ b/android/native/build.gradle @@ -14,7 +14,8 @@ android { "versionMajor=${versionMajor}", "versionMinor=${versionMinor}", "versionPatch=${versionPatch}", - "versionExtra=${versionExtra}" + "versionExtra=${versionExtra}", + "developmentBuild=${developmentBuild}" } } } diff --git a/android/native/jni/Android.mk b/android/native/jni/Android.mk index f8ca74d3c..50651d5ba 100644 --- a/android/native/jni/Android.mk +++ b/android/native/jni/Android.mk @@ -1,6 +1,7 @@ LOCAL_PATH := $(call my-dir)/.. #LOCAL_ADDRESS_SANITIZER:=true +#USE_BUILTIN_LUA:=true include $(CLEAR_VARS) LOCAL_MODULE := Curl @@ -42,11 +43,15 @@ LOCAL_MODULE := Irrlicht LOCAL_SRC_FILES := deps/$(APP_ABI)/Irrlicht/libIrrlichtMt.a include $(PREBUILT_STATIC_LIBRARY) +ifndef USE_BUILTIN_LUA + include $(CLEAR_VARS) LOCAL_MODULE := LuaJIT LOCAL_SRC_FILES := deps/$(APP_ABI)/LuaJIT/libluajit.a include $(PREBUILT_STATIC_LIBRARY) +endif + include $(CLEAR_VARS) LOCAL_MODULE := OpenAL LOCAL_SRC_FILES := deps/$(APP_ABI)/OpenAL-Soft/libopenal.a @@ -92,14 +97,20 @@ LOCAL_CFLAGS += \ -DUSE_CURL=1 \ -DUSE_SOUND=1 \ -DUSE_LEVELDB=0 \ - -DUSE_LUAJIT=1 \ -DUSE_GETTEXT=1 \ -DVERSION_MAJOR=${versionMajor} \ -DVERSION_MINOR=${versionMinor} \ -DVERSION_PATCH=${versionPatch} \ -DVERSION_EXTRA=${versionExtra} \ + -DDEVELOPMENT_BUILD=${developmentBuild} \ $(GPROF_DEF) +ifdef USE_BUILTIN_LUA + LOCAL_CFLAGS += -DUSE_LUAJIT=0 +else + LOCAL_CFLAGS += -DUSE_LUAJIT=1 +endif + ifdef NDEBUG LOCAL_CFLAGS += -DNDEBUG=1 endif @@ -120,12 +131,19 @@ LOCAL_C_INCLUDES := \ deps/$(APP_ABI)/Irrlicht/include \ deps/$(APP_ABI)/Gettext/include \ deps/$(APP_ABI)/Iconv/include \ - deps/$(APP_ABI)/LuaJIT/include \ deps/$(APP_ABI)/OpenAL-Soft/include \ deps/$(APP_ABI)/SQLite/include \ deps/$(APP_ABI)/Vorbis/include \ deps/$(APP_ABI)/Zstd/include +ifdef USE_BUILTIN_LUA + LOCAL_C_INCLUDES += \ + ../../lib/lua/src \ + ../../lib/bitop +else + LOCAL_C_INCLUDES += deps/$(APP_ABI)/LuaJIT/include +endif + LOCAL_SRC_FILES := \ $(wildcard ../../src/client/*.cpp) \ $(wildcard ../../src/client/*/*.cpp) \ @@ -207,6 +225,41 @@ LOCAL_SRC_FILES := \ ../../src/voxel.cpp \ ../../src/voxelalgorithms.cpp +# Built-in Lua +ifdef USE_BUILTIN_LUA + LOCAL_SRC_FILES += \ + ../../lib/lua/src/lapi.c \ + ../../lib/lua/src/lauxlib.c \ + ../../lib/lua/src/lbaselib.c \ + ../../lib/lua/src/lcode.c \ + ../../lib/lua/src/ldblib.c \ + ../../lib/lua/src/ldebug.c \ + ../../lib/lua/src/ldo.c \ + ../../lib/lua/src/ldump.c \ + ../../lib/lua/src/lfunc.c \ + ../../lib/lua/src/lgc.c \ + ../../lib/lua/src/linit.c \ + ../../lib/lua/src/liolib.c \ + ../../lib/lua/src/llex.c \ + ../../lib/lua/src/lmathlib.c \ + ../../lib/lua/src/lmem.c \ + ../../lib/lua/src/loadlib.c \ + ../../lib/lua/src/lobject.c \ + ../../lib/lua/src/lopcodes.c \ + ../../lib/lua/src/loslib.c \ + ../../lib/lua/src/lparser.c \ + ../../lib/lua/src/lstate.c \ + ../../lib/lua/src/lstring.c \ + ../../lib/lua/src/lstrlib.c \ + ../../lib/lua/src/ltable.c \ + ../../lib/lua/src/ltablib.c \ + ../../lib/lua/src/ltm.c \ + ../../lib/lua/src/lundump.c \ + ../../lib/lua/src/lvm.c \ + ../../lib/lua/src/lzio.c \ + ../../lib/bitop/bit.c +endif + # GMP LOCAL_SRC_FILES += ../../lib/gmp/mini-gmp.c @@ -218,12 +271,14 @@ LOCAL_STATIC_LIBRARIES += \ Freetype \ Iconv libcharset \ Irrlicht \ - LuaJIT \ OpenAL \ Gettext \ SQLite3 \ Vorbis libvorbisfile libogg \ Zstd +ifndef USE_BUILTIN_LUA + LOCAL_STATIC_LIBRARIES += LuaJIT +endif LOCAL_STATIC_LIBRARIES += android_native_app_glue $(PROFILER_LIBS) LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -landroid -lOpenSLES diff --git a/android/native/jni/Application.mk b/android/native/jni/Application.mk index e21bca61c..9d9596137 100644 --- a/android/native/jni/Application.mk +++ b/android/native/jni/Application.mk @@ -20,7 +20,7 @@ APP_CPPFLAGS := -g -Og -fno-omit-frame-pointer endif APP_CFLAGS := $(APP_CPPFLAGS) -Wno-inconsistent-missing-override -Wno-parentheses-equality -APP_CXXFLAGS := $(APP_CPPFLAGS) -fexceptions -frtti -std=gnu++17 +APP_CXXFLAGS := $(APP_CPPFLAGS) -fexceptions -frtti -std=gnu++14 APP_LDFLAGS := -Wl,--no-warn-mismatch,--gc-sections,--icf=safe ifeq ($(APP_ABI),arm64-v8a) |