mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Merge pull request #8832 from Robyt3/Android-Shortcuts-Graphics-Backends
Add Android shortcuts for launching with Vulkan/OpenGL
This commit is contained in:
commit
d78032e9a6
|
@ -197,6 +197,7 @@ cd "${BUILD_FOLDER}" || exit 1
|
||||||
|
|
||||||
mkdir -p src/main
|
mkdir -p src/main
|
||||||
mkdir -p src/main/res/values
|
mkdir -p src/main/res/values
|
||||||
|
mkdir -p src/main/res/xml
|
||||||
mkdir -p src/main/res/mipmap
|
mkdir -p src/main/res/mipmap
|
||||||
|
|
||||||
function copy_dummy_files() {
|
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/settings.gradle settings.gradle
|
||||||
copy_dummy_files scripts/android/files/AndroidManifest.xml src/main/AndroidManifest.xml
|
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/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.png
|
||||||
copy_dummy_files other/icons/DDNet_256x256x32.png src/main/res/mipmap/ic_launcher_round.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:name="org.ddnet.client.NativeMain"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||||
android:screenOrientation="landscape">
|
android:screenOrientation="landscape"
|
||||||
|
android:launchMode="singleInstance">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
@ -38,6 +39,9 @@
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.lib_name"
|
android:name="android.app.lib_name"
|
||||||
android:value="DDNet" />
|
android:value="DDNet" />
|
||||||
|
<meta-data
|
||||||
|
android:name="android.app.shortcuts"
|
||||||
|
android:resource="@xml/shortcuts" />
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</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/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/\"DDNet\"/\"${APK_BASENAME}\"/g" src/main/AndroidManifest.xml
|
||||||
sed -i "s/org.ddnet.client/${APK_PACKAGE_NAME}/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 static final int COMMAND_RESTART_APP = SDLActivity.COMMAND_USER + 1;
|
||||||
|
|
||||||
|
private String[] launchArguments = new String[0];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getLibraries() {
|
protected String[] getLibraries() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
|
@ -20,17 +22,35 @@ public class NativeMain extends SDLActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle SavedInstanceState) {
|
public void onCreate(Bundle SavedInstanceState) {
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
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);
|
super.onCreate(SavedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getArguments() {
|
||||||
|
return launchArguments;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onUnhandledMessage(int command, Object param) {
|
protected boolean onUnhandledMessage(int command, Object param) {
|
||||||
if(command == COMMAND_RESTART_APP) {
|
if(command == COMMAND_RESTART_APP) {
|
||||||
restartApp();
|
restartApp();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restartApp() {
|
private void restartApp() {
|
||||||
Intent restartIntent =
|
Intent restartIntent =
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<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>
|
</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