From 4c98d5201ec3d61e62009030410a0dceef23c4b6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 7 Dec 2019 13:03:29 +0100 Subject: [PATCH] fix #300, make the note title check at renaming case insensitive --- .../simplemobiletools/notes/pro/dialogs/RenameNoteDialog.kt | 2 +- .../com/simplemobiletools/notes/pro/interfaces/NotesDao.kt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/dialogs/RenameNoteDialog.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/dialogs/RenameNoteDialog.kt index 19c1e46b..b04e428d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/dialogs/RenameNoteDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/dialogs/RenameNoteDialog.kt @@ -38,7 +38,7 @@ class RenameNoteDialog(val activity: SimpleActivity, val note: Note, val current private fun newTitleConfirmed(title: String, dialog: AlertDialog) { when { title.isEmpty() -> activity.toast(R.string.no_title) - activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken) + activity.notesDB.getNoteIdWithTitleCaseSensitive(title) != null -> activity.toast(R.string.title_taken) else -> { note.title = title if (activity.config.autosaveNotes && currentNoteText != null) { diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/NotesDao.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/NotesDao.kt index 38eefd57..1fb7b141 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/NotesDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/interfaces/NotesDao.kt @@ -17,6 +17,9 @@ interface NotesDao { @Query("SELECT id FROM notes WHERE title = :title COLLATE NOCASE") fun getNoteIdWithTitle(title: String): Long? + @Query("SELECT id FROM notes WHERE title = :title") + fun getNoteIdWithTitleCaseSensitive(title: String): Long? + @Insert(onConflict = OnConflictStrategy.REPLACE) fun insertOrUpdate(note: Note): Long