mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-02-09 07:58:51 +01:00
add correct note title to all notes at importing a folder
This commit is contained in:
parent
e5dba29899
commit
f00ae5de18
@ -48,15 +48,16 @@ class ImportFolderDialog(val activity: SimpleActivity, val path: String, val cal
|
||||
else -> true
|
||||
}
|
||||
}.forEach {
|
||||
val storePath = if (updateFilesOnEdit) it.path else ""
|
||||
val storeContent = if (updateFilesOnEdit) "" else it.readText()
|
||||
val storePath = if (updateFilesOnEdit) it.absolutePath else ""
|
||||
val title = it.absolutePath.getFilenameFromPath()
|
||||
val value = if (updateFilesOnEdit) "" else it.readText()
|
||||
|
||||
if (updateFilesOnEdit) {
|
||||
activity.handleSAFDialog(path) {
|
||||
lastSavedNoteId = saveNote(storeContent, storePath)
|
||||
lastSavedNoteId = saveNote(title, value, storePath)
|
||||
}
|
||||
} else {
|
||||
lastSavedNoteId = saveNote(storeContent, storePath)
|
||||
lastSavedNoteId = saveNote(title, value, storePath)
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,9 +68,8 @@ class ImportFolderDialog(val activity: SimpleActivity, val path: String, val cal
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
private fun saveNote(storeContent: String, storePath: String): Int {
|
||||
val filename = storePath.getFilenameFromPath()
|
||||
val note = Note(0, filename, storeContent, TYPE_NOTE, storePath)
|
||||
private fun saveNote(title: String, value: String, path: String): Int {
|
||||
val note = Note(0, title, value, TYPE_NOTE, path)
|
||||
return activity.dbHelper.insertNote(note)
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteDatabase.CONFLICT_IGNORE
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import com.simplemobiletools.commons.extensions.getIntValue
|
||||
import com.simplemobiletools.commons.extensions.getStringValue
|
||||
@ -57,7 +58,7 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
|
||||
|
||||
fun insertNote(note: Note): Int {
|
||||
val values = fillContentValues(note)
|
||||
return mDb.insert(TABLE_NAME, null, values).toInt()
|
||||
return mDb.insertWithOnConflict(TABLE_NAME, null, values, CONFLICT_IGNORE).toInt()
|
||||
}
|
||||
|
||||
private fun fillContentValues(note: Note): ContentValues {
|
||||
|
Loading…
x
Reference in New Issue
Block a user