update commons to 3.12.20

This commit is contained in:
tibbi 2018-02-22 22:21:35 +01:00
parent bbbdabf383
commit 9c207ee349
5 changed files with 13 additions and 13 deletions

View File

@ -45,7 +45,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.8.10'
implementation 'com.simplemobiletools:commons:3.12.20'
implementation 'com.facebook.stetho:stetho:1.5.0'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"

View File

@ -15,6 +15,7 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.models.Release
import com.simplemobiletools.commons.views.MyEditText
@ -377,17 +378,16 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
fun exportNoteValueToFile(path: String, content: String, showSuccessToasts: Boolean, callback: ((success: Boolean) -> Unit)? = null) {
try {
val file = File(path)
if (file.isDirectory) {
if (getIsPathDirectory(path)) {
toast(R.string.name_taken)
return
}
if (needsStupidWritePermissions(path)) {
handleSAFDialog(file) {
var document = getFileDocument(path) ?: return@handleSAFDialog
if (!file.exists()) {
document = document.createFile("", file.name)
handleSAFDialog(path) {
var document = getDocumentFile(path) ?: return@handleSAFDialog
if (!getDoesFilePathExist(path)) {
document = document.createFile("", path.getFilenameFromPath())
}
contentResolver.openOutputStream(document.uri).apply {
write(content.toByteArray(Charset.forName("UTF-8")), 0, content.length)
@ -400,6 +400,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
callback?.invoke(true)
}
} else {
val file = File(path)
file.printWriter().use { out ->
out.write(content)
}
@ -446,7 +447,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
if (!deleteFile) {
doDeleteNote(mCurrentNote, deleteFile)
} else {
handleSAFDialog(File(mCurrentNote.path)) {
handleSAFDialog(mCurrentNote.path) {
doDeleteNote(mCurrentNote, deleteFile)
}
}
@ -466,7 +467,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
initViewPager()
if (deleteFile) {
deleteFile(File(note.path)) {
deleteFile(FileDirItem(note.path, note.title)) {
if (!it) {
toast(R.string.unknown_error_occurred)
}

View File

@ -11,7 +11,6 @@ import com.simplemobiletools.notes.activities.SimpleActivity
import com.simplemobiletools.notes.extensions.config
import com.simplemobiletools.notes.models.Note
import kotlinx.android.synthetic.main.dialog_export_files.view.*
import java.io.File
class ExportFilesDialog(val activity: SimpleActivity, val notes: ArrayList<Note>, val callback: (parent: String, extension: String) -> Unit) {
init {
@ -35,7 +34,7 @@ class ExportFilesDialog(val activity: SimpleActivity, val notes: ArrayList<Note>
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.export_as_file) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
activity.handleSAFDialog(File(realPath)) {
activity.handleSAFDialog(realPath) {
val extension = view.file_extension.value
activity.config.lastUsedExtension = extension
activity.config.lastUsedSavePath = realPath

View File

@ -32,7 +32,7 @@ class OpenFileDialog(val activity: SimpleActivity, val path: String, val callbac
val storeContent = if (updateFileOnEdit) "" else File(path).readText()
if (updateFileOnEdit) {
activity.handleSAFDialog(File(path)) {
activity.handleSAFDialog(path) {
saveNote(storeContent, storePath)
}
} else {

View File

@ -44,7 +44,7 @@ class RenameNoteDialog(val activity: SimpleActivity, val db: DBHelper, val note:
return@setOnClickListener
}
activity.renameFile(file, newFile) {
activity.renameFile(file.absolutePath, newFile.absolutePath) {
if (it) {
note.path = newFile.absolutePath
db.updateNotePath(note)