Skip to content

Commit b921356

Browse files
committed
remember last created note type
1 parent 4498428 commit b921356

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/dialogs/NewNoteDialog.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.simplemobiletools.commons.extensions.showKeyboard
88
import com.simplemobiletools.commons.extensions.toast
99
import com.simplemobiletools.commons.extensions.value
1010
import com.simplemobiletools.notes.pro.R
11+
import com.simplemobiletools.notes.pro.extensions.config
1112
import com.simplemobiletools.notes.pro.extensions.notesDB
1213
import com.simplemobiletools.notes.pro.helpers.TYPE_CHECKLIST
1314
import com.simplemobiletools.notes.pro.helpers.TYPE_TEXT
@@ -16,7 +17,9 @@ import kotlinx.android.synthetic.main.dialog_new_note.view.*
1617

1718
class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) {
1819
init {
19-
val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null)
20+
val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null).apply {
21+
new_note_type.check(if (activity.config.lastCreatedNoteType == TYPE_TEXT) type_text_note.id else type_checklist.id)
22+
}
2023

2124
AlertDialog.Builder(activity)
2225
.setPositiveButton(R.string.ok, null)
@@ -32,6 +35,7 @@ class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) {
3235
activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken)
3336
else -> {
3437
val type = if (view.new_note_type.checkedRadioButtonId == view.type_checklist.id) TYPE_CHECKLIST else TYPE_TEXT
38+
activity.config.lastCreatedNoteType = type
3539
val newNote = Note(null, title, "", type)
3640
callback(newNote)
3741
dismiss()

app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Config.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ class Config(context: Context) : BaseConfig(context) {
7272
var useIncognitoMode: Boolean
7373
get() = prefs.getBoolean(USE_INCOGNITO_MODE, false)
7474
set(useIncognitoMode) = prefs.edit().putBoolean(USE_INCOGNITO_MODE, useIncognitoMode).apply()
75+
76+
var lastCreatedNoteType: Int
77+
get() = prefs.getInt(LAST_CREATED_NOTE_TYPE, TYPE_TEXT)
78+
set(lastCreatedNoteType) = prefs.edit().putInt(LAST_CREATED_NOTE_TYPE, lastCreatedNoteType).apply()
7579
}

app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const val LAST_USED_EXTENSION = "last_used_extension"
2121
const val LAST_USED_SAVE_PATH = "last_used_save_path"
2222
const val ENABLE_LINE_WRAP = "enable_line_wrap"
2323
const val USE_INCOGNITO_MODE = "use_incognito_mode"
24+
const val LAST_CREATED_NOTE_TYPE = "last_created_note_type"
2425

2526
// gravity
2627
const val GRAVITY_LEFT = 0

0 commit comments

Comments
 (0)