mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
android: Fixed installed app shortcut creation failing on vanilla
This commit is contained in:
parent
0ff2aebdf1
commit
d97da17263
3 changed files with 34 additions and 6 deletions
|
|
@ -729,6 +729,10 @@ object NativeLibrary {
|
||||||
return uriString
|
return uriString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uri.scheme == "file") {
|
||||||
|
return uri.path!!
|
||||||
|
}
|
||||||
|
|
||||||
val pathSegment = uri.lastPathSegment ?: return ""
|
val pathSegment = uri.lastPathSegment ?: return ""
|
||||||
val virtualPath = pathSegment.substringAfter(":")
|
val virtualPath = pathSegment.substringAfter(":")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,16 @@ package org.citra.citra_emu.model
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
import java.util.HashSet
|
import java.util.HashSet
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.citra.citra_emu.CitraApplication
|
import org.citra.citra_emu.CitraApplication
|
||||||
|
import org.citra.citra_emu.NativeLibrary
|
||||||
import org.citra.citra_emu.activities.EmulationActivity
|
import org.citra.citra_emu.activities.EmulationActivity
|
||||||
|
import org.citra.citra_emu.utils.BuildUtil
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
@ -37,12 +42,25 @@ class Game(
|
||||||
val keyLastPlayedTime get() = "${filename}_LastPlayed"
|
val keyLastPlayedTime get() = "${filename}_LastPlayed"
|
||||||
|
|
||||||
val launchIntent: Intent
|
val launchIntent: Intent
|
||||||
get() = Intent(CitraApplication.appContext, EmulationActivity::class.java).apply {
|
get() {
|
||||||
action = Intent.ACTION_VIEW
|
var appUri: Uri
|
||||||
data = if (isInstalled) {
|
if (isInstalled) {
|
||||||
CitraApplication.documentsTree.getUri(path)
|
if (BuildUtil.isGooglePlayBuild) {
|
||||||
|
appUri = CitraApplication.documentsTree.getUri(path)
|
||||||
|
} else {
|
||||||
|
val nativePath = NativeLibrary.getUserDirectory() + "/" + path
|
||||||
|
val nativeFile = File(nativePath)
|
||||||
|
if (!nativeFile.exists()) {
|
||||||
|
throw IOException("Attempting to create shortcut for an executable that doesn't exist: $nativePath")
|
||||||
|
}
|
||||||
|
appUri = Uri.fromFile(nativeFile)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Uri.parse(path)
|
appUri = path.toUri()
|
||||||
|
}
|
||||||
|
return Intent(CitraApplication.appContext, EmulationActivity::class.java).apply {
|
||||||
|
action = Intent.ACTION_VIEW
|
||||||
|
data = appUri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,10 +219,16 @@ object FileUtil {
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getFilename(uri: Uri): String {
|
fun getFilename(uri: Uri): String {
|
||||||
val columns = arrayOf(DocumentsContract.Document.COLUMN_DISPLAY_NAME)
|
|
||||||
var filename = ""
|
var filename = ""
|
||||||
var c: Cursor? = null
|
var c: Cursor? = null
|
||||||
try {
|
try {
|
||||||
|
if (uri.scheme == "file") {
|
||||||
|
BuildUtil.assertNotGooglePlay()
|
||||||
|
val file = File(uri.path!!);
|
||||||
|
return file.name
|
||||||
|
}
|
||||||
|
|
||||||
|
val columns = arrayOf(DocumentsContract.Document.COLUMN_DISPLAY_NAME)
|
||||||
c = context.contentResolver.query(
|
c = context.contentResolver.query(
|
||||||
uri,
|
uri,
|
||||||
columns,
|
columns,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue