diff --git a/CHANGELOG.md b/CHANGELOG.md index ee16b3302..988db6d04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Unified the local and synchronized calendar pickers in event editor ([#629]) ## [1.9.0] - 2025-12-16 ### Changed diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt index 8f0cd849c..61381123c 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt @@ -1,6 +1,5 @@ package org.fossify.calendar.activities -import android.app.Activity import android.app.DatePickerDialog import android.app.TimePickerDialog import android.content.Intent @@ -38,7 +37,6 @@ import org.fossify.calendar.dialogs.ReminderWarningDialog import org.fossify.calendar.dialogs.RepeatLimitTypePickerDialog import org.fossify.calendar.dialogs.RepeatRuleWeeklyDialog import org.fossify.calendar.dialogs.SelectCalendarDialog -import org.fossify.calendar.dialogs.SelectEventCalendarDialog import org.fossify.calendar.dialogs.SelectEventColorDialog import org.fossify.calendar.extensions.calDAVHelper import org.fossify.calendar.extensions.calendarsDB @@ -108,7 +106,6 @@ import org.fossify.calendar.helpers.STORED_LOCALLY_ONLY import org.fossify.calendar.helpers.TIME_ZONE import org.fossify.calendar.helpers.generateImportId import org.fossify.calendar.models.Attendee -import org.fossify.calendar.models.CalDAVCalendar import org.fossify.calendar.models.CalendarEntity import org.fossify.calendar.models.Event import org.fossify.calendar.models.MyTimeZone @@ -384,8 +381,7 @@ class EventActivity : SimpleActivity() { checkRepeatTexts(mRepeatInterval) checkRepeatRule() updateTexts() - updateLocalCalendar() - updateCalDAVCalendar() + updateCalendar() checkAttendees() updateActionBarTitle() } @@ -461,9 +457,8 @@ class EventActivity : SimpleActivity() { } if (savedInstanceState == null) { + updateCalendar() updateTexts() - updateLocalCalendar() - updateCalDAVCalendar() } eventShowOnMap.setOnClickListener { showOnMap() } @@ -545,7 +540,7 @@ class EventActivity : SimpleActivity() { } } - calendarHolder.setOnClickListener { showCalendarDialog() } + eventCalendarHolder.setOnClickListener { showCalendarDialog() } eventAllDay.apply { isChecked = mEvent.getIsAllDay() jumpDrawablesToCurrentState() @@ -748,16 +743,22 @@ class EventActivity : SimpleActivity() { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) binding.eventTitle.requestFocus() binding.eventToolbar.title = getString(R.string.new_event) - if (config.defaultCalendarId != -1L) { - config.lastUsedCaldavCalendarId = mStoredCalendars - .firstOrNull { it.id == config.defaultCalendarId }?.caldavCalendarId - ?: 0 - } - val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList() - .contains(config.lastUsedCaldavCalendarId) - mEventCalendarId = - if (isLastCaldavCalendarOK) config.lastUsedCaldavCalendarId else STORED_LOCALLY_ONLY + val selectedCalendar = mStoredCalendars.firstOrNull { it.id == mCalendarId } + val selectedCaldavId = selectedCalendar?.caldavCalendarId ?: 0 + val isSelectedCaldavOk = + selectedCaldavId != 0 && config.caldavSync && config.getSyncedCalendarIdsAsList() + .contains(selectedCaldavId) + + if (isSelectedCaldavOk) { + mEventCalendarId = selectedCaldavId + config.lastUsedCaldavCalendarId = selectedCaldavId + } else { + mEventCalendarId = STORED_LOCALLY_ONLY + if (selectedCalendar == null || selectedCalendar.caldavCalendarId != 0) { + mCalendarId = config.lastUsedLocalCalendarId + } + } if (intent.action == Intent.ACTION_EDIT || intent.action == Intent.ACTION_INSERT) { val startTS = intent.getLongExtra("beginTime", System.currentTimeMillis()) / 1000L @@ -786,11 +787,7 @@ class EventActivity : SimpleActivity() { val addMinutes = if (intent.getBooleanExtra(NEW_EVENT_SET_HOUR_DURATION, false)) { // if an event is created at 23:00 on the weekly view, make it end // on 23:59 by default to avoid spanning across multiple days - if (mEventStartDateTime.hourOfDay == 23) { - 59 - } else { - 60 - } + if (mEventStartDateTime.hourOfDay == 23) 59 else 60 } else { config.defaultDuration } @@ -1140,14 +1137,29 @@ class EventActivity : SimpleActivity() { SelectCalendarDialog( activity = this, currCalendar = mCalendarId, - showCalDAVCalendars = false, - showNewCalendarOption = true, + showCalDAVCalendars = config.caldavSync, + showNewCalendarOption = false, addLastUsedOneAsFirstOption = false, showOnlyWritable = true, showManageCalendars = true - ) { - mCalendarId = it.id!! - updateLocalCalendar() + ) { calendar -> + mWasCalendarChanged = true + mCalendarId = calendar.id!! + + if (calendar.caldavCalendarId == 0) { + mEventCalendarId = STORED_LOCALLY_ONLY + config.lastUsedLocalCalendarId = mCalendarId + } else { + mEventCalendarId = calendar.caldavCalendarId + config.lastUsedCaldavCalendarId = calendar.caldavCalendarId + } + + updateCalendarInfo(calendar) + updateReminderTypeImages() + updateCalDAVVisibility() + updateAvailabilityText() + updateStatusText() + updateAccessLevelText() } } @@ -1344,9 +1356,7 @@ class EventActivity : SimpleActivity() { binding.eventAvailability.text = if (mAvailability == Attendees.AVAILABILITY_FREE) { getString(R.string.status_free) } else { - getString( - R.string.status_busy - ) + getString(R.string.status_busy) } } @@ -1378,145 +1388,51 @@ class EventActivity : SimpleActivity() { binding.eventRepetition.text = getRepetitionText(mRepeatInterval) } - private fun updateLocalCalendar() { + private fun updateCalendar() { ensureBackgroundThread { - val calendar = calendarsDB.getCalendarWithId(mCalendarId) - if (calendar != null) { - runOnUiThread { - binding.calendar.text = calendar.title - updateEventColorInfo(calendar.color) - } + val calendar = + calendarsDB.getCalendarWithId(mCalendarId) ?: return@ensureBackgroundThread + runOnUiThread { + updateCalendarInfo(calendar) + updateReminderTypeImages() + updateCalDAVVisibility() } } } - private fun updateCalDAVCalendar() { - if (config.caldavSync) { - binding.eventCaldavCalendarImage.beVisible() - binding.eventCaldavCalendarHolder.beVisible() - binding.eventCaldavCalendarDivider.beVisible() - - val calendars = calDAVHelper.getCalDAVCalendars("", true).filter { - it.canWrite() && config.getSyncedCalendarIdsAsList().contains(it.id) - } - updateCurrentCalendarInfo( - if (mEventCalendarId == STORED_LOCALLY_ONLY) { - null - } else { - getCalendarWithId( - calendars, - getCalendarId() - ) - } - ) + private fun updateCalendarInfo(calendar: CalendarEntity) = binding.apply { + val isCaldav = calendar.caldavCalendarId != 0 + mEventCalendarId = if (isCaldav) calendar.caldavCalendarId else STORED_LOCALLY_ONLY - binding.eventCaldavCalendarHolder.setOnClickListener { - hideKeyboard() - SelectEventCalendarDialog(this, calendars, mEventCalendarId) { - if (mEventCalendarId != STORED_LOCALLY_ONLY && it == STORED_LOCALLY_ONLY) { - mCalendarId = config.lastUsedLocalCalendarId - updateLocalCalendar() - } - mWasCalendarChanged = true - mEventCalendarId = it - config.lastUsedCaldavCalendarId = it - updateCurrentCalendarInfo(getCalendarWithId(calendars, it)) - updateReminderTypeImages() - updateCalDAVVisibility() - updateAvailabilityText() - updateStatusText() - updateAccessLevelText() - } - } + eventCalendarTitle.text = if (isCaldav) { + calendar.caldavDisplayName.ifEmpty { calendar.title } } else { - updateCurrentCalendarInfo(null) + calendar.title } - } - private fun getCalendarId() = - if (mEvent.source == SOURCE_SIMPLE_CALENDAR) { - config.lastUsedCaldavCalendarId + eventCalendarSubtitle.beVisibleIf(!isCaldav || calendar.caldavEmail.isNotEmpty()) + if (isCaldav) { + eventCalendarSubtitle.text = calendar.caldavEmail } else { - mEvent.getCalDAVCalendarId() + eventCalendarSubtitle.text = getString(R.string.offline_never_synced) } - private fun getCalendarWithId(calendars: List, calendarId: Int) = - calendars.firstOrNull { it.id == calendarId } - - private fun updateCurrentCalendarInfo(currentCalendar: CalDAVCalendar?) = binding.apply { - calendarImage.beVisibleIf(currentCalendar == null) - calendarHolder.beVisibleIf(currentCalendar == null) - eventCaldavCalendarDivider.beVisibleIf(currentCalendar == null) - eventCaldavCalendarEmail.beGoneIf(currentCalendar == null) - - if (currentCalendar == null) { - mEventCalendarId = STORED_LOCALLY_ONLY - val mediumMargin = - resources.getDimension(org.fossify.commons.R.dimen.medium_margin).toInt() - eventCaldavCalendarName.apply { - text = getString(R.string.store_locally_only) - setPadding(paddingLeft, paddingTop, paddingRight, mediumMargin) - } - - eventCaldavCalendarHolder.apply { - setPadding(paddingLeft, mediumMargin, paddingRight, mediumMargin) - } - - ensureBackgroundThread { - val calendar = calendarsDB.getCalendarWithId(mCalendarId) - runOnUiThread { - eventColorImage.beVisibleIf(calendar != null) - eventColorHolder.beVisibleIf(calendar != null) - eventColorDivider.beVisibleIf(calendar != null) - if (calendar != null) { - updateEventColorInfo(calendar.color) - } - } - } + val canCustomizeColors = if (isCaldav) { + getEventColors(calendar).isNotEmpty() } else { - eventCaldavCalendarEmail.text = currentCalendar.accountName - - ensureBackgroundThread { - val localCalendar = eventsHelper.getCalendarWithCalDAVCalendarId(currentCalendar.id) - val calendarColor = localCalendar?.color ?: currentCalendar.color - val canCustomizeColors = if (localCalendar != null) { - getEventColors(localCalendar).isNotEmpty() - } else { - false - } - - runOnUiThread { - eventCaldavCalendarName.apply { - text = currentCalendar.displayName - setPadding( - paddingLeft, - paddingTop, - paddingRight, - resources.getDimension(org.fossify.commons.R.dimen.tiny_margin).toInt() - ) - } - - eventCaldavCalendarHolder.apply { - setPadding(paddingLeft, 0, paddingRight, 0) - } + true + } - eventColorImage.beVisibleIf(canCustomizeColors) - eventColorHolder.beVisibleIf(canCustomizeColors) - eventColorDivider.beVisibleIf(canCustomizeColors) - if (canCustomizeColors) { - updateEventColorInfo(calendarColor) - } - } - } + eventColorImage.beVisibleIf(canCustomizeColors) + eventColorHolder.beVisibleIf(canCustomizeColors) + eventColorDivider.beVisibleIf(canCustomizeColors) + if (canCustomizeColors) { + updateEventColorInfo(defaultColor = calendar.color) } } private fun updateEventColorInfo(defaultColor: Int) { - val eventColor = if (mEventColor == 0) { - defaultColor - } else { - mEventColor - } + val eventColor = if (mEventColor == 0) defaultColor else mEventColor binding.eventColor.setFillWithStroke(eventColor, getProperBackgroundColor()) } @@ -1684,48 +1600,37 @@ class EventActivity : SimpleActivity() { generateImportId() } - val newCalendarId = - if ( - !config.caldavSync - || config.lastUsedCaldavCalendarId == 0 - || mEventCalendarId == STORED_LOCALLY_ONLY - ) { - mCalendarId - } else { - calDAVHelper.getCalDAVCalendars("", true).firstOrNull { it.id == mEventCalendarId } - ?.apply { - if (!canWrite()) { - runOnUiThread { - toast(R.string.insufficient_permissions) - } - return - } - } + val selectedCalendar = calendarsDB.getCalendarWithId(mCalendarId) ?: run { + runOnUiThread { toast(org.fossify.commons.R.string.unknown_error_occurred) } + return + } - eventsHelper.getCalendarWithCalDAVCalendarId(mEventCalendarId)?.id - ?: config.lastUsedLocalCalendarId + val selectedCaldavId = selectedCalendar.caldavCalendarId + if (selectedCaldavId != 0) { + val caldavCalendar = + calDAVHelper.getCalDAVCalendars("", true).firstOrNull { it.id == selectedCaldavId } + if (caldavCalendar == null || !caldavCalendar.canWrite()) { + runOnUiThread { toast(R.string.insufficient_permissions) } + return } + config.lastUsedCaldavCalendarId = selectedCaldavId + } else { + config.lastUsedLocalCalendarId = mCalendarId + } - val newSource = if (!config.caldavSync || mEventCalendarId == STORED_LOCALLY_ONLY) { - config.lastUsedLocalCalendarId = newCalendarId + val newCalendarId = mCalendarId + val newSource = if (selectedCaldavId == 0) { SOURCE_SIMPLE_CALENDAR } else { - "$CALDAV-$mEventCalendarId" + "$CALDAV-$selectedCaldavId" } + mEventCalendarId = if (selectedCaldavId == 0) STORED_LOCALLY_ONLY else selectedCaldavId val reminders = getReminders() if (!binding.eventAllDay.isChecked) { - if ((reminders.getOrNull(2)?.minutes ?: 0) < -1) { - reminders.removeAt(2) - } - - if ((reminders.getOrNull(1)?.minutes ?: 0) < -1) { - reminders.removeAt(1) - } - - if ((reminders.getOrNull(0)?.minutes ?: 0) < -1) { - reminders.removeAt(0) - } + if ((reminders.getOrNull(2)?.minutes ?: 0) < -1) reminders.removeAt(2) + if ((reminders.getOrNull(1)?.minutes ?: 0) < -1) reminders.removeAt(1) + if ((reminders.getOrNull(0)?.minutes ?: 0) < -1) reminders.removeAt(0) } val reminder1 = reminders.getOrNull(0) ?: Reminder(REMINDER_OFF, REMINDER_NOTIFICATION) @@ -2041,31 +1946,22 @@ class EventActivity : SimpleActivity() { } private val startDateSetListener = - DatePickerDialog.OnDateSetListener { view, year, monthOfYear, dayOfMonth -> + DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth -> dateSet(year, monthOfYear, dayOfMonth, true) } private val startTimeSetListener = - TimePickerDialog.OnTimeSetListener { view, hourOfDay, minute -> + TimePickerDialog.OnTimeSetListener { _, hourOfDay, minute -> timeSet(hourOfDay, minute, true) } private val endDateSetListener = - DatePickerDialog.OnDateSetListener { view, year, monthOfYear, dayOfMonth -> - dateSet( - year, - monthOfYear, - dayOfMonth, - false - ) + DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth -> + dateSet(year, monthOfYear, dayOfMonth, false) } - private val endTimeSetListener = TimePickerDialog.OnTimeSetListener { view, hourOfDay, minute -> - timeSet( - hourOfDay, - minute, - false - ) + private val endTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hourOfDay, minute -> + timeSet(hourOfDay, minute, false) } private fun dateSet(year: Int, month: Int, day: Int, isStart: Boolean) { @@ -2162,12 +2058,11 @@ class EventActivity : SimpleActivity() { } mAttendees.sortWith( - comparator = compareBy - { it.isMe }.thenBy - { it.status == Attendees.ATTENDEE_STATUS_ACCEPTED }.thenBy - { it.status == Attendees.ATTENDEE_STATUS_DECLINED }.thenBy - { it.status == Attendees.ATTENDEE_STATUS_TENTATIVE }.thenBy - { it.status } + comparator = compareBy { it.isMe } + .thenBy { it.status == Attendees.ATTENDEE_STATUS_ACCEPTED } + .thenBy { it.status == Attendees.ATTENDEE_STATUS_DECLINED } + .thenBy { it.status == Attendees.ATTENDEE_STATUS_TENTATIVE } + .thenBy { it.status } ) mAttendees.reverse() @@ -2175,9 +2070,7 @@ class EventActivity : SimpleActivity() { mAttendees.forEach { val attendee = it val deviceContact = mAvailableContacts.firstOrNull { - it.email.isNotEmpty() - && it.email == attendee.email - && it.photoUri.isNotEmpty() + it.email.isNotEmpty() && it.email == attendee.email && it.photoUri.isNotEmpty() } if (deviceContact != null) { attendee.photoUri = deviceContact.photoUri @@ -2237,7 +2130,7 @@ class EventActivity : SimpleActivity() { val adapter = AutoCompleteTextViewAdapter(this, mAvailableContacts) autoCompleteView.setAdapter(adapter) autoCompleteView.imeOptions = EditorInfo.IME_ACTION_NEXT - autoCompleteView.setOnItemClickListener { parent, view, position, id -> + autoCompleteView.setOnItemClickListener { _, _, position, _ -> val currAttendees = (autoCompleteView.adapter as AutoCompleteTextViewAdapter).resultList val selectedAttendee = currAttendees[position] addSelectedAttendee(selectedAttendee, autoCompleteView, attendeeHolder) @@ -2298,9 +2191,7 @@ class EventActivity : SimpleActivity() { updateAttendeeMe(this, attendee) } - eventContactMeStatus.apply { - beVisibleIf(attendee.isMe) - } + eventContactMeStatus.beVisibleIf(attendee.isMe) if (attendee.isMe) { eventContactAttendee.setOnClickListener { @@ -2445,16 +2336,17 @@ class EventActivity : SimpleActivity() { } val fullName = TextUtils.join(" ", names).trim() if (fullName.isNotEmpty() || photoUri.isNotEmpty()) { - val contact = Attendee( - contactId = id, - name = fullName, - email = "", - status = Attendees.ATTENDEE_STATUS_NONE, - photoUri = photoUri, - isMe = false, - relationship = Attendees.RELATIONSHIP_NONE + contacts.add( + Attendee( + contactId = id, + name = fullName, + email = "", + status = Attendees.ATTENDEE_STATUS_NONE, + photoUri = photoUri, + isMe = false, + relationship = Attendees.RELATIONSHIP_NONE + ) ) - contacts.add(contact) } } return contacts @@ -2471,16 +2363,17 @@ class EventActivity : SimpleActivity() { queryCursor(uri, projection) { cursor -> val id = cursor.getIntValue(Data.CONTACT_ID) val email = cursor.getStringValue(CommonDataKinds.Email.DATA) ?: return@queryCursor - val contact = Attendee( - contactId = id, - name = "", - email = email, - status = Attendees.ATTENDEE_STATUS_NONE, - photoUri = "", - isMe = false, - relationship = Attendees.RELATIONSHIP_NONE + contacts.add( + Attendee( + contactId = id, + name = "", + email = email, + status = Attendees.ATTENDEE_STATUS_NONE, + photoUri = "", + isMe = false, + relationship = Attendees.RELATIONSHIP_NONE + ) ) - contacts.add(contact) } return contacts @@ -2494,8 +2387,7 @@ class EventActivity : SimpleActivity() { eventTimeZoneImage, eventRepetitionImage, eventReminderImage, - calendarImage, - eventCaldavCalendarImage, + eventCalendarImage, eventReminder1Type, eventReminder2Type, eventReminder3Type, diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/TaskActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/TaskActivity.kt index f2970c91f..80e89f763 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/TaskActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/TaskActivity.kt @@ -368,7 +368,7 @@ class TaskActivity : SimpleActivity() { taskDate.setOnClickListener { setupDate() } taskTime.setOnClickListener { setupTime() } - taskTypeHolder.setOnClickListener { showCalendarDialog() } + calendarHolder.setOnClickListener { showCalendarDialog() } taskRepetition.setOnClickListener { showRepeatIntervalDialog() } taskRepetitionRuleHolder.setOnClickListener { showRepetitionRuleDialog() } taskRepetitionLimitHolder.setOnClickListener { showRepetitionTypePicker() } @@ -898,7 +898,7 @@ class TaskActivity : SimpleActivity() { activity = this, currCalendar = mCalendarId, showCalDAVCalendars = false, - showNewCalendarOption = true, + showNewCalendarOption = false, addLastUsedOneAsFirstOption = false, showOnlyWritable = true, showManageCalendars = true @@ -913,7 +913,8 @@ class TaskActivity : SimpleActivity() { val calendar = calendarsDB.getCalendarWithId(mCalendarId) if (calendar != null) { runOnUiThread { - binding.taskType.text = calendar.title + binding.calendarTitle.text = calendar.title + binding.calendarSubtitle.text = getString(R.string.offline_never_synced) updateTaskColorInfo(calendar.color) } } @@ -965,7 +966,7 @@ class TaskActivity : SimpleActivity() { updateTextColors(taskNestedScrollview) val textColor = getProperTextColor() arrayOf( - taskTimeImage, taskReminderImage, taskTypeImage, taskRepetitionImage, taskColorImage + taskTimeImage, taskReminderImage, calendarImage, taskRepetitionImage, taskColorImage ).forEach { it.applyColorFilter(textColor) } diff --git a/app/src/main/kotlin/org/fossify/calendar/dialogs/SelectEventCalendarDialog.kt b/app/src/main/kotlin/org/fossify/calendar/dialogs/SelectEventCalendarDialog.kt deleted file mode 100644 index b1a1b1044..000000000 --- a/app/src/main/kotlin/org/fossify/calendar/dialogs/SelectEventCalendarDialog.kt +++ /dev/null @@ -1,97 +0,0 @@ -package org.fossify.calendar.dialogs - -import android.app.Activity -import android.graphics.Color -import android.view.ViewGroup -import android.widget.RadioGroup -import androidx.appcompat.app.AlertDialog -import org.fossify.calendar.R -import org.fossify.calendar.databinding.DialogSelectRadioGroupBinding -import org.fossify.calendar.databinding.RadioButtonWithColorBinding -import org.fossify.calendar.extensions.eventsHelper -import org.fossify.calendar.helpers.STORED_LOCALLY_ONLY -import org.fossify.calendar.models.CalDAVCalendar -import org.fossify.commons.extensions.getAlertDialogBuilder -import org.fossify.commons.extensions.getProperBackgroundColor -import org.fossify.commons.extensions.setFillWithStroke -import org.fossify.commons.extensions.setupDialogStuff -import org.fossify.commons.extensions.updateTextColors -import org.fossify.commons.extensions.viewBinding -import org.fossify.commons.helpers.ensureBackgroundThread - -class SelectEventCalendarDialog( - val activity: Activity, - val calendars: List, - val currCalendarId: Int, - val callback: (id: Int) -> Unit -) { - private var dialog: AlertDialog? = null - private val radioGroup: RadioGroup - private var wasInit = false - private val binding by activity.viewBinding(DialogSelectRadioGroupBinding::inflate) - - init { - radioGroup = binding.dialogRadioGroup - - ensureBackgroundThread { - calendars.forEach { - val localCalendar = activity.eventsHelper.getCalendarWithCalDAVCalendarId(it.id) - if (localCalendar != null) { - it.color = localCalendar.color - } - } - - activity.runOnUiThread { - calendars.forEach { - addRadioButton(it.getFullTitle(), it.id, it.color) - } - addRadioButton( - activity.getString(R.string.store_locally_only), - STORED_LOCALLY_ONLY, - Color.TRANSPARENT - ) - wasInit = true - activity.updateTextColors(binding.dialogRadioHolder) - } - } - - activity.getAlertDialogBuilder() - .apply { - activity.setupDialogStuff(binding.root, this) { alertDialog -> - dialog = alertDialog - } - } - } - - private fun addRadioButton(title: String, typeId: Int, color: Int) { - val radioBinding = RadioButtonWithColorBinding.inflate(activity.layoutInflater) - radioBinding.dialogRadioButton.apply { - text = title - isChecked = typeId == currCalendarId - id = typeId - } - - if (typeId != STORED_LOCALLY_ONLY) { - radioBinding.dialogRadioColor.setFillWithStroke( - color, - activity.getProperBackgroundColor() - ) - } - - radioBinding.root.setOnClickListener { viewClicked(typeId) } - radioGroup.addView( - radioBinding.root, - RadioGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ) - ) - } - - private fun viewClicked(typeId: Int) { - if (wasInit) { - callback(typeId) - dialog?.dismiss() - } - } -} diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt index b37c4d35e..1f70a900d 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/Config.kt @@ -127,7 +127,7 @@ class Config(context: Context) : BaseConfig(context) { var lastUsedCaldavCalendarId: Int get() = prefs.getInt( LAST_USED_CALDAV_CALENDAR, - getSyncedCalendarIdsAsList().first().toInt() + getSyncedCalendarIdsAsList().first() ) set(calendarId) = prefs.edit().putInt(LAST_USED_CALDAV_CALENDAR, calendarId).apply() diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index a3004435a..482836a03 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -581,94 +581,52 @@ android:importantForAccessibility="no" /> + android:src="@drawable/ic_calendar_vector" /> + android:layout_toEndOf="@+id/event_calendar_image" + android:background="?attr/selectableItemBackground"> + tools:text="@string/regular_event" /> - - - - - - - - - - + tools:text="@string/offline_never_synced" /> @@ -676,7 +634,7 @@ android:id="@+id/calendar_divider" android:layout_width="match_parent" android:layout_height="@dimen/divider_height" - android:layout_below="@+id/calendar_holder" + android:layout_below="@+id/event_calendar_holder" android:background="@color/divider_grey" android:importantForAccessibility="no" /> diff --git a/app/src/main/res/layout/activity_task.xml b/app/src/main/res/layout/activity_task.xml index 5c00b3efb..dedbf330c 100644 --- a/app/src/main/res/layout/activity_task.xml +++ b/app/src/main/res/layout/activity_task.xml @@ -322,43 +322,59 @@ android:importantForAccessibility="no" /> + android:src="@drawable/ic_calendar_vector" /> + android:ellipsize="end" + android:maxLines="1" + android:paddingStart="0dp" + android:paddingTop="@dimen/medium_margin" + android:paddingEnd="@dimen/activity_margin" + android:paddingBottom="@dimen/tiny_margin" + android:textSize="@dimen/day_text_size" + tools:text="@string/regular_event" /> + + @@ -366,7 +382,7 @@ android:id="@+id/task_color_image" android:layout_width="@dimen/smaller_icon_size" android:layout_height="@dimen/smaller_icon_size" - android:layout_below="@+id/task_type_divider" + android:layout_below="@+id/calendar_divider" android:layout_alignTop="@+id/task_color_holder" android:layout_alignBottom="@+id/task_color_holder" android:layout_marginStart="@dimen/normal_margin" @@ -377,7 +393,7 @@ android:id="@+id/task_color_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@+id/task_type_divider" + android:layout_below="@+id/calendar_divider" android:layout_marginTop="@dimen/medium_margin" android:layout_marginBottom="@dimen/medium_margin" android:layout_toEndOf="@+id/task_color_image" diff --git a/app/src/main/res/layout/dialog_select_radio_group.xml b/app/src/main/res/layout/dialog_select_radio_group.xml deleted file mode 100644 index bd36bc9a0..000000000 --- a/app/src/main/res/layout/dialog_select_radio_group.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/app/src/main/res/layout/item_calendar.xml b/app/src/main/res/layout/item_calendar.xml index 32345bc02..82c17da2b 100644 --- a/app/src/main/res/layout/item_calendar.xml +++ b/app/src/main/res/layout/item_calendar.xml @@ -24,7 +24,7 @@ android:layout_toStartOf="@+id/calendar_color" android:paddingStart="@dimen/medium_margin" android:paddingEnd="@dimen/medium_margin" - tools:text="Event type" /> + tools:text="Calendar" /> Calendar with this title already exists Color Local calendar + Offline (never synced) Built-in calendar cannot be deleted Select a calendar Move affected events into the default calendar