From a66931c17d77df7bbce8c65df6377ac2ab9e4d55 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 17 Aug 2017 23:31:01 +0200 Subject: [PATCH] allow storing events locally only, even if caldav sync is on --- .../calendar/activities/EventActivity.kt | 21 +++++++++++++++++-- .../dialogs/SelectEventCalendarDialog.kt | 13 +++++++----- .../calendar/dialogs/SelectEventTypeDialog.kt | 12 +++++------ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-hi-rIN/strings.xml | 1 + app/src/main/res/values-hu/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-iw/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-pl/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sk/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 19 files changed, 49 insertions(+), 13 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index caaa1fe70..741102a7a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -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) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventCalendarDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventCalendarDialog.kt index 30cf4ecb0..6bcb3f170 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventCalendarDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventCalendarDialog.kt @@ -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, 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 Unit) { - val NEW_TYPE_ID = -2 + private val NEW_TYPE_ID = -2 - val dialog: AlertDialog? - val radioGroup: RadioGroup - var wasInit = false - var eventTypes = ArrayList() + private val dialog: AlertDialog? + private val radioGroup: RadioGroup + private var wasInit = false + private var eventTypes = ArrayList() 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 diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ef6c2b93c..7ace0124d 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d31a5d111..f4bee854b 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 04b90fc56..2db5c1d73 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %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 fcf5d7039..33dc47edd 100644 --- a/app/src/main/res/values-hi-rIN/strings.xml +++ b/app/src/main/res/values-hi-rIN/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 2b4d5f7a8..9b7efae76 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 611122948..13a84f918 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index 54105922a..081341a3e 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 3c7a884a4..a6031ecdb 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index b952b79d2..349184a79 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -200,6 +200,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %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 f337ddeab..2f5ec234f 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index f0c9e9d5f..08b95b452 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -195,6 +195,7 @@ CalDAV Selecione os calendários a sincronizar Gerir calendários sincronizados + Store locally only %1$d minuto diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index b35452dd5..077b742ec 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -209,6 +209,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d минута diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 42fe9e4f3..926c31e26 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -202,6 +202,7 @@ CalDAV Zvoľte kalendáre pre synchronizáciu Spravovať synchronizované kalendáre + Uložiť iba lokálne %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 14fe70ee4..91fdaa741 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minut diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 116ba0f25..37ad5eee4 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 165413fe0..3e1a010d7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -195,6 +195,7 @@ CalDAV Select calendars to sync Manage synced calendars + Store locally only %1$d minute