@@ -13,8 +13,10 @@ import com.google.gson.Gson
1313import com.google.gson.reflect.TypeToken
1414import com.simplemobiletools.commons.dialogs.ColorPickerDialog
1515import com.simplemobiletools.commons.dialogs.RadioGroupDialog
16+ import com.simplemobiletools.commons.dialogs.SecurityDialog
1617import com.simplemobiletools.commons.extensions.*
1718import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
19+ import com.simplemobiletools.commons.helpers.PROTECTION_NONE
1820import com.simplemobiletools.commons.helpers.ensureBackgroundThread
1921import com.simplemobiletools.commons.models.RadioItem
2022import com.simplemobiletools.notes.pro.R
@@ -99,7 +101,8 @@ class WidgetConfigureActivity : SimpleActivity() {
99101 NotesHelper (this ).getNotes {
100102 mNotes = it
101103 notes_picker_holder.beVisibleIf(mNotes.size > 1 && ! mIsCustomizingColors)
102- updateCurrentNote(mNotes.first())
104+ val note = mNotes.firstOrNull { ! it.isLocked() } ? : return @getNotes
105+ updateCurrentNote(note)
103106 }
104107 }
105108
@@ -111,7 +114,16 @@ class WidgetConfigureActivity : SimpleActivity() {
111114
112115 RadioGroupDialog (this , items, mCurrentNoteId.toInt()) {
113116 val selectedId = it as Int
114- updateCurrentNote(mNotes.first { it.id!! .toInt() == selectedId })
117+ val note = mNotes.firstOrNull { it.id!! .toInt() == selectedId } ? : return @RadioGroupDialog
118+ if (note.protectionType == PROTECTION_NONE ) {
119+ updateCurrentNote(note)
120+ } else {
121+ SecurityDialog (this , note.protectionHash, note.protectionType) { hash, type, success ->
122+ if (success) {
123+ updateCurrentNote(note)
124+ }
125+ }
126+ }
115127 }
116128 }
117129
@@ -146,6 +158,11 @@ class WidgetConfigureActivity : SimpleActivity() {
146158 }
147159
148160 private fun saveConfig () {
161+ if (mCurrentNoteId == 0L ) {
162+ finish()
163+ return
164+ }
165+
149166 val views = RemoteViews (packageName, R .layout.activity_main)
150167 views.setBackgroundColor(R .id.text_note_view, mBgColor)
151168 views.setBackgroundColor(R .id.checklist_note_view, mBgColor)
0 commit comments