mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-13 23:12:02 +02:00
update commons to 3.12.20
This commit is contained in:
parent
bbbdabf383
commit
9c207ee349
@ -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"
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user