mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 13:38:18 +00:00
Add Android shortcuts for launching with Vulkan/OpenGL
Define shortcuts to launch the client with either Vulkan or OpenGL graphics backend, which can be accessed by long-pressing the app icon on the home screen. This feature is available for Android 7.1 and newer.
This commit is contained in:
parent
14f1b36dd1
commit
dc0d4b3b76
|
@ -197,6 +197,7 @@ cd "${BUILD_FOLDER}" || exit 1
|
|||
|
||||
mkdir -p src/main
|
||||
mkdir -p src/main/res/values
|
||||
mkdir -p src/main/res/xml
|
||||
mkdir -p src/main/res/mipmap
|
||||
|
||||
function copy_dummy_files() {
|
||||
|
@ -213,6 +214,7 @@ copy_dummy_files scripts/android/files/proguard-rules.pro proguard-rules.pro
|
|||
copy_dummy_files scripts/android/files/settings.gradle settings.gradle
|
||||
copy_dummy_files scripts/android/files/AndroidManifest.xml src/main/AndroidManifest.xml
|
||||
copy_dummy_files scripts/android/files/res/values/strings.xml src/main/res/values/strings.xml
|
||||
copy_dummy_files scripts/android/files/res/xml/shortcuts.xml src/main/res/xml/shortcuts.xml
|
||||
copy_dummy_files other/icons/DDNet_256x256x32.png src/main/res/mipmap/ic_launcher.png
|
||||
copy_dummy_files other/icons/DDNet_256x256x32.png src/main/res/mipmap/ic_launcher_round.png
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
android:name="org.ddnet.client.NativeMain"
|
||||
android:exported="true"
|
||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||
android:screenOrientation="landscape">
|
||||
android:screenOrientation="landscape"
|
||||
android:launchMode="singleInstance">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -38,6 +39,9 @@
|
|||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="DDNet" />
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts" />
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -51,6 +51,8 @@ sed -i "s/TW_VERSION_NAME/${TW_VERSION_NAME}/g" build.gradle
|
|||
|
||||
sed -i "s/DDNet/${APK_BASENAME}/g" src/main/res/values/strings.xml
|
||||
|
||||
sed -i "s/org.ddnet.client/${APK_PACKAGE_NAME}/g" src/main/res/xml/shortcuts.xml
|
||||
|
||||
sed -i "s/\"DDNet\"/\"${APK_BASENAME}\"/g" src/main/AndroidManifest.xml
|
||||
sed -i "s/org.ddnet.client/${APK_PACKAGE_NAME}/g" src/main/AndroidManifest.xml
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ public class NativeMain extends SDLActivity {
|
|||
|
||||
private static final int COMMAND_RESTART_APP = SDLActivity.COMMAND_USER + 1;
|
||||
|
||||
private String[] launchArguments = new String[0];
|
||||
|
||||
@Override
|
||||
protected String[] getLibraries() {
|
||||
return new String[] {
|
||||
|
@ -20,17 +22,35 @@ public class NativeMain extends SDLActivity {
|
|||
@Override
|
||||
public void onCreate(Bundle SavedInstanceState) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if(intent != null) {
|
||||
String gfxBackend = intent.getStringExtra("gfx-backend");
|
||||
if(gfxBackend != null) {
|
||||
if(gfxBackend.equals("Vulkan")) {
|
||||
launchArguments = new String[] {"gfx_backend Vulkan"};
|
||||
} else if(gfxBackend.equals("OpenGL")) {
|
||||
launchArguments = new String[] {"gfx_backend OpenGL"};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.onCreate(SavedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getArguments() {
|
||||
return launchArguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onUnhandledMessage(int command, Object param) {
|
||||
if(command == COMMAND_RESTART_APP) {
|
||||
restartApp();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void restartApp() {
|
||||
Intent restartIntent =
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">DDNet</string>
|
||||
<string name="app_name">DDNet</string>
|
||||
<string name="shortcut_play_vulkan_short">Play (Vulkan)</string>
|
||||
<string name="shortcut_play_opengl_short">Play (OpenGL)</string>
|
||||
</resources>
|
||||
|
|
30
scripts/android/files/res/xml/shortcuts.xml
Normal file
30
scripts/android/files/res/xml/shortcuts.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<shortcut
|
||||
android:shortcutId="play-vulkan"
|
||||
android:enabled="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:shortcutShortLabel="@string/shortcut_play_vulkan_short">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetPackage="org.ddnet.client"
|
||||
android:targetClass="org.ddnet.client.NativeMain">
|
||||
<extra
|
||||
android:name="gfx-backend"
|
||||
android:value="Vulkan" />
|
||||
</intent>
|
||||
</shortcut>
|
||||
<shortcut
|
||||
android:shortcutId="play-opengl"
|
||||
android:enabled="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:shortcutShortLabel="@string/shortcut_play_opengl_short">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:targetPackage="org.ddnet.client"
|
||||
android:targetClass="org.ddnet.client.NativeMain">
|
||||
<extra
|
||||
android:name="gfx-backend"
|
||||
android:value="OpenGL" />
|
||||
</intent>
|
||||
</shortcut>
|
||||
</shortcuts>
|
Loading…
Reference in a new issue