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 { dependencies {
compile 'com.simplemobiletools:commons:2.9.8' compile 'com.simplemobiletools:commons:2.13.4'
compile 'com.facebook.stetho:stetho:1.4.1' compile 'com.facebook.stetho:stetho:1.4.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
} }
buildscript { buildscript {
ext.kotlin_version = '1.1.0' ext.kotlin_version = '1.1.1'
repositories { repositories {
mavenCentral() mavenCentral()
} }

View File

@ -194,22 +194,21 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
try { try {
val file = File(path) val file = File(path)
if (file.isDirectory) { if (file.isDirectory) {
toast(R.string.directory_exists) toast(R.string.name_taken)
return return
} }
if (needsStupidWritePermissions(path)) { if (needsStupidWritePermissions(path)) {
if (isShowingPermDialog(file)) handleSAFDialog(file) {
return var document = getFileDocument(path, config.treeUri) ?: return@handleSAFDialog
if (!file.exists()) {
var document = getFileDocument(path, config.treeUri) ?: return document = document.createFile("", file.name)
if (!file.exists()) { }
document = document.createFile("", file.name) contentResolver.openOutputStream(document.uri).apply {
} write(content.toByteArray(Charset.forName("UTF-8")), 0, content.length)
contentResolver.openOutputStream(document.uri).apply { flush()
write(content.toByteArray(Charset.forName("UTF-8")), 0, content.length) close()
flush() }
close()
} }
} else { } else {
file.printWriter().use { out -> file.printWriter().use { out ->
@ -254,11 +253,8 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
initViewPager() initViewPager()
if (deleteFile) { if (deleteFile) {
val file = File(path) deleteFile(File(path)) {
if (!file.delete() && !tryFastDocumentDelete(file)) { if (!it) {
val document = getFileDocument(path, config.treeUri) ?: return
if (!document.isFile || !document.delete()) {
toast(R.string.unknown_error_occurred) 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))) RadioItem(FONT_SIZE_EXTRA_LARGE, res.getString(R.string.extra_large)))
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) { RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
config.fontSize = it config.fontSize = it as Int
settings_font_size.text = getFontSizeText() settings_font_size.text = getFontSizeText()
updateWidget() updateWidget()
} }
@ -89,7 +89,7 @@ class SettingsActivity : SimpleActivity() {
RadioItem(GRAVITY_RIGHT, res.getString(R.string.right))) RadioItem(GRAVITY_RIGHT, res.getString(R.string.right)))
RadioGroupDialog(this@SettingsActivity, items, config.gravity) { RadioGroupDialog(this@SettingsActivity, items, config.gravity) {
config.gravity = it config.gravity = it as Int
settings_gravity.text = getGravityText() settings_gravity.text = getGravityText()
updateWidget() updateWidget()
} }
@ -114,7 +114,7 @@ class SettingsActivity : SimpleActivity() {
val items = notes.map { RadioItem(it.id, it.title) } as ArrayList val items = notes.map { RadioItem(it.id, it.title) } as ArrayList
RadioGroupDialog(this@SettingsActivity, items, config.widgetNoteId) { RadioGroupDialog(this@SettingsActivity, items, config.widgetNoteId) {
config.widgetNoteId = it config.widgetNoteId = it as Int
settings_widget_note.text = getCurrentWidgetNoteTitle(it, notes) settings_widget_note.text = getCurrentWidgetNoteTitle(it, notes)
updateWidget() updateWidget()
} }

View File

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

View File

@ -17,7 +17,7 @@
<string name="open_file">Abrir ficheiro</string> <string name="open_file">Abrir ficheiro</string>
<!-- File notes --> <!-- 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="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="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> <string name="update_file_at_note">Atualizar o ficheiro ao atualizar a nota</string>