@@ -13,8 +13,10 @@ import com.google.gson.Gson
13
13
import com.google.gson.reflect.TypeToken
14
14
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
15
15
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
16
+ import com.simplemobiletools.commons.dialogs.SecurityDialog
16
17
import com.simplemobiletools.commons.extensions.*
17
18
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
19
+ import com.simplemobiletools.commons.helpers.PROTECTION_NONE
18
20
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
19
21
import com.simplemobiletools.commons.models.RadioItem
20
22
import com.simplemobiletools.notes.pro.R
@@ -99,7 +101,8 @@ class WidgetConfigureActivity : SimpleActivity() {
99
101
NotesHelper (this ).getNotes {
100
102
mNotes = it
101
103
notes_picker_holder.beVisibleIf(mNotes.size > 1 && ! mIsCustomizingColors)
102
- updateCurrentNote(mNotes.first())
104
+ val note = mNotes.firstOrNull { ! it.isLocked() } ? : return @getNotes
105
+ updateCurrentNote(note)
103
106
}
104
107
}
105
108
@@ -111,7 +114,16 @@ class WidgetConfigureActivity : SimpleActivity() {
111
114
112
115
RadioGroupDialog (this , items, mCurrentNoteId.toInt()) {
113
116
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
+ }
115
127
}
116
128
}
117
129
@@ -146,6 +158,11 @@ class WidgetConfigureActivity : SimpleActivity() {
146
158
}
147
159
148
160
private fun saveConfig () {
161
+ if (mCurrentNoteId == 0L ) {
162
+ finish()
163
+ return
164
+ }
165
+
149
166
val views = RemoteViews (packageName, R .layout.activity_main)
150
167
views.setBackgroundColor(R .id.text_note_view, mBgColor)
151
168
views.setBackgroundColor(R .id.checklist_note_view, mBgColor)
0 commit comments