From 55fa9a04d5d3f129d20e0b47dc8f27de005e58c4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 20 Feb 2018 11:41:15 +0100 Subject: [PATCH] use proper actionbar title at OTG folders --- .../simplemobiletools/gallery/activities/MediaActivity.kt | 7 ++++++- .../gallery/asynctasks/GetDirectoriesAsynctask.kt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 87b35c151..dd4d9703d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -24,6 +24,7 @@ import com.google.gson.Gson import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.OTG_PATH import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE import com.simplemobiletools.commons.models.FileDirItem @@ -278,7 +279,11 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun tryloadGallery() { handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { - val dirName = getHumanizedFilename(mPath) + val dirName = when { + mPath == OTG_PATH -> getString(R.string.otg) + mPath.startsWith(OTG_PATH) -> mPath.trimEnd('/').substringAfterLast('/') + else -> getHumanizedFilename(mPath) + } supportActionBar?.title = if (mShowAll) resources.getString(R.string.all_folders) else dirName getMedia() setupLayoutManager() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index c9f8c60ef..d4b20cf2c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -51,7 +51,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va OTG_PATH -> context.getString(R.string.otg) else -> { if (parentDir.startsWith(OTG_PATH)) { - parentDir.getParentPath().trimEnd('/').substringAfterLast('/') + parentDir.trimEnd('/').substringAfterLast('/') } else { parentDir.getFilenameFromPath() }