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