From 4d1e73f9875a2ba1e95236d884d29428fcb19e73 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 27 Mar 2019 17:29:00 +0100 Subject: [PATCH] adding a backup way of retrieving OTG path --- .../filemanager/pro/activities/MainActivity.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 b9364534..322e280c 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 @@ -12,6 +12,7 @@ import android.view.Menu import android.view.MenuItem import androidx.appcompat.widget.SearchView import androidx.core.view.MenuItemCompat +import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* @@ -209,10 +210,19 @@ 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.wasOTGHandled = true config.OTGPath = trimEnd('/') } + + if (config.OTGPath.isEmpty()) { + runOnUiThread { + ConfirmationDialog(this, getString(R.string.usb_detected), positive = R.string.ok, negative = 0) { + config.wasOTGHandled = true + showOTGPermissionDialog() + } + } + } } }.start() }