diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/ManageEventTypesActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/ManageEventTypesActivity.kt index 1a4f89617..bbea77c9d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/ManageEventTypesActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/ManageEventTypesActivity.kt @@ -52,6 +52,10 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteItemsListener { } override fun deleteItems(ids: ArrayList) { + if (ids.contains(DBHelper.REGULAR_EVENT_ID)) { + toast(R.string.cannot_delete_default_type) + } + DBHelper.newInstance(applicationContext).deleteEventTypes(ids) { if (it > 0) { getEventTypes() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index 6671a1e62..d94621bb8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -51,6 +51,8 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont companion object { private val DB_NAME = "events.db" private val DB_VERSION = 7 + val REGULAR_EVENT_ID = 1 + private var mEventsListener: EventUpdateListener? = null fun newInstance(context: Context, callback: EventUpdateListener? = null): DBHelper { @@ -237,7 +239,14 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } fun deleteEventTypes(ids: ArrayList, callback: (deletedCnt: Int) -> Unit) { - val args = TextUtils.join(", ", ids) + var deleteIds = ids + if (ids.contains(DBHelper.REGULAR_EVENT_ID)) + deleteIds = ids.filter { it != DBHelper.REGULAR_EVENT_ID } as ArrayList + + if (deleteIds.isEmpty()) + return + + val args = TextUtils.join(", ", deleteIds) val selection = "$COL_TYPE_ID IN ($args)" callback.invoke(mDb.delete(TYPES_TABLE_NAME, selection, null)) } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 4cac4cb55..09f91e29e 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index e6da86809..e8bb89231 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f77369e7c..1fce10cb0 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml index 17c668726..67cc23947 100644 --- a/app/src/main/res/values-hi-rIN/strings.xml +++ b/app/src/main/res/values-hi-rIN/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 853bddea0..024c0542e 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index c5f9dd8fc..bd9e5bf2a 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index 725d51a72..f24029739 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 84c23e90d..88f15830e 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index e8996a551..10f6c1d89 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 3ad839c73..b97b39fa5 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 8f6c5f418..4907edbec 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -87,6 +87,7 @@ Typ s daným názvom už existuje Farba Bežná udalosť + Predvolený typ nie je možné vymazať Manage event types diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index b3628beeb..80635c1f0 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 484154c69..6ed28a65d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -87,6 +87,7 @@ Type with this title already exists Color Regular event + Default event type cannot be deleted Manage event types