diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt index 79182c0c6..6b8591ba0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt @@ -13,10 +13,8 @@ import com.simplemobiletools.calendar.pro.dialogs.CustomPeriodPickerDialog import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.seconds import com.simplemobiletools.calendar.pro.extensions.widgetsDB -import com.simplemobiletools.calendar.pro.helpers.EVENT_PERIOD_CUSTOM -import com.simplemobiletools.calendar.pro.helpers.EVENT_PERIOD_TODAY +import com.simplemobiletools.calendar.pro.helpers.* import com.simplemobiletools.calendar.pro.helpers.Formatter -import com.simplemobiletools.calendar.pro.helpers.MyWidgetListProvider import com.simplemobiletools.calendar.pro.models.ListEvent import com.simplemobiletools.calendar.pro.models.ListItem import com.simplemobiletools.calendar.pro.models.ListSectionDay @@ -40,7 +38,7 @@ class WidgetListConfigureActivity : SimpleActivity() { private var mBgColor = 0 private var mTextColorWithoutTransparency = 0 private var mTextColor = 0 - private var selectedPeriodOption = YEAR_SECONDS + private var selectedPeriodOption = 0 public override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false @@ -70,6 +68,8 @@ class WidgetListConfigureActivity : SimpleActivity() { val primaryColor = config.primaryColor config_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor) + + updateSelectedPeriod(config.lastUsedEventSpan) } override fun onResume() { @@ -99,6 +99,8 @@ class WidgetListConfigureActivity : SimpleActivity() { storeWidgetColors() requestWidgetUpdate() + config.lastUsedEventSpan = selectedPeriodOption + Intent().apply { putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mWidgetId) setResult(Activity.RESULT_OK, this) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt index 7ccf76d24..120ed7309 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt @@ -9,6 +9,7 @@ import com.simplemobiletools.calendar.pro.extensions.scheduleCalDAVSync import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle import com.simplemobiletools.commons.helpers.BaseConfig import com.simplemobiletools.commons.helpers.DAY_MINUTES +import com.simplemobiletools.commons.helpers.YEAR_SECONDS import java.util.* class Config(context: Context) : BaseConfig(context) { @@ -237,4 +238,8 @@ class Config(context: Context) : BaseConfig(context) { var highlightWeekendsColor: Int get() = prefs.getInt(HIGHLIGHT_WEEKENDS_COLOR, context.resources.getColor(R.color.red_text)) set(highlightWeekendsColor) = prefs.edit().putInt(HIGHLIGHT_WEEKENDS_COLOR, highlightWeekendsColor).apply() + + var lastUsedEventSpan: Int + get() = prefs.getInt(LAST_USED_EVENT_SPAN, YEAR_SECONDS) + set(lastUsedEventSpan) = prefs.edit().putInt(LAST_USED_EVENT_SPAN, lastUsedEventSpan).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index 40bcd9f9e..6e8991ec8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -103,6 +103,7 @@ const val WEEKLY_VIEW_ITEM_HEIGHT_MULTIPLIER = "weekly_view_item_height_multipli const val WEEKLY_VIEW_DAYS = "weekly_view_days" const val HIGHLIGHT_WEEKENDS = "highlight_weekends" const val HIGHLIGHT_WEEKENDS_COLOR = "highlight_weekends_color" +const val LAST_USED_EVENT_SPAN = "last_used_event_span" // repeat_rule for monthly and yearly repetition const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition)