store default calendar reminders
This commit is contained in:
parent
77eeb1aba7
commit
2da1739431
|
@ -18,15 +18,13 @@ import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccoun
|
|||
import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException
|
||||
import com.google.api.client.util.ExponentialBackOff
|
||||
import com.google.api.services.calendar.CalendarScopes
|
||||
import com.google.api.services.calendar.model.CalendarListEntry
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.asynctasks.FetchGoogleEventsTask
|
||||
import com.simplemobiletools.calendar.dialogs.CustomEventReminderDialog
|
||||
import com.simplemobiletools.calendar.dialogs.SnoozePickerDialog
|
||||
import com.simplemobiletools.calendar.extensions.*
|
||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE
|
||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM
|
||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL
|
||||
import com.simplemobiletools.calendar.helpers.PRIMARY
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
|
@ -382,9 +380,21 @@ class SettingsActivity : SimpleActivity() {
|
|||
Thread({
|
||||
val calendar = getGoogleSyncService().calendarList().get(PRIMARY).execute()
|
||||
config.googleDefaultEventColor = Color.parseColor(calendar.backgroundColor)
|
||||
storeDefaultReminders(calendar)
|
||||
}).start()
|
||||
}
|
||||
|
||||
private fun storeDefaultReminders(calendar: CalendarListEntry) {
|
||||
val reminderMinutes = ArrayList<Int>()
|
||||
val reminders = calendar.defaultReminders
|
||||
reminders.forEach {
|
||||
if (it.method == POPUP) {
|
||||
reminderMinutes.add(it.minutes)
|
||||
}
|
||||
}
|
||||
config.googleDefaultReminders = reminderMinutes.joinToString()
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.*
|
|||
// more info about event fields at https://developers.google.com/google-apps/calendar/v3/reference/events/insert
|
||||
class FetchGoogleEventsTask(val context: Context, val googleSyncListener: GoogleSyncListener? = null) : AsyncTask<Void, Void, String>() {
|
||||
private val ITEMS = "items"
|
||||
private val OVERRIDES = "overrides"
|
||||
private val NEXT_PAGE_TOKEN = "nextPageToken"
|
||||
|
||||
private var dbHelper = context.dbHelper
|
||||
|
|
|
@ -90,6 +90,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getInt(GOOGLE_DEFAULT_EVENT_COLOR, primaryColor)
|
||||
set(color) = prefs.edit().putInt(GOOGLE_DEFAULT_EVENT_COLOR, color).apply()
|
||||
|
||||
var googleDefaultReminders: String
|
||||
get() = prefs.getString(GOOGLE_DEFAULT_REMINDERS, "")
|
||||
set(reminders) = prefs.edit().putString(GOOGLE_DEFAULT_REMINDERS, reminders).apply()
|
||||
|
||||
fun addDisplayEventType(type: String) {
|
||||
addDisplayEventTypes(HashSet<String>(Arrays.asList(type)))
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ val SYNC_ACCOUNT_NAME = "sync_account_name"
|
|||
val SNOOZE_DELAY = "snooze_delay"
|
||||
val DISPLAY_PAST_EVENTS = "display_past_events"
|
||||
val GOOGLE_DEFAULT_EVENT_COLOR = "google_default_event_color"
|
||||
val GOOGLE_DEFAULT_REMINDERS = "google_default_reminders"
|
||||
|
||||
val letterIDs = intArrayOf(R.string.sunday_letter, R.string.monday_letter, R.string.tuesday_letter, R.string.wednesday_letter,
|
||||
R.string.thursday_letter, R.string.friday_letter, R.string.saturday_letter)
|
||||
|
@ -128,3 +129,5 @@ val POPUP = "popup"
|
|||
val OPERATION_INSERT = 1
|
||||
val OPERATION_UPDATE = 2
|
||||
val OPERATION_DELETE = 3
|
||||
val OVERRIDES = "overrides"
|
||||
val DEFAULT_REMINDERS = "defaultReminders"
|
||||
|
|
Loading…
Reference in New Issue