diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt
index e6762d5c1..726e5df7a 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt
@@ -11,6 +11,7 @@ import android.os.Parcelable
import android.support.v4.app.ActivityCompat
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.dialogs.CustomEventReminderDialog
+import com.simplemobiletools.calendar.dialogs.SelectCalendarsDialog
import com.simplemobiletools.calendar.dialogs.SnoozePickerDialog
import com.simplemobiletools.calendar.extensions.*
import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE
@@ -29,10 +30,6 @@ class SettingsActivity : SimpleActivity() {
lateinit var res: Resources
private var mStoredPrimaryColor = 0
- companion object {
- val REQUEST_AUTHORIZATION = 5
- }
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)
@@ -115,6 +112,11 @@ class SettingsActivity : SimpleActivity() {
private fun toggleCaldavSync() {
settings_caldav_sync.toggle()
config.caldavSync = settings_caldav_sync.isChecked
+ if (config.caldavSync) {
+ SelectCalendarsDialog(this) {
+
+ }
+ }
}
private fun setupSundayFirst() {
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/CustomEventReminderDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/CustomEventReminderDialog.kt
index f4913afe6..f24cbf587 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/CustomEventReminderDialog.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/CustomEventReminderDialog.kt
@@ -2,7 +2,6 @@ package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
-import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import com.simplemobiletools.calendar.R
@@ -13,7 +12,7 @@ import kotlinx.android.synthetic.main.dialog_custom_event_reminder.view.*
class CustomEventReminderDialog(val activity: Activity, val selectedMinutes: Int = 0, val callback: (minutes: Int) -> Unit) : AlertDialog.Builder(activity) {
var dialog: AlertDialog
- var view: View = (activity.layoutInflater.inflate(R.layout.dialog_custom_event_reminder, null) as ViewGroup).apply {
+ var view = (activity.layoutInflater.inflate(R.layout.dialog_custom_event_reminder, null) as ViewGroup).apply {
if (selectedMinutes == 0) {
dialog_radio_view.check(R.id.dialog_radio_minutes)
} else if (selectedMinutes % 1440 == 0) {
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatRuleWeeklyDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatRuleWeeklyDialog.kt
index d190d04c4..d69ce0ddb 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatRuleWeeklyDialog.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatRuleWeeklyDialog.kt
@@ -2,7 +2,6 @@ package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
-import android.view.View
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.commons.extensions.setupDialogStuff
@@ -12,7 +11,7 @@ import kotlinx.android.synthetic.main.dialog_vertical_linear_layout.view.*
class RepeatRuleWeeklyDialog(val activity: Activity, val curRepeatRule: Int, val callback: (repeatRule: Int) -> Unit) :
AlertDialog.Builder(activity) {
val dialog: AlertDialog
- val view: View = activity.layoutInflater.inflate(R.layout.dialog_vertical_linear_layout, null)
+ val view = activity.layoutInflater.inflate(R.layout.dialog_vertical_linear_layout, null)
init {
val days = arrayOf(R.string.monday, R.string.tuesday, R.string.wednesday, R.string.thursday, R.string.friday, R.string.saturday, R.string.sunday)
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt
new file mode 100644
index 000000000..87cf212cb
--- /dev/null
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt
@@ -0,0 +1,57 @@
+package com.simplemobiletools.calendar.dialogs
+
+import android.app.Activity
+import android.support.v7.app.AlertDialog
+import android.view.ViewGroup
+import com.simplemobiletools.calendar.R
+import com.simplemobiletools.calendar.extensions.getCalDAVCalendars
+import com.simplemobiletools.commons.extensions.setupDialogStuff
+import kotlinx.android.synthetic.main.calendar_item_account.view.*
+import kotlinx.android.synthetic.main.calendar_item_calendar.view.*
+import kotlinx.android.synthetic.main.dialog_select_calendars.view.*
+
+class SelectCalendarsDialog(val activity: Activity, val callback: (calendars: Int) -> Unit) : AlertDialog.Builder(activity) {
+ var prevAccount = ""
+ var dialog: AlertDialog
+ var view = (activity.layoutInflater.inflate(R.layout.dialog_select_calendars, null) as ViewGroup)
+
+ init {
+ val calendars = activity.getCalDAVCalendars()
+ val sorted = calendars.sortedWith(compareBy({ it.accountName }, { it.displayName }))
+ sorted.forEach {
+ if (prevAccount != it.accountName) {
+ prevAccount = it.accountName
+ addCalendarItem(false, it.accountName)
+ }
+
+ addCalendarItem(true, it.displayName)
+ }
+
+ dialog = AlertDialog.Builder(activity)
+ .setPositiveButton(R.string.ok, { dialogInterface, i -> confirmSelection() })
+ .setNegativeButton(R.string.cancel, null)
+ .create().apply {
+ activity.setupDialogStuff(view, this, R.string.select_caldav_calendars)
+ }
+ }
+
+ private fun addCalendarItem(isEvent: Boolean, text: String) {
+ val calendarItem = activity.layoutInflater.inflate(if (isEvent) R.layout.calendar_item_calendar else R.layout.calendar_item_account,
+ view.dialog_select_calendars_holder, false)
+
+ if (isEvent) {
+ calendarItem.calendar_item_calendar_switch.text = text
+ calendarItem.setOnClickListener {
+ calendarItem.calendar_item_calendar_switch.toggle()
+ }
+ } else {
+ calendarItem.calendar_item_account.text = text
+ }
+
+ view.dialog_select_calendars_holder.addView(calendarItem)
+ }
+
+ private fun confirmSelection() {
+
+ }
+}
diff --git a/app/src/main/res/layout/calendar_item_account.xml b/app/src/main/res/layout/calendar_item_account.xml
new file mode 100644
index 000000000..96c206a8d
--- /dev/null
+++ b/app/src/main/res/layout/calendar_item_account.xml
@@ -0,0 +1,16 @@
+
+
diff --git a/app/src/main/res/layout/calendar_item_calendar.xml b/app/src/main/res/layout/calendar_item_calendar.xml
new file mode 100644
index 000000000..4aefba01c
--- /dev/null
+++ b/app/src/main/res/layout/calendar_item_calendar.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/dialog_select_calendars.xml b/app/src/main/res/layout/dialog_select_calendars.xml
new file mode 100644
index 000000000..d15b701b8
--- /dev/null
+++ b/app/src/main/res/layout/dialog_select_calendars.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 2eb99ef2e..6341bcf5e 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 2dfda7398..a18fd5a78 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 2b36d13c1..544abe3a1 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml
index a569738c4..d78f3824b 100644
--- a/app/src/main/res/values-hi-rIN/strings.xml
+++ b/app/src/main/res/values-hi-rIN/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml
index 1e143ce17..b7257d484 100644
--- a/app/src/main/res/values-hu/strings.xml
+++ b/app/src/main/res/values-hu/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 169e580dd..1b1b7c2d7 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml
index cede253c2..f1b42e7e6 100644
--- a/app/src/main/res/values-iw/strings.xml
+++ b/app/src/main/res/values-iw/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 178833d4e..e904fb4b5 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml
index 0bbea0196..559d70712 100644
--- a/app/src/main/res/values-pl/strings.xml
+++ b/app/src/main/res/values-pl/strings.xml
@@ -195,7 +195,9 @@
Pokazuj wydarzenia z przeszłości
Opóźnij przypomnienie o
Widżety
- Nie możesz tego zrobić bez dostępu do internetu.
+
+
+ Select calendars to sync
- %1$d minutę
diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml
index 8a4643077..3210a09bf 100644
--- a/app/src/main/res/values-pt-rBR/strings.xml
+++ b/app/src/main/res/values-pt-rBR/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index 77e66e0f0..836b640f7 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -190,7 +190,9 @@
Mostrar eventos passados
Adiar lembrete com a opção Snooze
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minuto
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index c001ad119..52d639d2b 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -204,7 +204,9 @@
Показывать прошедшие события
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d минута
diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml
index 4363db67d..e3454a0ff 100644
--- a/app/src/main/res/values-sk/strings.xml
+++ b/app/src/main/res/values-sk/strings.xml
@@ -197,7 +197,9 @@
Zobraziť minulé udalosti spred
Posunúť pripomienku s Odložiť o
Widgety
- Nemôžete to urobiť bez internetu.
+
+
+ Zvoľte kalendáre pre synchronizáciu
- %1$d minútu
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index dd75ebf81..5aeeabd42 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -190,7 +190,9 @@
Visa tidigare händelser
Skjut upp påminnelse med Snooza
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minut
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index 0844c0e97..cd5ee0976 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 95ac100fa..b53992792 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -190,7 +190,9 @@
Display events from the past
Postpone reminder with Snooze by
Widgets
- You cannot do that while offline.
+
+
+ Select calendars to sync
- %1$d minute