summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-04-24 07:59:41 +0200
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:53 +0200
commit83dae1739cc0afd451ed8b03db9f68fc8908f2f0 (patch)
tree7b59a06711a3b38ae15ba02c0aaf84bd33cdfd72
parentandroid: Fix first time setup scrolling bug (diff)
downloadyuzu-83dae1739cc0afd451ed8b03db9f68fc8908f2f0.tar
yuzu-83dae1739cc0afd451ed8b03db9f68fc8908f2f0.tar.gz
yuzu-83dae1739cc0afd451ed8b03db9f68fc8908f2f0.tar.bz2
yuzu-83dae1739cc0afd451ed8b03db9f68fc8908f2f0.tar.lz
yuzu-83dae1739cc0afd451ed8b03db9f68fc8908f2f0.tar.xz
yuzu-83dae1739cc0afd451ed8b03db9f68fc8908f2f0.tar.zst
yuzu-83dae1739cc0afd451ed8b03db9f68fc8908f2f0.zip
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt22
-rw-r--r--src/android/app/src/main/res/values/strings.xml1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
index b455b7d35..c03c28aa1 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt
@@ -180,6 +180,10 @@ class MainActivity : AppCompatActivity() {
windowInsets
}
+ private fun hasExtension(path: String, extension: String): Boolean {
+ return path.substring(path.lastIndexOf(".") + 1).contains(extension)
+ }
+
val getGamesDirectory =
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { result ->
if (result == null)
@@ -212,6 +216,15 @@ class MainActivity : AppCompatActivity() {
if (result == null)
return@registerForActivityResult
+ if (!hasExtension(result.toString(), "keys")) {
+ Toast.makeText(
+ applicationContext,
+ R.string.invalid_keys_file,
+ Toast.LENGTH_SHORT
+ ).show()
+ return@registerForActivityResult
+ }
+
val takeFlags =
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
contentResolver.takePersistableUriPermission(
@@ -243,6 +256,15 @@ class MainActivity : AppCompatActivity() {
if (result == null)
return@registerForActivityResult
+ if (!hasExtension(result.toString(), "bin")) {
+ Toast.makeText(
+ applicationContext,
+ R.string.invalid_keys_file,
+ Toast.LENGTH_SHORT
+ ).show()
+ return@registerForActivityResult
+ }
+
val takeFlags =
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
contentResolver.takePersistableUriPermission(
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml
index 916f516c0..92fe67bf0 100644
--- a/src/android/app/src/main/res/values/strings.xml
+++ b/src/android/app/src/main/res/values/strings.xml
@@ -35,6 +35,7 @@
<string name="install_prod_keys_description">Required to decrypt retail games</string>
<string name="install_amiibo_keys">Install Amiibo Keys</string>
<string name="install_amiibo_keys_description">Required to use Amiibo in game</string>
+ <string name="invalid_keys_file">Invalid keys file selected</string>
<string name="install_keys_success">Keys successfully installed</string>
<string name="install_keys_failure">Keys file (prod.keys) is invalid</string>
<string name="install_amiibo_keys_failure">Keys file (key_retail.bin) is invalid</string>