From e834a0646754570070d2ed0f12cf03e2e41e6625 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 2 Dec 2017 20:21:48 +0100 Subject: [PATCH] update commons to 3.0.23 --- app/build.gradle | 2 +- .../notes/dialogs/RenameNoteDialog.kt | 61 ++++++++++--------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 31d40322..1edd5949 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,7 +45,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.0.21' + implementation 'com.simplemobiletools:commons:3.0.23' implementation 'com.facebook.stetho:stetho:1.5.0' debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/dialogs/RenameNoteDialog.kt b/app/src/main/kotlin/com/simplemobiletools/notes/dialogs/RenameNoteDialog.kt index d5409593..6fa1eb81 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/dialogs/RenameNoteDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/dialogs/RenameNoteDialog.kt @@ -22,41 +22,42 @@ class RenameNoteDialog(val activity: SimpleActivity, val db: DBHelper, val note: .setNegativeButton(R.string.cancel, null) .create().apply { window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) - activity.setupDialogStuff(view, this, R.string.rename_note) - getButton(BUTTON_POSITIVE).setOnClickListener { - val title = view.note_name.value - when { - title.isEmpty() -> activity.toast(R.string.no_title) - db.doesTitleExist(title) -> activity.toast(R.string.title_taken) - else -> { - note.title = title - val path = note.path - if (path.isNotEmpty()) { - if (title.isEmpty()) { - activity.toast(R.string.filename_cannot_be_empty) - return@setOnClickListener - } + activity.setupDialogStuff(view, this, R.string.rename_note) { + getButton(BUTTON_POSITIVE).setOnClickListener { + val title = view.note_name.value + when { + title.isEmpty() -> activity.toast(R.string.no_title) + db.doesTitleExist(title) -> activity.toast(R.string.title_taken) + else -> { + note.title = title + val path = note.path + if (path.isNotEmpty()) { + if (title.isEmpty()) { + activity.toast(R.string.filename_cannot_be_empty) + return@setOnClickListener + } - val file = File(path) - val newFile = File(file.parent, title) - if (!newFile.name.isAValidFilename()) { - activity.toast(R.string.invalid_name) - return@setOnClickListener - } + val file = File(path) + val newFile = File(file.parent, title) + if (!newFile.name.isAValidFilename()) { + activity.toast(R.string.invalid_name) + return@setOnClickListener + } - activity.renameFile(file, newFile) { - if (it) { - note.path = newFile.absolutePath - db.updateNotePath(note) - } else { - activity.toast(R.string.rename_file_error) - return@renameFile + activity.renameFile(file, newFile) { + if (it) { + note.path = newFile.absolutePath + db.updateNotePath(note) + } else { + activity.toast(R.string.rename_file_error) + return@renameFile + } } } + db.updateNoteTitle(note) + dismiss() + callback(note) } - db.updateNoteTitle(note) - dismiss() - callback(note) } } }