Skip to content

Commit 8e97b2c

Browse files
authored
feat: rename "Regular event" to "Local calendar" (#941)
* feat: rename "Regular event" to "Local calendar" * docs: update changelog * style: shorten line * docs: update changelog * feat: rephrase `cannot_delete_default_type` slightly
1 parent eae9bf4 commit 8e97b2c

File tree

13 files changed

+33
-26
lines changed

13 files changed

+33
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Changed
99
- Replaced "event types" concept with "calendars" ([#629])
10+
- Renamed built-in "Regular event" calendar to "Local calendar"
1011
- Weekday labels now use three-letter abbreviations instead of single letters ([#103])
1112
- Converting all-day events to timed events now respects the default start time and duration ([#917])
1213

app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ import org.fossify.calendar.helpers.NEW_EVENT_SET_HOUR_DURATION
8383
import org.fossify.calendar.helpers.NEW_EVENT_START_TS
8484
import org.fossify.calendar.helpers.ORIGINAL_END_TS
8585
import org.fossify.calendar.helpers.ORIGINAL_START_TS
86-
import org.fossify.calendar.helpers.REGULAR_EVENT_TYPE_ID
86+
import org.fossify.calendar.helpers.LOCAL_CALENDAR_ID
8787
import org.fossify.calendar.helpers.REMINDER_1_MINUTES
8888
import org.fossify.calendar.helpers.REMINDER_1_TYPE
8989
import org.fossify.calendar.helpers.REMINDER_2_MINUTES
@@ -186,7 +186,7 @@ class EventActivity : SimpleActivity() {
186186
private var mRepeatInterval = 0
187187
private var mRepeatLimit = 0L
188188
private var mRepeatRule = 0
189-
private var mEventTypeId = REGULAR_EVENT_TYPE_ID
189+
private var mEventTypeId = LOCAL_CALENDAR_ID
190190
private var mEventOccurrenceTS = 0L
191191
private var mLastSavePromptTS = 0L
192192
private var mEventCalendarId = STORED_LOCALLY_ONLY
@@ -406,7 +406,7 @@ class EventActivity : SimpleActivity() {
406406
event: Event?,
407407
) = binding.apply {
408408
if (localEventType == null || localEventType.caldavCalendarId != 0) {
409-
config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID
409+
config.lastUsedLocalEventTypeId = LOCAL_CALENDAR_ID
410410
}
411411

412412
mEventTypeId = if (config.defaultEventTypeId == -1L) {

app/src/main/kotlin/org/fossify/calendar/activities/TaskActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.fossify.commons.models.RadioItem
2626
import org.joda.time.DateTime
2727

2828
class TaskActivity : SimpleActivity() {
29-
private var mEventTypeId = REGULAR_EVENT_TYPE_ID
29+
private var mEventTypeId = LOCAL_CALENDAR_ID
3030
private lateinit var mTaskDateTime: DateTime
3131
private lateinit var mTask: Event
3232

@@ -237,7 +237,7 @@ class TaskActivity : SimpleActivity() {
237237

238238
private fun gotTask(savedInstanceState: Bundle?, localEventType: EventType?, task: Event?) {
239239
if (localEventType == null) {
240-
config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID
240+
config.lastUsedLocalEventTypeId = LOCAL_CALENDAR_ID
241241
}
242242

243243
mEventTypeId = if (config.defaultEventTypeId == -1L) config.lastUsedLocalEventTypeId else config.defaultEventTypeId

app/src/main/kotlin/org/fossify/calendar/adapters/ManageEventTypesAdapter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.fossify.calendar.R
66
import org.fossify.calendar.activities.SimpleActivity
77
import org.fossify.calendar.databinding.ItemEventTypeBinding
88
import org.fossify.calendar.extensions.eventsHelper
9-
import org.fossify.calendar.helpers.REGULAR_EVENT_TYPE_ID
9+
import org.fossify.calendar.helpers.LOCAL_CALENDAR_ID
1010
import org.fossify.calendar.interfaces.DeleteEventTypesListener
1111
import org.fossify.calendar.models.EventType
1212
import org.fossify.commons.adapters.MyRecyclerViewAdapter
@@ -163,7 +163,7 @@ class ManageEventTypesAdapter(
163163

164164
for (key in selectedKeys) {
165165
val type = getItemWithKey(key) ?: continue
166-
if (type.id == REGULAR_EVENT_TYPE_ID) {
166+
if (type.id == LOCAL_CALENDAR_ID) {
167167
activity.toast(R.string.cannot_delete_default_type)
168168
eventTypesToDelete.remove(type)
169169
toggleItemSelection(false, getItemKeyPosition(type.id!!.toInt()))

app/src/main/kotlin/org/fossify/calendar/databases/EventsDatabase.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
1010
import org.fossify.calendar.R
1111
import org.fossify.calendar.extensions.config
1212
import org.fossify.calendar.helpers.Converters
13-
import org.fossify.calendar.helpers.REGULAR_EVENT_TYPE_ID
13+
import org.fossify.calendar.helpers.LOCAL_CALENDAR_ID
1414
import org.fossify.calendar.interfaces.EventTypesDao
1515
import org.fossify.calendar.interfaces.EventsDao
1616
import org.fossify.calendar.interfaces.TasksDao
@@ -45,7 +45,7 @@ abstract class EventsDatabase : RoomDatabase() {
4545
.addCallback(object : Callback() {
4646
override fun onCreate(db: SupportSQLiteDatabase) {
4747
super.onCreate(db)
48-
insertRegularEventType(context)
48+
insertLocalCalendar(context)
4949
}
5050
})
5151
.addMigrations(MIGRATION_1_2)
@@ -70,12 +70,15 @@ abstract class EventsDatabase : RoomDatabase() {
7070
db = null
7171
}
7272

73-
private fun insertRegularEventType(context: Context) {
73+
private fun insertLocalCalendar(context: Context) {
7474
Executors.newSingleThreadScheduledExecutor().execute {
75-
val regularEvent = context.resources.getString(R.string.regular_event)
76-
val eventType = EventType(REGULAR_EVENT_TYPE_ID, regularEvent, context.getProperPrimaryColor())
75+
val eventType = EventType(
76+
id = LOCAL_CALENDAR_ID,
77+
title = context.resources.getString(R.string.regular_event),
78+
color = context.getProperPrimaryColor()
79+
)
7780
db!!.EventTypesDao().insertOrUpdate(eventType)
78-
context.config.addDisplayEventType(REGULAR_EVENT_TYPE_ID.toString())
81+
context.config.addDisplayEventType(LOCAL_CALENDAR_ID.toString())
7982
}
8083
}
8184

app/src/main/kotlin/org/fossify/calendar/dialogs/ImportEventsDialog.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ import org.fossify.calendar.helpers.IcsImporter.ImportResult.IMPORT_FAIL
1212
import org.fossify.calendar.helpers.IcsImporter.ImportResult.IMPORT_NOTHING_NEW
1313
import org.fossify.calendar.helpers.IcsImporter.ImportResult.IMPORT_OK
1414
import org.fossify.calendar.helpers.IcsImporter.ImportResult.IMPORT_PARTIAL
15-
import org.fossify.calendar.helpers.REGULAR_EVENT_TYPE_ID
15+
import org.fossify.calendar.helpers.LOCAL_CALENDAR_ID
1616
import org.fossify.commons.extensions.*
1717
import org.fossify.commons.helpers.ensureBackgroundThread
1818

1919
class ImportEventsDialog(val activity: SimpleActivity, val path: String, val callback: (refreshView: Boolean) -> Unit) {
20-
private var currEventTypeId = REGULAR_EVENT_TYPE_ID
20+
private var currEventTypeId = LOCAL_CALENDAR_ID
2121
private var currEventTypeCalDAVCalendarId = 0
2222
private val config = activity.config
2323
private val binding by activity.viewBinding(DialogImportEventsBinding::inflate)
2424

2525
init {
2626
ensureBackgroundThread {
2727
if (activity.eventTypesDB.getEventTypeWithId(config.lastUsedLocalEventTypeId) == null) {
28-
config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID
28+
config.lastUsedLocalEventTypeId = LOCAL_CALENDAR_ID
2929
}
3030

3131
val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId)
@@ -35,7 +35,7 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
3535
currEventTypeCalDAVCalendarId = config.lastUsedCaldavCalendarId
3636
lastUsedCalDAVCalendar.id!!
3737
} else {
38-
REGULAR_EVENT_TYPE_ID
38+
LOCAL_CALENDAR_ID
3939
}
4040
} else {
4141
config.lastUsedLocalEventTypeId

app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Config(context: Context) : BaseConfig(context) {
114114
set(calendarId) = prefs.edit().putInt(LAST_USED_CALDAV_CALENDAR, calendarId).apply()
115115

116116
var lastUsedLocalEventTypeId: Long
117-
get() = prefs.getLong(LAST_USED_LOCAL_EVENT_TYPE_ID, REGULAR_EVENT_TYPE_ID)
117+
get() = prefs.getLong(LAST_USED_LOCAL_EVENT_TYPE_ID, LOCAL_CALENDAR_ID)
118118
set(lastUsedLocalEventTypeId) = prefs.edit().putLong(LAST_USED_LOCAL_EVENT_TYPE_ID, lastUsedLocalEventTypeId).apply()
119119

120120
var lastUsedIgnoreEventTypesState: Boolean

app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const val CALDAV = "Caldav"
3939
const val VIEW_TO_OPEN = "view_to_open"
4040
const val SHORTCUT_NEW_EVENT = "shortcut_new_event"
4141
const val SHORTCUT_NEW_TASK = "shortcut_new_task"
42-
const val REGULAR_EVENT_TYPE_ID = 1L
42+
const val LOCAL_CALENDAR_ID = 1L
4343
const val TIME_ZONE = "time_zone"
4444
const val CURRENT_TIME_ZONE = "current_time_zone"
4545
const val IS_TASK = "is_task"

app/src/main/kotlin/org/fossify/calendar/helpers/EventsHelper.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ class EventsHelper(val context: Context) {
8787
fun getEventTypeWithCalDAVCalendarId(calendarId: Int) = eventTypesDB.getEventTypeWithCalDAVCalendarId(calendarId)
8888

8989
fun deleteEventTypes(eventTypes: ArrayList<EventType>, deleteEvents: Boolean) {
90-
val typesToDelete = eventTypes.asSequence().filter { it.caldavCalendarId == 0 && it.id != REGULAR_EVENT_TYPE_ID }.toMutableList()
90+
val typesToDelete = eventTypes
91+
.asSequence()
92+
.filter { it.caldavCalendarId == 0 && it.id != LOCAL_CALENDAR_ID }
93+
.toMutableList()
9194
val deleteIds = typesToDelete.map { it.id }.toMutableList()
9295
val deletedSet = deleteIds.map { it.toString() }.toHashSet()
9396
config.removeDisplayEventTypes(deletedSet)

app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class IcsImporter(val activity: SimpleActivity) {
4343
private var curRepeatInterval = 0
4444
private var curRepeatLimit = 0L
4545
private var curRepeatRule = 0
46-
private var curEventTypeId = REGULAR_EVENT_TYPE_ID
46+
private var curEventTypeId = LOCAL_CALENDAR_ID
4747
private var curLastModified = 0L
4848
private var curCategoryColor = -2
4949
private var curAvailability = Events.AVAILABILITY_BUSY
@@ -496,7 +496,7 @@ class IcsImporter(val activity: SimpleActivity) {
496496
curRepeatInterval = 0
497497
curRepeatLimit = 0L
498498
curRepeatRule = 0
499-
curEventTypeId = REGULAR_EVENT_TYPE_ID
499+
curEventTypeId = LOCAL_CALENDAR_ID
500500
curLastModified = 0L
501501
curCategoryColor = -2
502502
isNotificationDescription = false

0 commit comments

Comments
 (0)