mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 13:18:56 +07:00
Resolved #7177 - Android custom location save
This commit is contained in:
@ -23,15 +23,17 @@ class CustomFileLocationHelperAndroid(private val activity: Activity) : CustomFi
|
|||||||
// When we loaded, we returned a "content://" URI as file location.
|
// When we loaded, we returned a "content://" URI as file location.
|
||||||
val uri = Uri.parse(suggestedLocation)
|
val uri = Uri.parse(suggestedLocation)
|
||||||
val fileName = if (uri.scheme == "content") {
|
val fileName = if (uri.scheme == "content") {
|
||||||
val cursor = activity.contentResolver.query(uri, null, null, null, null)
|
try {
|
||||||
cursor.use {
|
val cursor = activity.contentResolver.query(uri, null, null, null, null)
|
||||||
// we should have a direct URI to a file, so first is enough
|
cursor.use {
|
||||||
if (it?.moveToFirst() == true) {
|
// we should have a direct URI to a file, so first is enough
|
||||||
it.getString(it.getColumnIndex(OpenableColumns.DISPLAY_NAME))
|
if (it?.moveToFirst() == true) {
|
||||||
} else {
|
it.getString(it.getColumnIndex(OpenableColumns.DISPLAY_NAME))
|
||||||
""
|
} else ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(ex:Exception) {}
|
||||||
|
suggestedLocation.split("2F").last() // I have no idea why but the content path ends with this before the filename
|
||||||
} else {
|
} else {
|
||||||
// if we didn't load, this is some file name entered by the user
|
// if we didn't load, this is some file name entered by the user
|
||||||
suggestedLocation
|
suggestedLocation
|
||||||
|
Reference in New Issue
Block a user