Browse Source

Android 11.0 compatibility (#195)

* Update dependencies and target SDK
* Update Gradle to 6.6.1
* Update target API level to 30
* Update AGP to 4.0.1
* Update Android Build Dependencies (androidx.appcompat:appcompat:1.2.0, androidx.multidex:multidex:2.0.1)
* Update readme
* Move /sdcard/lovegame directory. (closes #194)
* Potentially fixes black screen when reopening LOVE from app drawer (fixes #190)
* Downloader cleanup.
* Merge SDL AndroidManifest.xml to LOVE
* Implement partial "Share to LOVE" support.
* Enable resizeableActivity
Miku AuahDark 5 years ago
parent
commit
0e41ef20b3

+ 2 - 1
.gitignore

@@ -25,4 +25,5 @@ local.properties
 
 
 # Gradle build files
 # Gradle build files
 build
 build
-.externalNativeBuild
+.externalNativeBuild
+.cxx

+ 7 - 10
README.md

@@ -33,27 +33,24 @@ In the repository directory. For the last command, add `--depth 1` if needed.
 Instructions:
 Instructions:
 -------------
 -------------
 
 
-Detailed instructions can be viewed at https://bitbucket.org/MartinFelis/love-android-sdl2/wiki/Home (at the moment)
+Detailed instructions can be viewed at https://github.com/love2d/love-android/wiki
 
 
 Quick Start:
 Quick Start:
 ------------
 ------------
 
 
-Install the Android NDK and the Android SDK with SDK API 28, set the
-environment variables:
+Install the Android SDK with SDK API 30 and Android NDK 21.3.6528147, set the environment variables:
 
 
 * `ANDROID_HOME` to your Android SDK location.
 * `ANDROID_HOME` to your Android SDK location.
 
 
-* `ANDROID_NDK_HOME` to your Android NDK location. NDK r16 or later!
-
 (you may have to adjust the paths to the install directories of the Android
 (you may have to adjust the paths to the install directories of the Android
-SDK and Android NDK on your system) and run
+SDK on your system) and run
 
 
 ```
 ```
 ./gradlew assembleNormal
 ./gradlew assembleNormal
 ```
 ```
 
 
-in the root folder of this project. This should give you a .apk file in the app/build/outputs/apk/normal
-subdirectory that you can then sign and install on your phone. The .apk flavor is what you normally have
+in the root folder of this project. This should give you a .apk file in the `app/build/outputs/apk/normal`
+subdirectory that you can then sign and install on your phone. The `normal` .apk flavor is what you normally have
 when downloading one from love2d.org. If you want to build the ["embed"](https://love2d.org/wiki/Game_Distribution/APKTool
 when downloading one from love2d.org. If you want to build the ["embed"](https://love2d.org/wiki/Game_Distribution/APKTool
 APK, change `assembleNormal` to `assembleEmbedRelease` instead at command above.
 APK, change `assembleNormal` to `assembleEmbedRelease` instead at command above.
 
 
@@ -63,7 +60,7 @@ and on the tab "SDK Tools", select NDK. After that, open the repository root.
 Bugs:
 Bugs:
 -----
 -----
 
 
-Bugs and feature requests should be reported to the issue tracker at https://bitbucket.org/MartinFelis/love-android-sdl2/issues?status=new&status=open
+Bugs and feature requests should be reported to the issue tracker at https://github.com/love2d/love-android/issues
 
 
 Changelog:
 Changelog:
 ----------
 ----------
@@ -72,7 +69,7 @@ Changelog:
 
 
 * Contains all relevant changes for desktop LÖVE [11.3](https://love2d.org/wiki/11.3).
 * Contains all relevant changes for desktop LÖVE [11.3](https://love2d.org/wiki/11.3).
 * Added support for microphone recording on Android. **This is disabled in Play Store builds**.
 * Added support for microphone recording on Android. **This is disabled in Play Store builds**.
-* Added t.audio.mic (false by default). On Android, setting it to true requests microphone recording permission from the user.
+* Added t.audio.mic (`false` by default). On Android, setting it to true requests microphone recording permission from the user.
 * Fixed performance regression on Android devices with Adreno GPU.
 * Fixed performance regression on Android devices with Adreno GPU.
 * Fixed video playback support on Android devices with Adreno GPU.
 * Fixed video playback support on Android devices with Adreno GPU.
 
 

+ 9 - 8
app/build.gradle

@@ -1,14 +1,15 @@
 apply plugin: 'com.android.application'
 apply plugin: 'com.android.application'
 
 
 android {
 android {
-    compileSdkVersion 28
-    buildToolsVersion "28.0.3"
+    compileSdkVersion 30
+    buildToolsVersion '30.0.2'
+    ndkVersion '21.3.6528147'
     defaultConfig {
     defaultConfig {
-        applicationId "org.love2d.android"
+        applicationId 'org.love2d.android'
         versionCode 29
         versionCode 29
-        versionName "11.3a"
+        versionName '11.3a'
         minSdkVersion 14
         minSdkVersion 14
-        targetSdkVersion 28
+        targetSdkVersion 30
     }
     }
     buildTypes {
     buildTypes {
         release {
         release {
@@ -26,7 +27,7 @@ android {
         }
         }
         embed {
         embed {
             dimension 'mode'
             dimension 'mode'
-            applicationIdSuffix "embed"
+            applicationIdSuffix '.embed'
         }
         }
     }
     }
     lintOptions {
     lintOptions {
@@ -35,8 +36,8 @@ android {
 }
 }
 
 
 dependencies {
 dependencies {
-    api 'androidx.multidex:multidex:2.0.0'
+    api 'androidx.multidex:multidex:2.0.1'
     api fileTree(dir: 'libs', include: ['*.jar'])
     api fileTree(dir: 'libs', include: ['*.jar'])
-    api 'androidx.appcompat:appcompat:1.1.0-alpha01'
+    api 'androidx.appcompat:appcompat:1.2.0'
     api project(':love')
     api project(':love')
 }
 }

+ 1 - 5
app/proguard-rules.pro

@@ -16,8 +16,4 @@
 #   public *;
 #   public *;
 #}
 #}
 
 
--keep class br.com.tapps.love.LoveActivity { *; }
-
--keepclassmembers class br.com.tapps.love.LoveActivity {
-   public com.naef.jnlua.LuaState createLuaState();
-}
+-keep class org.love2d.android.GameActivity { *; }

+ 2 - 1
app/src/embed/AndroidManifest.xml

@@ -12,7 +12,8 @@
       android:icon="@drawable/love"
       android:icon="@drawable/love"
       android:label="LÖVE for Android"
       android:label="LÖVE for Android"
       android:usesCleartextTraffic="true"
       android:usesCleartextTraffic="true"
-	  tools:node="replace" >
+      android:hardwareAccelerated="true"
+      tools:node="replace" >
       <activity
       <activity
         android:name="org.love2d.android.GameActivity"
         android:name="org.love2d.android.GameActivity"
         android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
         android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"

+ 20 - 7
app/src/main/AndroidManifest.xml

@@ -1,20 +1,30 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <manifest package="org.love2d.android.executable"
 <manifest package="org.love2d.android.executable"
   android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
   android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
-  <uses-permission android:name="android.permission.INTERNET"/>
-  <uses-permission android:name="android.permission.VIBRATE"/>
+  <uses-permission android:name="android.permission.INTERNET" />
+  <uses-permission android:name="android.permission.VIBRATE" />
+  <uses-permission android:name="android.permission.BLUETOOTH" />
   <uses-permission android:name="android.permission.RECORD_AUDIO" />
   <uses-permission android:name="android.permission.RECORD_AUDIO" />
-  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="23" />
   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
 
 
   <!-- OpenGL ES 2.0 -->
   <!-- OpenGL ES 2.0 -->
   <uses-feature android:glEsVersion="0x00020000" />
   <uses-feature android:glEsVersion="0x00020000" />
+  <!-- Touchscreen support -->
+  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
+  <!-- Game controller support -->
+  <uses-feature android:name="android.hardware.bluetooth" android:required="false" />
+  <uses-feature android:name="android.hardware.gamepad" android:required="false" />
+  <uses-feature android:name="android.hardware.usb.host" android:required="false" />
+  <!-- External mouse input events -->
+  <uses-feature android:name="android.hardware.type.pc" android:required="false" />
 
 
   <application
   <application
       android:allowBackup="true"
       android:allowBackup="true"
       android:icon="@drawable/love"
       android:icon="@drawable/love"
       android:label="LÖVE for Android"
       android:label="LÖVE for Android"
-      android:usesCleartextTraffic="true" >
+      android:usesCleartextTraffic="true"
+      android:hardwareAccelerated="true" >
       <service android:name="org.love2d.android.DownloadService" />
       <service android:name="org.love2d.android.DownloadService" />
       <activity
       <activity
         android:name="org.love2d.android.GameActivity"
         android:name="org.love2d.android.GameActivity"
@@ -22,7 +32,7 @@
         android:label="LÖVE for Android"
         android:label="LÖVE for Android"
         android:launchMode="singleTask"
         android:launchMode="singleTask"
         android:screenOrientation="landscape"
         android:screenOrientation="landscape"
-        android:resizeableActivity="false"
+        android:resizeableActivity="true"
         android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
         android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
         <intent-filter>
         <intent-filter>
           <action android:name="android.intent.action.MAIN" />
           <action android:name="android.intent.action.MAIN" />
@@ -43,7 +53,6 @@
           <category android:name="android.intent.category.DEFAULT" />
           <category android:name="android.intent.category.DEFAULT" />
           <category android:name="android.intent.category.BROWSABLE" />
           <category android:name="android.intent.category.BROWSABLE" />
           <data android:scheme="content" />
           <data android:scheme="content" />
-          <data android:host="*" />
           <data android:mimeType="application/x-love-game" />
           <data android:mimeType="application/x-love-game" />
         </intent-filter>
         </intent-filter>
         <intent-filter>
         <intent-filter>
@@ -51,9 +60,13 @@
           <category android:name="android.intent.category.DEFAULT" />
           <category android:name="android.intent.category.DEFAULT" />
           <category android:name="android.intent.category.BROWSABLE" />
           <category android:name="android.intent.category.BROWSABLE" />
           <data android:scheme="content" />
           <data android:scheme="content" />
-          <data android:host="*" />
           <data android:mimeType="application/octet-stream" />
           <data android:mimeType="application/octet-stream" />
         </intent-filter>
         </intent-filter>
+        <intent-filter>
+          <action android:name="android.intent.action.SEND" />
+          <category android:name="android.intent.category.DEFAULT" />
+          <data android:mimeType="application/*" />
+        </intent-filter>
       </activity>
       </activity>
       <activity
       <activity
         android:name="org.love2d.android.DownloadActivity"
         android:name="org.love2d.android.DownloadActivity"

+ 1 - 1
build.gradle

@@ -13,7 +13,7 @@ buildscript {
         jcenter()
         jcenter()
     }
     }
     dependencies {
     dependencies {
-        classpath 'com.android.tools.build:gradle:3.2.1'
+        classpath 'com.android.tools.build:gradle:4.0.1'
 
 
         // NOTE: Do not place your application dependencies here; they belong
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
         // in the individual module build.gradle files

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 6
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
-#Sun Nov 18 11:20:03 CET 2018
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
+#Thu Oct 01 16:43:18 SGT 2020
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip

+ 42 - 30
gradlew

@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
 
 
 ##############################################################################
 ##############################################################################
 ##
 ##
@@ -6,20 +6,38 @@
 ##
 ##
 ##############################################################################
 ##############################################################################
 
 
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# 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_NAME="Gradle"
 APP_BASE_NAME=`basename "$0"`
 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=""
+
 # Use the maximum available, or set MAX_FD != -1 to use that value.
 # Use the maximum available, or set MAX_FD != -1 to use that value.
 MAX_FD="maximum"
 MAX_FD="maximum"
 
 
-warn ( ) {
+warn () {
     echo "$*"
     echo "$*"
 }
 }
 
 
-die ( ) {
+die () {
     echo
     echo
     echo "$*"
     echo "$*"
     echo
     echo
@@ -30,6 +48,7 @@ die ( ) {
 cygwin=false
 cygwin=false
 msys=false
 msys=false
 darwin=false
 darwin=false
+nonstop=false
 case "`uname`" in
 case "`uname`" in
   CYGWIN* )
   CYGWIN* )
     cygwin=true
     cygwin=true
@@ -40,26 +59,11 @@ case "`uname`" in
   MINGW* )
   MINGW* )
     msys=true
     msys=true
     ;;
     ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
 esac
 esac
 
 
-# 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
-
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 
 
 # Determine the Java command to use to start the JVM.
 # Determine the Java command to use to start the JVM.
@@ -85,7 +89,7 @@ location of your Java installation."
 fi
 fi
 
 
 # Increase the maximum file descriptors if we can.
 # Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
     MAX_FD_LIMIT=`ulimit -H -n`
     MAX_FD_LIMIT=`ulimit -H -n`
     if [ $? -eq 0 ] ; then
     if [ $? -eq 0 ] ; then
         if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
         if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -150,11 +154,19 @@ if $cygwin ; then
     esac
     esac
 fi
 fi
 
 
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
-    JVM_OPTS=("$@")
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
 }
 }
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+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" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"

+ 84 - 90
gradlew.bat

@@ -1,90 +1,84 @@
-@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
-
-@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=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@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 Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_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=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-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
+@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=
+
+@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

+ 10 - 8
love/build.gradle

@@ -6,14 +6,15 @@ android {
     // See https://code.google.com/p/android/issues/detail?id=52962
     // See https://code.google.com/p/android/issues/detail?id=52962
     // and http://stackoverflow.com/questions/27277433/why-does-gradle-build-my-module-in-release-mode-when-the-app-is-in-debug
     // and http://stackoverflow.com/questions/27277433/why-does-gradle-build-my-module-in-release-mode-when-the-app-is-in-debug
     // defaultPublishConfig "debug"
     // defaultPublishConfig "debug"
-    compileSdkVersion 28
-    buildToolsVersion '28.0.3'
+    compileSdkVersion 30
+    buildToolsVersion '30.0.2'
+    ndkVersion '21.3.6528147'
 
 
     defaultConfig {
     defaultConfig {
-        compileSdkVersion 28
-        buildToolsVersion "28.0.3"
+        compileSdkVersion 30
+        buildToolsVersion "30.0.2"
         minSdkVersion 14
         minSdkVersion 14
-        resValue "bool", "embed", "false"
+        resValue 'bool', 'embed', 'false'
         externalNativeBuild {
         externalNativeBuild {
             ndkBuild {
             ndkBuild {
                 arguments "-j4"
                 arguments "-j4"
@@ -24,6 +25,7 @@ android {
             // libraries Gradle should build and package with your APK.
             // libraries Gradle should build and package with your APK.
             abiFilters 'armeabi-v7a', 'arm64-v8a'
             abiFilters 'armeabi-v7a', 'arm64-v8a'
         }
         }
+        targetSdkVersion 30
     }
     }
     buildTypes {
     buildTypes {
         release {
         release {
@@ -41,7 +43,7 @@ android {
         }
         }
         embed {
         embed {
             dimension 'mode'
             dimension 'mode'
-            resValue "bool", "embed", "true"
+            resValue 'bool', 'embed', 'true'
         }
         }
     }
     }
     sourceSets {
     sourceSets {
@@ -59,7 +61,7 @@ android {
     }
     }
     externalNativeBuild {
     externalNativeBuild {
         ndkBuild {
         ndkBuild {
-            path "src/jni/Android.mk"
+            path 'src/jni/Android.mk'
         }
         }
     }
     }
     lintOptions {
     lintOptions {
@@ -73,5 +75,5 @@ android {
 
 
 dependencies {
 dependencies {
     api fileTree(dir: 'libs', include: ['*.jar'])
     api fileTree(dir: 'libs', include: ['*.jar'])
-    api 'androidx.appcompat:appcompat:1.1.0-alpha01'
+    api 'androidx.appcompat:appcompat:1.2.0'
 }
 }

+ 6 - 0
love/src/jni/SDL2/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java

@@ -243,6 +243,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
 
 
     // love2d-mod-start: allow restarting of the native thread
     // love2d-mod-start: allow restarting of the native thread
     public void startNative() {
     public void startNative() {
+        boolean hadSDLThread = SDLActivity.mSDLThread != null;
+
         // Set up JNI
         // Set up JNI
         SDL.setupJNI();
         SDL.setupJNI();
 
 
@@ -283,6 +285,10 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
                 SDLActivity.onNativeDropFile(filename);
                 SDLActivity.onNativeDropFile(filename);
             }
             }
         }
         }
+
+        if (hadSDLThread) {
+            resumeNativeThread();
+        }
     }
     }
     // love2d-mod-end: allow restarting of the native thread
     // love2d-mod-end: allow restarting of the native thread
 
 

+ 17 - 12
love/src/main/java/org/love2d/android/GameActivity.java

@@ -38,7 +38,6 @@ import android.content.Intent;
 import android.media.AudioManager;
 import android.media.AudioManager;
 import android.net.Uri;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Bundle;
-import android.os.Environment;
 import android.os.Vibrator;
 import android.os.Vibrator;
 import android.util.Log;
 import android.util.Log;
 import android.util.DisplayMetrics;
 import android.util.DisplayMetrics;
@@ -112,6 +111,7 @@ public class GameActivity extends SDLActivity {
         storagePermissionUnnecessary = false;
         storagePermissionUnnecessary = false;
         embed = context.getResources().getBoolean(R.bool.embed);
         embed = context.getResources().getBoolean(R.bool.embed);
 
 
+        // Get filename from "Open with" of another application
         handleIntent(this.getIntent());
         handleIntent(this.getIntent());
 
 
         super.onCreate(savedInstanceState);
         super.onCreate(savedInstanceState);
@@ -134,7 +134,17 @@ public class GameActivity extends SDLActivity {
     }
     }
 
 
     protected void handleIntent(Intent intent) {
     protected void handleIntent(Intent intent) {
-        Uri game = intent.getData();
+        Uri game = null;
+
+        // Try to handle "Share" intent.
+        // This is actually "bit tricky" to get working in user phone
+        // because shared static variables issue in the native side
+        // (user have to clear LOVE for Android in their recent apps list).
+        if (Intent.ACTION_SEND.equals(intent.getAction())) {
+            game = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
+        } else {
+            game = intent.getData();
+        }
 
 
         if (!embed && game != null) {
         if (!embed && game != null) {
             String scheme = game.getScheme();
             String scheme = game.getScheme();
@@ -229,17 +239,13 @@ public class GameActivity extends SDLActivity {
     }
     }
 
 
     protected void checkLovegameFolder() {
     protected void checkLovegameFolder() {
-        // If no game.love was found fall back to the game in <external storage>/lovegame
-        // if using normal or playstore build
+        // If no game.love was found and embed flavor is not used, fall back to the game in
+        // <external storage>/Android/data/<package name>/games/lovegame
         if (!embed) {
         if (!embed) {
             Log.d("GameActivity", "fallback to lovegame folder");
             Log.d("GameActivity", "fallback to lovegame folder");
-            if (hasExternalStoragePermission()) {
-                File ext = Environment.getExternalStorageDirectory();
-                if ((new File(ext, "/lovegame/main.lua")).exists()) {
-                    gamePath = ext.getPath() + "/lovegame/";
-                }
-            } else {
-                Log.d("GameActivity", "Cannot load game from /sdcard/lovegame: permission not granted");
+            File ext = getExternalFilesDir("games");
+            if ((new File(ext, "/lovegame/main.lua")).exists()) {
+                gamePath = ext.getPath() + "/lovegame/";
             }
             }
         }
         }
     }
     }
@@ -295,7 +301,6 @@ public class GameActivity extends SDLActivity {
             } else {
             } else {
                 Log.d("GameActivity", "cannot open game " + gamePath + ": no external storage permission given!");
                 Log.d("GameActivity", "cannot open game " + gamePath + ": no external storage permission given!");
             }
             }
-
         } else {
         } else {
             self.checkLovegameFolder();
             self.checkLovegameFolder();
             if (gamePath.length() > 0)
             if (gamePath.length() > 0)

+ 2 - 1
love/src/normal/java/org/love2d/android/DownloadActivity.java

@@ -27,6 +27,7 @@ import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager;
 import android.Manifest;
 import android.Manifest;
 import android.net.Uri;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Bundle;
 import android.util.Log;
 import android.util.Log;
 
 
@@ -37,7 +38,7 @@ public class DownloadActivity extends Activity {
     protected void onCreate(Bundle savedInstanceState) {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         super.onCreate(savedInstanceState);
 
 
-        if (android.os.Build.VERSION.SDK_INT >= 29 ||
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ||
             ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)
             ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)
         {
         {
             runDownloader();
             runDownloader();

+ 5 - 32
love/src/normal/java/org/love2d/android/DownloadService.java

@@ -60,14 +60,14 @@ public class DownloadService extends IntentService {
         request.setTitle(uri.getLastPathSegment());
         request.setTitle(uri.getLastPathSegment());
         request.setMimeType("application/x-love-game");
         request.setMimeType("application/x-love-game");
 
 
-        // in order for this if to run, you must use the android 3.2 to compile your app
-        if (Build.VERSION.SDK_INT >= 11) {
-            DownloadRequestSettings_API11 settings = new DownloadRequestSettings_API11();
-            settings.setup(request);
+        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
+            request.allowScanningByMediaScanner();
         }
         }
+
+        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
         request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, uri.getLastPathSegment());
         request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, uri.getLastPathSegment());
-        // get download service and enqueue file
 
 
+        // get download service and enqueue file
         Log.d("DownloadActivity", "creating manager");
         Log.d("DownloadActivity", "creating manager");
         DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
         DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
         Log.d("DownloadActivity", "enqueuing download");
         Log.d("DownloadActivity", "enqueuing download");
@@ -78,26 +78,6 @@ public class DownloadService extends IntentService {
         registerReceiver(downloadReceiver, intentFilter);
         registerReceiver(downloadReceiver, intentFilter);
     }
     }
 
 
-    /**
-     * @param context used to check the device version and DownloadManager information
-     * @return true if the download manager is available
-     */
-    public static boolean isDownloadManagerAvailable(Context context) {
-        try {
-            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
-                return false;
-            }
-            Intent intent = new Intent(Intent.ACTION_MAIN);
-            intent.addCategory(Intent.CATEGORY_LAUNCHER);
-            intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList");
-            List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
-                    PackageManager.MATCH_DEFAULT_ONLY);
-            return list.size() > 0;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
     private BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
     private BroadcastReceiver downloadReceiver = new BroadcastReceiver() {
 
 
         @Override
         @Override
@@ -107,10 +87,3 @@ public class DownloadService extends IntentService {
         }
         }
     };
     };
 }
 }
-
-class DownloadRequestSettings_API11 {
-    public static void setup(DownloadManager.Request request) {
-        request.allowScanningByMediaScanner();
-        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
-    }
-}