@@ -22,9 +22,7 @@ import com.simplemobiletools.notes.pro.adapters.ChecklistAdapter
2222import com.simplemobiletools.notes.pro.extensions.config
2323import com.simplemobiletools.notes.pro.extensions.getTextSize
2424import 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.*
2826import com.simplemobiletools.notes.pro.models.ChecklistItem
2927import com.simplemobiletools.notes.pro.models.Note
3028import com.simplemobiletools.notes.pro.models.Widget
@@ -72,7 +70,15 @@ class WidgetConfigureActivity : SimpleActivity() {
7270 }
7371
7472 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+
7682 if (mBgColor == 1 ) {
7783 mBgColor = Color .BLACK
7884 mBgAlpha = .2f
@@ -91,9 +97,8 @@ class WidgetConfigureActivity : SimpleActivity() {
9197 }
9298 updateBackgroundColor()
9399
94- mTextColor = config.widgetTextColor
95100 updateTextColor()
96- mIsCustomizingColors = intent. extras?.getBoolean(IS_CUSTOMIZING_COLORS ) ? : false
101+ mIsCustomizingColors = extras?.getBoolean(IS_CUSTOMIZING_COLORS ) ? : false
97102 notes_picker_holder.beVisibleIf(! mIsCustomizingColors)
98103
99104 NotesHelper (this ).getNotes {
@@ -150,7 +155,12 @@ class WidgetConfigureActivity : SimpleActivity() {
150155 views.setBackgroundColor(R .id.text_note_view, mBgColor)
151156 views.setBackgroundColor(R .id.checklist_note_view, mBgColor)
152157 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)
154164 ensureBackgroundThread {
155165 widgetsDB.insertOrUpdate(widget)
156166 }
0 commit comments