update commons to 3.12.17

This commit is contained in:
tibbi 2018-02-21 21:38:26 +01:00
parent eebd4c80d0
commit 0467112cc7
7 changed files with 18 additions and 15 deletions

View File

@ -45,7 +45,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.12.5'
implementation 'com.simplemobiletools:commons:3.12.17'
implementation files('../libs/RootTools.jar')

View File

@ -202,7 +202,7 @@ class MainActivity : SimpleActivity() {
val file = File(path)
if (file.exists() && !file.isDirectory) {
newPath = file.parent
} else if (!file.exists() && !isPathOnOTG(newPath)) {
} else if (!file.exists() && !newPath.startsWith(OTG_PATH)) {
newPath = internalStoragePath
}

View File

@ -20,6 +20,7 @@ import com.simplemobiletools.commons.dialogs.RenameItemDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.CONFLICT_OVERWRITE
import com.simplemobiletools.commons.helpers.CONFLICT_SKIP
import com.simplemobiletools.commons.helpers.OTG_PATH
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.commons.views.FastScroller
import com.simplemobiletools.commons.views.MyRecyclerView
@ -154,7 +155,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
private fun addFileUris(path: String, paths: ArrayList<String>) {
if (activity.getIsPathDirectory(path)) {
val shouldShowHidden = activity.config.shouldShowHidden
if (activity.isPathOnOTG(path)) {
if (path.startsWith(OTG_PATH)) {
activity.getDocumentFile(path)?.listFiles()?.filter { if (shouldShowHidden) true else !it.name.startsWith(".") }?.forEach {
addFileUris(it.uri.toString(), paths)
}
@ -227,7 +228,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
private fun compressSelection() {
val firstPath = fileDirItems[selectedPositions.first()].path
if (activity.isPathOnOTG(firstPath)) {
if (firstPath.startsWith(OTG_PATH)) {
activity.toast(R.string.unknown_error_occurred)
return
}
@ -253,7 +254,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
private fun decompressSelection() {
val firstPath = fileDirItems[selectedPositions.first()].path
if (activity.isPathOnOTG(firstPath)) {
if (firstPath.startsWith(OTG_PATH)) {
activity.toast(R.string.unknown_error_occurred)
return
}

View File

@ -2,9 +2,9 @@ package com.simplemobiletools.filemanager.extensions
import android.content.Context
import com.simplemobiletools.commons.extensions.hasExternalSDCard
import com.simplemobiletools.commons.extensions.isPathOnOTG
import com.simplemobiletools.commons.helpers.OTG_PATH
import com.simplemobiletools.filemanager.helpers.Config
val Context.config: Config get() = Config.newInstance(applicationContext)
fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || isPathOnOTG(path) || (hasExternalSDCard() && path.startsWith(config.sdCardPath)))
fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || path.startsWith(OTG_PATH) || (hasExternalSDCard() && path.startsWith(config.sdCardPath)))

View File

@ -175,7 +175,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
skipItemUpdating = false
Thread {
if (activity?.isActivityDestroyed() == false) {
if (context!!.isPathOnOTG(path)) {
if (path.startsWith(OTG_PATH)) {
val getProperFileSize = context!!.config.sorting and SORT_BY_SIZE != 0
context!!.getOTGItems(path, context!!.config.shouldShowHidden, getProperFileSize) {
callback(path, it)

View File

@ -3,8 +3,8 @@ package com.simplemobiletools.filemanager.helpers
import android.content.Context
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.OTG_PATH
import java.io.File
class Config(context: Context) : BaseConfig(context) {
@ -26,8 +26,8 @@ class Config(context: Context) : BaseConfig(context) {
get(): String {
var path = prefs.getString(HOME_FOLDER, "")
if (path.isEmpty() ||
(context.isPathOnOTG(path) && context.getDocumentFile(path)?.isDirectory != true) ||
(!context.isPathOnOTG(path) && !File(path).isDirectory)) {
(path.startsWith(OTG_PATH) && context.getDocumentFile(path)?.isDirectory != true) ||
(!path.startsWith(OTG_PATH) && !File(path).isDirectory)) {
path = context.getInternalStoragePath()
homeFolder = path
}

View File

@ -105,10 +105,12 @@ class RootHelpers {
files.forEachIndexed { index, fileDirItem ->
var line = lines[index]
if (line.isNotEmpty() && line != "0") {
line = line.substring(fileDirItem.path.length).trim()
val size = line.split(" ")[0]
if (size.areDigitsOnly()) {
fileDirItem.size = size.toLong()
if (line.length >= fileDirItem.path.length) {
line = line.substring(fileDirItem.path.length).trim()
val size = line.split(" ")[0]
if (size.areDigitsOnly()) {
fileDirItem.size = size.toLong()
}
}
}
}