@@ -22,9 +22,7 @@ import com.simplemobiletools.notes.pro.adapters.ChecklistAdapter
22
22
import com.simplemobiletools.notes.pro.extensions.config
23
23
import com.simplemobiletools.notes.pro.extensions.getTextSize
24
24
import com.simplemobiletools.notes.pro.extensions.widgetsDB
25
- import com.simplemobiletools.notes.pro.helpers.MyWidgetProvider
26
- import com.simplemobiletools.notes.pro.helpers.NotesHelper
27
- import com.simplemobiletools.notes.pro.helpers.TYPE_CHECKLIST
25
+ import com.simplemobiletools.notes.pro.helpers.*
28
26
import com.simplemobiletools.notes.pro.models.ChecklistItem
29
27
import com.simplemobiletools.notes.pro.models.Note
30
28
import com.simplemobiletools.notes.pro.models.Widget
@@ -72,7 +70,15 @@ class WidgetConfigureActivity : SimpleActivity() {
72
70
}
73
71
74
72
private fun initVariables () {
75
- mBgColor = config.widgetBgColor
73
+ val extras = intent.extras
74
+ if (extras?.getLong(CUSTOMIZED_WIDGET_ID , 0L ) == 0L ) {
75
+ mBgColor = config.widgetBgColor
76
+ mTextColor = config.widgetTextColor
77
+ } else {
78
+ mBgColor = extras?.getInt(CUSTOMIZED_WIDGET_BG_COLOR ) ? : config.widgetBgColor
79
+ mTextColor = extras?.getInt(CUSTOMIZED_WIDGET_TEXT_COLOR ) ? : config.widgetTextColor
80
+ }
81
+
76
82
if (mBgColor == 1 ) {
77
83
mBgColor = Color .BLACK
78
84
mBgAlpha = .2f
@@ -91,9 +97,8 @@ class WidgetConfigureActivity : SimpleActivity() {
91
97
}
92
98
updateBackgroundColor()
93
99
94
- mTextColor = config.widgetTextColor
95
100
updateTextColor()
96
- mIsCustomizingColors = intent. extras?.getBoolean(IS_CUSTOMIZING_COLORS ) ? : false
101
+ mIsCustomizingColors = extras?.getBoolean(IS_CUSTOMIZING_COLORS ) ? : false
97
102
notes_picker_holder.beVisibleIf(! mIsCustomizingColors)
98
103
99
104
NotesHelper (this ).getNotes {
@@ -150,7 +155,12 @@ class WidgetConfigureActivity : SimpleActivity() {
150
155
views.setBackgroundColor(R .id.text_note_view, mBgColor)
151
156
views.setBackgroundColor(R .id.checklist_note_view, mBgColor)
152
157
AppWidgetManager .getInstance(this ).updateAppWidget(mWidgetId, views)
153
- val widget = Widget (null , mWidgetId, mCurrentNoteId, mBgColor, mTextColor)
158
+
159
+ val extras = intent.extras
160
+ val id = if (extras?.containsKey(CUSTOMIZED_WIDGET_KEY_ID ) == true ) extras.getLong(CUSTOMIZED_WIDGET_KEY_ID ) else null
161
+ mWidgetId = extras?.getInt(CUSTOMIZED_WIDGET_ID , mWidgetId) ? : mWidgetId
162
+ mCurrentNoteId = extras?.getLong(CUSTOMIZED_WIDGET_NOTE_ID , mCurrentNoteId) ? : mCurrentNoteId
163
+ val widget = Widget (id, mWidgetId, mCurrentNoteId, mBgColor, mTextColor)
154
164
ensureBackgroundThread {
155
165
widgetsDB.insertOrUpdate(widget)
156
166
}
0 commit comments