check OTG path after launching the app

This commit is contained in:
tibbi 2019-03-25 17:32:09 +01:00
parent 3e43ca3aec
commit c2ba395720
1 changed files with 12 additions and 0 deletions

View File

@ -178,6 +178,7 @@ class MainActivity : SimpleActivity() {
private fun tryInitFileManager() {
handlePermission(PERMISSION_WRITE_STORAGE) {
checkOTGPath()
if (it) {
initFileManager()
} else {
@ -205,6 +206,17 @@ class MainActivity : SimpleActivity() {
}
}
private fun checkOTGPath() {
Thread {
if (!config.wasOTGHandled && hasPermission(PERMISSION_WRITE_STORAGE) && hasOTGConnected() && config.OTGPath.isEmpty()) {
config.wasOTGHandled = true
getStorageDirectories().firstOrNull { it.trimEnd('/') != internalStoragePath && it.trimEnd('/') != sdCardPath }?.apply {
config.OTGPath = trimEnd('/')
}
}
}.start()
}
private fun openPath(path: String, forceRefresh: Boolean = false) {
if (mIsPasswordProtectionPending && !mWasProtectionHandled) {
return