Merge pull request #1610 from Aga-C/remember-event-span

Added remembering event span in widget configurator (#1609)
This commit is contained in:
Tibor Kaputa 2022-01-14 10:21:45 +01:00 committed by GitHub
commit d7fdcd273f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -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)

View file

@ -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()
}

View file

@ -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)