update commons to 3.11.36
This commit is contained in:
parent
c340b9860e
commit
7bc23b8fbc
|
@ -45,7 +45,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.11.35'
|
||||
implementation 'com.simplemobiletools:commons:3.11.36'
|
||||
|
||||
implementation files('../libs/RootTools.jar')
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.dialogs.SaveAsDialog
|
||||
import com.simplemobiletools.filemanager.extensions.config
|
||||
|
@ -50,7 +51,7 @@ class ReadTextActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
SaveAsDialog(this, filePath) {
|
||||
getFileOutputStream(File(it)) {
|
||||
getFileOutputStream(FileDirItem(it, it.getFilenameFromPath())) {
|
||||
if (it != null) {
|
||||
it.bufferedWriter().use { it.write(read_text_view.text.toString()) }
|
||||
toast(R.string.file_saved)
|
||||
|
|
|
@ -220,7 +220,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
|
||||
val firstPath = fileDirItems[selectedPositions.first()].path
|
||||
CompressAsDialog(activity, firstPath) {
|
||||
activity.handleSAFDialog(File(firstPath)) {
|
||||
activity.handleSAFDialog(firstPath) {
|
||||
activity.toast(R.string.compressing)
|
||||
val paths = selectedPositions.map { fileDirItems[it].path }
|
||||
Thread {
|
||||
|
@ -243,7 +243,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
return
|
||||
|
||||
val firstPath = fileDirItems[selectedPositions.first()].path
|
||||
activity.handleSAFDialog(File(firstPath)) {
|
||||
activity.handleSAFDialog(firstPath) {
|
||||
activity.toast(R.string.decompressing)
|
||||
val paths = selectedPositions.map { fileDirItems[it].path }.filter { it.isZipFile() }
|
||||
Thread {
|
||||
|
@ -356,9 +356,9 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
|
||||
val files = ArrayList<FileDirItem>(selectedPositions.size)
|
||||
val removeFiles = ArrayList<FileDirItem>(selectedPositions.size)
|
||||
val SAFFile = File(fileDirItems[selectedPositions.first()].path)
|
||||
val SAFPath = fileDirItems[selectedPositions.first()].path
|
||||
|
||||
activity.handleSAFDialog(SAFFile) {
|
||||
activity.handleSAFDialog(SAFPath) {
|
||||
selectedPositions.sortedDescending().forEach {
|
||||
val file = fileDirItems[it]
|
||||
files.add(FileDirItem(file.path, file.name))
|
||||
|
|
|
@ -32,11 +32,11 @@ class CreateNewItemDialog(val activity: BaseSimpleActivity, val path: String, va
|
|||
}
|
||||
|
||||
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_directory) {
|
||||
createDirectory(file, this) {
|
||||
createDirectory("$path/$name", this) {
|
||||
callback(it)
|
||||
}
|
||||
} else {
|
||||
createFile(file, this) {
|
||||
createFile("$path/$name", this) {
|
||||
callback(it)
|
||||
}
|
||||
}
|
||||
|
@ -48,41 +48,41 @@ class CreateNewItemDialog(val activity: BaseSimpleActivity, val path: String, va
|
|||
}
|
||||
}
|
||||
|
||||
private fun createDirectory(file: File, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
||||
private fun createDirectory(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
||||
when {
|
||||
activity.needsStupidWritePermissions(path) -> activity.handleSAFDialog(file) {
|
||||
val documentFile = activity.getFileDocument(file.absolutePath)
|
||||
activity.needsStupidWritePermissions(this.path) -> activity.handleSAFDialog(path) {
|
||||
val documentFile = activity.getFileDocument(path)
|
||||
if (documentFile == null) {
|
||||
val error = String.format(activity.getString(R.string.could_not_create_folder), file.absolutePath)
|
||||
val error = String.format(activity.getString(R.string.could_not_create_folder), path)
|
||||
activity.showErrorToast(error)
|
||||
callback(false)
|
||||
return@handleSAFDialog
|
||||
}
|
||||
documentFile.createDirectory(file.name)
|
||||
documentFile.createDirectory(path.getFilenameFromPath())
|
||||
success(alertDialog)
|
||||
}
|
||||
file.mkdirs() -> {
|
||||
File(path).mkdirs() -> {
|
||||
success(alertDialog)
|
||||
}
|
||||
else -> callback(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createFile(file: File, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
||||
private fun createFile(path: String, alertDialog: AlertDialog, callback: (Boolean) -> Unit) {
|
||||
try {
|
||||
if (activity.needsStupidWritePermissions(path)) {
|
||||
activity.handleSAFDialog(file) {
|
||||
val documentFile = activity.getFileDocument(file.absolutePath)
|
||||
activity.handleSAFDialog(path) {
|
||||
val documentFile = activity.getFileDocument(path)
|
||||
if (documentFile == null) {
|
||||
val error = String.format(activity.getString(R.string.could_not_create_file), file.absolutePath)
|
||||
val error = String.format(activity.getString(R.string.could_not_create_file), path)
|
||||
activity.showErrorToast(error)
|
||||
callback(false)
|
||||
return@handleSAFDialog
|
||||
}
|
||||
documentFile.createFile("", file.name)
|
||||
documentFile.createFile("", path.getFilenameFromPath())
|
||||
success(alertDialog)
|
||||
}
|
||||
} else if (file.createNewFile()) {
|
||||
} else if (File(path).createNewFile()) {
|
||||
success(alertDialog)
|
||||
}
|
||||
} catch (exception: IOException) {
|
||||
|
|
Loading…
Reference in New Issue