瀏覽代碼

add shortcut

Laserlicht 10 月之前
父節點
當前提交
6c4633b064

+ 1 - 1
.github/workflows/github.yml

@@ -248,7 +248,7 @@ jobs:
             cmake -DENABLE_CCACHE:BOOL=ON -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 --preset ${{ matrix.preset }}
         elif [[ (${{matrix.preset}} == android-conan-ninja-release) && (${{github.ref}} != 'refs/heads/master') ]]
         then
-            cmake -DENABLE_CCACHE:BOOL=ON -DANDROID_GRADLE_PROPERTIES="applicationIdSuffix=.daily;signingConfig=dailySigning;applicationLabel=VCMI daily" --preset ${{ matrix.preset }}
+            cmake -DENABLE_CCACHE:BOOL=ON -DANDROID_GRADLE_PROPERTIES="applicationIdSuffix=.daily;signingConfig=dailySigning;applicationLabel=VCMI daily;applicationVariant=daily" --preset ${{ matrix.preset }}
         elif [[ ${{startsWith(matrix.platform, 'msvc') }} ]]
         then
             cmake --preset ${{ matrix.preset }}

+ 1 - 1
CMakePresets.json

@@ -317,7 +317,7 @@
             "description": "VCMI Android daily build",
             "inherits": "android-conan-ninja-release",
             "cacheVariables": {
-                "ANDROID_GRADLE_PROPERTIES": "applicationIdSuffix=.daily;signingConfig=dailySigning;applicationLabel=VCMI daily"
+                "ANDROID_GRADLE_PROPERTIES": "applicationIdSuffix=.daily;signingConfig=dailySigning;applicationLabel=VCMI daily;applicationVariant=daily"
             }
         }
     ],

+ 2 - 0
android/AndroidManifest.xml

@@ -30,6 +30,8 @@
 				<category android:name="android.intent.category.LAUNCHER"/>
 			</intent-filter>
 
+			<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts${applicationVariant}" /> 
+
 			<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
 			<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
 			<meta-data android:name="android.app.repository" android:value="default"/>

+ 2 - 0
android/vcmi-app/build.gradle

@@ -57,6 +57,7 @@ android {
 			applicationIdSuffix '.debug'
 			manifestPlaceholders = [
 				applicationLabel: 'VCMI debug',
+				applicationVariant: 'debug',
 			]
 			ndk {
 				debugSymbolLevel 'full'
@@ -70,6 +71,7 @@ android {
 			proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
 			manifestPlaceholders = [
 				applicationLabel: project.findProperty('applicationLabel') ?: 'VCMI',
+				applicationVariant: project.findProperty('applicationVariant') ?: '',
 			]
 			ndk {
 				debugSymbolLevel 'full'

+ 1 - 0
android/vcmi-app/src/main/res/values-de/strings.xml

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <string name="server_name">VCMI-Server</string>
+    <string name="shortcut_play">VCMI spielen</string>
 </resources>

+ 1 - 0
android/vcmi-app/src/main/res/values/strings.xml

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <string name="server_name">VCMI Server</string>
+    <string name="shortcut_play">Play VCMI</string>
 </resources>

+ 13 - 0
android/vcmi-app/src/main/res/xml/shortcuts.xml

@@ -0,0 +1,13 @@
+<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
+	<shortcut
+		android:shortcutId="play"
+		android:enabled="true"
+		android:icon="@mipmap/ic_launcher"
+		android:shortcutShortLabel="@string/shortcut_play"
+		android:shortcutLongLabel="@string/shortcut_play">
+		<intent
+			android:action="android.intent.action.VIEW"
+			android:targetPackage="is.xyz.vcmi"
+			android:targetClass="eu.vcmi.vcmi.VcmiSDLActivity" />
+	</shortcut>
+</shortcuts>

+ 13 - 0
android/vcmi-app/src/main/res/xml/shortcutsdaily.xml

@@ -0,0 +1,13 @@
+<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
+	<shortcut
+		android:shortcutId="play"
+		android:enabled="true"
+		android:icon="@mipmap/ic_launcher"
+		android:shortcutShortLabel="@string/shortcut_play"
+		android:shortcutLongLabel="@string/shortcut_play">
+		<intent
+			android:action="android.intent.action.VIEW"
+			android:targetPackage="is.xyz.vcmi.daily"
+			android:targetClass="eu.vcmi.vcmi.VcmiSDLActivity" />
+	</shortcut>
+</shortcuts>

+ 13 - 0
android/vcmi-app/src/main/res/xml/shortcutsdebug.xml

@@ -0,0 +1,13 @@
+<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
+	<shortcut
+		android:shortcutId="play"
+		android:enabled="true"
+		android:icon="@mipmap/ic_launcher"
+		android:shortcutShortLabel="@string/shortcut_play"
+		android:shortcutLongLabel="@string/shortcut_play">
+		<intent
+			android:action="android.intent.action.VIEW"
+			android:targetPackage="is.xyz.vcmi.debug"
+			android:targetClass="eu.vcmi.vcmi.VcmiSDLActivity" />
+	</shortcut>
+</shortcuts>