Browse Source

Addendum to #243 and #244

* Revert configurable activity name. Always use "org.love2d.android.GameActivity"

* Delete unnecessary AndroidManifext.xml for embed variant.

* Workaround non-UTF-8 app.name in gradle.properties. See gradle.properties for more information.
Miku AuahDark 2 years ago
parent
commit
eddaf2d70a
4 changed files with 32 additions and 43 deletions
  1. 22 2
      app/build.gradle
  2. 0 36
      app/src/embed/AndroidManifest.xml
  3. 1 1
      app/src/main/AndroidManifest.xml
  4. 9 4
      gradle.properties

+ 22 - 2
app/build.gradle

@@ -1,3 +1,5 @@
+import java.nio.charset.StandardCharsets
+
 apply plugin: 'com.android.application'
 
 android {
@@ -10,10 +12,28 @@ android {
         versionName project.properties["app.version_name"]
         minSdkVersion 16
         targetSdk 33
+        
+        def getAppName = {
+            def nameArray = project.properties["app.name_byte_array"]
+            def name = project.properties["app.name"]
+            if (name != null && nameArray != null) {
+                throw new Exception("Only define either `app.name` or `app.name_byte_array` in gradle.properties, but not both!")
+            }
+
+            if (name == null) {
+                def nameArraySplit = nameArray.split(",")
+                def nameBytes = new byte[nameArraySplit.length]
+                def count = 0
+                for (String s: nameArraySplit) {
+                    nameBytes[count++] = (byte) Integer.parseInt(s)
+                }
+                return new String(nameBytes, StandardCharsets.UTF_8)
+            }
+            return name
+        }
 
         manifestPlaceholders = [
-            NAME:project.properties["app.name"],
-            ACTIVITY_NAME:project.properties["app.activity_name"],
+            NAME:getAppName(),
             ORIENTATION:project.properties["app.orientation"],
         ]
     }

+ 0 - 36
app/src/embed/AndroidManifest.xml

@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest
-  package="org.love2d.android.executable"
-  xmlns:android="http://schemas.android.com/apk/res/android"
-  xmlns:tools="http://schemas.android.com/tools"
->
-  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
-  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" tools:replace="android:maxSdkVersion" />
-
-  <application
-      android:allowBackup="true"
-      android:icon="@drawable/love"
-      android:label="${NAME}"
-      android:usesCleartextTraffic="true"
-      android:hardwareAccelerated="true"
-      tools:node="replace" >
-      <activity
-        android:name="${ACTIVITY_NAME}"
-        android:exported="true"
-        android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
-        android:label="${NAME}"
-        android:launchMode="singleTask"
-        android:screenOrientation="${ORIENTATION}"
-        android:resizeableActivity="false"
-        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
-        <intent-filter>
-          <action android:name="android.intent.action.MAIN" />
-          <category android:name="android.intent.category.LAUNCHER" />
-          <category android:name="tv.ouya.intent.category.GAME" />
-        </intent-filter>
-        <intent-filter>
-          <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
-        </intent-filter>
-      </activity>
-    </application>
-</manifest>

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -28,7 +28,7 @@
       android:label="${NAME}"
       android:usesCleartextTraffic="true" >
     <activity
-        android:name="${ACTIVITY_NAME}"
+        android:name="org.love2d.android.GameActivity"
         android:exported="true"
         android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
         android:label="${NAME}"

+ 9 - 4
gradle.properties

@@ -1,10 +1,15 @@
 android.enableJetifier=true
 android.useAndroidX=true
-org.gradle.daemon=false
 
-app.name=Love2D
-app.activity_name=org.love2d.android.GameActivity
-app.application_id=org.love2d.unique_game_name
+# To set the application display name, only define either `app.name` or `app.name_byte_array`.
+# For a rule of thumb:
+# * Use `app.name` if your app name doesn't contain any non-ANSI characters.
+# * Otherwise, convert your app name to UTF-8 byte array, comma delimited, and put
+#   it in `app.name_byte_array`
+#app.name=LÖVE for Android
+app.name_byte_array=76,195,150,86,69,32,102,111,114,32,65,110,100,114,111,105,100
+
+app.application_id=org.love2d.android
 app.orientation=landscape
 app.version_code=30
 app.version_name=11.4