diff options
Diffstat (limited to 'build')
9 files changed, 170 insertions, 166 deletions
diff --git a/build/android/app/build.gradle b/build/android/app/build.gradle index e3619af17..7f4eba8c4 100644 --- a/build/android/app/build.gradle +++ b/build/android/app/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'com.android.application' android { compileSdkVersion 29 - buildToolsVersion '29.0.3' - ndkVersion '21.1.6352462' + buildToolsVersion '30.0.3' + ndkVersion '22.0.7026061' defaultConfig { applicationId 'net.minetest.minetest' minSdkVersion 16 @@ -11,8 +11,11 @@ android { versionCode project.versionCode } + // load properties Properties props = new Properties() - props.load(new FileInputStream(file('../local.properties'))) + def propfile = file('../local.properties') + if (propfile.exists()) + props.load(new FileInputStream(propfile)) if (props.getProperty('keystore') != null) { signingConfigs { @@ -61,10 +64,9 @@ task prepareAssets() { copy { from "${projRoot}/builtin" into "${assetsFolder}/builtin" } - /*copy { - // ToDo: fix Minetest shaders that currently don't work with OpenGL ES + copy { from "${projRoot}/client/shaders" into "${assetsFolder}/client/shaders" - }*/ + } copy { from "../native/deps/Android/Irrlicht/shaders" into "${assetsFolder}/client/shaders/Irrlicht" } @@ -107,5 +109,5 @@ android.applicationVariants.all { variant -> dependencies { implementation project(':native') - implementation 'androidx.appcompat:appcompat:1.1.0' + 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 index 0a7c8d95a..fa93e7069 100644 --- a/build/android/app/src/main/AndroidManifest.xml +++ b/build/android/app/src/main/AndroidManifest.xml @@ -17,8 +17,8 @@ android:allowBackup="false" android:icon="@mipmap/ic_launcher" android:label="@string/label" - android:resizeableActivity="false" android:requestLegacyExternalStorage="true" + android:resizeableActivity="false" tools:ignore="UnusedAttribute"> <meta-data @@ -53,11 +53,6 @@ android:value="Minetest" /> </activity> - <activity - android:name=".InputDialogActivity" - android:maxAspectRatio="3.0" - android:theme="@style/InputTheme" /> - <service android:name=".UnzipService" android:enabled="true" 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 new file mode 100644 index 000000000..8d0a503d0 --- /dev/null +++ b/build/android/app/src/main/java/net/minetest/minetest/CustomEditText.java @@ -0,0 +1,45 @@ +/* +Minetest +Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua> +Copyright (C) 2014-2020 ubulem, Bektur Mambetov <berkut87@gmail.com> + +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 index 635512569..38a388230 100644 --- a/build/android/app/src/main/java/net/minetest/minetest/GameActivity.java +++ b/build/android/app/src/main/java/net/minetest/minetest/GameActivity.java @@ -25,8 +25,16 @@ 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.EditText; + +import androidx.appcompat.app.AlertDialog; + +import java.util.Objects; public class GameActivity extends NativeActivity { static { @@ -34,8 +42,8 @@ public class GameActivity extends NativeActivity { System.loadLibrary("Minetest"); } - private int messageReturnCode; - private String messageReturnValue; + private int messageReturnCode = -1; + private String messageReturnValue = ""; public static native void putMessageBoxResult(String text); @@ -43,8 +51,6 @@ public class GameActivity extends NativeActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - messageReturnCode = -1; - messageReturnValue = ""; } private void makeFullScreen() { @@ -73,29 +79,46 @@ public class GameActivity extends NativeActivity { // Ignore the back press so Minetest can handle it } - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == 101) { - if (resultCode == RESULT_OK) { - String text = data.getStringExtra("text"); - messageReturnCode = 0; - messageReturnValue = text; - } else - messageReturnCode = 1; - } + public void showDialog(String acceptButton, String hint, String current, int editType) { + runOnUiThread(() -> showDialogUI(hint, current, editType)); } - public void showDialog(String acceptButton, String hint, String current, int editType) { - Intent intent = new Intent(this, InputDialogActivity.class); - Bundle params = new Bundle(); - params.putString("acceptButton", acceptButton); - params.putString("hint", hint); - params.putString("current", current); - params.putInt("editType", editType); - intent.putExtras(params); - startActivityForResult(intent, 101); - messageReturnValue = ""; - messageReturnCode = -1; + private void showDialogUI(String hint, String current, int editType) { + final AlertDialog.Builder builder = new AlertDialog.Builder(this); + EditText editText = new CustomEditText(this); + builder.setView(editText); + AlertDialog alertDialog = builder.create(); + 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) -> { + if (KeyCode == KeyEvent.KEYCODE_ENTER) { + imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); + messageReturnCode = 0; + messageReturnValue = editText.getText().toString(); + alertDialog.dismiss(); + return true; + } + return false; + }); + alertDialog.show(); + alertDialog.setOnCancelListener(dialog -> { + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); + messageReturnValue = current; + messageReturnCode = -1; + }); } public int getDialogState() { @@ -119,8 +142,8 @@ public class GameActivity extends NativeActivity { return getResources().getDisplayMetrics().widthPixels; } - public void openURL(String url) { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + 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/InputDialogActivity.java b/build/android/app/src/main/java/net/minetest/minetest/InputDialogActivity.java deleted file mode 100644 index 7c6aa111d..000000000 --- a/build/android/app/src/main/java/net/minetest/minetest/InputDialogActivity.java +++ /dev/null @@ -1,98 +0,0 @@ -/* -Minetest -Copyright (C) 2014-2020 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua> -Copyright (C) 2014-2020 ubulem, Bektur Mambetov <berkut87@gmail.com> - -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.Activity; -import android.content.Intent; -import android.os.Build; -import android.os.Bundle; -import android.text.InputType; -import android.view.KeyEvent; -import android.view.View; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; - -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AppCompatActivity; - -import java.util.Objects; - -public class InputDialogActivity extends AppCompatActivity { - private AlertDialog alertDialog; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle b = getIntent().getExtras(); - int editType = Objects.requireNonNull(b).getInt("editType"); - String hint = b.getString("hint"); - String current = b.getString("current"); - final AlertDialog.Builder builder = new AlertDialog.Builder(this); - EditText editText = new EditText(this); - builder.setView(editText); - 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 == 3) - editText.setInputType(InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_PASSWORD); - else - editText.setInputType(InputType.TYPE_CLASS_TEXT); - editText.setOnKeyListener((view, KeyCode, event) -> { - if (KeyCode == KeyEvent.KEYCODE_ENTER) { - imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); - pushResult(editText.getText().toString()); - return true; - } - return false; - }); - alertDialog = builder.create(); - if (!this.isFinishing()) - alertDialog.show(); - alertDialog.setOnCancelListener(dialog -> { - pushResult(editText.getText().toString()); - setResult(Activity.RESULT_CANCELED); - alertDialog.dismiss(); - makeFullScreen(); - finish(); - }); - } - - private void pushResult(String text) { - Intent resultData = new Intent(); - resultData.putExtra("text", text); - setResult(AppCompatActivity.RESULT_OK, resultData); - alertDialog.dismiss(); - makeFullScreen(); - finish(); - } - - 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); - } -} diff --git a/build/android/app/src/main/res/values/styles.xml b/build/android/app/src/main/res/values/styles.xml index 618507e63..291a4eaf1 100644 --- a/build/android/app/src/main/res/values/styles.xml +++ b/build/android/app/src/main/res/values/styles.xml @@ -8,15 +8,8 @@ <item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">shortEdges</item> </style> - <style name="InputTheme" parent="Theme.AppCompat.DayNight.Dialog"> - <item name="windowNoTitle">true</item> - <item name="android:windowBackground">@android:color/transparent</item> - </style> - - <style name="CustomProgressBar" parent="@style/Widget.AppCompat.ProgressBar.Horizontal"> + <style name="CustomProgressBar" parent="Widget.AppCompat.ProgressBar.Horizontal"> <item name="android:indeterminateOnly">false</item> - <item name="android:minHeight">10dip</item> - <item name="android:maxHeight">20dip</item> </style> </resources> diff --git a/build/android/build.gradle b/build/android/build.gradle index 8707b563c..be9eaada4 100644 --- a/build/android/build.gradle +++ b/build/android/build.gradle @@ -1,10 +1,10 @@ // 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", 3) // Version Minor +project.ext.set("versionMinor", 4) // Version Minor project.ext.set("versionPatch", 0) // Version Patch -project.ext.set("versionExtra", "-dev") // Version Extra -project.ext.set("versionCode", 30) // Android Version Code +project.ext.set("versionExtra", "") // 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 @@ -15,8 +15,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.6.3' - classpath 'org.ajoberstar.grgit:grgit-gradle:4.0.2' + 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 } @@ -31,4 +31,5 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir + delete 'native/deps' } diff --git a/build/android/gradle/wrapper/gradle-wrapper.properties b/build/android/gradle/wrapper/gradle-wrapper.properties index d612cf333..7fd9307d7 100644 --- a/build/android/gradle/wrapper/gradle-wrapper.properties +++ b/build/android/gradle/wrapper/gradle-wrapper.properties @@ -1,2 +1,6 @@ -#Mon Apr 06 00:06:16 CEST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip +#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/native/build.gradle b/build/android/native/build.gradle index cbd50db6a..8ea6347b3 100644 --- a/build/android/native/build.gradle +++ b/build/android/native/build.gradle @@ -1,16 +1,16 @@ apply plugin: 'com.android.library' -import org.ajoberstar.grgit.Grgit +apply plugin: 'de.undercouch.download' android { compileSdkVersion 29 - buildToolsVersion '29.0.3' - ndkVersion '21.1.6352462' + buildToolsVersion '30.0.3' + ndkVersion '22.0.7026061' defaultConfig { minSdkVersion 16 targetSdkVersion 29 externalNativeBuild { ndkBuild { - arguments '-j8', + arguments '-j' + Runtime.getRuntime().availableProcessors(), "versionMajor=${versionMajor}", "versionMinor=${versionMinor}", "versionPatch=${versionPatch}", @@ -45,15 +45,54 @@ android { } } -task cloneGitRepo() { - def destination = file('deps') - if(!destination.exists()) { - def grgit = Grgit.clone( - dir: destination, - uri: 'https://github.com/minetest/minetest_android_deps_binaries' - ) - grgit.close() +// 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 cloneGitRepo +preBuild.dependsOn getDeps +preBuild.dependsOn getSqlite |