allow storing events locally only, even if caldav sync is on

This commit is contained in:
tibbi 2017-08-17 23:31:01 +02:00
parent 53e08da673
commit a66931c17d
19 changed files with 49 additions and 13 deletions

View File

@ -396,6 +396,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
updateCurrentCalendarInfo(getCalendarWithId(calendars))
event_caldav_calendar_holder.setOnClickListener {
hideKeyboard()
SelectEventCalendarDialog(this, calendars, config.lastUsedCaldavCalendar) {
config.lastUsedCaldavCalendar = it
updateCurrentCalendarInfo(getCalendarWithId(calendars))
@ -408,8 +409,24 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
calendars.firstOrNull { it.id == config.lastUsedCaldavCalendar }
private fun updateCurrentCalendarInfo(currentCalendar: CalDAVCalendar?) {
event_caldav_calendar_name.text = currentCalendar?.displayName
event_caldav_calendar_email.text = currentCalendar?.accountName
if (currentCalendar == null) {
event_caldav_calendar_email.beGone()
event_caldav_calendar_name.apply {
text = getString(R.string.store_locally_only)
apply {
setPadding(paddingLeft, paddingTop, paddingRight, resources.getDimension(R.dimen.medium_margin).toInt())
}
}
} else {
event_caldav_calendar_email.text = currentCalendar.accountName
event_caldav_calendar_email.beVisible()
event_caldav_calendar_name.apply {
text = currentCalendar.displayName
apply {
setPadding(paddingLeft, paddingTop, paddingRight, resources.getDimension(R.dimen.tiny_margin).toInt())
}
}
}
}
private fun toggleAllDay(isChecked: Boolean) {

View File

@ -17,9 +17,11 @@ import kotlinx.android.synthetic.main.dialog_select_radio_group.view.*
import kotlinx.android.synthetic.main.radio_button_with_color.view.*
class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalDAVCalendar>, val currCalendarId: Int, val callback: (id: Int) -> Unit) {
val dialog: AlertDialog?
val radioGroup: RadioGroup
var wasInit = false
private val STORE_LOCALLY_ONLY = 0
private val dialog: AlertDialog?
private val radioGroup: RadioGroup
private var wasInit = false
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_select_radio_group, null) as ViewGroup
@ -28,8 +30,9 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalD
activity.dbHelper.getEventTypes {
activity.runOnUiThread {
calendars.forEach {
addRadioButton(it.displayName, it.id.toInt(), it.color)
addRadioButton(it.displayName, it.id, it.color)
}
addRadioButton(activity.getString(R.string.store_locally_only), STORE_LOCALLY_ONLY, Color.TRANSPARENT)
wasInit = true
activity.updateTextColors(view.dialog_radio_holder)
}
@ -56,7 +59,7 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalD
radioGroup.addView(view, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
}
fun viewClicked(typeId: Int) {
private fun viewClicked(typeId: Int) {
if (!wasInit)
return

View File

@ -19,12 +19,12 @@ import kotlinx.android.synthetic.main.radio_button_with_color.view.*
import java.util.*
class SelectEventTypeDialog(val activity: Activity, val currEventType: Int, val callback: (checkedId: Int) -> Unit) {
val NEW_TYPE_ID = -2
private val NEW_TYPE_ID = -2
val dialog: AlertDialog?
val radioGroup: RadioGroup
var wasInit = false
var eventTypes = ArrayList<EventType>()
private val dialog: AlertDialog?
private val radioGroup: RadioGroup
private var wasInit = false
private var eventTypes = ArrayList<EventType>()
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_select_radio_group, null) as ViewGroup
@ -63,7 +63,7 @@ class SelectEventTypeDialog(val activity: Activity, val currEventType: Int, val
radioGroup.addView(view, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
}
fun viewClicked(typeId: Int) {
private fun viewClicked(typeId: Int) {
if (!wasInit)
return

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -200,6 +200,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minutę</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Selecione os calendários a sincronizar</string>
<string name="manage_synced_calendars">Gerir calendários sincronizados</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minuto</item>

View File

@ -209,6 +209,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d минута</item>

View File

@ -202,6 +202,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Zvoľte kalendáre pre synchronizáciu</string>
<string name="manage_synced_calendars">Spravovať synchronizované kalendáre</string>
<string name="store_locally_only">Uložiť iba lokálne</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minútu</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minut</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>

View File

@ -195,6 +195,7 @@
<string name="caldav">CalDAV</string>
<string name="select_caldav_calendars">Select calendars to sync</string>
<string name="manage_synced_calendars">Manage synced calendars</string>
<string name="store_locally_only">Store locally only</string>
<plurals name="by_minutes">
<item quantity="one">%1$d minute</item>