autoformatting some files, no real change

This commit is contained in:
tibbi 2021-07-27 15:22:30 +02:00
parent 2d6d675758
commit e4915ccb61
2 changed files with 110 additions and 65 deletions

View File

@ -301,7 +301,8 @@ class EventActivity : SimpleActivity() {
mRepeatRule != mEvent.repeatRule ||
mEventTypeId != mEvent.eventType ||
mWasCalendarChanged ||
hasTimeChanged) {
hasTimeChanged
) {
return true
}
@ -688,11 +689,13 @@ class EventActivity : SimpleActivity() {
}
private fun getBaseString(day: Int): String {
return getString(if (isMaleGender(day)) {
R.string.repeat_every_m
} else {
R.string.repeat_every_f
})
return getString(
if (isMaleGender(day)) {
R.string.repeat_every_m
} else {
R.string.repeat_every_f
}
)
}
private fun isMaleGender(day: Int) = day == 1 || day == 2 || day == 4 || day == 5
@ -705,26 +708,30 @@ class EventActivity : SimpleActivity() {
}
val isMale = isMaleGender(mEventStartDateTime.dayOfWeek)
return getString(when (order) {
1 -> if (isMale) R.string.first_m else R.string.first_f
2 -> if (isMale) R.string.second_m else R.string.second_f
3 -> if (isMale) R.string.third_m else R.string.third_f
4 -> if (isMale) R.string.fourth_m else R.string.fourth_f
5 -> if (isMale) R.string.fifth_m else R.string.fifth_f
else -> if (isMale) R.string.last_m else R.string.last_f
})
return getString(
when (order) {
1 -> if (isMale) R.string.first_m else R.string.first_f
2 -> if (isMale) R.string.second_m else R.string.second_f
3 -> if (isMale) R.string.third_m else R.string.third_f
4 -> if (isMale) R.string.fourth_m else R.string.fourth_f
5 -> if (isMale) R.string.fifth_m else R.string.fifth_f
else -> if (isMale) R.string.last_m else R.string.last_f
}
)
}
private fun getDayString(day: Int): String {
return getString(when (day) {
1 -> R.string.monday_alt
2 -> R.string.tuesday_alt
3 -> R.string.wednesday_alt
4 -> R.string.thursday_alt
5 -> R.string.friday_alt
6 -> R.string.saturday_alt
else -> R.string.sunday_alt
})
return getString(
when (day) {
1 -> R.string.monday_alt
2 -> R.string.tuesday_alt
3 -> R.string.wednesday_alt
4 -> R.string.thursday_alt
5 -> R.string.friday_alt
6 -> R.string.saturday_alt
else -> R.string.sunday_alt
}
)
}
private fun getRepeatXthDayInMonthString(includeBase: Boolean, repeatRule: Int): String {
@ -942,9 +949,11 @@ class EventActivity : SimpleActivity() {
private fun resetTime() {
if (mEventEndDateTime.isBefore(mEventStartDateTime) &&
mEventStartDateTime.dayOfMonth() == mEventEndDateTime.dayOfMonth() &&
mEventStartDateTime.monthOfYear() == mEventEndDateTime.monthOfYear()) {
mEventStartDateTime.monthOfYear() == mEventEndDateTime.monthOfYear()
) {
mEventEndDateTime = mEventEndDateTime.withTime(mEventStartDateTime.hourOfDay, mEventStartDateTime.minuteOfHour, mEventStartDateTime.secondOfMinute, 0)
mEventEndDateTime =
mEventEndDateTime.withTime(mEventStartDateTime.hourOfDay, mEventStartDateTime.minuteOfHour, mEventStartDateTime.secondOfMinute, 0)
updateEndTimeText()
checkStartEndValidity()
}
@ -1256,8 +1265,10 @@ class EventActivity : SimpleActivity() {
private fun setupStartDate() {
hideKeyboard()
config.backgroundColor.getContrastColor()
val datepicker = DatePickerDialog(this, mDialogTheme, startDateSetListener, mEventStartDateTime.year, mEventStartDateTime.monthOfYear - 1,
mEventStartDateTime.dayOfMonth)
val datepicker = DatePickerDialog(
this, mDialogTheme, startDateSetListener, mEventStartDateTime.year, mEventStartDateTime.monthOfYear - 1,
mEventStartDateTime.dayOfMonth
)
datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY
datepicker.show()
@ -1265,13 +1276,22 @@ class EventActivity : SimpleActivity() {
private fun setupStartTime() {
hideKeyboard()
TimePickerDialog(this, mDialogTheme, startTimeSetListener, mEventStartDateTime.hourOfDay, mEventStartDateTime.minuteOfHour, config.use24HourFormat).show()
TimePickerDialog(
this,
mDialogTheme,
startTimeSetListener,
mEventStartDateTime.hourOfDay,
mEventStartDateTime.minuteOfHour,
config.use24HourFormat
).show()
}
private fun setupEndDate() {
hideKeyboard()
val datepicker = DatePickerDialog(this, mDialogTheme, endDateSetListener, mEventEndDateTime.year, mEventEndDateTime.monthOfYear - 1,
mEventEndDateTime.dayOfMonth)
val datepicker = DatePickerDialog(
this, mDialogTheme, endDateSetListener, mEventEndDateTime.year, mEventEndDateTime.monthOfYear - 1,
mEventEndDateTime.dayOfMonth
)
datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY
datepicker.show()
@ -1510,21 +1530,25 @@ class EventActivity : SimpleActivity() {
}
private fun getAttendeeStatusImage(attendee: Attendee): Drawable {
return resources.getDrawable(when (attendee.status) {
Attendees.ATTENDEE_STATUS_ACCEPTED -> R.drawable.ic_check_green
Attendees.ATTENDEE_STATUS_DECLINED -> R.drawable.ic_cross_red
else -> R.drawable.ic_question_yellow
})
return resources.getDrawable(
when (attendee.status) {
Attendees.ATTENDEE_STATUS_ACCEPTED -> R.drawable.ic_check_green
Attendees.ATTENDEE_STATUS_DECLINED -> R.drawable.ic_cross_red
else -> R.drawable.ic_question_yellow
}
)
}
private fun updateAttendeeMe(holder: RelativeLayout, attendee: Attendee) {
holder.apply {
event_contact_me_status.text = getString(when (attendee.status) {
Attendees.ATTENDEE_STATUS_ACCEPTED -> R.string.going
Attendees.ATTENDEE_STATUS_DECLINED -> R.string.not_going
Attendees.ATTENDEE_STATUS_TENTATIVE -> R.string.maybe_going
else -> R.string.invited
})
event_contact_me_status.text = getString(
when (attendee.status) {
Attendees.ATTENDEE_STATUS_ACCEPTED -> R.string.going
Attendees.ATTENDEE_STATUS_DECLINED -> R.string.not_going
Attendees.ATTENDEE_STATUS_TENTATIVE -> R.string.maybe_going
else -> R.string.invited
}
)
event_contact_status_image.apply {
beVisibleIf(attendee.showStatusImage())
@ -1576,7 +1600,8 @@ class EventActivity : SimpleActivity() {
StructuredName.MIDDLE_NAME,
StructuredName.FAMILY_NAME,
StructuredName.SUFFIX,
StructuredName.PHOTO_THUMBNAIL_URI)
StructuredName.PHOTO_THUMBNAIL_URI
)
val selection = "${Data.MIMETYPE} = ?"
val selectionArgs = arrayOf(StructuredName.CONTENT_ITEM_TYPE)
@ -1621,8 +1646,10 @@ class EventActivity : SimpleActivity() {
private fun updateIconColors() {
event_show_on_map.applyColorFilter(getAdjustedPrimaryColor())
val textColor = config.textColor
arrayOf(event_time_image, event_time_zone_image, event_repetition_image, event_reminder_image, event_type_image, event_caldav_calendar_image,
event_reminder_1_type, event_reminder_2_type, event_reminder_3_type, event_attendees_image).forEach {
arrayOf(
event_time_image, event_time_zone_image, event_repetition_image, event_reminder_image, event_type_image, event_caldav_calendar_image,
event_reminder_1_type, event_reminder_2_type, event_reminder_3_type, event_attendees_image
).forEach {
it.applyColorFilter(textColor)
}
}

View File

@ -128,7 +128,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
override fun onResume() {
super.onResume()
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredAdjustedPrimaryColor != getAdjustedPrimaryColor()
|| mStoredDayCode != Formatter.getTodayCode() || mStoredDimPastEvents != config.dimPastEvents || mStoredHighlightWeekends != config.highlightWeekends) {
|| mStoredDayCode != Formatter.getTodayCode() || mStoredDimPastEvents != config.dimPastEvents || mStoredHighlightWeekends != config.highlightWeekends
) {
updateViewPager()
}
@ -430,7 +431,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
RadioItem(MONTHLY_VIEW, getString(R.string.monthly_view)),
RadioItem(MONTHLY_DAILY_VIEW, getString(R.string.monthly_daily_view)),
RadioItem(YEARLY_VIEW, getString(R.string.yearly_view)),
RadioItem(EVENTS_LIST_VIEW, getString(R.string.simple_event_list)))
RadioItem(EVENTS_LIST_VIEW, getString(R.string.simple_event_list))
)
RadioGroupDialog(this, items, config.storedView) {
resetActionBarTitle()
@ -578,22 +580,26 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun handleParseResult(result: ImportResult) {
toast(when (result) {
ImportResult.IMPORT_NOTHING_NEW -> R.string.no_new_items
ImportResult.IMPORT_OK -> R.string.holidays_imported_successfully
ImportResult.IMPORT_PARTIAL -> R.string.importing_some_holidays_failed
else -> R.string.importing_holidays_failed
}, Toast.LENGTH_LONG)
toast(
when (result) {
ImportResult.IMPORT_NOTHING_NEW -> R.string.no_new_items
ImportResult.IMPORT_OK -> R.string.holidays_imported_successfully
ImportResult.IMPORT_PARTIAL -> R.string.importing_some_holidays_failed
else -> R.string.importing_holidays_failed
}, Toast.LENGTH_LONG
)
}
private fun addContactEvents(birthdays: Boolean, reminders: ArrayList<Int>, initEventsFound: Int, initEventsAdded: Int, callback: (Int) -> Unit) {
var eventsFound = initEventsFound
var eventsAdded = initEventsAdded
val uri = Data.CONTENT_URI
val projection = arrayOf(Contacts.DISPLAY_NAME,
val projection = arrayOf(
Contacts.DISPLAY_NAME,
CommonDataKinds.Event.CONTACT_ID,
CommonDataKinds.Event.CONTACT_LAST_UPDATED_TIMESTAMP,
CommonDataKinds.Event.START_DATE)
CommonDataKinds.Event.START_DATE
)
val selection = "${Data.MIMETYPE} = ? AND ${CommonDataKinds.Event.TYPE} = ?"
val type = if (birthdays) CommonDataKinds.Event.TYPE_BIRTHDAY else CommonDataKinds.Event.TYPE_ANNIVERSARY
@ -624,9 +630,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
val timestamp = date.time / 1000L
val lastUpdated = cursor.getLongValue(CommonDataKinds.Event.CONTACT_LAST_UPDATED_TIMESTAMP)
val event = Event(null, timestamp, timestamp, name, reminder1Minutes = reminders[0], reminder2Minutes = reminders[1],
val event = Event(
null, timestamp, timestamp, name, reminder1Minutes = reminders[0], reminder2Minutes = reminders[1],
reminder3Minutes = reminders[2], importId = contactId, timeZone = DateTimeZone.getDefault().id, flags = FLAG_ALL_DAY,
repeatInterval = YEAR, repeatRule = REPEAT_SAME_DAY, eventType = eventTypeId, source = source, lastUpdated = lastUpdated)
repeatInterval = YEAR, repeatRule = REPEAT_SAME_DAY, eventType = eventTypeId, source = source, lastUpdated = lastUpdated
)
val importIDsToDelete = ArrayList<String>()
for ((key, value) in importIDs) {
@ -659,7 +667,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
}
private fun addPrivateEvents(birthdays: Boolean, contacts: ArrayList<SimpleContact>, reminders: ArrayList<Int>, callback: (eventsFound: Int, eventsAdded: Int) -> Unit) {
private fun addPrivateEvents(
birthdays: Boolean,
contacts: ArrayList<SimpleContact>,
reminders: ArrayList<Int>,
callback: (eventsFound: Int, eventsAdded: Int) -> Unit
) {
var eventsAdded = 0
var eventsFound = 0
if (contacts.isEmpty()) {
@ -695,9 +708,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
val timestamp = date.time / 1000L
val lastUpdated = System.currentTimeMillis()
val event = Event(null, timestamp, timestamp, contact.name, reminder1Minutes = reminders[0], reminder2Minutes = reminders[1],
val event = Event(
null, timestamp, timestamp, contact.name, reminder1Minutes = reminders[0], reminder2Minutes = reminders[1],
reminder3Minutes = reminders[2], importId = contact.contactId.toString(), timeZone = DateTimeZone.getDefault().id, flags = FLAG_ALL_DAY,
repeatInterval = YEAR, repeatRule = REPEAT_SAME_DAY, eventType = eventTypeId, source = source, lastUpdated = lastUpdated)
repeatInterval = YEAR, repeatRule = REPEAT_SAME_DAY, eventType = eventTypeId, source = source, lastUpdated = lastUpdated
)
val importIDsToDelete = ArrayList<String>()
for ((key, value) in importIDs) {
@ -939,11 +954,13 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
toast(R.string.no_entries_for_exporting)
} else {
IcsExporter().exportEvents(this, outputStream, events, true) {
toast(when (it) {
ExportResult.EXPORT_OK -> R.string.exporting_successful
ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed
else -> R.string.exporting_failed
})
toast(
when (it) {
ExportResult.EXPORT_OK -> R.string.exporting_successful
ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed
else -> R.string.exporting_failed
}
)
}
}
}
@ -965,7 +982,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
FAQItem(R.string.faq_4_title, R.string.faq_4_text),
FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons),
FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons),
FAQItem(R.string.faq_7_title_commons, R.string.faq_7_text_commons))
FAQItem(R.string.faq_7_title_commons, R.string.faq_7_text_commons)
)
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
}