diff --git a/app/build.gradle b/app/build.gradle index d578a8a8..e351bcd4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,7 +45,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.11.38' + implementation 'com.simplemobiletools:commons:3.11.42' implementation files('../libs/RootTools.jar') diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index 721e464b..d03b2893 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -180,11 +180,12 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList() - selectedPositions.forEach { fileDirItems[it] } + selectedPositions.forEach { files.add(fileDirItems[it]) } - val source = if (!files[0].isDirectory) File(files[0].path).parent else files[0].path + val firstFile = files[0] + val source = if (!firstFile.isDirectory) firstFile.path.substring(0, firstFile.path.length - firstFile.name.length) else firstFile.path FilePickerDialog(activity, source, false, activity.config.shouldShowHidden, true) { - if (activity.isPathOnRoot(source)) { + if (activity.isPathOnRoot(it)) { copyRootItems(files, it) } else { activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, activity.config.shouldShowHidden) { @@ -268,7 +269,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList Unit) { when { activity.needsStupidWritePermissions(this.path) -> activity.handleSAFDialog(path) { - val documentFile = activity.getFileDocument(path) + val documentFile = activity.getDocumentFile(path) if (documentFile == null) { val error = String.format(activity.getString(R.string.could_not_create_folder), path) activity.showErrorToast(error) @@ -72,7 +72,7 @@ class CreateNewItemDialog(val activity: BaseSimpleActivity, val path: String, va try { if (activity.needsStupidWritePermissions(path)) { activity.handleSAFDialog(path) { - val documentFile = activity.getFileDocument(path) + val documentFile = activity.getDocumentFile(path) if (documentFile == null) { val error = String.format(activity.getString(R.string.could_not_create_file), path) activity.showErrorToast(error) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt index 91f80ab8..fa3cae28 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -176,7 +176,8 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb Thread { if (activity?.isActivityDestroyed() == false) { if (context!!.isPathOnOTG(path)) { - context!!.getOTGItems(path) { + val getProperFileSize = context!!.config.sorting and SORT_BY_SIZE != 0 + context!!.getOTGItems(path, context!!.config.shouldShowHidden, getProperFileSize) { callback(path, it) } } else if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) { diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/Config.kt index b13a8816..aa8b037b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/Config.kt @@ -1,11 +1,10 @@ package com.simplemobiletools.filemanager.helpers import android.content.Context -import com.simplemobiletools.commons.extensions.getFileDocument +import com.simplemobiletools.commons.extensions.getDocumentFile import com.simplemobiletools.commons.extensions.getInternalStoragePath import com.simplemobiletools.commons.extensions.isPathOnOTG import com.simplemobiletools.commons.helpers.BaseConfig -import com.simplemobiletools.commons.helpers.SORT_BY_NAME import java.io.File class Config(context: Context) : BaseConfig(context) { @@ -27,7 +26,7 @@ class Config(context: Context) : BaseConfig(context) { get(): String { var path = prefs.getString(HOME_FOLDER, "") if (path.isEmpty() || - (context.isPathOnOTG(path) && context.getFileDocument(path)?.isDirectory != true) || + (context.isPathOnOTG(path) && context.getDocumentFile(path)?.isDirectory != true) || (!context.isPathOnOTG(path) && !File(path).isDirectory)) { path = context.getInternalStoragePath() homeFolder = path @@ -67,10 +66,6 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getStringSet(FAVORITES, HashSet()) set(favorites) = prefs.edit().remove(FAVORITES).putStringSet(FAVORITES, favorites).apply() - var sorting: Int - get() = prefs.getInt(SORT_ORDER, SORT_BY_NAME) - set(sorting) = prefs.edit().putInt(SORT_ORDER, sorting).apply() - fun saveFolderSorting(path: String, value: Int) { if (path.isEmpty()) { sorting = value diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/Constants.kt index 46058b8c..7a5c8eda 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/Constants.kt @@ -6,7 +6,6 @@ const val PATH = "path" const val SHOW_HIDDEN = "show_hidden" const val HOME_FOLDER = "home_folder" const val FAVORITES = "favorites" -const val SORT_ORDER = "sort_order" const val SORT_FOLDER_PREFIX = "sort_folder_" const val TEMPORARILY_SHOW_HIDDEN = "temporarily_show_hidden" const val IS_ROOT_AVAILABLE = "is_root_available"