From c2ba395720e02497b9627989aa48a8ce0e6938c2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Mar 2019 17:32:09 +0100 Subject: [PATCH] check OTG path after launching the app --- .../filemanager/pro/activities/MainActivity.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt index b792ca80..b9364534 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt @@ -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