update commons to 2.13.4

This commit is contained in:
tibbi 2017-03-18 23:10:15 +01:00
parent 116304f102
commit a25f826c5a
5 changed files with 26 additions and 39 deletions

View File

@ -32,13 +32,13 @@ android {
}
dependencies {
compile 'com.simplemobiletools:commons:2.9.8'
compile 'com.simplemobiletools:commons:2.13.4'
compile 'com.facebook.stetho:stetho:1.4.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
buildscript {
ext.kotlin_version = '1.1.0'
ext.kotlin_version = '1.1.1'
repositories {
mavenCentral()
}

View File

@ -194,22 +194,21 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
try {
val file = File(path)
if (file.isDirectory) {
toast(R.string.directory_exists)
toast(R.string.name_taken)
return
}
if (needsStupidWritePermissions(path)) {
if (isShowingPermDialog(file))
return
var document = getFileDocument(path, config.treeUri) ?: return
if (!file.exists()) {
document = document.createFile("", file.name)
}
contentResolver.openOutputStream(document.uri).apply {
write(content.toByteArray(Charset.forName("UTF-8")), 0, content.length)
flush()
close()
handleSAFDialog(file) {
var document = getFileDocument(path, config.treeUri) ?: return@handleSAFDialog
if (!file.exists()) {
document = document.createFile("", file.name)
}
contentResolver.openOutputStream(document.uri).apply {
write(content.toByteArray(Charset.forName("UTF-8")), 0, content.length)
flush()
close()
}
}
} else {
file.printWriter().use { out ->
@ -254,11 +253,8 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
initViewPager()
if (deleteFile) {
val file = File(path)
if (!file.delete() && !tryFastDocumentDelete(file)) {
val document = getFileDocument(path, config.treeUri) ?: return
if (!document.isFile || !document.delete()) {
deleteFile(File(path)) {
if (!it) {
toast(R.string.unknown_error_occurred)
}
}

View File

@ -66,7 +66,7 @@ class SettingsActivity : SimpleActivity() {
RadioItem(FONT_SIZE_EXTRA_LARGE, res.getString(R.string.extra_large)))
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
config.fontSize = it
config.fontSize = it as Int
settings_font_size.text = getFontSizeText()
updateWidget()
}
@ -89,7 +89,7 @@ class SettingsActivity : SimpleActivity() {
RadioItem(GRAVITY_RIGHT, res.getString(R.string.right)))
RadioGroupDialog(this@SettingsActivity, items, config.gravity) {
config.gravity = it
config.gravity = it as Int
settings_gravity.text = getGravityText()
updateWidget()
}
@ -114,7 +114,7 @@ class SettingsActivity : SimpleActivity() {
val items = notes.map { RadioItem(it.id, it.title) } as ArrayList
RadioGroupDialog(this@SettingsActivity, items, config.widgetNoteId) {
config.widgetNoteId = it
config.widgetNoteId = it as Int
settings_widget_note.text = getCurrentWidgetNoteTitle(it, notes)
updateWidget()
}

View File

@ -1,13 +1,11 @@
package com.simplemobiletools.notes.dialogs
import android.content.DialogInterface.BUTTON_POSITIVE
import android.provider.DocumentsContract
import android.support.v7.app.AlertDialog
import android.view.WindowManager
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.notes.R
import com.simplemobiletools.notes.activities.SimpleActivity
import com.simplemobiletools.notes.extensions.config
import com.simplemobiletools.notes.helpers.DBHelper
import com.simplemobiletools.notes.models.Note
import kotlinx.android.synthetic.main.new_note.view.*
@ -47,22 +45,15 @@ class RenameNoteDialog(val activity: SimpleActivity, val db: DBHelper, val note:
return@setOnClickListener
}
if (context.needsStupidWritePermissions(newFile.absolutePath)) {
if (activity.isShowingPermDialog(file))
return@setOnClickListener
var document = context.getFastDocument(file)
if (document?.isFile == false) {
document = context.getFileDocument(file.absolutePath, context.config.treeUri)
activity.renameFile(file, newFile) {
if (it) {
note.path = newFile.absolutePath
db.updateNotePath(note)
} else {
activity.toast(R.string.rename_file_error)
return@renameFile
}
DocumentsContract.renameDocument(context.contentResolver, document!!.uri, newFile.name)
} else if (!file.renameTo(newFile)) {
activity.toast(R.string.rename_file_error)
return@setOnClickListener
}
note.path = newFile.absolutePath
db.updateNotePath(note)
}
db.updateNoteTitle(note)
dismiss()

View File

@ -17,7 +17,7 @@
<string name="open_file">Abrir ficheiro</string>
<!-- File notes -->
<string name="save_as_file">Guardar como ficheiro/string>
<string name="save_as_file">Guardar como ficheiro</string>
<string name="file_too_large">Ficheiro muito grande, o limite são 10 MB</string>
<string name="only_import_file_content">Importar apenas o conteúdo do ficheiro</string>
<string name="update_file_at_note">Atualizar o ficheiro ao atualizar a nota</string>