@ -180,6 +180,10 @@ class MainActivity : AppCompatActivity() {
windowInsets
windowInsets
}
}
private fun hasExtension ( path : String , extension : String ) : Boolean {
return path . substring ( path . lastIndexOf ( " . " ) + 1 ) . contains ( extension )
}
val getGamesDirectory =
val getGamesDirectory =
registerForActivityResult ( ActivityResultContracts . OpenDocumentTree ( ) ) { result ->
registerForActivityResult ( ActivityResultContracts . OpenDocumentTree ( ) ) { result ->
if ( result == null )
if ( result == null )
@ -212,6 +216,15 @@ class MainActivity : AppCompatActivity() {
if ( result == null )
if ( result == null )
return @registerForActivityResult
return @registerForActivityResult
if ( ! hasExtension ( result . toString ( ) , " keys " ) ) {
Toast . makeText (
applicationContext ,
R . string . invalid _keys _file ,
Toast . LENGTH _SHORT
) . show ( )
return @registerForActivityResult
}
val takeFlags =
val takeFlags =
Intent . FLAG _GRANT _WRITE _URI _PERMISSION or Intent . FLAG _GRANT _READ _URI _PERMISSION
Intent . FLAG _GRANT _WRITE _URI _PERMISSION or Intent . FLAG _GRANT _READ _URI _PERMISSION
contentResolver . takePersistableUriPermission (
contentResolver . takePersistableUriPermission (
@ -243,6 +256,15 @@ class MainActivity : AppCompatActivity() {
if ( result == null )
if ( result == null )
return @registerForActivityResult
return @registerForActivityResult
if ( ! hasExtension ( result . toString ( ) , " bin " ) ) {
Toast . makeText (
applicationContext ,
R . string . invalid _keys _file ,
Toast . LENGTH _SHORT
) . show ( )
return @registerForActivityResult
}
val takeFlags =
val takeFlags =
Intent . FLAG _GRANT _WRITE _URI _PERMISSION or Intent . FLAG _GRANT _READ _URI _PERMISSION
Intent . FLAG _GRANT _WRITE _URI _PERMISSION or Intent . FLAG _GRANT _READ _URI _PERMISSION
contentResolver . takePersistableUriPermission (
contentResolver . takePersistableUriPermission (