Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Added app shortcut to instantly launch game #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/src/debug/res/xml-v25/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="start_game"
android:enabled="true"
android:icon="@mipmap/ic_shortcut_start"
android:shortcutShortLabel="@string/start_game_label"
android:shortcutLongLabel="@string/start_game_label"
android:shortcutDisabledMessage="@string/start_game_label">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="is.xyz.omw.debug"
android:targetClass="ui.activity.MainActivity" >
<extra android:name="runGame" android:value="true" />
</intent>
</shortcut>
</shortcuts>
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />

</activity>
<activity
android:name="ui.activity.GameActivity"
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/java/ui/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
package ui.activity

import android.annotation.SuppressLint
import android.app.AlarmManager
import android.app.AlertDialog
import android.app.PendingIntent
import android.app.ProgressDialog
import android.content.*
import android.net.Uri
Expand All @@ -38,18 +36,14 @@ import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import com.bugsnag.android.Bugsnag

import com.libopenmw.openmw.BuildConfig
import com.libopenmw.openmw.R
import constants.Constants
import file.GameInstaller

import java.io.BufferedReader
import java.io.File
import java.io.FileInputStream
import java.io.IOException
import java.io.InputStreamReader

import file.utils.CopyFilesFromAssets
import mods.ModType
Expand Down Expand Up @@ -83,6 +77,15 @@ class MainActivity : AppCompatActivity() {
if (prefs.getString("bugsnag_consent", "")!! == "") {
askBugsnagConsent()
}

checkIfShouldInstantlyRunGame()
}

private fun checkIfShouldInstantlyRunGame() {
val shouldStartGame = intent?.hasExtra("runGame") ?: false
if (shouldStartGame) {
checkStartGame()
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_shortcut_start.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_shortcut_start_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_shortcut_start_foreground"/>
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions app/src/main/res/xml-v25/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="start_game"
android:enabled="true"
android:icon="@mipmap/ic_shortcut_start"
android:shortcutShortLabel="@string/start_game_label"
android:shortcutLongLabel="@string/start_game_label"
android:shortcutDisabledMessage="@string/start_game_label">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="is.xyz.omw"
android:targetClass="ui.activity.MainActivity" >
<extra android:name="runGame" android:value="true" />
</intent>
</shortcut>
</shortcuts>
17 changes: 17 additions & 0 deletions app/src/nightly/res/xml-v25/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="start_game"
android:enabled="true"
android:icon="@mipmap/ic_shortcut_start"
android:shortcutShortLabel="@string/start_game_label"
android:shortcutLongLabel="@string/start_game_label"
android:shortcutDisabledMessage="@string/start_game_label">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="is.xyz.omw_nightly"
android:targetClass="ui.activity.MainActivity" >
<extra android:name="runGame" android:value="true" />
</intent>
</shortcut>
</shortcuts>