mirror of
				https://github.com/SimpleMobileTools/Simple-Notes.git
				synced 2025-06-05 17:00:23 +02:00 
			
		
		
		
	remember last created note type
This commit is contained in:
		| @@ -8,6 +8,7 @@ import com.simplemobiletools.commons.extensions.showKeyboard | ||||
| import com.simplemobiletools.commons.extensions.toast | ||||
| import com.simplemobiletools.commons.extensions.value | ||||
| import com.simplemobiletools.notes.pro.R | ||||
| import com.simplemobiletools.notes.pro.extensions.config | ||||
| import com.simplemobiletools.notes.pro.extensions.notesDB | ||||
| import com.simplemobiletools.notes.pro.helpers.TYPE_CHECKLIST | ||||
| import com.simplemobiletools.notes.pro.helpers.TYPE_TEXT | ||||
| @@ -16,7 +17,9 @@ import kotlinx.android.synthetic.main.dialog_new_note.view.* | ||||
|  | ||||
| class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) { | ||||
|     init { | ||||
|         val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null) | ||||
|         val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null).apply { | ||||
|             new_note_type.check(if (activity.config.lastCreatedNoteType == TYPE_TEXT) type_text_note.id else type_checklist.id) | ||||
|         } | ||||
|  | ||||
|         AlertDialog.Builder(activity) | ||||
|                 .setPositiveButton(R.string.ok, null) | ||||
| @@ -32,6 +35,7 @@ class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) { | ||||
|                                     activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken) | ||||
|                                     else -> { | ||||
|                                         val type = if (view.new_note_type.checkedRadioButtonId == view.type_checklist.id) TYPE_CHECKLIST else TYPE_TEXT | ||||
|                                         activity.config.lastCreatedNoteType = type | ||||
|                                         val newNote = Note(null, title, "", type) | ||||
|                                         callback(newNote) | ||||
|                                         dismiss() | ||||
|   | ||||
| @@ -72,4 +72,8 @@ class Config(context: Context) : BaseConfig(context) { | ||||
|     var useIncognitoMode: Boolean | ||||
|         get() = prefs.getBoolean(USE_INCOGNITO_MODE, false) | ||||
|         set(useIncognitoMode) = prefs.edit().putBoolean(USE_INCOGNITO_MODE, useIncognitoMode).apply() | ||||
|  | ||||
|     var lastCreatedNoteType: Int | ||||
|         get() = prefs.getInt(LAST_CREATED_NOTE_TYPE, TYPE_TEXT) | ||||
|         set(lastCreatedNoteType) = prefs.edit().putInt(LAST_CREATED_NOTE_TYPE, lastCreatedNoteType).apply() | ||||
| } | ||||
|   | ||||
| @@ -21,6 +21,7 @@ const val LAST_USED_EXTENSION = "last_used_extension" | ||||
| const val LAST_USED_SAVE_PATH = "last_used_save_path" | ||||
| const val ENABLE_LINE_WRAP = "enable_line_wrap" | ||||
| const val USE_INCOGNITO_MODE = "use_incognito_mode" | ||||
| const val LAST_CREATED_NOTE_TYPE = "last_created_note_type" | ||||
|  | ||||
| // gravity | ||||
| const val GRAVITY_LEFT = 0 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user