use proper actionbar title at OTG folders

This commit is contained in:
tibbi 2018-02-20 11:41:15 +01:00
parent d5496e04ba
commit 55fa9a04d5
2 changed files with 7 additions and 2 deletions

View file

@ -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()

View file

@ -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()
}