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