Migrate from kotlin synthetics to View binding

This commit is contained in:
Naveen 2023-09-03 18:55:41 +05:30
parent 670e5d6a87
commit 7867e71cde
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3
62 changed files with 1846 additions and 2142 deletions

View file

@ -28,6 +28,8 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.AutoCompleteTextViewAdapter
import com.simplemobiletools.calendar.pro.databinding.ActivityEventBinding
import com.simplemobiletools.calendar.pro.databinding.ItemAttendeeBinding
import com.simplemobiletools.calendar.pro.dialogs.*
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.*
@ -40,10 +42,6 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.views.MyAutoCompleteTextView
import kotlinx.android.synthetic.main.activity_event.*
import kotlinx.android.synthetic.main.activity_event.view.event_reminder_2
import kotlinx.android.synthetic.main.activity_event.view.event_reminder_3
import kotlinx.android.synthetic.main.item_attendee.view.*
import org.joda.time.DateTime
import org.joda.time.DateTimeZone
import java.util.TimeZone
@ -85,10 +83,12 @@ class EventActivity : SimpleActivity() {
private lateinit var mEventEndDateTime: DateTime
private lateinit var mEvent: Event
private val binding by viewBinding(ActivityEventBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_event)
setContentView(binding.root)
setupOptionsMenu()
refreshMenuItems()
@ -96,8 +96,8 @@ class EventActivity : SimpleActivity() {
return
}
updateMaterialActivityViews(event_coordinator, event_holder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(event_nested_scrollview, event_toolbar)
updateMaterialActivityViews(binding.eventCoordinator, binding.eventHolder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(binding.eventNestedScrollview, binding.eventToolbar)
val intent = intent ?: return
mWasContactsPermissionChecked = hasPermission(PERMISSION_READ_CONTACTS)
@ -123,7 +123,7 @@ class EventActivity : SimpleActivity() {
override fun onResume() {
super.onResume()
setupToolbar(event_toolbar, NavigationIcon.Arrow)
setupToolbar(binding.eventToolbar, NavigationIcon.Arrow)
}
override fun onBackPressed() {
@ -235,7 +235,7 @@ class EventActivity : SimpleActivity() {
super.onActivityResult(requestCode, resultCode, resultData)
}
private fun gotEvent(savedInstanceState: Bundle?, localEventType: EventType?, event: Event?) {
private fun gotEvent(savedInstanceState: Bundle?, localEventType: EventType?, event: Event?) = binding.apply {
if (localEventType == null || localEventType.caldavCalendarId != 0) {
config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID
}
@ -251,7 +251,7 @@ class EventActivity : SimpleActivity() {
if (intent.getBooleanExtra(IS_DUPLICATE_INTENT, false)) {
mEvent.id = null
event_toolbar.title = getString(R.string.new_event)
eventToolbar.title = getString(R.string.new_event)
} else {
cancelNotification(mEvent.id!!)
}
@ -274,24 +274,24 @@ class EventActivity : SimpleActivity() {
updateCalDAVCalendar()
}
event_show_on_map.setOnClickListener { showOnMap() }
event_start_date.setOnClickListener { setupStartDate() }
event_start_time.setOnClickListener { setupStartTime() }
event_end_date.setOnClickListener { setupEndDate() }
event_end_time.setOnClickListener { setupEndTime() }
event_time_zone.setOnClickListener { setupTimeZone() }
eventShowOnMap.setOnClickListener { showOnMap() }
eventStartDate.setOnClickListener { setupStartDate() }
eventStartTime.setOnClickListener { setupStartTime() }
eventEndDate.setOnClickListener { setupEndDate() }
eventEndTime.setOnClickListener { setupEndTime() }
eventTimeZone.setOnClickListener { setupTimeZone() }
event_all_day.setOnCheckedChangeListener { _, isChecked -> toggleAllDay(isChecked) }
event_repetition.setOnClickListener { showRepeatIntervalDialog() }
event_repetition_rule_holder.setOnClickListener { showRepetitionRuleDialog() }
event_repetition_limit_holder.setOnClickListener { showRepetitionTypePicker() }
eventAllDay.setOnCheckedChangeListener { _, isChecked -> toggleAllDay(isChecked) }
eventRepetition.setOnClickListener { showRepeatIntervalDialog() }
eventRepetitionRuleHolder.setOnClickListener { showRepetitionRuleDialog() }
eventRepetitionLimitHolder.setOnClickListener { showRepetitionTypePicker() }
event_reminder_1.setOnClickListener {
eventReminder1.setOnClickListener {
handleNotificationAvailability {
if (config.wasAlarmWarningShown) {
showReminder1Dialog()
} else {
ReminderWarningDialog(this) {
ReminderWarningDialog(this@EventActivity) {
config.wasAlarmWarningShown = true
showReminder1Dialog()
}
@ -299,31 +299,31 @@ class EventActivity : SimpleActivity() {
}
}
event_reminder_2.setOnClickListener { showReminder2Dialog() }
event_reminder_3.setOnClickListener { showReminder3Dialog() }
eventReminder2.setOnClickListener { showReminder2Dialog() }
eventReminder3.setOnClickListener { showReminder3Dialog() }
event_reminder_1_type.setOnClickListener {
eventReminder1Type.setOnClickListener {
showReminderTypePicker(mReminder1Type) {
mReminder1Type = it
updateReminderTypeImage(event_reminder_1_type, Reminder(mReminder1Minutes, mReminder1Type))
updateReminderTypeImage(eventReminder1Type, Reminder(mReminder1Minutes, mReminder1Type))
}
}
event_reminder_2_type.setOnClickListener {
eventReminder2Type.setOnClickListener {
showReminderTypePicker(mReminder2Type) {
mReminder2Type = it
updateReminderTypeImage(event_reminder_2_type, Reminder(mReminder2Minutes, mReminder2Type))
updateReminderTypeImage(eventReminder2Type, Reminder(mReminder2Minutes, mReminder2Type))
}
}
event_reminder_3_type.setOnClickListener {
eventReminder3Type.setOnClickListener {
showReminderTypePicker(mReminder3Type) {
mReminder3Type = it
updateReminderTypeImage(event_reminder_3_type, Reminder(mReminder3Minutes, mReminder3Type))
updateReminderTypeImage(eventReminder3Type, Reminder(mReminder3Minutes, mReminder3Type))
}
}
event_availability.setOnClickListener {
eventAvailability.setOnClickListener {
showAvailabilityPicker(mAvailability) {
mAvailability = it
updateAvailabilityText()
@ -331,21 +331,21 @@ class EventActivity : SimpleActivity() {
}
}
event_type_holder.setOnClickListener { showEventTypeDialog() }
event_all_day.apply {
eventTypeHolder.setOnClickListener { showEventTypeDialog() }
eventAllDay.apply {
isChecked = mEvent.getIsAllDay()
jumpDrawablesToCurrentState()
}
event_all_day_holder.setOnClickListener {
event_all_day.toggle()
eventAllDayHolder.setOnClickListener {
eventAllDay.toggle()
}
event_color_holder.setOnClickListener {
eventColorHolder.setOnClickListener {
showEventColorDialog()
}
updateTextColors(event_nested_scrollview)
updateTextColors(eventNestedScrollview)
updateIconColors()
refreshMenuItems()
showOrHideTimeZone()
@ -353,7 +353,7 @@ class EventActivity : SimpleActivity() {
private fun refreshMenuItems() {
if (::mEvent.isInitialized) {
event_toolbar.menu.apply {
binding.eventToolbar.menu.apply {
findItem(R.id.delete).isVisible = mEvent.id != null
findItem(R.id.share).isVisible = mEvent.id != null
findItem(R.id.duplicate).isVisible = mEvent.id != null
@ -362,7 +362,7 @@ class EventActivity : SimpleActivity() {
}
private fun setupOptionsMenu() {
event_toolbar.setOnMenuItemClickListener { menuItem ->
binding.eventToolbar.setOnMenuItemClickListener { menuItem ->
if (!::mEvent.isInitialized) {
return@setOnMenuItemClickListener true
}
@ -429,10 +429,10 @@ class EventActivity : SimpleActivity() {
}
val reminders = getReminders()
if (event_title.text.toString() != mEvent.title ||
event_location.text.toString() != mEvent.location ||
event_description.text.toString() != mEvent.description ||
event_time_zone.text != mEvent.getTimeZoneString() ||
if (binding.eventTitle.text.toString() != mEvent.title ||
binding.eventLocation.text.toString() != mEvent.location ||
binding.eventDescription.text.toString() != mEvent.description ||
binding.eventTimeZone.text != mEvent.getTimeZoneString() ||
reminders != mEvent.getReminders() ||
mRepeatInterval != mEvent.repeatInterval ||
mRepeatRule != mEvent.repeatRule ||
@ -467,7 +467,7 @@ class EventActivity : SimpleActivity() {
mOriginalEndTS = realStart + duration
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
event_toolbar.title = getString(R.string.edit_event)
binding.eventToolbar.title = getString(R.string.edit_event)
mOriginalTimeZone = mEvent.timeZone
if (config.allowChangingTimeZones) {
try {
@ -483,9 +483,9 @@ class EventActivity : SimpleActivity() {
mEventEndDateTime = Formatter.getDateTimeFromTS(realStart + duration)
}
event_title.setText(mEvent.title)
event_location.setText(mEvent.location)
event_description.setText(mEvent.description)
binding.eventTitle.setText(mEvent.title)
binding.eventLocation.setText(mEvent.location)
binding.eventDescription.setText(mEvent.description)
mReminder1Minutes = mEvent.reminder1Minutes
mReminder2Minutes = mEvent.reminder2Minutes
@ -510,8 +510,8 @@ class EventActivity : SimpleActivity() {
private fun setupNewEvent() {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
event_title.requestFocus()
event_toolbar.title = getString(R.string.new_event)
binding.eventTitle.requestFocus()
binding.eventToolbar.title = getString(R.string.new_event)
if (config.defaultEventTypeId != -1L) {
config.lastUsedCaldavCalendarId = mStoredEventTypes.firstOrNull { it.id == config.defaultEventTypeId }?.caldavCalendarId ?: 0
}
@ -528,15 +528,15 @@ class EventActivity : SimpleActivity() {
if (intent.getBooleanExtra("allDay", false)) {
mEvent.flags = mEvent.flags or FLAG_ALL_DAY
event_all_day.isChecked = true
binding.eventAllDay.isChecked = true
toggleAllDay(true)
}
event_title.setText(intent.getStringExtra("title"))
event_location.setText(intent.getStringExtra("eventLocation"))
event_description.setText(intent.getStringExtra("description"))
if (event_description.value.isNotEmpty()) {
event_description.movementMethod = LinkMovementMethod.getInstance()
binding.eventTitle.setText(intent.getStringExtra("title"))
binding.eventLocation.setText(intent.getStringExtra("eventLocation"))
binding.eventDescription.setText(intent.getStringExtra("description"))
if (binding.eventDescription.value.isNotEmpty()) {
binding.eventDescription.movementMethod = LinkMovementMethod.getInstance()
}
} else {
val startTS = intent.getLongExtra(NEW_EVENT_START_TS, 0L)
@ -627,10 +627,10 @@ class EventActivity : SimpleActivity() {
}
private fun checkRepeatTexts(limit: Int) {
event_repetition_limit_holder.beGoneIf(limit == 0)
binding.eventRepetitionLimitHolder.beGoneIf(limit == 0)
checkRepetitionLimitText()
event_repetition_rule_holder.beVisibleIf(mRepeatInterval.isXWeeklyRepetition() || mRepeatInterval.isXMonthlyRepetition() || mRepeatInterval.isXYearlyRepetition())
binding.eventRepetitionRuleHolder.beVisibleIf(mRepeatInterval.isXWeeklyRepetition() || mRepeatInterval.isXMonthlyRepetition() || mRepeatInterval.isXYearlyRepetition())
checkRepetitionRuleText()
}
@ -647,20 +647,20 @@ class EventActivity : SimpleActivity() {
}
private fun checkRepetitionLimitText() {
event_repetition_limit.text = when {
binding.eventRepetitionLimit.text = when {
mRepeatLimit == 0L -> {
event_repetition_limit_label.text = getString(R.string.repeat)
binding.eventRepetitionLimitLabel.text = getString(R.string.repeat)
resources.getString(R.string.forever)
}
mRepeatLimit > 0 -> {
event_repetition_limit_label.text = getString(R.string.repeat_till)
binding.eventRepetitionLimitLabel.text = getString(R.string.repeat_till)
val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit)
Formatter.getFullDate(this, repeatLimitDateTime)
}
else -> {
event_repetition_limit_label.text = getString(R.string.repeat)
binding.eventRepetitionLimitLabel.text = getString(R.string.repeat)
"${-mRepeatLimit} ${getString(R.string.times)}"
}
}
@ -794,23 +794,23 @@ class EventActivity : SimpleActivity() {
private fun checkRepetitionRuleText() {
when {
mRepeatInterval.isXWeeklyRepetition() -> {
event_repetition_rule.text = if (mRepeatRule == EVERY_DAY_BIT) getString(R.string.every_day) else getShortDaysFromBitmask(mRepeatRule)
binding.eventRepetitionRule.text = if (mRepeatRule == EVERY_DAY_BIT) getString(R.string.every_day) else getShortDaysFromBitmask(mRepeatRule)
}
mRepeatInterval.isXMonthlyRepetition() -> {
val repeatString = if (mRepeatRule == REPEAT_ORDER_WEEKDAY_USE_LAST || mRepeatRule == REPEAT_ORDER_WEEKDAY)
R.string.repeat else R.string.repeat_on
event_repetition_rule_label.text = getString(repeatString)
event_repetition_rule.text = getMonthlyRepetitionRuleText()
binding.eventRepetitionRuleLabel.text = getString(repeatString)
binding.eventRepetitionRule.text = getMonthlyRepetitionRuleText()
}
mRepeatInterval.isXYearlyRepetition() -> {
val repeatString = if (mRepeatRule == REPEAT_ORDER_WEEKDAY_USE_LAST || mRepeatRule == REPEAT_ORDER_WEEKDAY)
R.string.repeat else R.string.repeat_on
event_repetition_rule_label.text = getString(repeatString)
event_repetition_rule.text = getYearlyRepetitionRuleText()
binding.eventRepetitionRuleLabel.text = getString(repeatString)
binding.eventRepetitionRule.text = getYearlyRepetitionRuleText()
}
}
}
@ -903,12 +903,12 @@ class EventActivity : SimpleActivity() {
}
private fun updateReminder1Text() {
event_reminder_1.text = getFormattedMinutes(mReminder1Minutes)
binding.eventReminder1.text = getFormattedMinutes(mReminder1Minutes)
}
private fun updateReminder2Text() {
event_reminder_2.apply {
beGoneIf(event_reminder_2.isGone() && mReminder1Minutes == REMINDER_OFF)
binding.eventReminder2.apply {
beGoneIf(isGone() && mReminder1Minutes == REMINDER_OFF)
if (mReminder2Minutes == REMINDER_OFF) {
text = resources.getString(R.string.add_another_reminder)
alpha = 0.4f
@ -920,8 +920,8 @@ class EventActivity : SimpleActivity() {
}
private fun updateReminder3Text() {
event_reminder_3.apply {
beGoneIf(event_reminder_3.isGone() && (mReminder2Minutes == REMINDER_OFF || mReminder1Minutes == REMINDER_OFF))
binding.eventReminder3.apply {
beGoneIf(isGone() && (mReminder2Minutes == REMINDER_OFF || mReminder1Minutes == REMINDER_OFF))
if (mReminder3Minutes == REMINDER_OFF) {
text = resources.getString(R.string.add_another_reminder)
alpha = 0.4f
@ -953,19 +953,19 @@ class EventActivity : SimpleActivity() {
}
private fun updateReminderTypeImages() {
updateReminderTypeImage(event_reminder_1_type, Reminder(mReminder1Minutes, mReminder1Type))
updateReminderTypeImage(event_reminder_2_type, Reminder(mReminder2Minutes, mReminder2Type))
updateReminderTypeImage(event_reminder_3_type, Reminder(mReminder3Minutes, mReminder3Type))
updateReminderTypeImage(binding.eventReminder1Type, Reminder(mReminder1Minutes, mReminder1Type))
updateReminderTypeImage(binding.eventReminder2Type, Reminder(mReminder2Minutes, mReminder2Type))
updateReminderTypeImage(binding.eventReminder3Type, Reminder(mReminder3Minutes, mReminder3Type))
}
private fun updateCalDAVVisibility() {
val isSyncedEvent = mEventCalendarId != STORED_LOCALLY_ONLY
event_attendees_image.beVisibleIf(isSyncedEvent)
event_attendees_holder.beVisibleIf(isSyncedEvent)
event_attendees_divider.beVisibleIf(isSyncedEvent)
event_availability_divider.beVisibleIf(isSyncedEvent)
event_availability_image.beVisibleIf(isSyncedEvent)
event_availability.beVisibleIf(isSyncedEvent)
binding.eventAttendeesImage.beVisibleIf(isSyncedEvent)
binding.eventAttendeesHolder.beVisibleIf(isSyncedEvent)
binding.eventAttendeesDivider.beVisibleIf(isSyncedEvent)
binding.eventAvailabilityDivider.beVisibleIf(isSyncedEvent)
binding.eventAvailabilityImage.beVisibleIf(isSyncedEvent)
binding.eventAvailability.beVisibleIf(isSyncedEvent)
}
private fun updateReminderTypeImage(view: ImageView, reminder: Reminder) {
@ -978,15 +978,15 @@ class EventActivity : SimpleActivity() {
private fun updateAvailabilityImage() {
val drawable = if (mAvailability == Attendees.AVAILABILITY_FREE) R.drawable.ic_event_available_vector else R.drawable.ic_event_busy_vector
val icon = resources.getColoredDrawableWithColor(drawable, getProperTextColor())
event_availability_image.setImageDrawable(icon)
binding.eventAvailabilityImage.setImageDrawable(icon)
}
private fun updateAvailabilityText() {
event_availability.text = if (mAvailability == Attendees.AVAILABILITY_FREE) getString(R.string.status_free) else getString(R.string.status_busy)
binding.eventAvailability.text = if (mAvailability == Attendees.AVAILABILITY_FREE) getString(R.string.status_free) else getString(R.string.status_busy)
}
private fun updateRepetitionText() {
event_repetition.text = getRepetitionText(mRepeatInterval)
binding.eventRepetition.text = getRepetitionText(mRepeatInterval)
}
private fun updateEventType() {
@ -994,7 +994,7 @@ class EventActivity : SimpleActivity() {
val eventType = eventTypesDB.getEventTypeWithId(mEventTypeId)
if (eventType != null) {
runOnUiThread {
event_type.text = eventType.title
binding.eventType.text = eventType.title
updateEventColorInfo(eventType.color)
}
}
@ -1003,16 +1003,16 @@ class EventActivity : SimpleActivity() {
private fun updateCalDAVCalendar() {
if (config.caldavSync) {
event_caldav_calendar_image.beVisible()
event_caldav_calendar_holder.beVisible()
event_caldav_calendar_divider.beVisible()
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()))
event_caldav_calendar_holder.setOnClickListener {
binding.eventCaldavCalendarHolder.setOnClickListener {
hideKeyboard()
SelectEventCalendarDialog(this, calendars, mEventCalendarId) {
if (mEventCalendarId != STORED_LOCALLY_ONLY && it == STORED_LOCALLY_ONLY) {
@ -1038,37 +1038,37 @@ class EventActivity : SimpleActivity() {
private fun getCalendarWithId(calendars: List<CalDAVCalendar>, calendarId: Int) = calendars.firstOrNull { it.id == calendarId }
private fun updateCurrentCalendarInfo(currentCalendar: CalDAVCalendar?) {
event_type_image.beVisibleIf(currentCalendar == null)
event_type_holder.beVisibleIf(currentCalendar == null)
event_caldav_calendar_divider.beVisibleIf(currentCalendar == null)
event_caldav_calendar_email.beGoneIf(currentCalendar == null)
private fun updateCurrentCalendarInfo(currentCalendar: CalDAVCalendar?) = binding.apply {
eventTypeImage.beVisibleIf(currentCalendar == null)
eventTypeHolder.beVisibleIf(currentCalendar == null)
eventCaldavCalendarDivider.beVisibleIf(currentCalendar == null)
eventCaldavCalendarEmail.beGoneIf(currentCalendar == null)
if (currentCalendar == null) {
mEventCalendarId = STORED_LOCALLY_ONLY
val mediumMargin = resources.getDimension(R.dimen.medium_margin).toInt()
event_caldav_calendar_name.apply {
eventCaldavCalendarName.apply {
text = getString(R.string.store_locally_only)
setPadding(paddingLeft, paddingTop, paddingRight, mediumMargin)
}
event_caldav_calendar_holder.apply {
eventCaldavCalendarHolder.apply {
setPadding(paddingLeft, mediumMargin, paddingRight, mediumMargin)
}
ensureBackgroundThread {
val eventType = eventTypesDB.getEventTypeWithId(mEventTypeId)
runOnUiThread {
event_color_image.beVisibleIf(eventType != null)
event_color_holder.beVisibleIf(eventType != null)
event_color_divider.beVisibleIf(eventType != null)
eventColorImage.beVisibleIf(eventType != null)
eventColorHolder.beVisibleIf(eventType != null)
eventColorDivider.beVisibleIf(eventType != null)
if (eventType != null) {
updateEventColorInfo(eventType.color)
}
}
}
} else {
event_caldav_calendar_email.text = currentCalendar.accountName
eventCaldavCalendarEmail.text = currentCalendar.accountName
ensureBackgroundThread {
val eventType = eventsHelper.getEventTypeWithCalDAVCalendarId(currentCalendar.id)
@ -1080,18 +1080,18 @@ class EventActivity : SimpleActivity() {
}
runOnUiThread {
event_caldav_calendar_name.apply {
eventCaldavCalendarName.apply {
text = currentCalendar.displayName
setPadding(paddingLeft, paddingTop, paddingRight, resources.getDimension(R.dimen.tiny_margin).toInt())
}
event_caldav_calendar_holder.apply {
eventCaldavCalendarHolder.apply {
setPadding(paddingLeft, 0, paddingRight, 0)
}
event_color_image.beVisibleIf(canCustomizeColors)
event_color_holder.beVisibleIf(canCustomizeColors)
event_color_divider.beVisibleIf(canCustomizeColors)
eventColorImage.beVisibleIf(canCustomizeColors)
eventColorHolder.beVisibleIf(canCustomizeColors)
eventColorDivider.beVisibleIf(canCustomizeColors)
if (canCustomizeColors) {
updateEventColorInfo(calendarColor)
}
@ -1106,7 +1106,7 @@ class EventActivity : SimpleActivity() {
} else {
mEventColor
}
event_color.setFillWithStroke(eventColor, getProperBackgroundColor())
binding.eventColor.setFillWithStroke(eventColor, getProperBackgroundColor())
}
private fun getEventColors(eventType: EventType): IntArray {
@ -1129,8 +1129,8 @@ class EventActivity : SimpleActivity() {
private fun toggleAllDay(isAllDay: Boolean) {
hideKeyboard()
mIsAllDayEvent = isAllDay
event_start_time.beGoneIf(isAllDay)
event_end_time.beGoneIf(isAllDay)
binding.eventStartTime.beGoneIf(isAllDay)
binding.eventEndTime.beGoneIf(isAllDay)
updateTimeZoneText()
showOrHideTimeZone()
resetTime()
@ -1138,9 +1138,9 @@ class EventActivity : SimpleActivity() {
private fun showOrHideTimeZone() {
val allowChangingTimeZones = config.allowChangingTimeZones && !mIsAllDayEvent
event_time_zone_divider.beVisibleIf(allowChangingTimeZones)
event_time_zone_image.beVisibleIf(allowChangingTimeZones)
event_time_zone.beVisibleIf(allowChangingTimeZones)
binding.eventTimeZoneDivider.beVisibleIf(allowChangingTimeZones)
binding.eventTimeZoneImage.beVisibleIf(allowChangingTimeZones)
binding.eventTimeZone.beVisibleIf(allowChangingTimeZones)
}
private fun shareEvent() {
@ -1196,11 +1196,11 @@ class EventActivity : SimpleActivity() {
}
private fun saveEvent() {
val newTitle = event_title.value
val newTitle = binding.eventTitle.value
if (newTitle.isEmpty()) {
toast(R.string.title_empty)
runOnUiThread {
event_title.requestFocus()
binding.eventTitle.requestFocus()
}
return
}
@ -1248,7 +1248,7 @@ class EventActivity : SimpleActivity() {
}
val reminders = getReminders()
if (!event_all_day.isChecked) {
if (!binding.eventAllDay.isChecked) {
if ((reminders.getOrNull(2)?.minutes ?: 0) < -1) {
reminders.removeAt(2)
}
@ -1282,7 +1282,7 @@ class EventActivity : SimpleActivity() {
startTS = newStartTS
endTS = newEndTS
title = newTitle
description = event_description.value
description = binding.eventDescription.value
reminder1Minutes = reminder1.minutes
reminder2Minutes = reminder2.minutes
reminder3Minutes = reminder3.minutes
@ -1292,14 +1292,14 @@ class EventActivity : SimpleActivity() {
repeatInterval = mRepeatInterval
importId = newImportId
timeZone = if (mIsAllDayEvent || timeZone.isEmpty()) DateTimeZone.getDefault().id else timeZone
flags = mEvent.flags.addBitIf(event_all_day.isChecked, FLAG_ALL_DAY)
flags = mEvent.flags.addBitIf(binding.eventAllDay.isChecked, FLAG_ALL_DAY)
repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit
repeatRule = mRepeatRule
attendees = if (mEventCalendarId == STORED_LOCALLY_ONLY) "" else getAllAttendees(true)
eventType = newEventType
lastUpdated = System.currentTimeMillis()
source = newSource
location = event_location.value
location = binding.eventLocation.value
availability = mAvailability
color = mEventColor
}
@ -1389,12 +1389,12 @@ class EventActivity : SimpleActivity() {
}
private fun updateStartDateText() {
event_start_date.text = Formatter.getDate(this, mEventStartDateTime)
binding.eventStartDate.text = Formatter.getDate(this, mEventStartDateTime)
checkStartEndValidity()
}
private fun updateStartTimeText() {
event_start_time.text = Formatter.getTime(this, mEventStartDateTime)
binding.eventStartTime.text = Formatter.getTime(this, mEventStartDateTime)
checkStartEndValidity()
}
@ -1404,33 +1404,33 @@ class EventActivity : SimpleActivity() {
}
private fun updateEndDateText() {
event_end_date.text = Formatter.getDate(this, mEventEndDateTime)
binding.eventEndDate.text = Formatter.getDate(this, mEventEndDateTime)
checkStartEndValidity()
}
private fun updateEndTimeText() {
event_end_time.text = Formatter.getTime(this, mEventEndDateTime)
binding.eventEndTime.text = Formatter.getTime(this, mEventEndDateTime)
checkStartEndValidity()
}
private fun updateTimeZoneText() {
event_time_zone.text = mEvent.getTimeZoneString()
binding.eventTimeZone.text = mEvent.getTimeZoneString()
}
private fun checkStartEndValidity() {
val textColor = if (mEventStartDateTime.isAfter(mEventEndDateTime)) resources.getColor(R.color.red_text) else getProperTextColor()
event_end_date.setTextColor(textColor)
event_end_time.setTextColor(textColor)
binding.eventEndDate.setTextColor(textColor)
binding.eventEndTime.setTextColor(textColor)
}
private fun showOnMap() {
if (event_location.value.isEmpty()) {
if (binding.eventLocation.value.isEmpty()) {
toast(R.string.please_fill_location)
return
}
val pattern = Pattern.compile(LAT_LON_PATTERN)
val locationValue = event_location.value
val locationValue = binding.eventLocation.value
val uri = if (pattern.matcher(locationValue).find()) {
val delimiter = if (locationValue.contains(';')) ";" else ","
val parts = locationValue.split(delimiter)
@ -1648,22 +1648,23 @@ class EventActivity : SimpleActivity() {
}
addAttendee()
val imageHeight = event_repetition_image.height
if (imageHeight > 0) {
event_attendees_image.layoutParams.height = imageHeight
} else {
event_repetition_image.onGlobalLayout {
event_attendees_image.layoutParams.height = event_repetition_image.height
binding.apply {
val imageHeight = eventRepetitionImage.height
if (imageHeight > 0) {
eventAttendeesImage.layoutParams.height = imageHeight
} else {
eventRepetitionImage.onGlobalLayout {
eventAttendeesImage.layoutParams.height = eventRepetitionImage.height
}
}
}
}
}
private fun addAttendee(attendee: Attendee? = null) {
val attendeeHolder = layoutInflater.inflate(R.layout.item_attendee, event_attendees_holder, false) as RelativeLayout
val autoCompleteView = attendeeHolder.event_attendee
val selectedAttendeeHolder = attendeeHolder.event_contact_attendee
val selectedAttendeeDismiss = attendeeHolder.event_contact_dismiss
val attendeeHolder = ItemAttendeeBinding.inflate(layoutInflater, binding.eventAttendeesHolder, false)
val autoCompleteView = attendeeHolder.eventAttendee
val selectedAttendeeDismiss = attendeeHolder.eventContactDismiss
mAttendeeAutoCompleteViews.add(autoCompleteView)
autoCompleteView.onTextChangeListener {
@ -1677,18 +1678,18 @@ class EventActivity : SimpleActivity() {
}
}
event_attendees_holder.addView(attendeeHolder)
binding.eventAttendeesHolder.addView(attendeeHolder.root)
val textColor = getProperTextColor()
val backgroundColor = getProperBackgroundColor()
val primaryColor = getProperPrimaryColor()
autoCompleteView.setColors(textColor, primaryColor, backgroundColor)
selectedAttendeeHolder.event_contact_name.setColors(textColor, primaryColor, backgroundColor)
selectedAttendeeHolder.event_contact_me_status.setColors(textColor, primaryColor, backgroundColor)
attendeeHolder.eventContactName.setColors(textColor, primaryColor, backgroundColor)
attendeeHolder.eventContactMeStatus.setColors(textColor, primaryColor, backgroundColor)
selectedAttendeeDismiss.applyColorFilter(textColor)
selectedAttendeeDismiss.setOnClickListener {
attendeeHolder.beGone()
attendeeHolder.root.beGone()
mSelectedContacts = mSelectedContacts.filter { it.toString() != selectedAttendeeDismiss.tag }.toMutableList() as ArrayList<Attendee>
}
@ -1698,44 +1699,44 @@ class EventActivity : SimpleActivity() {
autoCompleteView.setOnItemClickListener { parent, view, position, id ->
val currAttendees = (autoCompleteView.adapter as AutoCompleteTextViewAdapter).resultList
val selectedAttendee = currAttendees[position]
addSelectedAttendee(selectedAttendee, autoCompleteView, selectedAttendeeHolder)
addSelectedAttendee(selectedAttendee, autoCompleteView, attendeeHolder)
}
if (attendee != null) {
addSelectedAttendee(attendee, autoCompleteView, selectedAttendeeHolder)
addSelectedAttendee(attendee, autoCompleteView, attendeeHolder)
}
}
private fun addSelectedAttendee(attendee: Attendee, autoCompleteView: MyAutoCompleteTextView, selectedAttendeeHolder: RelativeLayout) {
private fun addSelectedAttendee(attendee: Attendee, autoCompleteView: MyAutoCompleteTextView, attendeeHolder: ItemAttendeeBinding) {
mSelectedContacts.add(attendee)
autoCompleteView.beGone()
autoCompleteView.focusSearch(View.FOCUS_DOWN)?.requestFocus()
selectedAttendeeHolder.apply {
beVisible()
attendeeHolder.apply {
root.beVisible()
val attendeeStatusBackground = resources.getDrawable(R.drawable.attendee_status_circular_background)
(attendeeStatusBackground as LayerDrawable).findDrawableByLayerId(R.id.attendee_status_circular_background)
.applyColorFilter(getProperBackgroundColor())
event_contact_status_image.apply {
eventContactStatusImage.apply {
background = attendeeStatusBackground
setImageDrawable(getAttendeeStatusImage(attendee))
beVisibleIf(attendee.showStatusImage())
}
event_contact_name.text = if (attendee.isMe) getString(R.string.my_status) else attendee.getPublicName()
eventContactName.text = if (attendee.isMe) getString(R.string.my_status) else attendee.getPublicName()
if (attendee.isMe) {
(event_contact_name.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.START_OF, event_contact_me_status.id)
(eventContactName.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.START_OF, eventContactMeStatus.id)
}
val placeholder = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(event_contact_name.value))
event_contact_image.apply {
val placeholder = BitmapDrawable(resources, SimpleContactsHelper(this@EventActivity).getContactLetterIcon(eventContactName.value))
eventContactImage.apply {
attendee.updateImage(this@EventActivity, this, placeholder)
beVisible()
}
event_contact_dismiss.apply {
eventContactDismiss.apply {
tag = attendee.toString()
beGoneIf(attendee.isMe)
}
@ -1744,12 +1745,12 @@ class EventActivity : SimpleActivity() {
updateAttendeeMe(this, attendee)
}
event_contact_me_status.apply {
eventContactMeStatus.apply {
beVisibleIf(attendee.isMe)
}
if (attendee.isMe) {
event_contact_attendee.setOnClickListener {
eventContactAttendee.setOnClickListener {
val items = arrayListOf(
RadioItem(Attendees.ATTENDEE_STATUS_ACCEPTED, getString(R.string.going)),
RadioItem(Attendees.ATTENDEE_STATUS_DECLINED, getString(R.string.not_going)),
@ -1775,9 +1776,9 @@ class EventActivity : SimpleActivity() {
)
}
private fun updateAttendeeMe(holder: RelativeLayout, attendee: Attendee) {
private fun updateAttendeeMe(holder: ItemAttendeeBinding, attendee: Attendee) {
holder.apply {
event_contact_me_status.text = getString(
eventContactMeStatus.text = getString(
when (attendee.status) {
Attendees.ATTENDEE_STATUS_ACCEPTED -> R.string.going
Attendees.ATTENDEE_STATUS_DECLINED -> R.string.not_going
@ -1786,7 +1787,7 @@ class EventActivity : SimpleActivity() {
}
)
event_contact_status_image.apply {
eventContactStatusImage.apply {
beVisibleIf(attendee.showStatusImage())
setImageDrawable(getAttendeeStatusImage(attendee))
}
@ -1879,19 +1880,19 @@ class EventActivity : SimpleActivity() {
return contacts
}
private fun updateIconColors() {
event_show_on_map.applyColorFilter(getProperPrimaryColor())
private fun updateIconColors() = binding.apply {
eventShowOnMap.applyColorFilter(getProperPrimaryColor())
val textColor = getProperTextColor()
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, event_availability_image, event_color_image
eventTimeImage, eventTimeZoneImage, eventRepetitionImage, eventReminderImage, eventTypeImage, eventCaldavCalendarImage,
eventReminder1Type, eventReminder2Type, eventReminder3Type, eventAttendeesImage, eventAvailabilityImage, eventColorImage
).forEach {
it.applyColorFilter(textColor)
}
}
private fun updateActionBarTitle() {
event_toolbar.title = if (mIsNewEvent) {
binding.eventToolbar.title = if (mIsNewEvent) {
getString(R.string.new_event)
} else {
getString(R.string.edit_event)

View file

@ -21,6 +21,7 @@ import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.EventListAdapter
import com.simplemobiletools.calendar.pro.adapters.QuickFilterEventTypeAdapter
import com.simplemobiletools.calendar.pro.databases.EventsDatabase
import com.simplemobiletools.calendar.pro.databinding.ActivityMainBinding
import com.simplemobiletools.calendar.pro.dialogs.ExportEventsDialog
import com.simplemobiletools.calendar.pro.dialogs.ImportEventsDialog
import com.simplemobiletools.calendar.pro.dialogs.SelectEventTypesDialog
@ -49,7 +50,6 @@ import com.simplemobiletools.commons.models.Release
import com.simplemobiletools.commons.models.SimpleContact
import com.simplemobiletools.commons.views.MyLinearLayoutManager
import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.activity_main.*
import org.joda.time.DateTime
import org.joda.time.DateTimeZone
import java.io.FileOutputStream
@ -88,19 +88,21 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private var searchResultEvents = ArrayList<Event>()
private var bottomItemAtRefresh: ListItem? = null
private val binding by viewBinding(ActivityMainBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setContentView(binding.root)
appLaunched(BuildConfig.APPLICATION_ID)
setupOptionsMenu()
refreshMenuItems()
updateMaterialActivityViews(main_coordinator, main_holder, useTransparentNavigation = false, useTopSearchMenu = true)
updateMaterialActivityViews(binding.mainCoordinator, binding.mainHolder, useTransparentNavigation = false, useTopSearchMenu = true)
checkWhatsNewDialog()
calendar_fab.beVisibleIf(config.storedView != YEARLY_VIEW && config.storedView != WEEKLY_VIEW)
calendar_fab.setOnClickListener {
binding.calendarFab.beVisibleIf(config.storedView != YEARLY_VIEW && config.storedView != WEEKLY_VIEW)
binding.calendarFab.setOnClickListener {
if (config.allowCreatingTasks) {
if (fab_extended_overlay.isVisible()) {
if (binding.fabExtendedOverlay.isVisible()) {
openNewEvent()
Handler().postDelayed({
@ -113,14 +115,14 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
openNewEvent()
}
}
fab_event_label.setOnClickListener { openNewEvent() }
fab_task_label.setOnClickListener { openNewTask() }
binding.fabEventLabel.setOnClickListener { openNewEvent() }
binding.fabTaskLabel.setOnClickListener { openNewTask() }
fab_extended_overlay.setOnClickListener {
binding.fabExtendedOverlay.setOnClickListener {
hideExtendedFab()
}
fab_task_icon.setOnClickListener {
binding.fabTaskIcon.setOnClickListener {
openNewTask()
Handler().postDelayed({
@ -138,7 +140,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
refreshCalDAVCalendars(false)
}
swipe_refresh_layout.setOnRefreshListener {
binding.swipeRefreshLayout.setOnRefreshListener {
refreshCalDAVCalendars(true)
}
@ -191,23 +193,25 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
updateStatusbarColor(getProperBackgroundColor())
main_menu.updateColors()
storeStateVariables()
updateWidgets()
updateTextColors(calendar_coordinator)
fab_extended_overlay.background = ColorDrawable(getProperBackgroundColor().adjustAlpha(0.8f))
fab_event_label.setTextColor(getProperTextColor())
fab_task_label.setTextColor(getProperTextColor())
binding.apply {
mainMenu.updateColors()
storeStateVariables()
updateWidgets()
updateTextColors(calendarCoordinator)
fabExtendedOverlay.background = ColorDrawable(getProperBackgroundColor().adjustAlpha(0.8f))
fabEventLabel.setTextColor(getProperTextColor())
fabTaskLabel.setTextColor(getProperTextColor())
fab_task_icon.drawable.applyColorFilter(mStoredPrimaryColor.getContrastColor())
fab_task_icon.background.applyColorFilter(mStoredPrimaryColor)
fabTaskIcon.drawable.applyColorFilter(mStoredPrimaryColor.getContrastColor())
fabTaskIcon.background.applyColorFilter(mStoredPrimaryColor)
search_holder.background = ColorDrawable(getProperBackgroundColor())
checkSwipeRefreshAvailability()
checkShortcuts()
searchHolder.background = ColorDrawable(getProperBackgroundColor())
checkSwipeRefreshAvailability()
checkShortcuts()
if (!main_menu.isSearchOpen) {
refreshMenuItems()
if (!mainMenu.isSearchOpen) {
refreshMenuItems()
}
}
setupQuickFilter()
@ -231,33 +235,33 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
fun refreshMenuItems() {
if (fab_extended_overlay.isVisible()) {
if (binding.fabExtendedOverlay.isVisible()) {
hideExtendedFab()
}
shouldGoToTodayBeVisible = currentFragments.lastOrNull()?.shouldGoToTodayBeVisible() ?: false
main_menu.getToolbar().menu.apply {
binding.mainMenu.getToolbar().menu.apply {
goToTodayButton = findItem(R.id.go_to_today)
findItem(R.id.print).isVisible = config.storedView != MONTHLY_DAILY_VIEW
findItem(R.id.filter).isVisible = mShouldFilterBeVisible
findItem(R.id.go_to_today).isVisible = shouldGoToTodayBeVisible && !main_menu.isSearchOpen
findItem(R.id.go_to_today).isVisible = shouldGoToTodayBeVisible && !binding.mainMenu.isSearchOpen
findItem(R.id.go_to_date).isVisible = config.storedView != EVENTS_LIST_VIEW
findItem(R.id.refresh_caldav_calendars).isVisible = config.caldavSync
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
}
}
private fun setupOptionsMenu() {
main_menu.getToolbar().inflateMenu(R.menu.menu_main)
main_menu.toggleHideOnScroll(false)
main_menu.setupMenu()
private fun setupOptionsMenu() = binding.apply {
mainMenu.getToolbar().inflateMenu(R.menu.menu_main)
mainMenu.toggleHideOnScroll(false)
mainMenu.setupMenu()
main_menu.onSearchTextChangedListener = { text ->
mainMenu.onSearchTextChangedListener = { text ->
searchQueryChanged(text)
}
main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
if (fab_extended_overlay.isVisible()) {
mainMenu.getToolbar().setOnMenuItemClickListener { menuItem ->
if (fabExtendedOverlay.isVisible()) {
hideExtendedFab()
}
@ -283,13 +287,13 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
override fun onBackPressed() {
if (main_menu.isSearchOpen) {
if (binding.mainMenu.isSearchOpen) {
closeSearch()
} else {
swipe_refresh_layout.isRefreshing = false
binding.swipeRefreshLayout.isRefreshing = false
checkSwipeRefreshAvailability()
when {
fab_extended_overlay.isVisible() -> hideExtendedFab()
binding.fabExtendedOverlay.isVisible() -> hideExtendedFab()
currentFragments.size > 1 -> removeTopFragment()
else -> super.onBackPressed()
}
@ -333,7 +337,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun setupQuickFilter() {
eventsHelper.getEventTypes(this, false) {
val quickFilterEventTypes = config.quickFilterEventTypes
quick_event_type_filter.adapter = QuickFilterEventTypeAdapter(this, it, quickFilterEventTypes) {
binding.quickEventTypeFilter.adapter = QuickFilterEventTypeAdapter(this, it, quickFilterEventTypes) {
if (config.displayEventTypes.isEmpty() && !config.wasFilteredOutWarningShown) {
toast(R.string.everything_filtered_out, Toast.LENGTH_LONG)
config.wasFilteredOutWarningShown = true
@ -346,7 +350,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun closeSearch() {
main_menu.closeSearch()
binding.mainMenu.closeSearch()
minFetchedSearchTS = 0L
maxFetchedSearchTS = 0L
searchResultEvents.clear()
@ -403,7 +407,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
val newEventIntent = Intent(this, SplashActivity::class.java)
newEventIntent.action = SHORTCUT_NEW_EVENT
return ShortcutInfo.Builder(this, "new_event")
return ShortcutInfo.Builder(this, "newEvent")
.setShortLabel(newEvent)
.setLongLabel(newEvent)
.setIcon(Icon.createWithBitmap(newEventBitmap))
@ -419,7 +423,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
val newTaskBitmap = newTaskDrawable.convertToBitmap()
val newTaskIntent = Intent(this, SplashActivity::class.java)
newTaskIntent.action = SHORTCUT_NEW_TASK
return ShortcutInfo.Builder(this, "new_task")
return ShortcutInfo.Builder(this, "newTask")
.setShortLabel(newTask)
.setLongLabel(newTask)
.setIcon(Icon.createWithBitmap(newTaskBitmap))
@ -433,7 +437,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
intent.removeExtra(VIEW_TO_OPEN)
intent.removeExtra(DAY_CODE)
if (dayCodeToOpen.isNotEmpty()) {
calendar_fab.beVisible()
binding.calendarFab.beVisible()
if (viewToOpen != LAST_VIEW) {
config.storedView = viewToOpen
}
@ -523,7 +527,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun resetActionBarTitle() {
main_menu.updateHintText(getString(R.string.search))
binding.mainMenu.updateHintText(getString(R.string.search))
}
private fun showFilterDialog() {
@ -572,7 +576,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
toast(R.string.refreshing_complete)
}
runOnUiThread {
swipe_refresh_layout.isRefreshing = false
binding.swipeRefreshLayout.isRefreshing = false
}
}
@ -869,7 +873,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun updateView(view: Int) {
calendar_fab.beVisibleIf(view != YEARLY_VIEW && view != WEEKLY_VIEW)
binding.calendarFab.beVisibleIf(view != YEARLY_VIEW && view != WEEKLY_VIEW)
val dateCode = getDateCodeToDisplay(view)
config.storedView = view
checkSwipeRefreshAvailability()
@ -931,7 +935,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
fragment.arguments = bundle
supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow()
main_menu.toggleForceArrowBackIcon(false)
binding.mainMenu.toggleForceArrowBackIcon(false)
}
private fun fixDayCode(dayCode: String? = null): String? = when {
@ -942,15 +946,19 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun showExtendedFab() {
animateFabIcon(false)
arrayOf(fab_event_label, fab_extended_overlay, fab_task_icon, fab_task_label).forEach {
it.fadeIn()
binding.apply {
arrayOf(fabEventLabel, fabExtendedOverlay, fabTaskIcon, fabTaskLabel).forEach {
it.fadeIn()
}
}
}
private fun hideExtendedFab() {
animateFabIcon(true)
arrayOf(fab_event_label, fab_extended_overlay, fab_task_icon, fab_task_label).forEach {
it.fadeOut()
binding.apply {
arrayOf(fabEventLabel, fabExtendedOverlay, fabTaskIcon, fabTaskLabel).forEach {
it.fadeOut()
}
}
}
@ -961,7 +969,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
R.drawable.ic_today_vector
}
val newDrawable = resources.getColoredDrawableWithColor(newDrawableId, getProperPrimaryColor())
calendar_fab.setImageDrawable(newDrawable)
binding.calendarFab.setImageDrawable(newDrawable)
}
private fun openNewEvent() {
@ -990,7 +998,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
fragment.arguments = bundle
supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow()
resetActionBarTitle()
calendar_fab.beVisible()
binding.calendarFab.beVisible()
showBackNavigationArrow()
}
@ -1028,17 +1036,17 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
refreshEvents()
}
calendar_fab.beGoneIf(currentFragments.size == 1 && config.storedView == YEARLY_VIEW)
binding.calendarFab.beGoneIf(currentFragments.size == 1 && config.storedView == YEARLY_VIEW)
if (currentFragments.size > 1) {
showBackNavigationArrow()
} else {
main_menu.toggleForceArrowBackIcon(false)
binding.mainMenu.toggleForceArrowBackIcon(false)
}
}
private fun showBackNavigationArrow() {
main_menu.toggleForceArrowBackIcon(true)
main_menu.onNavigateBackClickListener = {
binding.mainMenu.toggleForceArrowBackIcon(true)
binding.mainMenu.onNavigateBackClickListener = {
onBackPressed()
}
}
@ -1088,9 +1096,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun tryImportEventsFromFile(uri: Uri) {
when {
uri.scheme == "file" -> showImportEventsDialog(uri.path!!)
uri.scheme == "content" -> {
when (uri.scheme) {
"file" -> showImportEventsDialog(uri.path!!)
"content" -> {
val tempFile = getTempFile()
if (tempFile == null) {
toast(R.string.unknown_error_occurred)
@ -1206,11 +1214,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun searchQueryChanged(text: String) {
mLatestSearchQuery = text
if (text.isNotEmpty() && search_holder.isGone()) {
search_holder.fadeIn()
if (text.isNotEmpty() && binding.searchHolder.isGone()) {
binding.searchHolder.fadeIn()
} else if (text.isEmpty()) {
search_holder.fadeOut()
search_results_list.adapter = null
binding.searchHolder.fadeOut()
binding.searchResultsList.adapter = null
}
val placeholderTextId = if (config.displayEventTypes.isEmpty()) {
@ -1219,10 +1227,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
R.string.no_items_found
}
search_placeholder.setText(placeholderTextId)
search_placeholder_2.beVisibleIf(text.length == 1)
binding.searchPlaceholder.setText(placeholderTextId)
binding.searchPlaceholder2.beVisibleIf(text.length == 1)
if (text.length >= 2) {
if (search_results_list.adapter == null) {
if (binding.searchResultsList.adapter == null) {
minFetchedSearchTS = DateTime().minusYears(2).seconds()
maxFetchedSearchTS = DateTime().plusYears(2).seconds()
}
@ -1252,13 +1260,13 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
}
} else if (text.length == 1) {
search_placeholder.beVisible()
search_results_list.beGone()
binding.searchPlaceholder.beVisible()
binding.searchResultsList.beGone()
}
}
private fun showSearchResultEvents(events: ArrayList<Event>, updateStatus: Int) {
val currentSearchQuery = main_menu.getCurrentQuery()
val currentSearchQuery = binding.mainMenu.getCurrentQuery()
val filtered = try {
events.filter {
it.title.contains(currentSearchQuery, true) || it.location.contains(currentSearchQuery, true) || it.description.contains(
@ -1272,12 +1280,12 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
searchResultEvents = filtered.toMutableList() as ArrayList<Event>
runOnUiThread {
search_results_list.beVisibleIf(filtered.isNotEmpty())
search_placeholder.beVisibleIf(filtered.isEmpty())
binding.searchResultsList.beVisibleIf(filtered.isNotEmpty())
binding.searchPlaceholder.beVisibleIf(filtered.isEmpty())
val listItems = getEventListItems(filtered)
val currAdapter = search_results_list.adapter
val currAdapter = binding.searchResultsList.adapter
if (currAdapter == null) {
val eventsAdapter = EventListAdapter(this, listItems, true, this, search_results_list) {
val eventsAdapter = EventListAdapter(this, listItems, true, this, binding.searchResultsList) {
hideKeyboard()
if (it is ListEvent) {
Intent(applicationContext, getActivityToOpen(it.isTask)).apply {
@ -1287,9 +1295,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
}
search_results_list.adapter = eventsAdapter
binding.searchResultsList.adapter = eventsAdapter
search_results_list.endlessScrollListener = object : MyRecyclerView.EndlessScrollListener {
binding.searchResultsList.endlessScrollListener = object : MyRecyclerView.EndlessScrollListener {
override fun updateTop() {
fetchPreviousPeriod()
}
@ -1303,14 +1311,14 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
if (updateStatus == UPDATE_TOP) {
val item = listItems.indexOfFirst { it == bottomItemAtRefresh }
if (item != -1) {
search_results_list.scrollToPosition(item)
binding.searchResultsList.scrollToPosition(item)
}
} else if (updateStatus == UPDATE_BOTTOM) {
search_results_list.smoothScrollBy(0, resources.getDimension(R.dimen.endless_scroll_move_height).toInt())
binding.searchResultsList.smoothScrollBy(0, resources.getDimension(R.dimen.endless_scroll_move_height).toInt())
} else {
val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSectionDay && !it.isPastSection }
if (firstNonPastSectionIndex != -1) {
search_results_list.scrollToPosition(firstNonPastSectionIndex)
binding.searchResultsList.scrollToPosition(firstNonPastSectionIndex)
}
}
}
@ -1322,8 +1330,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
return
}
val lastPosition = (search_results_list.layoutManager as MyLinearLayoutManager).findLastVisibleItemPosition()
bottomItemAtRefresh = (search_results_list.adapter as EventListAdapter).listItems[lastPosition]
val lastPosition = (binding.searchResultsList.layoutManager as MyLinearLayoutManager).findLastVisibleItemPosition()
bottomItemAtRefresh = (binding.searchResultsList.adapter as EventListAdapter).listItems[lastPosition]
val oldMinFetchedTS = minFetchedSearchTS - 1
minFetchedSearchTS -= FETCH_INTERVAL
@ -1363,9 +1371,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun checkSwipeRefreshAvailability() {
swipe_refresh_layout.isEnabled = config.caldavSync && config.pullToRefresh && config.storedView != WEEKLY_VIEW
if (!swipe_refresh_layout.isEnabled) {
swipe_refresh_layout.isRefreshing = false
binding.swipeRefreshLayout.isEnabled = config.caldavSync && config.pullToRefresh && config.storedView != WEEKLY_VIEW
if (!binding.swipeRefreshLayout.isEnabled) {
binding.swipeRefreshLayout.isRefreshing = false
}
}
@ -1375,13 +1383,13 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun openDayAt(timestamp: Long) {
val dayCode = Formatter.getDayCodeFromTS(timestamp / 1000L)
calendar_fab.beVisible()
binding.calendarFab.beVisible()
config.storedView = DAILY_VIEW
updateViewPager(dayCode)
}
// events fetched from Thunderbird, https://www.thunderbird.net/en-US/calendar/holidays and
// https://holidays.kayaposoft.com/public_holidays.php?year=2021
// https://holidays.kayaposoft.com/publicHolidays.php?year=2021
private fun getHolidayRadioItems(): ArrayList<RadioItem> {
val items = ArrayList<RadioItem>()

View file

@ -3,34 +3,42 @@ package com.simplemobiletools.calendar.pro.activities
import android.os.Bundle
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.ManageEventTypesAdapter
import com.simplemobiletools.calendar.pro.databinding.ActivityManageEventTypesBinding
import com.simplemobiletools.calendar.pro.dialogs.EditEventTypeDialog
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.calendar.pro.interfaces.DeleteEventTypesListener
import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import kotlinx.android.synthetic.main.activity_manage_event_types.*
class ManageEventTypesActivity : SimpleActivity(), DeleteEventTypesListener {
private val binding by viewBinding(ActivityManageEventTypesBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_manage_event_types)
setContentView(binding.root)
setupOptionsMenu()
updateMaterialActivityViews(manage_event_types_coordinator, manage_event_types_list, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(manage_event_types_list, manage_event_types_toolbar)
updateMaterialActivityViews(
binding.manageEventTypesCoordinator,
binding.manageEventTypesList,
useTransparentNavigation = true,
useTopSearchMenu = false
)
setupMaterialScrollListener(binding.manageEventTypesList, binding.manageEventTypesToolbar)
getEventTypes()
updateTextColors(manage_event_types_list)
updateTextColors(binding.manageEventTypesList)
}
override fun onResume() {
super.onResume()
setupToolbar(manage_event_types_toolbar, NavigationIcon.Arrow)
setupToolbar(binding.manageEventTypesToolbar, NavigationIcon.Arrow)
}
private fun showEventTypeDialog(eventType: EventType? = null) {
@ -41,15 +49,15 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteEventTypesListener {
private fun getEventTypes() {
eventsHelper.getEventTypes(this, false) {
val adapter = ManageEventTypesAdapter(this, it, this, manage_event_types_list) {
val adapter = ManageEventTypesAdapter(this, it, this, binding.manageEventTypesList) {
showEventTypeDialog(it as EventType)
}
manage_event_types_list.adapter = adapter
binding.manageEventTypesList.adapter = adapter
}
}
private fun setupOptionsMenu() {
manage_event_types_toolbar.setOnMenuItemClickListener { menuItem ->
binding.manageEventTypesToolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.add_event_type -> showEventTypeDialog()
else -> return@setOnMenuItemClickListener false

View file

@ -10,22 +10,26 @@ import androidx.appcompat.widget.SearchView
import androidx.core.view.MenuItemCompat
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.SelectTimeZoneAdapter
import com.simplemobiletools.calendar.pro.databinding.ActivitySelectTimeZoneBinding
import com.simplemobiletools.calendar.pro.helpers.CURRENT_TIME_ZONE
import com.simplemobiletools.calendar.pro.helpers.TIME_ZONE
import com.simplemobiletools.calendar.pro.helpers.getAllTimeZones
import com.simplemobiletools.calendar.pro.models.MyTimeZone
import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.NavigationIcon
import kotlinx.android.synthetic.main.activity_select_time_zone.*
import java.util.*
import java.util.Locale
import java.util.TimeZone
class SelectTimeZoneActivity : SimpleActivity() {
private var mSearchMenuItem: MenuItem? = null
private val allTimeZones = getAllTimeZones()
private val binding by viewBinding(ActivitySelectTimeZoneBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_select_time_zone)
setContentView(binding.root)
setupOptionsMenu()
SelectTimeZoneAdapter(this, allTimeZones) {
@ -35,23 +39,23 @@ class SelectTimeZoneActivity : SimpleActivity() {
setResult(RESULT_OK, data)
finish()
}.apply {
select_time_zone_list.adapter = this
binding.selectTimeZoneList.adapter = this
}
val currentTimeZone = intent.getStringExtra(CURRENT_TIME_ZONE) ?: TimeZone.getDefault().id
val pos = allTimeZones.indexOfFirst { it.zoneName.equals(currentTimeZone, true) }
if (pos != -1) {
select_time_zone_list.scrollToPosition(pos)
binding.selectTimeZoneList.scrollToPosition(pos)
}
}
override fun onResume() {
super.onResume()
setupToolbar(select_time_zone_toolbar, NavigationIcon.Arrow, searchMenuItem = mSearchMenuItem)
setupToolbar(binding.selectTimeZoneToolbar, NavigationIcon.Arrow, searchMenuItem = mSearchMenuItem)
}
private fun setupOptionsMenu() {
setupSearch(select_time_zone_toolbar.menu)
setupSearch(binding.selectTimeZoneToolbar.menu)
}
private fun setupSearch(menu: Menu) {
@ -89,8 +93,8 @@ class SelectTimeZoneActivity : SimpleActivity() {
private fun searchQueryChanged(text: String) {
val timeZones = allTimeZones.filter {
it.zoneName.toLowerCase(Locale.getDefault()).contains(text.toLowerCase(Locale.getDefault()))
it.zoneName.lowercase(Locale.getDefault()).contains(text.lowercase(Locale.getDefault()))
}.toMutableList() as ArrayList<MyTimeZone>
(select_time_zone_list.adapter as? SelectTimeZoneAdapter)?.updateTimeZones(timeZones)
(binding.selectTimeZoneList.adapter as? SelectTimeZoneAdapter)?.updateTimeZones(timeZones)
}
}

View file

@ -11,26 +11,26 @@ import android.widget.Toast
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.ActivitySettingsBinding
import com.simplemobiletools.calendar.pro.dialogs.ManageAutomaticBackupsDialog
import com.simplemobiletools.calendar.pro.dialogs.SelectCalendarsDialog
import com.simplemobiletools.calendar.pro.dialogs.SelectEventTypeDialog
import com.simplemobiletools.calendar.pro.dialogs.SelectEventTypesDialog
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.*
import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.dialogs.*
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.AlarmSound
import com.simplemobiletools.commons.models.RadioItem
import kotlinx.android.synthetic.main.activity_settings.*
import org.joda.time.DateTime
import org.joda.time.DateTimeConstants
import java.io.File
import java.io.InputStream
import java.text.SimpleDateFormat
import java.util.*
import java.util.Calendar
import java.util.Locale
import kotlin.system.exitProcess
class SettingsActivity : SimpleActivity() {
@ -39,19 +39,21 @@ class SettingsActivity : SimpleActivity() {
private var mStoredPrimaryColor = 0
private val binding by viewBinding(ActivitySettingsBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)
setContentView(binding.root)
mStoredPrimaryColor = getProperPrimaryColor()
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
}
override fun onResume() {
super.onResume()
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
setupSettingItems()
}
@ -99,7 +101,7 @@ class SettingsActivity : SimpleActivity() {
setupDimEvents()
setupDimCompletedTasks()
setupAllowChangingTimeZones()
updateTextColors(settings_holder)
updateTextColors(binding.settingsHolder)
checkPrimaryColor()
setupEnableAutomaticBackups()
setupManageAutomaticBackups()
@ -107,19 +109,19 @@ class SettingsActivity : SimpleActivity() {
setupImportSettings()
arrayOf(
settings_color_customization_section_label,
settings_general_settings_label,
settings_reminders_label,
settings_caldav_label,
settings_new_events_label,
settings_weekly_view_label,
settings_monthly_view_label,
settings_event_lists_label,
settings_widgets_label,
settings_events_label,
settings_tasks_label,
settings_backups_label,
settings_migrating_label
binding.settingsColorCustomizationSectionLabel,
binding.settingsGeneralSettingsLabel,
binding.settingsRemindersLabel,
binding.settingsCaldavLabel,
binding.settingsNewEventsLabel,
binding.settingsWeeklyViewLabel,
binding.settingsMonthlyViewLabel,
binding.settingsEventListsLabel,
binding.settingsWidgetsLabel,
binding.settingsEventsLabel,
binding.settingsTasksLabel,
binding.settingsBackupsLabel,
binding.settingsMigratingLabel
).forEach {
it.setTextColor(getProperPrimaryColor())
}
@ -163,71 +165,71 @@ class SettingsActivity : SimpleActivity() {
}
private fun setupCustomizeColors() {
settings_color_customization_holder.setOnClickListener {
binding.settingsColorCustomizationHolder.setOnClickListener {
startCustomizationActivity()
}
}
private fun setupCustomizeNotifications() {
settings_customize_notifications_holder.beVisibleIf(isOreoPlus())
settings_customize_notifications_holder.setOnClickListener {
binding.settingsCustomizeNotificationsHolder.beVisibleIf(isOreoPlus())
binding.settingsCustomizeNotificationsHolder.setOnClickListener {
launchCustomizeNotificationsIntent()
}
}
private fun setupUseEnglish() {
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
settings_use_english.isChecked = config.useEnglish
settings_use_english_holder.setOnClickListener {
settings_use_english.toggle()
config.useEnglish = settings_use_english.isChecked
private fun setupUseEnglish() = binding.apply {
settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
settingsUseEnglish.isChecked = config.useEnglish
settingsUseEnglishHolder.setOnClickListener {
settingsUseEnglish.toggle()
config.useEnglish = settingsUseEnglish.isChecked
exitProcess(0)
}
}
private fun setupLanguage() {
settings_language.text = Locale.getDefault().displayLanguage
settings_language_holder.beVisibleIf(isTiramisuPlus())
settings_language_holder.setOnClickListener {
private fun setupLanguage() = binding.apply {
settingsLanguage.text = Locale.getDefault().displayLanguage
settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
settingsLanguageHolder.setOnClickListener {
launchChangeAppLanguageIntent()
}
}
private fun setupManageEventTypes() {
settings_manage_event_types_holder.setOnClickListener {
binding.settingsManageEventTypesHolder.setOnClickListener {
startActivity(Intent(this, ManageEventTypesActivity::class.java))
}
}
private fun setupManageQuickFilterEventTypes() {
settings_manage_quick_filter_event_types_holder.setOnClickListener {
private fun setupManageQuickFilterEventTypes() = binding.apply {
settingsManageQuickFilterEventTypesHolder.setOnClickListener {
showQuickFilterPicker()
}
eventsHelper.getEventTypes(this, false) {
settings_manage_quick_filter_event_types_holder.beGoneIf(it.size < 2)
eventsHelper.getEventTypes(this@SettingsActivity, false) {
settingsManageQuickFilterEventTypesHolder.beGoneIf(it.size < 2)
}
}
private fun setupHourFormat() {
settings_hour_format.isChecked = config.use24HourFormat
settings_hour_format_holder.setOnClickListener {
settings_hour_format.toggle()
config.use24HourFormat = settings_hour_format.isChecked
private fun setupHourFormat() = binding.apply {
settingsHourFormat.isChecked = config.use24HourFormat
settingsHourFormatHolder.setOnClickListener {
settingsHourFormat.toggle()
config.use24HourFormat = settingsHourFormat.isChecked
}
}
private fun setupAllowCreatingTasks() {
settings_allow_creating_tasks.isChecked = config.allowCreatingTasks
settings_allow_creating_tasks_holder.setOnClickListener {
settings_allow_creating_tasks.toggle()
config.allowCreatingTasks = settings_allow_creating_tasks.isChecked
private fun setupAllowCreatingTasks() = binding.apply {
settingsAllowCreatingTasks.isChecked = config.allowCreatingTasks
settingsAllowCreatingTasksHolder.setOnClickListener {
settingsAllowCreatingTasks.toggle()
config.allowCreatingTasks = settingsAllowCreatingTasks.isChecked
}
}
private fun setupCaldavSync() {
settings_caldav_sync.isChecked = config.caldavSync
settings_caldav_sync_holder.setOnClickListener {
private fun setupCaldavSync() = binding.apply {
settingsCaldavSync.isChecked = config.caldavSync
settingsCaldavSyncHolder.setOnClickListener {
if (config.caldavSync) {
toggleCaldavSync(false)
} else {
@ -248,30 +250,30 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupPullToRefresh() {
settings_caldav_pull_to_refresh_holder.beVisibleIf(config.caldavSync)
settings_caldav_pull_to_refresh.isChecked = config.pullToRefresh
settings_caldav_pull_to_refresh_holder.setOnClickListener {
settings_caldav_pull_to_refresh.toggle()
config.pullToRefresh = settings_caldav_pull_to_refresh.isChecked
private fun setupPullToRefresh() = binding.apply {
settingsCaldavPullToRefreshHolder.beVisibleIf(config.caldavSync)
settingsCaldavPullToRefresh.isChecked = config.pullToRefresh
settingsCaldavPullToRefreshHolder.setOnClickListener {
settingsCaldavPullToRefresh.toggle()
config.pullToRefresh = settingsCaldavPullToRefresh.isChecked
}
}
private fun setupManageSyncedCalendars() {
settings_manage_synced_calendars_holder.beVisibleIf(config.caldavSync)
settings_manage_synced_calendars_holder.setOnClickListener {
private fun setupManageSyncedCalendars() = binding.apply {
settingsManageSyncedCalendarsHolder.beVisibleIf(config.caldavSync)
settingsManageSyncedCalendarsHolder.setOnClickListener {
showCalendarPicker()
}
}
private fun toggleCaldavSync(enable: Boolean) {
private fun toggleCaldavSync(enable: Boolean) = binding.apply {
if (enable) {
showCalendarPicker()
} else {
settings_caldav_sync.isChecked = false
settingsCaldavSync.isChecked = false
config.caldavSync = false
settings_manage_synced_calendars_holder.beGone()
settings_caldav_pull_to_refresh_holder.beGone()
settingsManageSyncedCalendarsHolder.beGone()
settingsCaldavPullToRefreshHolder.beGone()
ensureBackgroundThread {
config.getSyncedCalendarIdsAsList().forEach {
@ -283,20 +285,20 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun showCalendarPicker() {
private fun showCalendarPicker() = binding.apply {
val oldCalendarIds = config.getSyncedCalendarIdsAsList()
SelectCalendarsDialog(this) {
SelectCalendarsDialog(this@SettingsActivity) {
val newCalendarIds = config.getSyncedCalendarIdsAsList()
if (newCalendarIds.isEmpty() && !config.caldavSync) {
return@SelectCalendarsDialog
}
settings_manage_synced_calendars_holder.beVisibleIf(newCalendarIds.isNotEmpty())
settings_caldav_pull_to_refresh_holder.beVisibleIf(newCalendarIds.isNotEmpty())
settings_caldav_sync.isChecked = newCalendarIds.isNotEmpty()
settingsManageSyncedCalendarsHolder.beVisibleIf(newCalendarIds.isNotEmpty())
settingsCaldavPullToRefreshHolder.beVisibleIf(newCalendarIds.isNotEmpty())
settingsCaldavSync.isChecked = newCalendarIds.isNotEmpty()
config.caldavSync = newCalendarIds.isNotEmpty()
if (settings_caldav_sync.isChecked) {
if (settingsCaldavSync.isChecked) {
toast(R.string.syncing)
}
@ -311,13 +313,13 @@ class SettingsActivity : SimpleActivity() {
if (!existingEventTypeNames.contains(calendarTitle.lowercase(Locale.getDefault()))) {
val eventType = EventType(null, it.displayName, it.color, it.id, it.displayName, it.accountName)
existingEventTypeNames.add(calendarTitle.lowercase(Locale.getDefault()))
eventsHelper.insertOrUpdateEventType(this, eventType)
eventsHelper.insertOrUpdateEventType(this@SettingsActivity, eventType)
}
}
syncCalDAVCalendars {
calDAVHelper.refreshCalendars(showToasts = true, scheduleNextSync = true) {
if (settings_caldav_sync.isChecked) {
if (settingsCaldavSync.isChecked) {
toast(R.string.synchronization_completed)
}
}
@ -344,7 +346,7 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupStartWeekOn() {
private fun setupStartWeekOn() = binding.apply {
val items = arrayListOf(
RadioItem(DateTimeConstants.SUNDAY, getString(R.string.sunday)),
RadioItem(DateTimeConstants.MONDAY, getString(R.string.monday)),
@ -355,128 +357,134 @@ class SettingsActivity : SimpleActivity() {
RadioItem(DateTimeConstants.SATURDAY, getString(R.string.saturday)),
)
settings_start_week_on.text = getDayOfWeekString(config.firstDayOfWeek)
settings_start_week_on_holder.setOnClickListener {
RadioGroupDialog(this, items, config.firstDayOfWeek) { any ->
settingsStartWeekOn.text = getDayOfWeekString(config.firstDayOfWeek)
settingsStartWeekOnHolder.setOnClickListener {
RadioGroupDialog(this@SettingsActivity, items, config.firstDayOfWeek) { any ->
val firstDayOfWeek = any as Int
config.firstDayOfWeek = firstDayOfWeek
settings_start_week_on.text = getDayOfWeekString(firstDayOfWeek)
settingsStartWeekOn.text = getDayOfWeekString(firstDayOfWeek)
}
}
}
private fun setupHighlightWeekends() {
settings_highlight_weekends.isChecked = config.highlightWeekends
settings_highlight_weekends_color_holder.beVisibleIf(config.highlightWeekends)
settings_highlight_weekends_holder.setOnClickListener {
settings_highlight_weekends.toggle()
config.highlightWeekends = settings_highlight_weekends.isChecked
settings_highlight_weekends_color_holder.beVisibleIf(config.highlightWeekends)
private fun setupHighlightWeekends() = binding.apply {
settingsHighlightWeekends.isChecked = config.highlightWeekends
settingsHighlightWeekendsColorHolder.beVisibleIf(config.highlightWeekends)
settingsHighlightWeekendsHolder.setOnClickListener {
settingsHighlightWeekends.toggle()
config.highlightWeekends = settingsHighlightWeekends.isChecked
settingsHighlightWeekendsColorHolder.beVisibleIf(config.highlightWeekends)
}
}
private fun setupHighlightWeekendsColor() {
settings_highlight_weekends_color.setFillWithStroke(config.highlightWeekendsColor, getProperBackgroundColor())
settings_highlight_weekends_color_holder.setOnClickListener {
ColorPickerDialog(this, config.highlightWeekendsColor) { wasPositivePressed, color ->
private fun setupHighlightWeekendsColor() = binding.apply {
settingsHighlightWeekendsColor.setFillWithStroke(config.highlightWeekendsColor, getProperBackgroundColor())
settingsHighlightWeekendsColorHolder.setOnClickListener {
ColorPickerDialog(this@SettingsActivity, config.highlightWeekendsColor) { wasPositivePressed, color ->
if (wasPositivePressed) {
config.highlightWeekendsColor = color
settings_highlight_weekends_color.setFillWithStroke(color, getProperBackgroundColor())
settingsHighlightWeekendsColor.setFillWithStroke(color, getProperBackgroundColor())
}
}
}
}
private fun setupDeleteAllEvents() {
settings_delete_all_events_holder.setOnClickListener {
ConfirmationDialog(this, messageId = R.string.delete_all_events_confirmation) {
private fun setupDeleteAllEvents() = binding.apply {
settingsDeleteAllEventsHolder.setOnClickListener {
ConfirmationDialog(this@SettingsActivity, messageId = R.string.delete_all_events_confirmation) {
eventsHelper.deleteAllEvents()
}
}
}
private fun setupDisplayDescription() {
settings_display_description.isChecked = config.displayDescription
settings_replace_description_holder.beVisibleIf(config.displayDescription)
settings_display_description_holder.setOnClickListener {
settings_display_description.toggle()
config.displayDescription = settings_display_description.isChecked
settings_replace_description_holder.beVisibleIf(config.displayDescription)
private fun setupDisplayDescription() = binding.apply {
settingsDisplayDescription.isChecked = config.displayDescription
settingsReplaceDescriptionHolder.beVisibleIf(config.displayDescription)
settingsDisplayDescriptionHolder.setOnClickListener {
settingsDisplayDescription.toggle()
config.displayDescription = settingsDisplayDescription.isChecked
settingsReplaceDescriptionHolder.beVisibleIf(config.displayDescription)
}
}
private fun setupReplaceDescription() {
settings_replace_description.isChecked = config.replaceDescription
settings_replace_description_holder.setOnClickListener {
settings_replace_description.toggle()
config.replaceDescription = settings_replace_description.isChecked
private fun setupReplaceDescription() = binding.apply {
settingsReplaceDescription.isChecked = config.replaceDescription
settingsReplaceDescriptionHolder.setOnClickListener {
settingsReplaceDescription.toggle()
config.replaceDescription = settingsReplaceDescription.isChecked
}
}
private fun setupWeeklyStart() {
settings_start_weekly_at.text = getHoursString(config.startWeeklyAt)
settings_start_weekly_at_holder.setOnClickListener {
private fun setupWeeklyStart() = binding.apply {
settingsStartWeeklyAt.text = getHoursString(config.startWeeklyAt)
settingsStartWeeklyAtHolder.setOnClickListener {
val items = ArrayList<RadioItem>()
(0..16).mapTo(items) { RadioItem(it, getHoursString(it)) }
RadioGroupDialog(this@SettingsActivity, items, config.startWeeklyAt) {
config.startWeeklyAt = it as Int
settings_start_weekly_at.text = getHoursString(it)
settingsStartWeeklyAt.text = getHoursString(it)
}
}
}
private fun setupMidnightSpanEvents() {
settings_midnight_span_event.isChecked = config.showMidnightSpanningEventsAtTop
settings_midnight_span_events_holder.setOnClickListener {
settings_midnight_span_event.toggle()
config.showMidnightSpanningEventsAtTop = settings_midnight_span_event.isChecked
private fun setupMidnightSpanEvents() = binding.apply {
settingsMidnightSpanEvent.isChecked = config.showMidnightSpanningEventsAtTop
settingsMidnightSpanEventsHolder.setOnClickListener {
settingsMidnightSpanEvent.toggle()
config.showMidnightSpanningEventsAtTop = settingsMidnightSpanEvent.isChecked
}
}
private fun setupAllowCustomizeDayCount() {
settings_allow_customize_day_count.isChecked = config.allowCustomizeDayCount
settings_allow_customize_day_count_holder.setOnClickListener {
settings_allow_customize_day_count.toggle()
config.allowCustomizeDayCount = settings_allow_customize_day_count.isChecked
private fun setupAllowCustomizeDayCount() = binding.apply {
settingsAllowCustomizeDayCount.isChecked = config.allowCustomizeDayCount
settingsAllowCustomizeDayCountHolder.setOnClickListener {
settingsAllowCustomizeDayCount.toggle()
config.allowCustomizeDayCount = settingsAllowCustomizeDayCount.isChecked
}
}
private fun setupStartWeekWithCurrentDay() {
settings_start_week_with_current_day.isChecked = config.startWeekWithCurrentDay
settings_start_week_with_current_day_holder.setOnClickListener {
settings_start_week_with_current_day.toggle()
config.startWeekWithCurrentDay = settings_start_week_with_current_day.isChecked
private fun setupStartWeekWithCurrentDay() = binding.apply {
settingsStartWeekWithCurrentDay.isChecked = config.startWeekWithCurrentDay
settingsStartWeekWithCurrentDayHolder.setOnClickListener {
settingsStartWeekWithCurrentDay.toggle()
config.startWeekWithCurrentDay = settingsStartWeekWithCurrentDay.isChecked
}
}
private fun setupWeekNumbers() {
settings_week_numbers.isChecked = config.showWeekNumbers
settings_week_numbers_holder.setOnClickListener {
settings_week_numbers.toggle()
config.showWeekNumbers = settings_week_numbers.isChecked
private fun setupWeekNumbers() = binding.apply {
settingsWeekNumbers.isChecked = config.showWeekNumbers
settingsWeekNumbersHolder.setOnClickListener {
settingsWeekNumbers.toggle()
config.showWeekNumbers = settingsWeekNumbers.isChecked
}
}
private fun setupShowGrid() {
settings_show_grid.isChecked = config.showGrid
settings_show_grid_holder.setOnClickListener {
settings_show_grid.toggle()
config.showGrid = settings_show_grid.isChecked
private fun setupShowGrid() = binding.apply {
settingsShowGrid.isChecked = config.showGrid
settingsShowGridHolder.setOnClickListener {
settingsShowGrid.toggle()
config.showGrid = settingsShowGrid.isChecked
}
}
private fun setupReminderSound() {
settings_reminder_sound_holder.beGoneIf(isOreoPlus())
settings_reminder_sound.text = config.reminderSoundTitle
private fun setupReminderSound() = binding.apply {
settingsReminderSoundHolder.beGoneIf(isOreoPlus())
settingsReminderSound.text = config.reminderSoundTitle
settings_reminder_sound_holder.setOnClickListener {
SelectAlarmSoundDialog(this, config.reminderSoundUri, config.reminderAudioStream, GET_RINGTONE_URI, RingtoneManager.TYPE_NOTIFICATION, false,
settingsReminderSoundHolder.setOnClickListener {
SelectAlarmSoundDialog(this@SettingsActivity,
config.reminderSoundUri,
config.reminderAudioStream,
GET_RINGTONE_URI,
RingtoneManager.TYPE_NOTIFICATION,
false,
onAlarmPicked = {
if (it != null) {
updateReminderSound(it)
}
}, onAlarmSoundDeleted = {
},
onAlarmSoundDeleted = {
if (it.uri == config.reminderSoundUri) {
val defaultAlarm = getDefaultAlarmSound(RingtoneManager.TYPE_NOTIFICATION)
updateReminderSound(defaultAlarm)
@ -488,12 +496,12 @@ class SettingsActivity : SimpleActivity() {
private fun updateReminderSound(alarmSound: AlarmSound) {
config.reminderSoundTitle = alarmSound.title
config.reminderSoundUri = alarmSound.uri
settings_reminder_sound.text = alarmSound.title
binding.settingsReminderSound.text = alarmSound.title
}
private fun setupReminderAudioStream() {
settings_reminder_audio_stream.text = getAudioStreamText()
settings_reminder_audio_stream_holder.setOnClickListener {
private fun setupReminderAudioStream() = binding.apply {
settingsReminderAudioStream.text = getAudioStreamText()
settingsReminderAudioStreamHolder.setOnClickListener {
val items = arrayListOf(
RadioItem(AudioManager.STREAM_ALARM, getString(R.string.alarm_stream)),
RadioItem(AudioManager.STREAM_SYSTEM, getString(R.string.system_stream)),
@ -503,7 +511,7 @@ class SettingsActivity : SimpleActivity() {
RadioGroupDialog(this@SettingsActivity, items, config.reminderAudioStream) {
config.reminderAudioStream = it as Int
settings_reminder_audio_stream.text = getAudioStreamText()
settingsReminderAudioStream.text = getAudioStreamText()
}
}
}
@ -517,35 +525,35 @@ class SettingsActivity : SimpleActivity() {
}
)
private fun setupVibrate() {
settings_vibrate.isChecked = config.vibrateOnReminder
settings_vibrate_holder.setOnClickListener {
settings_vibrate.toggle()
config.vibrateOnReminder = settings_vibrate.isChecked
private fun setupVibrate() = binding.apply {
settingsVibrate.isChecked = config.vibrateOnReminder
settingsVibrateHolder.setOnClickListener {
settingsVibrate.toggle()
config.vibrateOnReminder = settingsVibrate.isChecked
}
}
private fun setupLoopReminders() {
settings_loop_reminders.isChecked = config.loopReminders
settings_loop_reminders_holder.setOnClickListener {
settings_loop_reminders.toggle()
config.loopReminders = settings_loop_reminders.isChecked
private fun setupLoopReminders() = binding.apply {
settingsLoopReminders.isChecked = config.loopReminders
settingsLoopRemindersHolder.setOnClickListener {
settingsLoopReminders.toggle()
config.loopReminders = settingsLoopReminders.isChecked
}
}
private fun setupUseSameSnooze() {
settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
settings_use_same_snooze.isChecked = config.useSameSnooze
settings_use_same_snooze_holder.setOnClickListener {
settings_use_same_snooze.toggle()
config.useSameSnooze = settings_use_same_snooze.isChecked
settings_snooze_time_holder.beVisibleIf(config.useSameSnooze)
private fun setupUseSameSnooze() = binding.apply {
settingsSnoozeTimeHolder.beVisibleIf(config.useSameSnooze)
settingsUseSameSnooze.isChecked = config.useSameSnooze
settingsUseSameSnoozeHolder.setOnClickListener {
settingsUseSameSnooze.toggle()
config.useSameSnooze = settingsUseSameSnooze.isChecked
settingsSnoozeTimeHolder.beVisibleIf(config.useSameSnooze)
}
}
private fun setupSnoozeTime() {
updateSnoozeTime()
settings_snooze_time_holder.setOnClickListener {
binding.settingsSnoozeTimeHolder.setOnClickListener {
showPickSecondsDialogHelper(config.snoozeTime, true) {
config.snoozeTime = it / 60
updateSnoozeTime()
@ -554,51 +562,51 @@ class SettingsActivity : SimpleActivity() {
}
private fun updateSnoozeTime() {
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
binding.settingsSnoozeTime.text = formatMinutesToTimeString(config.snoozeTime)
}
private fun setupDefaultReminder() {
settings_use_last_event_reminders.isChecked = config.usePreviousEventReminders
private fun setupDefaultReminder() = binding.apply {
settingsUseLastEventReminders.isChecked = config.usePreviousEventReminders
toggleDefaultRemindersVisibility(!config.usePreviousEventReminders)
settings_use_last_event_reminders_holder.setOnClickListener {
settings_use_last_event_reminders.toggle()
config.usePreviousEventReminders = settings_use_last_event_reminders.isChecked
toggleDefaultRemindersVisibility(!settings_use_last_event_reminders.isChecked)
settingsUseLastEventRemindersHolder.setOnClickListener {
settingsUseLastEventReminders.toggle()
config.usePreviousEventReminders = settingsUseLastEventReminders.isChecked
toggleDefaultRemindersVisibility(!settingsUseLastEventReminders.isChecked)
}
}
private fun setupDefaultReminder1() {
settings_default_reminder_1.text = getFormattedMinutes(config.defaultReminder1)
settings_default_reminder_1_holder.setOnClickListener {
private fun setupDefaultReminder1() = binding.apply {
settingsDefaultReminder1.text = getFormattedMinutes(config.defaultReminder1)
settingsDefaultReminder1Holder.setOnClickListener {
showPickSecondsDialogHelper(config.defaultReminder1) {
config.defaultReminder1 = if (it == -1 || it == 0) it else it / 60
settings_default_reminder_1.text = getFormattedMinutes(config.defaultReminder1)
settingsDefaultReminder1.text = getFormattedMinutes(config.defaultReminder1)
}
}
}
private fun setupDefaultReminder2() {
settings_default_reminder_2.text = getFormattedMinutes(config.defaultReminder2)
settings_default_reminder_2_holder.setOnClickListener {
private fun setupDefaultReminder2() = binding.apply {
settingsDefaultReminder2.text = getFormattedMinutes(config.defaultReminder2)
settingsDefaultReminder2Holder.setOnClickListener {
showPickSecondsDialogHelper(config.defaultReminder2) {
config.defaultReminder2 = if (it == -1 || it == 0) it else it / 60
settings_default_reminder_2.text = getFormattedMinutes(config.defaultReminder2)
settingsDefaultReminder2.text = getFormattedMinutes(config.defaultReminder2)
}
}
}
private fun setupDefaultReminder3() {
settings_default_reminder_3.text = getFormattedMinutes(config.defaultReminder3)
settings_default_reminder_3_holder.setOnClickListener {
private fun setupDefaultReminder3() = binding.apply {
settingsDefaultReminder3.text = getFormattedMinutes(config.defaultReminder3)
settingsDefaultReminder3Holder.setOnClickListener {
showPickSecondsDialogHelper(config.defaultReminder3) {
config.defaultReminder3 = if (it == -1 || it == 0) it else it / 60
settings_default_reminder_3.text = getFormattedMinutes(config.defaultReminder3)
settingsDefaultReminder3.text = getFormattedMinutes(config.defaultReminder3)
}
}
}
private fun toggleDefaultRemindersVisibility(show: Boolean) {
arrayOf(settings_default_reminder_1_holder, settings_default_reminder_2_holder, settings_default_reminder_3_holder).forEach {
private fun toggleDefaultRemindersVisibility(show: Boolean) = binding.apply {
arrayOf(settingsDefaultReminder1Holder, settingsDefaultReminder2Holder, settingsDefaultReminder3Holder).forEach {
it.beVisibleIf(show)
}
}
@ -618,7 +626,7 @@ class SettingsActivity : SimpleActivity() {
private fun setupDisplayPastEvents() {
var displayPastEvents = config.displayPastEvents
updatePastEventsText(displayPastEvents)
settings_display_past_events_holder.setOnClickListener {
binding.settingsDisplayPastEventsHolder.setOnClickListener {
CustomIntervalPickerDialog(this, displayPastEvents * 60) {
val result = it / 60
displayPastEvents = result
@ -629,7 +637,7 @@ class SettingsActivity : SimpleActivity() {
}
private fun updatePastEventsText(displayPastEvents: Int) {
settings_display_past_events.text = getDisplayPastEventsText(displayPastEvents)
binding.settingsDisplayPastEvents.text = getDisplayPastEventsText(displayPastEvents)
}
private fun getDisplayPastEventsText(displayPastEvents: Int): String {
@ -640,9 +648,9 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupFontSize() {
settings_font_size.text = getFontSizeText()
settings_font_size_holder.setOnClickListener {
private fun setupFontSize() = binding.apply {
settingsFontSize.text = getFontSizeText()
settingsFontSizeHolder.setOnClickListener {
val items = arrayListOf(
RadioItem(FONT_SIZE_SMALL, getString(R.string.small)),
RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)),
@ -652,14 +660,14 @@ class SettingsActivity : SimpleActivity() {
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
config.fontSize = it as Int
settings_font_size.text = getFontSizeText()
settingsFontSize.text = getFontSizeText()
updateWidgets()
}
}
}
private fun setupCustomizeWidgetColors() {
settings_widget_color_customization_holder.setOnClickListener {
binding.settingsWidgetColorCustomizationHolder.setOnClickListener {
Intent(this, WidgetListConfigureActivity::class.java).apply {
putExtra(IS_CUSTOMIZING_COLORS, true)
startActivity(this)
@ -667,9 +675,9 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupViewToOpenFromListWidget() {
settings_list_widget_view_to_open.text = getDefaultViewText()
settings_list_widget_view_to_open_holder.setOnClickListener {
private fun setupViewToOpenFromListWidget() = binding.apply {
settingsListWidgetViewToOpen.text = getDefaultViewText()
settingsListWidgetViewToOpenHolder.setOnClickListener {
val items = arrayListOf(
RadioItem(DAILY_VIEW, getString(R.string.daily_view)),
RadioItem(WEEKLY_VIEW, getString(R.string.weekly_view)),
@ -682,7 +690,7 @@ class SettingsActivity : SimpleActivity() {
RadioGroupDialog(this@SettingsActivity, items, config.listWidgetViewToOpen) {
config.listWidgetViewToOpen = it as Int
settings_list_widget_view_to_open.text = getDefaultViewText()
settingsListWidgetViewToOpen.text = getDefaultViewText()
updateWidgets()
}
}
@ -700,33 +708,33 @@ class SettingsActivity : SimpleActivity() {
}
)
private fun setupDimEvents() {
settings_dim_past_events.isChecked = config.dimPastEvents
settings_dim_past_events_holder.setOnClickListener {
settings_dim_past_events.toggle()
config.dimPastEvents = settings_dim_past_events.isChecked
private fun setupDimEvents() = binding.apply {
settingsDimPastEvents.isChecked = config.dimPastEvents
settingsDimPastEventsHolder.setOnClickListener {
settingsDimPastEvents.toggle()
config.dimPastEvents = settingsDimPastEvents.isChecked
}
}
private fun setupDimCompletedTasks() {
settings_dim_completed_tasks.isChecked = config.dimCompletedTasks
settings_dim_completed_tasks_holder.setOnClickListener {
settings_dim_completed_tasks.toggle()
config.dimCompletedTasks = settings_dim_completed_tasks.isChecked
private fun setupDimCompletedTasks() = binding.apply {
settingsDimCompletedTasks.isChecked = config.dimCompletedTasks
settingsDimCompletedTasksHolder.setOnClickListener {
settingsDimCompletedTasks.toggle()
config.dimCompletedTasks = settingsDimCompletedTasks.isChecked
}
}
private fun setupAllowChangingTimeZones() {
settings_allow_changing_time_zones.isChecked = config.allowChangingTimeZones
settings_allow_changing_time_zones_holder.setOnClickListener {
settings_allow_changing_time_zones.toggle()
config.allowChangingTimeZones = settings_allow_changing_time_zones.isChecked
private fun setupAllowChangingTimeZones() = binding.apply {
settingsAllowChangingTimeZones.isChecked = config.allowChangingTimeZones
settingsAllowChangingTimeZonesHolder.setOnClickListener {
settingsAllowChangingTimeZones.toggle()
config.allowChangingTimeZones = settingsAllowChangingTimeZones.isChecked
}
}
private fun setupDefaultStartTime() {
updateDefaultStartTimeText()
settings_default_start_time_holder.setOnClickListener {
binding.settingsDefaultStartTimeHolder.setOnClickListener {
val currentDefaultTime = when (config.defaultStartTime) {
DEFAULT_START_TIME_NEXT_FULL_HOUR -> DEFAULT_START_TIME_NEXT_FULL_HOUR
DEFAULT_START_TIME_CURRENT_TIME -> DEFAULT_START_TIME_CURRENT_TIME
@ -785,22 +793,22 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun updateDefaultStartTimeText() {
private fun updateDefaultStartTimeText() = binding.apply {
when (config.defaultStartTime) {
DEFAULT_START_TIME_CURRENT_TIME -> settings_default_start_time.text = getString(R.string.current_time)
DEFAULT_START_TIME_NEXT_FULL_HOUR -> settings_default_start_time.text = getString(R.string.next_full_hour)
DEFAULT_START_TIME_CURRENT_TIME -> settingsDefaultStartTime.text = getString(R.string.current_time)
DEFAULT_START_TIME_NEXT_FULL_HOUR -> settingsDefaultStartTime.text = getString(R.string.next_full_hour)
else -> {
val hours = config.defaultStartTime / 60
val minutes = config.defaultStartTime % 60
val dateTime = DateTime.now().withHourOfDay(hours).withMinuteOfHour(minutes)
settings_default_start_time.text = Formatter.getTime(this, dateTime)
settingsDefaultStartTime.text = Formatter.getTime(this@SettingsActivity, dateTime)
}
}
}
private fun setupDefaultDuration() {
updateDefaultDurationText()
settings_default_duration_holder.setOnClickListener {
binding.settingsDefaultDurationHolder.setOnClickListener {
CustomIntervalPickerDialog(this, config.defaultDuration * 60) {
val result = it / 60
config.defaultDuration = result
@ -811,18 +819,18 @@ class SettingsActivity : SimpleActivity() {
private fun updateDefaultDurationText() {
val duration = config.defaultDuration
settings_default_duration.text = if (duration == 0) {
binding.settingsDefaultDuration.text = if (duration == 0) {
"0 ${getString(R.string.minutes_raw)}"
} else {
getFormattedMinutes(duration, false)
}
}
private fun setupDefaultEventType() {
private fun setupDefaultEventType() = binding.apply {
updateDefaultEventTypeText()
settings_default_event_type.text = getString(R.string.last_used_one)
settings_default_event_type_holder.setOnClickListener {
SelectEventTypeDialog(this, config.defaultEventTypeId, true, false, true, true, false) {
settingsDefaultEventType.text = getString(R.string.last_used_one)
settingsDefaultEventTypeHolder.setOnClickListener {
SelectEventTypeDialog(this@SettingsActivity, config.defaultEventTypeId, true, false, true, true, false) {
config.defaultEventTypeId = it.id!!
updateDefaultEventTypeText()
}
@ -832,7 +840,7 @@ class SettingsActivity : SimpleActivity() {
private fun updateDefaultEventTypeText() {
if (config.defaultEventTypeId == -1L) {
runOnUiThread {
settings_default_event_type.text = getString(R.string.last_used_one)
binding.settingsDefaultEventType.text = getString(R.string.last_used_one)
}
} else {
ensureBackgroundThread {
@ -840,7 +848,7 @@ class SettingsActivity : SimpleActivity() {
if (eventType != null) {
config.lastUsedCaldavCalendarId = eventType.caldavCalendarId
runOnUiThread {
settings_default_event_type.text = eventType.title
binding.settingsDefaultEventType.text = eventType.title
}
} else {
config.defaultEventTypeId = -1
@ -850,16 +858,16 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupEnableAutomaticBackups() {
settings_backups_label.beVisibleIf(isRPlus())
settings_backups_divider.beVisibleIf(isRPlus())
settings_enable_automatic_backups_holder.beVisibleIf(isRPlus())
settings_enable_automatic_backups.isChecked = config.autoBackup
settings_enable_automatic_backups_holder.setOnClickListener {
private fun setupEnableAutomaticBackups() = binding.apply {
settingsBackupsLabel.beVisibleIf(isRPlus())
settingsBackupsDivider.beVisibleIf(isRPlus())
settingsEnableAutomaticBackupsHolder.beVisibleIf(isRPlus())
settingsEnableAutomaticBackups.isChecked = config.autoBackup
settingsEnableAutomaticBackupsHolder.setOnClickListener {
val wasBackupDisabled = !config.autoBackup
if (wasBackupDisabled) {
ManageAutomaticBackupsDialog(
activity = this,
activity = this@SettingsActivity,
onSuccess = {
enableOrDisableAutomaticBackups(true)
scheduleNextAutomaticBackup()
@ -872,11 +880,11 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupManageAutomaticBackups() {
settings_manage_automatic_backups_holder.beVisibleIf(isRPlus() && config.autoBackup)
settings_manage_automatic_backups_holder.setOnClickListener {
private fun setupManageAutomaticBackups() = binding.apply {
settingsManageAutomaticBackupsHolder.beVisibleIf(isRPlus() && config.autoBackup)
settingsManageAutomaticBackupsHolder.setOnClickListener {
ManageAutomaticBackupsDialog(
activity = this,
activity = this@SettingsActivity,
onSuccess = {
scheduleNextAutomaticBackup()
}
@ -884,14 +892,14 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun enableOrDisableAutomaticBackups(enable: Boolean) {
private fun enableOrDisableAutomaticBackups(enable: Boolean) = binding.apply {
config.autoBackup = enable
settings_enable_automatic_backups.isChecked = enable
settings_manage_automatic_backups_holder.beVisibleIf(enable)
settingsEnableAutomaticBackups.isChecked = enable
settingsManageAutomaticBackupsHolder.beVisibleIf(enable)
}
private fun setupExportSettings() {
settings_export_holder.setOnClickListener {
binding.settingsExportHolder.setOnClickListener {
val configItems = LinkedHashMap<String, Any>().apply {
put(IS_USING_SHARED_THEME, config.isUsingSharedTheme)
put(TEXT_COLOR, config.textColor)
@ -944,7 +952,7 @@ class SettingsActivity : SimpleActivity() {
}
private fun setupImportSettings() {
settings_import_holder.setOnClickListener {
binding.settingsImportHolder.setOnClickListener {
if (isQPlus()) {
Intent(Intent.ACTION_GET_CONTENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
@ -1008,6 +1016,7 @@ class SettingsActivity : SimpleActivity() {
checkAppIconColor()
}
}
USE_ENGLISH -> config.useEnglish = value.toBoolean()
WAS_USE_ENGLISH_TOGGLED -> config.wasUseEnglishToggled = value.toBoolean()
WIDGET_BG_COLOR -> config.widgetBgColor = value.toInt()

View file

@ -10,6 +10,7 @@ import androidx.core.content.ContextCompat
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.ActivityTaskBinding
import com.simplemobiletools.calendar.pro.dialogs.*
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.*
@ -23,7 +24,7 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem
import kotlinx.android.synthetic.main.activity_task.*
import org.joda.time.DateTime
import kotlin.math.pow
@ -48,10 +49,12 @@ class TaskActivity : SimpleActivity() {
private var mIsNewTask = true
private var mEventColor = 0
private val binding by viewBinding(ActivityTaskBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_task)
setContentView(binding.root)
setupOptionsMenu()
refreshMenuItems()
@ -59,8 +62,8 @@ class TaskActivity : SimpleActivity() {
return
}
updateMaterialActivityViews(task_coordinator, task_holder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(task_nested_scrollview, task_toolbar)
updateMaterialActivityViews(binding.taskCoordinator, binding.taskHolder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(binding.taskNestedScrollview, binding.taskToolbar)
val intent = intent ?: return
updateColors()
@ -85,12 +88,12 @@ class TaskActivity : SimpleActivity() {
override fun onResume() {
super.onResume()
setupToolbar(task_toolbar, NavigationIcon.Arrow)
setupToolbar(binding.taskToolbar, NavigationIcon.Arrow)
}
private fun refreshMenuItems() {
if (::mTask.isInitialized) {
task_toolbar.menu.apply {
binding.taskToolbar.menu.apply {
findItem(R.id.delete).isVisible = mTask.id != null
findItem(R.id.share).isVisible = mTask.id != null
findItem(R.id.duplicate).isVisible = mTask.id != null
@ -99,7 +102,7 @@ class TaskActivity : SimpleActivity() {
}
private fun setupOptionsMenu() {
task_toolbar.setOnMenuItemClickListener { menuItem ->
binding.taskToolbar.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.save -> saveCurrentTask()
R.id.delete -> deleteTask()
@ -125,8 +128,8 @@ class TaskActivity : SimpleActivity() {
val reminders = getReminders()
val originalReminders = mTask.getReminders()
if (task_title.text.toString() != mTask.title ||
task_description.text.toString() != mTask.description ||
if (binding.taskTitle.text.toString() != mTask.title ||
binding.taskDescription.text.toString() != mTask.description ||
reminders != originalReminders ||
mRepeatInterval != mTask.repeatInterval ||
mRepeatRule != mTask.repeatRule ||
@ -232,7 +235,7 @@ class TaskActivity : SimpleActivity() {
if (intent.getBooleanExtra(IS_DUPLICATE_INTENT, false)) {
mTask.id = null
task_toolbar.title = getString(R.string.new_task)
binding.taskToolbar.title = getString(R.string.new_task)
}
} else {
mTask = Event(null)
@ -247,34 +250,37 @@ class TaskActivity : SimpleActivity() {
}
}
task_all_day.setOnCheckedChangeListener { _, isChecked -> toggleAllDay(isChecked) }
task_all_day_holder.setOnClickListener {
task_all_day.toggle()
}
binding.apply {
taskAllDay.setOnCheckedChangeListener { _, isChecked -> toggleAllDay(isChecked) }
taskAllDayHolder.setOnClickListener {
taskAllDay.toggle()
}
task_date.setOnClickListener { setupDate() }
task_time.setOnClickListener { setupTime() }
task_type_holder.setOnClickListener { showEventTypeDialog() }
task_repetition.setOnClickListener { showRepeatIntervalDialog() }
task_repetition_rule_holder.setOnClickListener { showRepetitionRuleDialog() }
task_repetition_limit_holder.setOnClickListener { showRepetitionTypePicker() }
taskDate.setOnClickListener { setupDate() }
taskTime.setOnClickListener { setupTime() }
taskTypeHolder.setOnClickListener { showEventTypeDialog() }
taskRepetition.setOnClickListener { showRepeatIntervalDialog() }
taskRepetitionRuleHolder.setOnClickListener { showRepetitionRuleDialog() }
taskRepetitionLimitHolder.setOnClickListener { showRepetitionTypePicker() }
task_reminder_1.setOnClickListener {
handleNotificationAvailability {
if (config.wasAlarmWarningShown) {
showReminder1Dialog()
} else {
ReminderWarningDialog(this) {
config.wasAlarmWarningShown = true
taskReminder1.setOnClickListener {
handleNotificationAvailability {
if (config.wasAlarmWarningShown) {
showReminder1Dialog()
} else {
ReminderWarningDialog(this@TaskActivity) {
config.wasAlarmWarningShown = true
showReminder1Dialog()
}
}
}
}
taskReminder2.setOnClickListener { showReminder2Dialog() }
taskReminder3.setOnClickListener { showReminder3Dialog() }
taskColorHolder.setOnClickListener { showTaskColorDialog() }
}
task_reminder_2.setOnClickListener { showReminder2Dialog() }
task_reminder_3.setOnClickListener { showReminder3Dialog() }
task_color_holder.setOnClickListener { showTaskColorDialog() }
refreshMenuItems()
setupMarkCompleteButton()
@ -290,7 +296,7 @@ class TaskActivity : SimpleActivity() {
mOriginalStartTS = realStart
mTaskDateTime = Formatter.getDateTimeFromTS(realStart)
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
task_toolbar.title = getString(R.string.edit_task)
binding.taskToolbar.title = getString(R.string.edit_task)
mEventTypeId = mTask.eventType
mReminder1Minutes = mTask.reminder1Minutes
@ -304,9 +310,9 @@ class TaskActivity : SimpleActivity() {
mRepeatRule = mTask.repeatRule
mEventColor = mTask.color
task_title.setText(mTask.title)
task_description.setText(mTask.description)
task_all_day.isChecked = mTask.getIsAllDay()
binding.taskTitle.setText(mTask.title)
binding.taskDescription.setText(mTask.description)
binding.taskAllDay.isChecked = mTask.getIsAllDay()
toggleAllDay(mTask.getIsAllDay())
checkRepeatTexts(mRepeatInterval)
}
@ -317,8 +323,8 @@ class TaskActivity : SimpleActivity() {
mTaskDateTime = dateTime
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
task_title.requestFocus()
task_toolbar.title = getString(R.string.new_task)
binding.taskTitle.requestFocus()
binding.taskToolbar.title = getString(R.string.new_task)
mTask.apply {
this.startTS = mTaskDateTime.seconds()
@ -349,11 +355,11 @@ class TaskActivity : SimpleActivity() {
}
private fun saveTask() {
val newTitle = task_title.value
val newTitle = binding.taskTitle.value
if (newTitle.isEmpty()) {
toast(R.string.title_empty)
runOnUiThread {
task_title.requestFocus()
binding.taskTitle.requestFocus()
}
return
}
@ -366,7 +372,7 @@ class TaskActivity : SimpleActivity() {
}
val reminders = getReminders()
if (!task_all_day.isChecked) {
if (!binding.taskAllDay.isChecked) {
if ((reminders.getOrNull(2)?.minutes ?: 0) < -1) {
reminders.removeAt(2)
}
@ -397,7 +403,7 @@ class TaskActivity : SimpleActivity() {
startTS = mTaskDateTime.withSecondOfMinute(0).withMillisOfSecond(0).seconds()
endTS = startTS
title = newTitle
description = task_description.value
description = binding.taskDescription.value
// migrate completed task to the new completed tasks db
if (!wasRepeatable && mTask.isTaskCompleted()) {
@ -407,7 +413,7 @@ class TaskActivity : SimpleActivity() {
}
}
importId = newImportId
flags = mTask.flags.addBitIf(task_all_day.isChecked, FLAG_ALL_DAY)
flags = mTask.flags.addBitIf(binding.taskAllDay.isChecked, FLAG_ALL_DAY)
lastUpdated = System.currentTimeMillis()
eventType = mEventTypeId
type = TYPE_TASK
@ -479,11 +485,13 @@ class TaskActivity : SimpleActivity() {
finish()
}
}
EDIT_FUTURE_OCCURRENCES -> {
eventsHelper.editFutureOccurrences(mTask, mTaskOccurrenceTS, true) {
finish()
}
}
EDIT_ALL_OCCURRENCES -> {
eventsHelper.editAllOccurrences(mTask, mOriginalStartTS, showToasts = true) {
finish()
@ -613,21 +621,21 @@ class TaskActivity : SimpleActivity() {
}
private fun updateDateText() {
task_date.text = Formatter.getDate(this, mTaskDateTime)
binding.taskDate.text = Formatter.getDate(this, mTaskDateTime)
}
private fun updateTimeText() {
task_time.text = Formatter.getTime(this, mTaskDateTime)
binding.taskTime.text = Formatter.getTime(this, mTaskDateTime)
}
private fun toggleAllDay(isChecked: Boolean) {
hideKeyboard()
task_time.beGoneIf(isChecked)
binding.taskTime.beGoneIf(isChecked)
}
private fun setupMarkCompleteButton() {
toggle_mark_complete.setOnClickListener { toggleCompletion() }
toggle_mark_complete.beVisibleIf(mTask.id != null)
binding.toggleMarkComplete.setOnClickListener { toggleCompletion() }
binding.toggleMarkComplete.beVisibleIf(mTask.id != null)
updateTaskCompletedButton()
ensureBackgroundThread {
// the stored value might be incorrect so update it (e.g. user completed the task via notification action before editing)
@ -640,16 +648,16 @@ class TaskActivity : SimpleActivity() {
private fun updateTaskCompletedButton() {
if (mTaskCompleted) {
toggle_mark_complete.background = ContextCompat.getDrawable(this, R.drawable.button_background_stroke)
toggle_mark_complete.setText(R.string.mark_incomplete)
toggle_mark_complete.setTextColor(getProperTextColor())
binding.toggleMarkComplete.background = ContextCompat.getDrawable(this, R.drawable.button_background_stroke)
binding.toggleMarkComplete.setText(R.string.mark_incomplete)
binding.toggleMarkComplete.setTextColor(getProperTextColor())
} else {
val markCompleteBgColor = if (isWhiteTheme()) {
Color.WHITE
} else {
getProperPrimaryColor()
}
toggle_mark_complete.setTextColor(markCompleteBgColor.getContrastColor())
binding.toggleMarkComplete.setTextColor(markCompleteBgColor.getContrastColor())
}
}
@ -669,12 +677,12 @@ class TaskActivity : SimpleActivity() {
}
private fun updateReminder1Text() {
task_reminder_1.text = getFormattedMinutes(mReminder1Minutes)
binding.taskReminder1.text = getFormattedMinutes(mReminder1Minutes)
}
private fun updateReminder2Text() {
task_reminder_2.apply {
beGoneIf(task_reminder_2.isGone() && mReminder1Minutes == REMINDER_OFF)
binding.taskReminder2.apply {
beGoneIf(binding.taskReminder2.isGone() && mReminder1Minutes == REMINDER_OFF)
if (mReminder2Minutes == REMINDER_OFF) {
text = resources.getString(R.string.add_another_reminder)
alpha = 0.4f
@ -686,8 +694,8 @@ class TaskActivity : SimpleActivity() {
}
private fun updateReminder3Text() {
task_reminder_3.apply {
beGoneIf(task_reminder_3.isGone() && (mReminder2Minutes == REMINDER_OFF || mReminder1Minutes == REMINDER_OFF))
binding.taskReminder3.apply {
beGoneIf(binding.taskReminder3.isGone() && (mReminder2Minutes == REMINDER_OFF || mReminder1Minutes == REMINDER_OFF))
if (mReminder3Minutes == REMINDER_OFF) {
text = resources.getString(R.string.add_another_reminder)
alpha = 0.4f
@ -750,13 +758,13 @@ class TaskActivity : SimpleActivity() {
val eventType = eventTypesDB.getEventTypeWithId(mEventTypeId)
if (eventType != null) {
runOnUiThread {
task_type.text = eventType.title
binding.taskType.text = eventType.title
updateTaskColorInfo(eventType.color)
}
}
task_color_image.beVisibleIf(eventType != null)
task_color_holder.beVisibleIf(eventType != null)
task_color_divider.beVisibleIf(eventType != null)
binding.taskColorImage.beVisibleIf(eventType != null)
binding.taskColorHolder.beVisibleIf(eventType != null)
binding.taskColorDivider.beVisibleIf(eventType != null)
}
}
@ -789,16 +797,19 @@ class TaskActivity : SimpleActivity() {
} else {
mEventColor
}
task_color.setFillWithStroke(taskColor, getProperBackgroundColor())
binding.taskColor.setFillWithStroke(taskColor, getProperBackgroundColor())
}
private fun updateColors() {
updateTextColors(task_nested_scrollview)
val textColor = getProperTextColor()
arrayOf(
task_time_image, task_reminder_image, task_type_image, task_repetition_image, task_color_image
).forEach {
it.applyColorFilter(textColor)
binding.apply {
updateTextColors(taskNestedScrollview)
val textColor = getProperTextColor()
arrayOf(
taskTimeImage, taskReminderImage, taskTypeImage, taskRepetitionImage, taskColorImage
).forEach {
it.applyColorFilter(textColor)
}
}
}
@ -821,10 +832,10 @@ class TaskActivity : SimpleActivity() {
}
private fun checkRepeatTexts(limit: Int) {
task_repetition_limit_holder.beGoneIf(limit == 0)
binding.taskRepetitionLimitHolder.beGoneIf(limit == 0)
checkRepetitionLimitText()
task_repetition_rule_holder.beVisibleIf(mRepeatInterval.isXWeeklyRepetition() || mRepeatInterval.isXMonthlyRepetition() || mRepeatInterval.isXYearlyRepetition())
binding.taskRepetitionRuleHolder.beVisibleIf(mRepeatInterval.isXWeeklyRepetition() || mRepeatInterval.isXMonthlyRepetition() || mRepeatInterval.isXYearlyRepetition())
checkRepetitionRuleText()
}
@ -841,18 +852,20 @@ class TaskActivity : SimpleActivity() {
}
private fun checkRepetitionLimitText() {
task_repetition_limit.text = when {
binding.taskRepetitionLimit.text = when {
mRepeatLimit == 0L -> {
task_repetition_limit_label.text = getString(R.string.repeat)
binding.taskRepetitionLimitLabel.text = getString(R.string.repeat)
resources.getString(R.string.forever)
}
mRepeatLimit > 0 -> {
task_repetition_limit_label.text = getString(R.string.repeat_till)
binding.taskRepetitionLimitLabel.text = getString(R.string.repeat_till)
val repeatLimitDateTime = Formatter.getDateTimeFromTS(mRepeatLimit)
Formatter.getFullDate(this, repeatLimitDateTime)
}
else -> {
task_repetition_limit_label.text = getString(R.string.repeat)
binding.taskRepetitionLimitLabel.text = getString(R.string.repeat)
"${-mRepeatLimit} ${getString(R.string.times)}"
}
}
@ -864,12 +877,14 @@ class TaskActivity : SimpleActivity() {
mRepeatInterval.isXWeeklyRepetition() -> RepeatRuleWeeklyDialog(this, mRepeatRule) {
setRepeatRule(it)
}
mRepeatInterval.isXMonthlyRepetition() -> {
val items = getAvailableMonthlyRepetitionRules()
RadioGroupDialog(this, items, mRepeatRule) {
setRepeatRule(it as Int)
}
}
mRepeatInterval.isXYearlyRepetition() -> {
val items = getAvailableYearlyRepetitionRules()
RadioGroupDialog(this, items, mRepeatRule) {
@ -984,21 +999,23 @@ class TaskActivity : SimpleActivity() {
private fun checkRepetitionRuleText() {
when {
mRepeatInterval.isXWeeklyRepetition() -> {
task_repetition_rule.text = if (mRepeatRule == EVERY_DAY_BIT) getString(R.string.every_day) else getShortDaysFromBitmask(mRepeatRule)
binding.taskRepetitionRule.text = if (mRepeatRule == EVERY_DAY_BIT) getString(R.string.every_day) else getShortDaysFromBitmask(mRepeatRule)
}
mRepeatInterval.isXMonthlyRepetition() -> {
val repeatString = if (mRepeatRule == REPEAT_ORDER_WEEKDAY_USE_LAST || mRepeatRule == REPEAT_ORDER_WEEKDAY)
R.string.repeat else R.string.repeat_on
task_repetition_rule_label.text = getString(repeatString)
task_repetition_rule.text = getMonthlyRepetitionRuleText()
binding.taskRepetitionRuleLabel.text = getString(repeatString)
binding.taskRepetitionRule.text = getMonthlyRepetitionRuleText()
}
mRepeatInterval.isXYearlyRepetition() -> {
val repeatString = if (mRepeatRule == REPEAT_ORDER_WEEKDAY_USE_LAST || mRepeatRule == REPEAT_ORDER_WEEKDAY)
R.string.repeat else R.string.repeat_on
task_repetition_rule_label.text = getString(repeatString)
task_repetition_rule.text = getYearlyRepetitionRuleText()
binding.taskRepetitionRuleLabel.text = getString(repeatString)
binding.taskRepetitionRule.text = getYearlyRepetitionRuleText()
}
}
}
@ -1015,11 +1032,11 @@ class TaskActivity : SimpleActivity() {
}
private fun updateRepetitionText() {
task_repetition.text = getRepetitionText(mRepeatInterval)
binding.taskRepetition.text = getRepetitionText(mRepeatInterval)
}
private fun updateActionBarTitle() {
task_toolbar.title = if (mIsNewTask) {
binding.taskToolbar.title = if (mIsNewTask) {
getString(R.string.new_task)
} else {
getString(R.string.edit_task)

View file

@ -7,13 +7,13 @@ import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.WidgetConfigDateBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.MyWidgetDateProvider
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
import kotlinx.android.synthetic.main.widget_config_date.*
class WidgetDateConfigureActivity : SimpleActivity() {
private var mBgAlpha = 0f
@ -22,11 +22,13 @@ class WidgetDateConfigureActivity : SimpleActivity() {
private var mBgColor = 0
private var mTextColor = 0
private val binding by viewBinding(WidgetConfigDateBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
super.onCreate(savedInstanceState)
setResult(Activity.RESULT_CANCELED)
setContentView(R.layout.widget_config_date)
setContentView(binding.root)
initVariables()
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
@ -37,12 +39,14 @@ class WidgetDateConfigureActivity : SimpleActivity() {
}
val primaryColor = getProperPrimaryColor()
config_save.setOnClickListener { saveConfig() }
config_bg_color.setOnClickListener { pickBackgroundColor() }
config_text_color.setOnClickListener { pickTextColor() }
config_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor)
widget_date_label.text = Formatter.getTodayDayNumber()
widget_month_label.text = Formatter.getCurrentMonthShort()
binding.apply {
configSave.setOnClickListener { saveConfig() }
configBgColor.setOnClickListener { pickBackgroundColor() }
configTextColor.setOnClickListener { pickTextColor() }
configBgSeekbar.setColors(mTextColor, primaryColor, primaryColor)
widgetDateLabel.text = Formatter.getTodayDayNumber()
widgetMonthLabel.text = Formatter.getCurrentMonthShort()
}
}
private fun initVariables() {
@ -50,7 +54,7 @@ class WidgetDateConfigureActivity : SimpleActivity() {
mBgAlpha = Color.alpha(mBgColor) / 255f
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
config_bg_seekbar.apply {
binding.configBgSeekbar.apply {
progress = (mBgAlpha * 100).toInt()
onSeekBarChangeListener { progress ->
@ -112,16 +116,20 @@ class WidgetDateConfigureActivity : SimpleActivity() {
}
private fun updateTextColor() {
config_text_color.setFillWithStroke(mTextColor, mTextColor)
widget_date_label.setTextColor(mTextColor)
widget_month_label.setTextColor(mTextColor)
config_save.setTextColor(getProperPrimaryColor().getContrastColor())
binding.apply {
configTextColor.setFillWithStroke(mTextColor, mTextColor)
widgetDateLabel.setTextColor(mTextColor)
widgetMonthLabel.setTextColor(mTextColor)
configSave.setTextColor(getProperPrimaryColor().getContrastColor())
}
}
private fun updateBackgroundColor() {
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
config_date_time_wrapper.background.applyColorFilter(mBgColor)
config_bg_color.setFillWithStroke(mBgColor, mBgColor)
config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
binding.apply {
configDateTimeWrapper.background.applyColorFilter(mBgColor)
configBgColor.setFillWithStroke(mBgColor, mBgColor)
configSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
}
}
}

View file

@ -9,6 +9,7 @@ import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.EventListAdapter
import com.simplemobiletools.calendar.pro.databinding.WidgetConfigListBinding
import com.simplemobiletools.calendar.pro.dialogs.CustomPeriodPickerDialog
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.seconds
@ -26,9 +27,8 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem
import kotlinx.android.synthetic.main.widget_config_list.*
import org.joda.time.DateTime
import java.util.*
import java.util.TreeSet
class WidgetListConfigureActivity : SimpleActivity() {
private var mBgAlpha = 0f
@ -38,11 +38,13 @@ class WidgetListConfigureActivity : SimpleActivity() {
private var mTextColor = 0
private var mSelectedPeriodOption = 0
private val binding by viewBinding(WidgetConfigListBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
super.onCreate(savedInstanceState)
setResult(Activity.RESULT_CANCELED)
setContentView(R.layout.widget_config_list)
setContentView(binding.root)
initVariables()
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
@ -52,23 +54,25 @@ class WidgetListConfigureActivity : SimpleActivity() {
finish()
}
EventListAdapter(this, getListItems(), false, null, config_events_list) {}.apply {
updateTextColor(mTextColor)
config_events_list.adapter = this
binding.apply {
EventListAdapter(this@WidgetListConfigureActivity, getListItems(), false, null, configEventsList) {}.apply {
updateTextColor(mTextColor)
configEventsList.adapter = this
}
periodPickerHolder.background = ColorDrawable(getProperBackgroundColor())
periodPickerValue.setOnClickListener { showPeriodSelector() }
configSave.setOnClickListener { saveConfig() }
configBgColor.setOnClickListener { pickBackgroundColor() }
configTextColor.setOnClickListener { pickTextColor() }
periodPickerHolder.beGoneIf(isCustomizingColors)
val primaryColor = getProperPrimaryColor()
configBgSeekbar.setColors(mTextColor, primaryColor, primaryColor)
}
period_picker_holder.background = ColorDrawable(getProperBackgroundColor())
period_picker_value.setOnClickListener { showPeriodSelector() }
config_save.setOnClickListener { saveConfig() }
config_bg_color.setOnClickListener { pickBackgroundColor() }
config_text_color.setOnClickListener { pickTextColor() }
period_picker_holder.beGoneIf(isCustomizingColors)
val primaryColor = getProperPrimaryColor()
config_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor)
updateSelectedPeriod(config.lastUsedEventSpan)
}
@ -77,7 +81,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
mBgAlpha = Color.alpha(mBgColor) / 255f
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
config_bg_seekbar.apply {
binding.configBgSeekbar.apply {
progress = (mBgAlpha * 100).toInt()
onSeekBarChangeListener { progress ->
@ -155,10 +159,11 @@ class WidgetListConfigureActivity : SimpleActivity() {
when (selectedPeriod) {
0 -> {
mSelectedPeriodOption = YEAR_SECONDS
period_picker_value.setText(R.string.within_the_next_one_year)
binding.periodPickerValue.setText(R.string.within_the_next_one_year)
}
EVENT_PERIOD_TODAY -> period_picker_value.setText(R.string.today_only)
else -> period_picker_value.text = getFormattedSeconds(mSelectedPeriodOption)
EVENT_PERIOD_TODAY -> binding.periodPickerValue.setText(R.string.today_only)
else -> binding.periodPickerValue.text = getFormattedSeconds(mSelectedPeriodOption)
}
}
@ -206,16 +211,16 @@ class WidgetListConfigureActivity : SimpleActivity() {
}
private fun updateTextColor() {
(config_events_list.adapter as? EventListAdapter)?.updateTextColor(mTextColor)
config_text_color.setFillWithStroke(mTextColor, mTextColor)
config_save.setTextColor(getProperPrimaryColor().getContrastColor())
(binding.configEventsList.adapter as? EventListAdapter)?.updateTextColor(mTextColor)
binding.configTextColor.setFillWithStroke(mTextColor, mTextColor)
binding.configSave.setTextColor(getProperPrimaryColor().getContrastColor())
}
private fun updateBackgroundColor() {
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
config_events_list.background.applyColorFilter(mBgColor)
config_bg_color.setFillWithStroke(mBgColor, mBgColor)
config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
binding.configEventsList.background.applyColorFilter(mBgColor)
binding.configBgColor.setFillWithStroke(mBgColor, mBgColor)
binding.configSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
}
private fun getListItems(): ArrayList<ListItem> {

View file

@ -1,5 +1,6 @@
package com.simplemobiletools.calendar.pro.activities
import android.annotation.SuppressLint
import android.app.Activity
import android.appwidget.AppWidgetManager
import android.content.Context
@ -8,12 +9,12 @@ import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DayMonthlyNumberViewBinding
import com.simplemobiletools.calendar.pro.databinding.TopNavigationBinding
import com.simplemobiletools.calendar.pro.databinding.WidgetConfigMonthlyBinding
import com.simplemobiletools.calendar.pro.extensions.addDayEvents
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.isWeekendIndex
@ -25,18 +26,10 @@ import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import kotlinx.android.synthetic.main.day_monthly_number_view.view.day_monthly_number_background
import kotlinx.android.synthetic.main.day_monthly_number_view.view.day_monthly_number_id
import kotlinx.android.synthetic.main.first_row.week_num
import kotlinx.android.synthetic.main.top_navigation.top_left_arrow
import kotlinx.android.synthetic.main.top_navigation.top_right_arrow
import kotlinx.android.synthetic.main.top_navigation.top_value
import kotlinx.android.synthetic.main.widget_config_monthly.*
import org.joda.time.DateTime
class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
private var mDays: List<DayMonthly>? = null
private var dayLabelHeight = 0
private var mBgAlpha = 0f
private var mWidgetId = 0
@ -44,11 +37,14 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
private var mBgColor = 0
private var mTextColor = 0
private val binding by viewBinding(WidgetConfigMonthlyBinding::inflate)
private val topNavigationBinding by lazy { TopNavigationBinding.bind(binding.root) }
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
super.onCreate(savedInstanceState)
setResult(Activity.RESULT_CANCELED)
setContentView(R.layout.widget_config_monthly)
setContentView(binding.root)
initVariables()
val isCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
@ -59,10 +55,12 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
}
val primaryColor = getProperPrimaryColor()
config_save.setOnClickListener { saveConfig() }
config_bg_color.setOnClickListener { pickBackgroundColor() }
config_text_color.setOnClickListener { pickTextColor() }
config_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor)
binding.apply {
configSave.setOnClickListener { saveConfig() }
configBgColor.setOnClickListener { pickBackgroundColor() }
configTextColor.setOnClickListener { pickTextColor() }
configBgSeekbar.setColors(mTextColor, primaryColor, primaryColor)
}
}
private fun initVariables() {
@ -70,7 +68,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
mBgAlpha = Color.alpha(mBgColor) / 255f
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
config_bg_seekbar.apply {
binding.configBgSeekbar.apply {
progress = (mBgAlpha * 100).toInt()
onSeekBarChangeListener { progress ->
@ -135,75 +133,82 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
}
private fun updateTextColor() {
top_left_arrow.applyColorFilter(mTextColor)
top_right_arrow.applyColorFilter(mTextColor)
top_value.setTextColor(mTextColor)
config_text_color.setFillWithStroke(mTextColor, mTextColor)
topNavigationBinding.topLeftArrow.applyColorFilter(mTextColor)
topNavigationBinding.topRightArrow.applyColorFilter(mTextColor)
topNavigationBinding.topValue.setTextColor(mTextColor)
binding.configTextColor.setFillWithStroke(mTextColor, mTextColor)
binding.configSave.setTextColor(getProperPrimaryColor().getContrastColor())
updateLabels()
config_save.setTextColor(getProperPrimaryColor().getContrastColor())
}
private fun updateBackgroundColor() {
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
config_calendar.background.applyColorFilter(mBgColor)
config_bg_color.setFillWithStroke(mBgColor, mBgColor)
config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
binding.configCalendar.root.background.applyColorFilter(mBgColor)
binding.configBgColor.setFillWithStroke(mBgColor, mBgColor)
binding.configSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
}
private fun updateDays() {
val len = mDays!!.size
val daysLength = mDays!!.size
binding.configCalendar.apply {
if (config.showWeekNumbers) {
firstRow.weekNum.setTextColor(mTextColor)
firstRow.weekNum.beVisible()
if (config.showWeekNumbers) {
week_num.setTextColor(mTextColor)
week_num.beVisible()
for (i in 0..5) {
findViewById<TextView>(resources.getIdentifier("week_num_$i", "id", packageName)).apply {
text = "${mDays!![i * 7 + 3].weekOfYear}:"
setTextColor(mTextColor)
beVisible()
arrayOf(weekNum0, weekNum1, weekNum2, weekNum3, weekNum4, weekNum5).forEachIndexed { index, textView ->
textView.apply {
@SuppressLint("SetTextI18n")
text = "${mDays!![index * 7 + 3].weekOfYear}:"
setTextColor(mTextColor)
beVisible()
}
}
}
}
val dividerMargin = resources.displayMetrics.density.toInt()
for (i in 0 until len) {
findViewById<LinearLayout>(resources.getIdentifier("day_$i", "id", packageName)).apply {
val dividerMargin = resources.displayMetrics.density.toInt()
val dayViews = arrayOf(
day0, day1, day2, day3, day4, day5, day6, day7, day8, day9, day10, day11, day12, day13,
day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25, day26, day27,
day28, day29, day30, day31, day32, day33, day34, day35, day36, day37, day38, day39, day40, day41
)
for (i in 0 until daysLength) {
val day = mDays!![i]
removeAllViews()
val dayTextColor = if (config.highlightWeekends && day.isWeekend) {
config.highlightWeekendsColor
} else {
mTextColor
}
addDayNumber(dayTextColor, day, this, dayLabelHeight) { dayLabelHeight = it }
context.addDayEvents(day, this, resources, dividerMargin)
dayViews[i].apply {
removeAllViews()
addDayNumber(dayTextColor, day, this)
context.addDayEvents(day, this, resources, dividerMargin)
}
}
}
}
private fun addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: LinearLayout, dayLabelHeight: Int, callback: (Int) -> Unit) {
private fun addDayNumber(rawTextColor: Int, day: DayMonthly, linearLayout: LinearLayout) {
var textColor = rawTextColor
if (!day.isThisMonth) {
textColor = textColor.adjustAlpha(LOWER_ALPHA)
}
(View.inflate(this, R.layout.day_monthly_number_view, null) as RelativeLayout).apply {
layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
linearLayout.addView(this)
DayMonthlyNumberViewBinding.inflate(layoutInflater).apply {
root.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
linearLayout.addView(root)
day_monthly_number_background.beVisibleIf(day.isToday)
day_monthly_number_id.apply {
dayMonthlyNumberBackground.beVisibleIf(day.isToday)
dayMonthlyNumberId.apply {
setTextColor(textColor)
text = day.value.toString()
gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
}
if (day.isToday) {
day_monthly_number_background.setColorFilter(getProperPrimaryColor())
day_monthly_number_id.setTextColor(getProperPrimaryColor().getContrastColor())
dayMonthlyNumberBackground.setColorFilter(getProperPrimaryColor())
dayMonthlyNumberId.setTextColor(getProperPrimaryColor().getContrastColor())
}
}
}
@ -211,22 +216,22 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
override fun updateMonthlyCalendar(context: Context, month: String, days: ArrayList<DayMonthly>, checkedEvents: Boolean, currTargetDate: DateTime) {
runOnUiThread {
mDays = days
top_value.text = month
topNavigationBinding.topValue.text = month
updateDays()
}
}
private fun updateLabels() {
val weekendsTextColor = config.highlightWeekendsColor
for (i in 0..6) {
findViewById<TextView>(resources.getIdentifier("label_$i", "id", packageName)).apply {
val textColor = if (config.highlightWeekends && context.isWeekendIndex(i)) {
binding.configCalendar.firstRow.apply {
arrayOf(label0, label1, label2, label3, label4, label5, label6).forEachIndexed { index, textView ->
val textColor = if (config.highlightWeekends && isWeekendIndex(index)) {
weekendsTextColor
} else {
mTextColor
}
setTextColor(textColor)
textView.setTextColor(textColor)
}
}
}

View file

@ -1,42 +1,46 @@
package com.simplemobiletools.calendar.pro.adapters
import android.graphics.drawable.BitmapDrawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.Filter
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.ItemAutocompleteEmailNameBinding
import com.simplemobiletools.calendar.pro.models.Attendee
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.normalizeString
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
import kotlinx.android.synthetic.main.item_autocomplete_email_name.view.*
class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: ArrayList<Attendee>) : ArrayAdapter<Attendee>(activity, 0, contacts) {
class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val attendees: ArrayList<Attendee>) : ArrayAdapter<Attendee>(activity, 0, attendees) {
var resultList = ArrayList<Attendee>()
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val contact = resultList[position]
val attendee = resultList[position]
val attendeeHasName = attendee.name.isNotEmpty()
var listItem = convertView
if (listItem == null || listItem.tag != contact.name.isNotEmpty()) {
val layout = if (contact.name.isNotEmpty()) R.layout.item_autocomplete_email_name else R.layout.item_autocomplete_email
listItem = LayoutInflater.from(activity).inflate(layout, parent, false)
if (listItem == null || listItem.tag != attendeeHasName) {
listItem = ItemAutocompleteEmailNameBinding.inflate(activity.layoutInflater, parent, false).root
}
val nameToUse = when {
contact.name.isNotEmpty() -> contact.name
contact.email.isNotEmpty() -> contact.email
attendee.name.isNotEmpty() -> attendee.name
attendee.email.isNotEmpty() -> attendee.email
else -> "A"
}
val placeholder = BitmapDrawable(activity.resources, SimpleContactsHelper(context).getContactLetterIcon(nameToUse))
listItem!!.apply {
tag = contact.name.isNotEmpty()
item_autocomplete_name?.text = contact.name
item_autocomplete_email?.text = contact.email
listItem.tag = attendeeHasName
ItemAutocompleteEmailNameBinding.bind(listItem).apply {
itemAutocompleteTitle.text = if (attendeeHasName) {
attendee.name
} else {
attendee.email
}
contact.updateImage(context, item_autocomplete_image, placeholder)
itemAutocompleteSubtitle.text = attendee.email
itemAutocompleteSubtitle.beVisibleIf(attendeeHasName)
attendee.updateImage(context, itemAutocompleteImage, placeholder)
}
return listItem
@ -44,31 +48,35 @@ class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: Ar
override fun getFilter() = object : Filter() {
override fun performFiltering(constraint: CharSequence?): FilterResults {
val filterResults = Filter.FilterResults()
val filterResults = FilterResults()
if (constraint != null) {
resultList.clear()
val results = mutableListOf<Attendee>()
val searchString = constraint.toString().normalizeString()
contacts.forEach {
attendees.forEach {
if (it.email.contains(searchString, true) || it.name.contains(searchString, true)) {
resultList.add(it)
results.add(it)
}
}
resultList.sortWith(compareBy<Attendee>
results.sortWith(compareBy<Attendee>
{ it.name.startsWith(searchString, true) }.thenBy
{ it.email.startsWith(searchString, true) }.thenBy
{ it.name.contains(searchString, true) }.thenBy
{ it.email.contains(searchString, true) })
resultList.reverse()
results.reverse()
filterResults.values = resultList
filterResults.count = resultList.size
filterResults.values = results
filterResults.count = results.size
}
return filterResults
}
override fun publishResults(constraint: CharSequence?, results: FilterResults?) {
if (results?.count ?: -1 > 0) {
resultList.clear()
if (results != null && results.count > 0) {
@Suppress("UNCHECKED_CAST")
resultList.addAll(results.values as List<Attendee>)
notifyDataSetChanged()
} else {
notifyDataSetInvalidated()

View file

@ -3,20 +3,19 @@ package com.simplemobiletools.calendar.pro.adapters
import android.app.Activity
import android.content.res.ColorStateList
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.CheckableColorButtonBinding
import com.simplemobiletools.commons.extensions.applyColorFilter
import kotlinx.android.synthetic.main.checkable_color_button.view.*
class CheckableColorAdapter(private val activity: Activity, private val colors: IntArray, var currentColor: Int, val callback: (color: Int) -> Unit) :
RecyclerView.Adapter<CheckableColorAdapter.CheckableColorViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CheckableColorViewHolder {
val itemView = LayoutInflater.from(activity).inflate(R.layout.checkable_color_button, parent, false)
return CheckableColorViewHolder(itemView)
return CheckableColorViewHolder(
binding = CheckableColorButtonBinding.inflate(activity.layoutInflater, parent, false)
)
}
override fun onBindViewHolder(holder: CheckableColorViewHolder, position: Int) {
@ -31,10 +30,10 @@ class CheckableColorAdapter(private val activity: Activity, private val colors:
callback(color)
}
inner class CheckableColorViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
inner class CheckableColorViewHolder(val binding: CheckableColorButtonBinding) : RecyclerView.ViewHolder(binding.root) {
fun bindView(color: Int, checked: Boolean) {
itemView.checkable_color_button.apply {
binding.checkableColorButton.apply {
backgroundTintList = ColorStateList.valueOf(color)
setOnClickListener {
updateSelection(color)

View file

@ -6,6 +6,7 @@ import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.EventListItemBinding
import com.simplemobiletools.calendar.pro.dialogs.DeleteEventDialog
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.Formatter
@ -18,7 +19,6 @@ import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.event_list_item.view.*
class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, recyclerView: MyRecyclerView, var dayCode: String, itemClick: (Any) -> Unit) :
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
@ -58,11 +58,15 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
override fun onActionModeDestroyed() {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.event_list_item, parent)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return createViewHolder(
view = EventListItemBinding.inflate(activity.layoutInflater, parent, false).root
)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val event = events[position]
holder.bindView(event, true, true) { itemView, layoutPosition ->
holder.bindView(event, allowSingleClick = true, allowLongClick = true) { itemView, _ ->
setupView(itemView, event)
}
bindViewHolder(holder)
@ -82,12 +86,12 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
}
private fun setupView(view: View, event: Event) {
view.apply {
event_item_holder.isSelected = selectedKeys.contains(event.id?.toInt())
event_item_holder.background.applyColorFilter(textColor)
event_item_title.text = event.title
event_item_title.checkViewStrikeThrough(event.isTaskCompleted())
event_item_time.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS)
EventListItemBinding.bind(view).apply {
eventItemHolder.isSelected = selectedKeys.contains(event.id?.toInt())
eventItemHolder.background.applyColorFilter(textColor)
eventItemTitle.text = event.title
eventItemTitle.checkViewStrikeThrough(event.isTaskCompleted())
eventItemTime.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(activity, event.startTS)
if (event.startTS != event.endTS) {
val startDayCode = Formatter.getDayCodeFromTS(event.startTS)
val endDayCode = Formatter.getDayCodeFromTS(event.endTS)
@ -95,19 +99,18 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
val endDate = Formatter.getDayTitle(activity, endDayCode, false)
val startDayString = if (startDayCode != dayCode) " ($startDate)" else ""
if (!event.getIsAllDay()) {
val endTimeString = Formatter.getTimeFromTS(context, event.endTS)
val endTimeString = Formatter.getTimeFromTS(activity, event.endTS)
val endDayString = if (endDayCode != dayCode) " ($endDate)" else ""
event_item_time.text = "${event_item_time.text}$startDayString - $endTimeString$endDayString"
}
else {
eventItemTime.text = "${eventItemTime.text}$startDayString - $endTimeString$endDayString"
} else {
val endDayString = if (endDayCode != dayCode) " - ($endDate)" else ""
event_item_time.text = "${event_item_time.text}$startDayString$endDayString"
eventItemTime.text = "${eventItemTime.text}$startDayString$endDayString"
}
}
event_item_description.text = if (replaceDescriptionWithLocation) event.location else event.description.replace("\n", " ")
event_item_description.beVisibleIf(displayDescription && event_item_description.text.isNotEmpty())
event_item_color_bar.background.applyColorFilter(event.color)
eventItemDescription.text = if (replaceDescriptionWithLocation) event.location else event.description.replace("\n", " ")
eventItemDescription.beVisibleIf(displayDescription && eventItemDescription.text.isNotEmpty())
eventItemColorBar.background.applyColorFilter(event.color)
var newTextColor = textColor
@ -121,11 +124,11 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA)
}
event_item_time.setTextColor(newTextColor)
event_item_title.setTextColor(newTextColor)
event_item_description?.setTextColor(newTextColor)
event_item_task_image.applyColorFilter(newTextColor)
event_item_task_image.beVisibleIf(event.isTask())
eventItemTime.setTextColor(newTextColor)
eventItemTitle.setTextColor(newTextColor)
eventItemDescription.setTextColor(newTextColor)
eventItemTaskImage.applyColorFilter(newTextColor)
eventItemTaskImage.beVisibleIf(event.isTask())
val startMargin = if (event.isTask()) {
0
@ -133,7 +136,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
mediumMargin
}
(event_item_title.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin
(eventItemTitle.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin
}
}

View file

@ -6,6 +6,9 @@ import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.EventListItemBinding
import com.simplemobiletools.calendar.pro.databinding.EventListSectionDayBinding
import com.simplemobiletools.calendar.pro.databinding.EventListSectionMonthBinding
import com.simplemobiletools.calendar.pro.dialogs.DeleteEventDialog
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.*
@ -22,8 +25,6 @@ import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.event_list_item.view.*
import kotlinx.android.synthetic.main.event_list_section_day.view.*
class EventListAdapter(
activity: SimpleActivity, var listItems: ArrayList<ListItem>, val allowLongClick: Boolean, val listener: RefreshRecyclerViewListener?,
@ -75,17 +76,19 @@ class EventListAdapter(
override fun onActionModeDestroyed() {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyRecyclerViewAdapter.ViewHolder {
val layoutId = when (viewType) {
ITEM_SECTION_DAY -> R.layout.event_list_section_day
ITEM_SECTION_MONTH -> R.layout.event_list_section_month
else -> R.layout.event_list_item
val layoutInflater = activity.layoutInflater
val binding = when (viewType) {
ITEM_SECTION_DAY -> EventListSectionDayBinding.inflate(layoutInflater, parent, false)
ITEM_SECTION_MONTH -> EventListSectionMonthBinding.inflate(layoutInflater, parent, false)
else -> EventListItemBinding.inflate(layoutInflater, parent, false)
}
return createViewHolder(layoutId, parent)
return createViewHolder(binding.root)
}
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
val listItem = listItems[position]
holder.bindView(listItem, true, allowLongClick && listItem is ListEvent) { itemView, layoutPosition ->
holder.bindView(listItem, allowSingleClick = true, allowLongClick = allowLongClick && listItem is ListEvent) { itemView, _ ->
when (listItem) {
is ListSectionDay -> setupListSectionDay(itemView, listItem)
is ListEvent -> setupListEvent(itemView, listItem)
@ -129,27 +132,27 @@ class EventListAdapter(
}
private fun setupListEvent(view: View, listEvent: ListEvent) {
view.apply {
event_item_holder.isSelected = selectedKeys.contains(listEvent.hashCode())
event_item_holder.background.applyColorFilter(textColor)
event_item_title.text = listEvent.title
event_item_title.checkViewStrikeThrough(listEvent.isTaskCompleted)
event_item_time.text = if (listEvent.isAllDay) allDayString else Formatter.getTimeFromTS(context, listEvent.startTS)
EventListItemBinding.bind(view).apply {
eventItemHolder.isSelected = selectedKeys.contains(listEvent.hashCode())
eventItemHolder.background.applyColorFilter(textColor)
eventItemTitle.text = listEvent.title
eventItemTitle.checkViewStrikeThrough(listEvent.isTaskCompleted)
eventItemTime.text = if (listEvent.isAllDay) allDayString else Formatter.getTimeFromTS(activity, listEvent.startTS)
if (listEvent.startTS != listEvent.endTS) {
if (!listEvent.isAllDay) {
event_item_time.text = "${event_item_time.text} - ${Formatter.getTimeFromTS(context, listEvent.endTS)}"
eventItemTime.text = "${eventItemTime.text} - ${Formatter.getTimeFromTS(activity, listEvent.endTS)}"
}
val startCode = Formatter.getDayCodeFromTS(listEvent.startTS)
val endCode = Formatter.getDayCodeFromTS(listEvent.endTS)
if (startCode != endCode) {
event_item_time.text = "${event_item_time.text} (${Formatter.getDateDayTitle(endCode)})"
eventItemTime.text = "${eventItemTime.text} (${Formatter.getDateDayTitle(endCode)})"
}
}
event_item_description.text = if (replaceDescription) listEvent.location else listEvent.description.replace("\n", " ")
event_item_description.beVisibleIf(displayDescription && event_item_description.text.isNotEmpty())
event_item_color_bar.background.applyColorFilter(listEvent.color)
eventItemDescription.text = if (replaceDescription) listEvent.location else listEvent.description.replace("\n", " ")
eventItemDescription.beVisibleIf(displayDescription && eventItemDescription.text.isNotEmpty())
eventItemColorBar.background.applyColorFilter(listEvent.color)
var newTextColor = textColor
if (listEvent.isAllDay || listEvent.startTS <= now && listEvent.endTS <= now) {
@ -169,23 +172,24 @@ class EventListAdapter(
newTextColor = properPrimaryColor
}
event_item_time.setTextColor(newTextColor)
event_item_title.setTextColor(newTextColor)
event_item_description.setTextColor(newTextColor)
event_item_task_image.applyColorFilter(newTextColor)
event_item_task_image.beVisibleIf(listEvent.isTask)
eventItemTime.setTextColor(newTextColor)
eventItemTitle.setTextColor(newTextColor)
eventItemDescription.setTextColor(newTextColor)
eventItemTaskImage.applyColorFilter(newTextColor)
eventItemTaskImage.beVisibleIf(listEvent.isTask)
val startMargin = if (listEvent.isTask) {
0
} else {
mediumMargin
}
(event_item_title.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin
(eventItemTitle.layoutParams as ConstraintLayout.LayoutParams).marginStart = startMargin
}
}
private fun setupListSectionDay(view: View, listSectionDay: ListSectionDay) {
view.event_section_title.apply {
EventListSectionDayBinding.bind(view).eventSectionTitle.apply {
text = listSectionDay.title
val dayColor = if (listSectionDay.isToday) properPrimaryColor else textColor
setTextColor(dayColor)
@ -193,7 +197,7 @@ class EventListAdapter(
}
private fun setupListSectionMonth(view: View, listSectionMonth: ListSectionMonth) {
view.event_section_title.apply {
EventListSectionMonthBinding.bind(view).eventSectionTitle.apply {
text = listSectionMonth.title
setTextColor(properPrimaryColor)
}
@ -214,7 +218,7 @@ class EventListAdapter(
listItems.removeAll(eventsToDelete)
ensureBackgroundThread {
val nonRepeatingEventIDs = eventsToDelete.filter { !it.isRepeatable }.mapNotNull { it.id }.toMutableList()
val nonRepeatingEventIDs = eventsToDelete.filter { !it.isRepeatable }.map { it.id }.toMutableList()
activity.eventsHelper.deleteEvents(nonRepeatingEventIDs, true)
val repeatingEventIDs = eventsToDelete.filter { it.isRepeatable }.map { it.id }

View file

@ -6,8 +6,6 @@ import android.graphics.Paint
import android.widget.RemoteViews
import android.widget.RemoteViewsService
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.R.id.event_item_holder
import com.simplemobiletools.calendar.pro.R.id.event_section_title
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.calendar.pro.extensions.getWidgetFontSize
@ -131,7 +129,7 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
Intent().apply {
putExtra(EVENT_ID, item.id)
putExtra(EVENT_OCCURRENCE_TS, item.startTS)
setOnClickFillInIntent(event_item_holder, this)
setOnClickFillInIntent(R.id.event_item_holder, this)
}
}
}
@ -143,14 +141,14 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
}
remoteView.apply {
setTextColor(event_section_title, curTextColor)
setTextSize(event_section_title, mediumFontSize - 3f)
setText(event_section_title, item.title)
setTextColor(R.id.event_section_title, curTextColor)
setTextSize(R.id.event_section_title, mediumFontSize - 3f)
setText(R.id.event_section_title, item.title)
Intent().apply {
putExtra(DAY_CODE, item.code)
putExtra(VIEW_TO_OPEN, context.config.listWidgetViewToOpen)
setOnClickFillInIntent(event_section_title, this)
setOnClickFillInIntent(R.id.event_section_title, this)
}
}
}
@ -158,9 +156,9 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV
private fun setupListSectionMonth(remoteView: RemoteViews, item: ListSectionMonth) {
val curTextColor = textColor
remoteView.apply {
setTextColor(event_section_title, curTextColor)
setTextSize(event_section_title, mediumFontSize)
setText(event_section_title, item.title)
setTextColor(R.id.event_section_title, curTextColor)
setTextSize(R.id.event_section_title, mediumFontSize)
setText(R.id.event_section_title, item.title)
}
}

View file

@ -1,23 +1,21 @@
package com.simplemobiletools.calendar.pro.adapters
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.FilterEventTypeViewBinding
import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.setFillWithStroke
import kotlinx.android.synthetic.main.filter_event_type_view.view.*
class FilterEventTypeAdapter(val activity: SimpleActivity, val eventTypes: List<EventType>, val displayEventTypes: Set<String>) :
RecyclerView.Adapter<FilterEventTypeAdapter.ViewHolder>() {
RecyclerView.Adapter<FilterEventTypeAdapter.EventTypeViewHolder>() {
private val selectedKeys = HashSet<Long>()
init {
eventTypes.forEachIndexed { index, eventType ->
eventTypes.forEachIndexed { _, eventType ->
if (displayEventTypes.contains(eventType.id.toString())) {
selectedKeys.add(eventType.id!!)
}
@ -36,30 +34,28 @@ class FilterEventTypeAdapter(val activity: SimpleActivity, val eventTypes: List<
fun getSelectedItemsList() = selectedKeys.asSequence().map { it }.toMutableList() as ArrayList<Long>
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = activity.layoutInflater.inflate(R.layout.filter_event_type_view, parent, false)
return ViewHolder(view)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EventTypeViewHolder {
return EventTypeViewHolder(
binding = FilterEventTypeViewBinding.inflate(activity.layoutInflater, parent, false)
)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val eventType = eventTypes[position]
holder.bindView(eventType)
}
override fun onBindViewHolder(holder: EventTypeViewHolder, position: Int) = holder.bindView(eventType = eventTypes[position])
override fun getItemCount() = eventTypes.size
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bindView(eventType: EventType): View {
inner class EventTypeViewHolder(val binding: FilterEventTypeViewBinding) : RecyclerView.ViewHolder(binding.root) {
fun bindView(eventType: EventType) {
val isSelected = selectedKeys.contains(eventType.id)
itemView.apply {
filter_event_type_checkbox.isChecked = isSelected
filter_event_type_checkbox.setColors(activity.getProperTextColor(), activity.getProperPrimaryColor(), activity.getProperBackgroundColor())
filter_event_type_checkbox.text = eventType.getDisplayTitle()
filter_event_type_color.setFillWithStroke(eventType.color, activity.getProperBackgroundColor())
filter_event_type_holder.setOnClickListener { viewClicked(!isSelected, eventType) }
binding.apply {
filterEventTypeCheckbox.isChecked = isSelected
filterEventTypeCheckbox.setColors(activity.getProperTextColor(), activity.getProperPrimaryColor(), activity.getProperBackgroundColor())
filterEventTypeCheckbox.text = eventType.getDisplayTitle()
filterEventTypeColor.setFillWithStroke(eventType.color, activity.getProperBackgroundColor())
filterEventTypeHolder.setOnClickListener {
viewClicked(!isSelected, eventType)
}
}
return itemView
}
private fun viewClicked(select: Boolean, eventType: EventType) {

View file

@ -4,6 +4,7 @@ import android.view.*
import android.widget.PopupMenu
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.ItemEventTypeBinding
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.calendar.pro.helpers.REGULAR_EVENT_TYPE_ID
import com.simplemobiletools.calendar.pro.interfaces.DeleteEventTypesListener
@ -14,12 +15,14 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.item_event_type.view.*
class ManageEventTypesAdapter(
activity: SimpleActivity, val eventTypes: ArrayList<EventType>, val listener: DeleteEventTypesListener?, recyclerView: MyRecyclerView,
itemClick: (Any) -> Unit
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
private val MOVE_EVENTS = 0
private val DELETE_EVENTS = 1
init {
setupDragListener(true)
}
@ -55,11 +58,15 @@ class ManageEventTypesAdapter(
override fun onActionModeDestroyed() {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_event_type, parent)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return createViewHolder(
view = ItemEventTypeBinding.inflate(activity.layoutInflater, parent, false).root
)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val eventType = eventTypes[position]
holder.bindView(eventType, true, true) { itemView, layoutPosition ->
holder.bindView(eventType, allowSingleClick = true, allowLongClick = true) { itemView, _ ->
setupView(itemView, eventType)
}
bindViewHolder(holder)
@ -72,19 +79,19 @@ class ManageEventTypesAdapter(
private fun getSelectedItems() = eventTypes.filter { selectedKeys.contains(it.id?.toInt()) } as ArrayList<EventType>
private fun setupView(view: View, eventType: EventType) {
view.apply {
event_item_frame.isSelected = selectedKeys.contains(eventType.id?.toInt())
event_type_title.text = eventType.getDisplayTitle()
event_type_color.setFillWithStroke(eventType.color, activity.getProperBackgroundColor())
event_type_title.setTextColor(textColor)
ItemEventTypeBinding.bind(view).apply {
eventItemFrame.isSelected = selectedKeys.contains(eventType.id?.toInt())
eventTypeTitle.text = eventType.getDisplayTitle()
eventTypeColor.setFillWithStroke(eventType.color, activity.getProperBackgroundColor())
eventTypeTitle.setTextColor(textColor)
overflow_menu_icon.drawable.apply {
overflowMenuIcon.drawable.apply {
mutate()
setTint(activity.getProperTextColor())
}
overflow_menu_icon.setOnClickListener {
showPopupMenu(overflow_menu_anchor, eventType)
overflowMenuIcon.setOnClickListener {
showPopupMenu(overflowMenuAnchor, eventType)
}
}
}
@ -104,6 +111,7 @@ class ManageEventTypesAdapter(
itemClick(eventType)
}
}
R.id.cab_delete -> {
executeItemMenuOperation(eventTypeId) {
askConfirmDelete()
@ -133,8 +141,6 @@ class ManageEventTypesAdapter(
activity.eventsHelper.doEventTypesContainEvents(eventTypes) {
activity.runOnUiThread {
if (it) {
val MOVE_EVENTS = 0
val DELETE_EVENTS = 1
val res = activity.resources
val items = ArrayList<RadioItem>().apply {
add(RadioItem(MOVE_EVENTS, res.getString(R.string.move_events_into_default)))

View file

@ -1,24 +1,23 @@
package com.simplemobiletools.calendar.pro.adapters
import android.view.View
import android.view.ViewGroup
import androidx.core.view.updateLayoutParams
import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.QuickFilterEventTypeViewBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import kotlinx.android.synthetic.main.quick_filter_event_type_view.view.*
class QuickFilterEventTypeAdapter(
val activity: SimpleActivity,
private val allEventTypes: List<EventType>,
private val quickFilterEventTypeIds: Set<String>,
val callback: () -> Unit
) :
RecyclerView.Adapter<QuickFilterEventTypeAdapter.ViewHolder>() {
) : RecyclerView.Adapter<QuickFilterEventTypeAdapter.QuickFilterViewHolder>() {
private val activeKeys = HashSet<Long>()
private val quickFilterEventTypes = ArrayList<EventType>()
private val displayEventTypes = activity.config.displayEventTypes
@ -52,36 +51,42 @@ class QuickFilterEventTypeAdapter(
notifyItemChanged(pos)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QuickFilterViewHolder {
val parentWidth = parent.measuredWidth
val nrOfItems = quickFilterEventTypes.size
val view = activity.layoutInflater.inflate(R.layout.quick_filter_event_type_view, parent, false)
if (nrOfItems * minItemWidth > parentWidth) view.layoutParams.width = minItemWidth
else view.layoutParams.width = parentWidth / nrOfItems
return ViewHolder(view)
val numberOfItems = quickFilterEventTypes.size
val binding = QuickFilterEventTypeViewBinding.inflate(activity.layoutInflater, parent, false)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
width = if (numberOfItems * minItemWidth > parentWidth) {
minItemWidth
} else {
parentWidth / numberOfItems
}
}
return QuickFilterViewHolder(binding)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
override fun onBindViewHolder(holder: QuickFilterViewHolder, position: Int) {
val eventType = quickFilterEventTypes[position]
holder.bindView(eventType)
}
override fun getItemCount() = quickFilterEventTypes.size
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bindView(eventType: EventType): View {
inner class QuickFilterViewHolder(val binding: QuickFilterEventTypeViewBinding) : RecyclerView.ViewHolder(binding.root) {
fun bindView(eventType: EventType) {
val isSelected = activeKeys.contains(eventType.id)
itemView.apply {
quick_filter_event_type.text = eventType.title
binding.apply {
quickFilterEventType.text = eventType.title
val textColor = if (isSelected) textColorActive else textColorInactive
quick_filter_event_type.setTextColor(textColor)
quickFilterEventType.setTextColor(textColor)
val indicatorHeightRes = if (isSelected) R.dimen.quick_filter_active_line_size else R.dimen.quick_filter_inactive_line_size
quick_filter_event_type_color.layoutParams.height = resources.getDimensionPixelSize(indicatorHeightRes)
quick_filter_event_type_color.setBackgroundColor(eventType.color)
quickFilterEventTypeColor.layoutParams.height = root.resources.getDimensionPixelSize(indicatorHeightRes)
quickFilterEventTypeColor.setBackgroundColor(eventType.color)
// avoid too quick clicks, could cause glitches
quick_filter_event_type.setOnClickListener {
quickFilterEventType.setOnClickListener {
if (System.currentTimeMillis() - lastClickTS > 300) {
lastClickTS = System.currentTimeMillis()
viewClicked(!isSelected, eventType)
@ -89,8 +94,6 @@ class QuickFilterEventTypeAdapter(
}
}
}
return itemView
}
private fun viewClicked(select: Boolean, eventType: EventType) {

View file

@ -1,24 +1,23 @@
package com.simplemobiletools.calendar.pro.adapters
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.ItemSelectTimeZoneBinding
import com.simplemobiletools.calendar.pro.models.MyTimeZone
import com.simplemobiletools.commons.extensions.getProperTextColor
import kotlinx.android.synthetic.main.item_select_time_zone.view.*
class SelectTimeZoneAdapter(val activity: SimpleActivity, var timeZones: ArrayList<MyTimeZone>, val itemClick: (Any) -> Unit) :
RecyclerView.Adapter<SelectTimeZoneAdapter.ViewHolder>() {
RecyclerView.Adapter<SelectTimeZoneAdapter.TimeZoneViewHolder>() {
val textColor = activity.getProperTextColor()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = activity.layoutInflater.inflate(R.layout.item_select_time_zone, parent, false)
return ViewHolder(view)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TimeZoneViewHolder {
return TimeZoneViewHolder(
binding = ItemSelectTimeZoneBinding.inflate(activity.layoutInflater, parent, false)
)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
override fun onBindViewHolder(holder: TimeZoneViewHolder, position: Int) {
val timeZone = timeZones[position]
holder.bindView(timeZone)
}
@ -30,21 +29,19 @@ class SelectTimeZoneAdapter(val activity: SimpleActivity, var timeZones: ArrayLi
notifyDataSetChanged()
}
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bindView(timeZone: MyTimeZone): View {
itemView.apply {
item_time_zone_title.text = timeZone.zoneName
item_time_zone_shift.text = timeZone.title
inner class TimeZoneViewHolder(val binding: ItemSelectTimeZoneBinding) : RecyclerView.ViewHolder(binding.root) {
fun bindView(timeZone: MyTimeZone) {
binding.apply {
itemTimeZoneTitle.text = timeZone.zoneName
itemTimeZoneShift.text = timeZone.title
item_time_zone_title.setTextColor(textColor)
item_time_zone_shift.setTextColor(textColor)
itemTimeZoneTitle.setTextColor(textColor)
itemTimeZoneShift.setTextColor(textColor)
item_select_time_zone_holder.setOnClickListener {
itemSelectTimeZoneHolder.setOnClickListener {
itemClick(timeZone)
}
}
return itemView
}
}
}

View file

@ -1,38 +1,37 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.app.Activity
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DialogCustomEventRepeatIntervalBinding
import com.simplemobiletools.calendar.pro.helpers.DAY
import com.simplemobiletools.calendar.pro.helpers.MONTH
import com.simplemobiletools.calendar.pro.helpers.WEEK
import com.simplemobiletools.calendar.pro.helpers.YEAR
import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.dialog_custom_event_repeat_interval.view.*
class CustomEventRepeatIntervalDialog(val activity: Activity, val callback: (seconds: Int) -> Unit) {
private var dialog: AlertDialog? = null
private var view = activity.layoutInflater.inflate(R.layout.dialog_custom_event_repeat_interval, null) as ViewGroup
private val binding by activity.viewBinding(DialogCustomEventRepeatIntervalBinding::inflate)
init {
view.dialog_radio_view.check(R.id.dialog_radio_days)
binding.dialogRadioView.check(R.id.dialog_radio_days)
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmRepeatInterval() }
.setPositiveButton(R.string.ok) { _, _ -> confirmRepeatInterval() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
alertDialog.showKeyboard(view.dialog_custom_repeat_interval_value)
alertDialog.showKeyboard(binding.dialogCustomRepeatIntervalValue)
}
}
}
private fun confirmRepeatInterval() {
val value = view.dialog_custom_repeat_interval_value.value
val multiplier = getMultiplier(view.dialog_radio_view.checkedRadioButtonId)
val days = Integer.valueOf(if (value.isEmpty()) "0" else value)
val value = binding.dialogCustomRepeatIntervalValue.value
val multiplier = getMultiplier(binding.dialogRadioView.checkedRadioButtonId)
val days = Integer.valueOf(value.ifEmpty { "0" })
callback(days * multiplier)
activity.hideKeyboard()
dialog?.dismiss()

View file

@ -1,29 +1,28 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.app.Activity
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DialogCustomPeriodPickerBinding
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.DAY_SECONDS
import com.simplemobiletools.commons.helpers.MONTH_SECONDS
import com.simplemobiletools.commons.helpers.WEEK_SECONDS
import kotlinx.android.synthetic.main.dialog_custom_period_picker.view.*
class CustomPeriodPickerDialog(val activity: Activity, val callback: (value: Int) -> Unit) {
private var dialog: AlertDialog? = null
private var view = (activity.layoutInflater.inflate(R.layout.dialog_custom_period_picker, null) as ViewGroup)
private val binding by activity.viewBinding(DialogCustomPeriodPickerBinding::inflate)
init {
view.dialog_custom_period_value.setText("")
view.dialog_radio_view.check(R.id.dialog_radio_days)
binding.dialogCustomPeriodValue.setText("")
binding.dialogRadioView.check(R.id.dialog_radio_days)
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmReminder() }
.setPositiveButton(R.string.ok) { _, _ -> confirmReminder() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
alertDialog.showKeyboard(view.dialog_custom_period_value)
alertDialog.showKeyboard(binding.dialogCustomPeriodValue)
}
}
}
@ -35,14 +34,9 @@ class CustomPeriodPickerDialog(val activity: Activity, val callback: (value: Int
}
private fun confirmReminder() {
val value = view.dialog_custom_period_value.value
val type = view.dialog_radio_view.checkedRadioButtonId
val periodValue = if (value.isEmpty()) {
"0"
} else {
value
}
val value = binding.dialogCustomPeriodValue.value
val type = binding.dialogRadioView.checkedRadioButtonId
val periodValue = value.ifEmpty { "0" }
val period = calculatePeriod(Integer.valueOf(periodValue), type)
callback(period)
activity.hideKeyboard()

View file

@ -1,6 +1,7 @@
package com.simplemobiletools.calendar.pro.dialogs
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DatetimePatternInfoLayoutBinding
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
@ -8,7 +9,7 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
class DateTimePatternInfoDialog(activity: BaseSimpleActivity) {
init {
val view = activity.layoutInflater.inflate(R.layout.datetime_pattern_info_layout, null)
val view = DatetimePatternInfoLayoutBinding.inflate(activity.layoutInflater).root
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { _, _ -> { } }
.apply {

View file

@ -1,16 +1,16 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.app.Activity
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DialogDeleteEventBinding
import com.simplemobiletools.calendar.pro.helpers.DELETE_ALL_OCCURRENCES
import com.simplemobiletools.calendar.pro.helpers.DELETE_FUTURE_OCCURRENCES
import com.simplemobiletools.calendar.pro.helpers.DELETE_SELECTED_OCCURRENCE
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_delete_event.view.*
import com.simplemobiletools.commons.extensions.viewBinding
class DeleteEventDialog(
val activity: Activity,
@ -20,38 +20,39 @@ class DeleteEventDialog(
val callback: (deleteRule: Int) -> Unit
) {
private var dialog: AlertDialog? = null
private val binding by activity.viewBinding(DialogDeleteEventBinding::inflate)
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_delete_event, null).apply {
delete_event_repeat_description.beVisibleIf(hasRepeatableEvent)
delete_event_radio_view.beVisibleIf(hasRepeatableEvent)
binding.apply {
deleteEventRepeatDescription.beVisibleIf(hasRepeatableEvent)
deleteEventRadioView.beVisibleIf(hasRepeatableEvent)
if (!hasRepeatableEvent) {
delete_event_radio_view.check(R.id.delete_event_all)
deleteEventRadioView.check(R.id.delete_event_all)
}
if (eventIds.size > 1) {
delete_event_repeat_description.setText(R.string.selection_contains_repetition)
deleteEventRepeatDescription.setText(R.string.selection_contains_repetition)
}
if (isTask) {
delete_event_repeat_description.setText(R.string.task_is_repeatable)
deleteEventRepeatDescription.setText(R.string.task_is_repeatable)
} else {
delete_event_repeat_description.setText(R.string.event_is_repeatable)
deleteEventRepeatDescription.setText(R.string.event_is_repeatable)
}
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed(view as ViewGroup) }
.setPositiveButton(R.string.yes) { _, _ -> dialogConfirmed(binding) }
.setNegativeButton(R.string.no, null)
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
}
}
}
private fun dialogConfirmed(view: ViewGroup) {
val deleteRule = when (view.delete_event_radio_view.checkedRadioButtonId) {
private fun dialogConfirmed(binding: DialogDeleteEventBinding) {
val deleteRule = when (binding.deleteEventRadioView.checkedRadioButtonId) {
R.id.delete_event_all -> DELETE_ALL_OCCURRENCES
R.id.delete_event_future -> DELETE_FUTURE_OCCURRENCES
else -> DELETE_SELECTED_OCCURRENCE

View file

@ -4,6 +4,7 @@ import android.app.Activity
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DialogEventTypeBinding
import com.simplemobiletools.calendar.pro.extensions.calDAVHelper
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.calendar.pro.helpers.OTHER_EVENT
@ -11,25 +12,25 @@ import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import kotlinx.android.synthetic.main.dialog_event_type.view.*
class EditEventTypeDialog(val activity: Activity, var eventType: EventType? = null, val callback: (eventType: EventType) -> Unit) {
private var isNewEvent = eventType == null
private val binding by activity.viewBinding(DialogEventTypeBinding::inflate)
init {
if (eventType == null) {
eventType = EventType(null, "", activity.getProperPrimaryColor())
}
val view = activity.layoutInflater.inflate(R.layout.dialog_event_type, null).apply {
setupColor(type_color)
type_title.setText(eventType!!.title)
type_color.setOnClickListener {
binding.apply {
setupColor(typeColor)
typeTitle.setText(eventType!!.title)
typeColor.setOnClickListener {
if (eventType?.caldavCalendarId == 0) {
ColorPickerDialog(activity, eventType!!.color) { wasPositivePressed, color ->
if (wasPositivePressed) {
eventType!!.color = color
setupColor(type_color)
setupColor(typeColor)
}
}
} else {
@ -37,7 +38,7 @@ class EditEventTypeDialog(val activity: Activity, var eventType: EventType? = nu
val colors = activity.calDAVHelper.getAvailableCalDAVCalendarColors(eventType!!).keys.toIntArray()
SelectEventTypeColorDialog(activity, colors = colors, currentColor = currentColor) {
eventType!!.color = it
setupColor(type_color)
setupColor(typeColor)
}
}
}
@ -47,11 +48,11 @@ class EditEventTypeDialog(val activity: Activity, var eventType: EventType? = nu
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, if (isNewEvent) R.string.add_new_type else R.string.edit_type) { alertDialog ->
alertDialog.showKeyboard(view.type_title)
activity.setupDialogStuff(binding.root, this, if (isNewEvent) R.string.add_new_type else R.string.edit_type) { alertDialog ->
alertDialog.showKeyboard(binding.typeTitle)
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
ensureBackgroundThread {
eventTypeConfirmed(view.type_title.value, alertDialog)
eventTypeConfirmed(binding.typeTitle.value, alertDialog)
}
}
}

View file

@ -1,36 +1,37 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.DialogEditRepeatingEventBinding
import com.simplemobiletools.calendar.pro.helpers.EDIT_ALL_OCCURRENCES
import com.simplemobiletools.calendar.pro.helpers.EDIT_FUTURE_OCCURRENCES
import com.simplemobiletools.calendar.pro.helpers.EDIT_SELECTED_OCCURRENCE
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_edit_repeating_event.view.*
import com.simplemobiletools.commons.extensions.viewBinding
class EditRepeatingEventDialog(val activity: SimpleActivity, val isTask: Boolean = false, val callback: (allOccurrences: Int?) -> Unit) {
private var dialog: AlertDialog? = null
private val binding by activity.viewBinding(DialogEditRepeatingEventBinding::inflate)
init {
val view = (activity.layoutInflater.inflate(R.layout.dialog_edit_repeating_event, null) as ViewGroup).apply {
edit_repeating_event_one_only.setOnClickListener { sendResult(EDIT_SELECTED_OCCURRENCE) }
edit_repeating_event_this_and_future_occurences.setOnClickListener { sendResult(EDIT_FUTURE_OCCURRENCES) }
edit_repeating_event_all_occurrences.setOnClickListener { sendResult(EDIT_ALL_OCCURRENCES) }
binding.apply {
editRepeatingEventOneOnly.setOnClickListener { sendResult(EDIT_SELECTED_OCCURRENCE) }
editRepeatingEventThisAndFutureOccurences.setOnClickListener { sendResult(EDIT_FUTURE_OCCURRENCES) }
editRepeatingEventAllOccurrences.setOnClickListener { sendResult(EDIT_ALL_OCCURRENCES) }
if (isTask) {
edit_repeating_event_title.setText(R.string.task_is_repeatable)
editRepeatingEventTitle.setText(R.string.task_is_repeatable)
} else {
edit_repeating_event_title.setText(R.string.event_is_repeatable)
editRepeatingEventTitle.setText(R.string.event_is_repeatable)
}
}
activity.getAlertDialogBuilder()
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
alertDialog.hideKeyboard()
alertDialog.setOnDismissListener { sendResult(null) }

View file

@ -1,16 +1,15 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.adapters.FilterEventTypeAdapter
import com.simplemobiletools.calendar.pro.databinding.DialogExportEventsBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import kotlinx.android.synthetic.main.dialog_export_events.view.*
import java.io.File
class ExportEventsDialog(
@ -19,33 +18,34 @@ class ExportEventsDialog(
) {
private var realPath = path.ifEmpty { activity.internalStoragePath }
private val config = activity.config
private val binding by activity.viewBinding(DialogExportEventsBinding::inflate)
init {
val view = (activity.layoutInflater.inflate(R.layout.dialog_export_events, null) as ViewGroup).apply {
export_events_folder.setText(activity.humanizePath(realPath))
export_events_filename.setText("${activity.getString(R.string.events)}_${activity.getCurrentFormattedDateTime()}")
binding.apply {
exportEventsFolder.setText(activity.humanizePath(realPath))
exportEventsFilename.setText("${activity.getString(R.string.events)}_${activity.getCurrentFormattedDateTime()}")
export_events_checkbox.isChecked = config.exportEvents
export_events_checkbox_holder.setOnClickListener {
export_events_checkbox.toggle()
exportEventsCheckbox.isChecked = config.exportEvents
exportEventsCheckboxHolder.setOnClickListener {
exportEventsCheckbox.toggle()
}
export_tasks_checkbox.isChecked = config.exportTasks
export_tasks_checkbox_holder.setOnClickListener {
export_tasks_checkbox.toggle()
exportTasksCheckbox.isChecked = config.exportTasks
exportTasksCheckboxHolder.setOnClickListener {
exportTasksCheckbox.toggle()
}
export_past_events_checkbox.isChecked = config.exportPastEntries
export_past_events_checkbox_holder.setOnClickListener {
export_past_events_checkbox.toggle()
exportPastEventsCheckbox.isChecked = config.exportPastEntries
exportPastEventsCheckboxHolder.setOnClickListener {
exportPastEventsCheckbox.toggle()
}
if (hidePath) {
export_events_folder_hint.beGone()
export_events_folder.beGone()
exportEventsFolderHint.beGone()
exportEventsFolder.beGone()
} else {
export_events_folder.setOnClickListener {
activity.hideKeyboard(export_events_filename)
exportEventsFolder.setOnClickListener {
activity.hideKeyboard(exportEventsFilename)
FilePickerDialog(activity, realPath, false, showFAB = true) {
export_events_folder.setText(activity.humanizePath(it))
exportEventsFolder.setText(activity.humanizePath(it))
realPath = it
}
}
@ -55,9 +55,9 @@ class ExportEventsDialog(
val eventTypes = HashSet<String>()
it.mapTo(eventTypes) { it.id.toString() }
export_events_types_list.adapter = FilterEventTypeAdapter(activity, it, eventTypes)
exportEventsTypesList.adapter = FilterEventTypeAdapter(activity, it, eventTypes)
if (it.size > 1) {
export_events_pick_types.beVisible()
exportEventsPickTypes.beVisible()
}
}
}
@ -66,9 +66,9 @@ class ExportEventsDialog(
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.export_events) { alertDialog ->
activity.setupDialogStuff(binding.root, this, R.string.export_events) { alertDialog ->
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.export_events_filename.value
val filename = binding.exportEventsFilename.value
when {
filename.isEmpty() -> activity.toast(R.string.empty_name)
filename.isAValidFilename() -> {
@ -78,8 +78,8 @@ class ExportEventsDialog(
return@setOnClickListener
}
val exportEventsChecked = view.export_events_checkbox.isChecked
val exportTasksChecked = view.export_tasks_checkbox.isChecked
val exportEventsChecked = binding.exportEventsCheckbox.isChecked
val exportTasksChecked = binding.exportTasksCheckbox.isChecked
if (!exportEventsChecked && !exportTasksChecked) {
activity.toast(R.string.no_entries_for_exporting)
return@setOnClickListener
@ -90,14 +90,15 @@ class ExportEventsDialog(
lastExportPath = file.absolutePath.getParentPath()
exportEvents = exportEventsChecked
exportTasks = exportTasksChecked
exportPastEntries = view.export_past_events_checkbox.isChecked
exportPastEntries = binding.exportPastEventsCheckbox.isChecked
}
val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsList()
val eventTypes = (binding.exportEventsTypesList.adapter as FilterEventTypeAdapter).getSelectedItemsList()
callback(file, eventTypes)
alertDialog.dismiss()
}
}
else -> activity.toast(R.string.invalid_name)
}
}

View file

@ -1,9 +1,9 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.DialogImportEventsBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.eventTypesDB
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
@ -15,12 +15,12 @@ import com.simplemobiletools.calendar.pro.helpers.IcsImporter.ImportResult.IMPOR
import com.simplemobiletools.calendar.pro.helpers.REGULAR_EVENT_TYPE_ID
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import kotlinx.android.synthetic.main.dialog_import_events.view.*
class ImportEventsDialog(val activity: SimpleActivity, val path: String, val callback: (refreshView: Boolean) -> Unit) {
private var currEventTypeId = REGULAR_EVENT_TYPE_ID
private var currEventTypeCalDAVCalendarId = 0
private val config = activity.config
private val binding by activity.viewBinding(DialogImportEventsBinding::inflate)
init {
ensureBackgroundThread {
@ -48,10 +48,18 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
}
private fun initDialog() {
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_events, null) as ViewGroup).apply {
binding.apply {
updateEventType(this)
import_event_type_title.setOnClickListener {
SelectEventTypeDialog(activity, currEventTypeId, true, true, false, true, false) {
importEventTypeTitle.setOnClickListener {
SelectEventTypeDialog(
activity = activity,
currEventType = currEventTypeId,
showCalDAVCalendars = true,
showNewEventTypeOption = true,
addLastUsedOneAsFirstOption = false,
showOnlyWritable = true,
showManageEventTypes = false
) {
currEventTypeId = it.id!!
currEventTypeCalDAVCalendarId = it.caldavCalendarId
@ -62,8 +70,8 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
}
}
import_events_checkbox_holder.setOnClickListener {
import_events_checkbox.toggle()
importEventsCheckboxHolder.setOnClickListener {
importEventsCheckbox.toggle()
}
}
@ -71,12 +79,12 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.import_events) { alertDialog ->
activity.setupDialogStuff(binding.root, this, R.string.import_events) { alertDialog ->
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(null)
activity.toast(R.string.importing)
ensureBackgroundThread {
val overrideFileEventTypes = view.import_events_checkbox.isChecked
val overrideFileEventTypes = binding.importEventsCheckbox.isChecked
val result = IcsImporter(activity).importEvents(path, currEventTypeId, currEventTypeCalDAVCalendarId, overrideFileEventTypes)
handleParseResult(result)
alertDialog.dismiss()
@ -86,12 +94,12 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
}
}
private fun updateEventType(view: ViewGroup) {
private fun updateEventType(binding: DialogImportEventsBinding) {
ensureBackgroundThread {
val eventType = activity.eventTypesDB.getEventTypeWithId(currEventTypeId)
activity.runOnUiThread {
view.import_event_type_title.setText(eventType!!.getDisplayTitle())
view.import_event_type_color.setFillWithStroke(eventType.color, activity.getProperBackgroundColor())
binding.importEventTypeTitle.setText(eventType!!.getDisplayTitle())
binding.importEventTypeColor.setFillWithStroke(eventType.color, activity.getProperBackgroundColor())
}
}
}

View file

@ -1,59 +1,58 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.DialogManageAutomaticBackupsBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import kotlinx.android.synthetic.main.dialog_manage_automatic_backups.view.*
import java.io.File
class ManageAutomaticBackupsDialog(private val activity: SimpleActivity, onSuccess: () -> Unit) {
private val view = (activity.layoutInflater.inflate(R.layout.dialog_manage_automatic_backups, null) as ViewGroup)
private val binding by activity.viewBinding(DialogManageAutomaticBackupsBinding::inflate)
private val config = activity.config
private var backupFolder = config.autoBackupFolder
private var selectedEventTypes = config.autoBackupEventTypes.ifEmpty { config.displayEventTypes }
init {
view.apply {
backup_events_folder.setText(activity.humanizePath(backupFolder))
binding.apply {
backupEventsFolder.setText(activity.humanizePath(backupFolder))
val filename = config.autoBackupFilename.ifEmpty {
"${activity.getString(R.string.events)}_%Y%M%D_%h%m%s"
}
backup_events_filename.setText(filename)
backup_events_filename_hint.setEndIconOnClickListener {
backupEventsFilename.setText(filename)
backupEventsFilenameHint.setEndIconOnClickListener {
DateTimePatternInfoDialog(activity)
}
backup_events_filename_hint.setEndIconOnLongClickListener {
backupEventsFilenameHint.setEndIconOnLongClickListener {
DateTimePatternInfoDialog(activity)
true
}
backup_events_checkbox.isChecked = config.autoBackupEvents
backup_events_checkbox_holder.setOnClickListener {
backup_events_checkbox.toggle()
backupEventsCheckbox.isChecked = config.autoBackupEvents
backupEventsCheckboxHolder.setOnClickListener {
backupEventsCheckbox.toggle()
}
backup_tasks_checkbox.isChecked = config.autoBackupTasks
backup_tasks_checkbox_holder.setOnClickListener {
backup_tasks_checkbox.toggle()
backupTasksCheckbox.isChecked = config.autoBackupTasks
backupTasksCheckboxHolder.setOnClickListener {
backupTasksCheckbox.toggle()
}
backup_past_events_checkbox.isChecked = config.autoBackupPastEntries
backup_past_events_checkbox_holder.setOnClickListener {
backup_past_events_checkbox.toggle()
backupPastEventsCheckbox.isChecked = config.autoBackupPastEntries
backupPastEventsCheckboxHolder.setOnClickListener {
backupPastEventsCheckbox.toggle()
}
backup_events_folder.setOnClickListener {
backupEventsFolder.setOnClickListener {
selectBackupFolder()
}
manage_event_types_holder.setOnClickListener {
manageEventTypesHolder.setOnClickListener {
SelectEventTypesDialog(activity, selectedEventTypes) {
selectedEventTypes = it
}
@ -63,9 +62,9 @@ class ManageAutomaticBackupsDialog(private val activity: SimpleActivity, onSucce
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.manage_automatic_backups) { dialog ->
activity.setupDialogStuff(binding.root, this, R.string.manage_automatic_backups) { dialog ->
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.backup_events_filename.value
val filename = binding.backupEventsFilename.value
when {
filename.isEmpty() -> activity.toast(R.string.empty_name)
filename.isAValidFilename() -> {
@ -75,8 +74,8 @@ class ManageAutomaticBackupsDialog(private val activity: SimpleActivity, onSucce
return@setOnClickListener
}
val backupEventsChecked = view.backup_events_checkbox.isChecked
val backupTasksChecked = view.backup_tasks_checkbox.isChecked
val backupEventsChecked = binding.backupEventsCheckbox.isChecked
val backupTasksChecked = binding.backupTasksCheckbox.isChecked
if (!backupEventsChecked && !backupTasksChecked || selectedEventTypes.isEmpty()) {
activity.toast(R.string.no_entries_for_exporting)
return@setOnClickListener
@ -88,7 +87,7 @@ class ManageAutomaticBackupsDialog(private val activity: SimpleActivity, onSucce
autoBackupFilename = filename
autoBackupEvents = backupEventsChecked
autoBackupTasks = backupTasksChecked
autoBackupPastEntries = view.backup_past_events_checkbox.isChecked
autoBackupPastEntries = binding.backupPastEventsCheckbox.isChecked
if (autoBackupEventTypes != selectedEventTypes) {
autoBackupEventTypes = selectedEventTypes
}
@ -101,6 +100,7 @@ class ManageAutomaticBackupsDialog(private val activity: SimpleActivity, onSucce
dialog.dismiss()
}
}
else -> activity.toast(R.string.invalid_name)
}
}
@ -109,8 +109,8 @@ class ManageAutomaticBackupsDialog(private val activity: SimpleActivity, onSucce
}
private fun selectBackupFolder() {
activity.hideKeyboard(view.backup_events_filename)
FilePickerDialog(activity, backupFolder, false, showFAB = true) { path ->
activity.hideKeyboard(binding.backupEventsFilename)
FilePickerDialog(activity, backupFolder, pickFile = false, showFAB = true) { path ->
activity.handleSAFDialog(path) { grantedSAF ->
if (!grantedSAF) {
return@handleSAFDialog
@ -122,7 +122,7 @@ class ManageAutomaticBackupsDialog(private val activity: SimpleActivity, onSucce
}
backupFolder = path
view.backup_events_folder.setText(activity.humanizePath(path))
binding.backupEventsFolder.setText(activity.humanizePath(path))
}
}
}

View file

@ -6,22 +6,19 @@ import android.net.Uri
import android.provider.Settings
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.hideKeyboard
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.calendar.pro.databinding.DialogReminderWarningBinding
import com.simplemobiletools.commons.extensions.*
class ReminderWarningDialog(val activity: Activity, val callback: () -> Unit) {
private var dialog: AlertDialog? = null
private val binding by activity.viewBinding(DialogReminderWarningBinding::inflate)
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_reminder_warning, null)
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() }
.setNeutralButton(R.string.settings, null)
.apply {
activity.setupDialogStuff(view, this, R.string.disclaimer, cancelOnTouchOutside = false) { alertDialog ->
activity.setupDialogStuff(binding.root, this, R.string.disclaimer, cancelOnTouchOutside = false) { alertDialog ->
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
redirectToSettings()
}

View file

@ -2,33 +2,32 @@ package com.simplemobiletools.calendar.pro.dialogs
import android.app.Activity
import android.app.DatePickerDialog
import android.view.View
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DialogRepeatLimitTypePickerBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.seconds
import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.getJavaDayOfWeekFromJoda
import com.simplemobiletools.calendar.pro.helpers.getNowSeconds
import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.dialog_repeat_limit_type_picker.view.*
import org.joda.time.DateTime
class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long, val startTS: Long, val callback: (repeatLimit: Long) -> Unit) {
private var dialog: AlertDialog? = null
private var view: View
private val binding by activity.viewBinding(DialogRepeatLimitTypePickerBinding::inflate)
init {
view = activity.layoutInflater.inflate(R.layout.dialog_repeat_limit_type_picker, null).apply {
repeat_type_date.setOnClickListener { showRepetitionLimitDialog() }
repeat_type_count.setOnClickListener { dialog_radio_view.check(R.id.repeat_type_x_times) }
repeat_type_forever.setOnClickListener {
binding.apply {
repeatTypeDate.setOnClickListener { showRepetitionLimitDialog() }
repeatTypeCount.setOnClickListener { dialogRadioView.check(R.id.repeat_type_x_times) }
repeatTypeForever.setOnClickListener {
callback(0)
dialog?.dismiss()
}
}
view.dialog_radio_view.check(getCheckedItem())
binding.dialogRadioView.check(getCheckedItem())
if (repeatLimit in 1..startTS) {
repeatLimit = startTS
@ -37,15 +36,15 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
updateRepeatLimitText()
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmRepetition() }
.setPositiveButton(R.string.ok) { _, _ -> confirmRepetition() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
activity.currentFocus?.clearFocus()
view.repeat_type_count.onTextChangeListener {
view.dialog_radio_view.check(R.id.repeat_type_x_times)
binding.repeatTypeCount.onTextChangeListener {
binding.dialogRadioView.check(R.id.repeat_type_x_times)
}
}
}
@ -54,9 +53,10 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
private fun getCheckedItem() = when {
repeatLimit > 0 -> R.id.repeat_type_till_date
repeatLimit < 0 -> {
view.repeat_type_count.setText((-repeatLimit).toString())
binding.repeatTypeCount.setText((-repeatLimit).toString())
R.id.repeat_type_x_times
}
else -> R.id.repeat_type_forever
}
@ -66,15 +66,15 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
}
val repeatLimitDateTime = Formatter.getDateTimeFromTS(repeatLimit)
view.repeat_type_date.setText(Formatter.getFullDate(activity, repeatLimitDateTime))
binding.repeatTypeDate.setText(Formatter.getFullDate(activity, repeatLimitDateTime))
}
private fun confirmRepetition() {
when (view.dialog_radio_view.checkedRadioButtonId) {
when (binding.dialogRadioView.checkedRadioButtonId) {
R.id.repeat_type_till_date -> callback(repeatLimit)
R.id.repeat_type_forever -> callback(0)
else -> {
var count = view.repeat_type_count.value
var count = binding.repeatTypeCount.value
count = if (count.isEmpty()) {
"0"
} else {
@ -97,7 +97,7 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
datePicker.show()
}
private val repetitionLimitDateSetListener = DatePickerDialog.OnDateSetListener { v, year, monthOfYear, dayOfMonth ->
private val repetitionLimitDateSetListener = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
val repeatLimitDateTime = DateTime().withDate(year, monthOfYear + 1, dayOfMonth).withTime(23, 59, 59, 0)
repeatLimit = if (repeatLimitDateTime.seconds() < startTS) {
0
@ -106,6 +106,6 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Long,
}
updateRepeatLimitText()
view.dialog_radio_view.check(R.id.repeat_type_till_date)
binding.dialogRadioView.check(R.id.repeat_type_till_date)
}
}

View file

@ -2,21 +2,23 @@ package com.simplemobiletools.calendar.pro.dialogs
import android.app.Activity
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DialogVerticalLinearLayoutBinding
import com.simplemobiletools.calendar.pro.databinding.MyCheckboxBinding
import com.simplemobiletools.calendar.pro.extensions.withFirstDayOfWeekToFront
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
import kotlinx.android.synthetic.main.dialog_vertical_linear_layout.view.dialog_vertical_linear_layout
class RepeatRuleWeeklyDialog(val activity: Activity, val curRepeatRule: Int, val callback: (repeatRule: Int) -> Unit) {
private val view = activity.layoutInflater.inflate(R.layout.dialog_vertical_linear_layout, null)
private val binding by activity.viewBinding(DialogVerticalLinearLayoutBinding::inflate)
init {
val days = activity.resources.getStringArray(R.array.week_days)
var checkboxes = ArrayList<MyAppCompatCheckbox>(7)
for (i in 0..6) {
val pow = Math.pow(2.0, i.toDouble()).toInt()
(activity.layoutInflater.inflate(R.layout.my_checkbox, null) as MyAppCompatCheckbox).apply {
MyCheckboxBinding.inflate(activity.layoutInflater).root.apply {
isChecked = curRepeatRule and pow != 0
text = days[i]
id = pow
@ -26,22 +28,22 @@ class RepeatRuleWeeklyDialog(val activity: Activity, val curRepeatRule: Int, val
checkboxes = activity.withFirstDayOfWeekToFront(checkboxes)
checkboxes.forEach {
view.dialog_vertical_linear_layout.addView(it)
binding.dialogVerticalLinearLayout.addView(it)
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> callback(getRepeatRuleSum()) }
.setPositiveButton(R.string.ok) { _, _ -> callback(getRepeatRuleSum()) }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this)
activity.setupDialogStuff(binding.root, this)
}
}
private fun getRepeatRuleSum(): Int {
var sum = 0
val cnt = view.dialog_vertical_linear_layout.childCount
val cnt = binding.dialogVerticalLinearLayout.childCount
for (i in 0 until cnt) {
val child = view.dialog_vertical_linear_layout.getChildAt(i)
val child = binding.dialogVerticalLinearLayout.getChildAt(i)
if (child is MyAppCompatCheckbox) {
if (child.isChecked)
sum += child.id

View file

@ -1,30 +1,30 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.text.TextUtils
import android.view.ViewGroup
import android.widget.RelativeLayout
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.CalendarItemAccountBinding
import com.simplemobiletools.calendar.pro.databinding.CalendarItemCalendarBinding
import com.simplemobiletools.calendar.pro.databinding.DialogSelectCalendarsBinding
import com.simplemobiletools.calendar.pro.extensions.calDAVHelper
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
import kotlinx.android.synthetic.main.calendar_item_account.view.*
import kotlinx.android.synthetic.main.calendar_item_calendar.view.*
import kotlinx.android.synthetic.main.dialog_select_calendars.view.*
class SelectCalendarsDialog(val activity: SimpleActivity, val callback: () -> Unit) {
private var prevAccount = ""
private var view = (activity.layoutInflater.inflate(R.layout.dialog_select_calendars, null) as ViewGroup)
private val binding by activity.viewBinding(DialogSelectCalendarsBinding::inflate)
init {
val ids = activity.config.getSyncedCalendarIdsAsList()
val calendars = activity.calDAVHelper.getCalDAVCalendars("", true)
view.apply {
dialog_select_calendars_placeholder.beVisibleIf(calendars.isEmpty())
dialog_select_calendars_holder.beVisibleIf(calendars.isNotEmpty())
binding.apply {
dialogSelectCalendarsPlaceholder.beVisibleIf(calendars.isEmpty())
dialogSelectCalendarsHolder.beVisibleIf(calendars.isNotEmpty())
}
val sorted = calendars.sortedWith(compareBy({ it.accountName }, { it.displayName }))
@ -38,38 +38,37 @@ class SelectCalendarsDialog(val activity: SimpleActivity, val callback: () -> Un
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmSelection() }
.setPositiveButton(R.string.ok) { _, _ -> confirmSelection() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.select_caldav_calendars)
activity.setupDialogStuff(binding.root, this, R.string.select_caldav_calendars)
}
}
private fun addCalendarItem(isEvent: Boolean, text: String, tag: Int = 0, shouldCheck: Boolean = false) {
val layout = if (isEvent) R.layout.calendar_item_calendar else R.layout.calendar_item_account
val calendarItem = activity.layoutInflater.inflate(layout, view.dialog_select_calendars_holder, false)
if (isEvent) {
calendarItem.calendar_item_calendar_switch.apply {
this.tag = tag
this.text = text
isChecked = shouldCheck
calendarItem.setOnClickListener {
toggle()
val itemBinding = if (isEvent) {
CalendarItemCalendarBinding.inflate(activity.layoutInflater, binding.dialogSelectCalendarsHolder, false).apply {
calendarItemCalendarSwitch.tag = tag
calendarItemCalendarSwitch.text = text
calendarItemCalendarSwitch.isChecked = shouldCheck
root.setOnClickListener {
calendarItemCalendarSwitch.toggle()
}
}
} else {
calendarItem.calendar_item_account.text = text
CalendarItemAccountBinding.inflate(activity.layoutInflater, binding.dialogSelectCalendarsHolder, false).apply {
calendarItemAccount.text = text
}
}
view.dialog_select_calendars_holder.addView(calendarItem)
binding.dialogSelectCalendarsHolder.addView(itemBinding.root)
}
private fun confirmSelection() {
val calendarIds = ArrayList<Int>()
val childCnt = view.dialog_select_calendars_holder.childCount
val childCnt = binding.dialogSelectCalendarsHolder.childCount
for (i in 0..childCnt) {
val child = view.dialog_select_calendars_holder.getChildAt(i)
val child = binding.dialogSelectCalendarsHolder.getChildAt(i)
if (child is RelativeLayout) {
val check = child.getChildAt(0)
if (check is MyAppCompatCheckbox && check.isChecked) {

View file

@ -3,26 +3,25 @@ package com.simplemobiletools.calendar.pro.dialogs
import android.app.Activity
import android.graphics.Color
import android.view.ViewGroup
import android.widget.RadioButton
import android.widget.RadioGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DialogSelectRadioGroupBinding
import com.simplemobiletools.calendar.pro.databinding.RadioButtonWithColorBinding
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.calendar.pro.helpers.STORED_LOCALLY_ONLY
import com.simplemobiletools.calendar.pro.models.CalDAVCalendar
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
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<CalDAVCalendar>, 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 {
val view = activity.layoutInflater.inflate(R.layout.dialog_select_radio_group, null) as ViewGroup
radioGroup = view.dialog_radio_group
radioGroup = binding.dialogRadioGroup
ensureBackgroundThread {
calendars.forEach {
@ -38,32 +37,32 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List<CalD
}
addRadioButton(activity.getString(R.string.store_locally_only), STORED_LOCALLY_ONLY, Color.TRANSPARENT)
wasInit = true
activity.updateTextColors(view.dialog_radio_holder)
activity.updateTextColors(binding.dialogRadioHolder)
}
}
activity.getAlertDialogBuilder()
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
}
}
}
private fun addRadioButton(title: String, typeId: Int, color: Int) {
val view = activity.layoutInflater.inflate(R.layout.radio_button_with_color, null)
(view.dialog_radio_button as RadioButton).apply {
val radioBinding = RadioButtonWithColorBinding.inflate(activity.layoutInflater)
radioBinding.dialogRadioButton.apply {
text = title
isChecked = typeId == currCalendarId
id = typeId
}
if (typeId != STORED_LOCALLY_ONLY) {
view.dialog_radio_color.setFillWithStroke(color, activity.getProperBackgroundColor())
radioBinding.dialogRadioColor.setFillWithStroke(color, activity.getProperBackgroundColor())
}
view.setOnClickListener { viewClicked(typeId) }
radioGroup.addView(view, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
radioBinding.root.setOnClickListener { viewClicked(typeId) }
radioGroup.addView(radioBinding.root, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
}
private fun viewClicked(typeId: Int) {

View file

@ -1,26 +1,26 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.app.Activity
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.CheckableColorAdapter
import com.simplemobiletools.calendar.pro.databinding.DialogSelectColorBinding
import com.simplemobiletools.calendar.pro.views.AutoGridLayoutManager
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_select_color.view.*
import com.simplemobiletools.commons.extensions.viewBinding
class SelectEventColorDialog(val activity: Activity, val colors: IntArray, var currentColor: Int, val callback: (color: Int) -> Unit) {
private var dialog: AlertDialog? = null
private val binding by activity.viewBinding(DialogSelectColorBinding::inflate)
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_select_color, null) as ViewGroup
val colorAdapter = CheckableColorAdapter(activity, colors, currentColor) { color ->
callback(color)
dialog?.dismiss()
}
view.color_grid.apply {
binding.colorGrid.apply {
val width = activity.resources.getDimensionPixelSize(R.dimen.smaller_icon_size)
val spacing = activity.resources.getDimensionPixelSize(R.dimen.small_margin) * 2
layoutManager = AutoGridLayoutManager(context = activity, itemWidth = width + spacing)
@ -34,7 +34,7 @@ class SelectEventColorDialog(val activity: Activity, val colors: IntArray, var c
dialog?.dismiss()
}
activity.setupDialogStuff(view, this, R.string.event_color) {
activity.setupDialogStuff(binding.root, this, R.string.event_color) {
dialog = it
}
}

View file

@ -1,27 +1,27 @@
package com.simplemobiletools.calendar.pro.dialogs
import android.app.Activity
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.adapters.CheckableColorAdapter
import com.simplemobiletools.calendar.pro.databinding.DialogSelectColorBinding
import com.simplemobiletools.calendar.pro.views.AutoGridLayoutManager
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_select_color.view.*
import com.simplemobiletools.commons.extensions.viewBinding
class SelectEventTypeColorDialog(val activity: Activity, val colors: IntArray, var currentColor: Int, val callback: (color: Int) -> Unit) {
private var dialog: AlertDialog? = null
private val binding by activity.viewBinding(DialogSelectColorBinding::inflate)
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_select_color, null) as ViewGroup
val colorAdapter = CheckableColorAdapter(activity, colors, currentColor) { color ->
callback(color)
dialog?.dismiss()
}
view.color_grid.apply {
binding.colorGrid.apply {
val width = activity.resources.getDimensionPixelSize(R.dimen.smaller_icon_size)
val spacing = activity.resources.getDimensionPixelSize(R.dimen.small_margin) * 2
layoutManager = AutoGridLayoutManager(context = activity, itemWidth = width + spacing)
@ -31,7 +31,7 @@ class SelectEventTypeColorDialog(val activity: Activity, val colors: IntArray, v
activity.getAlertDialogBuilder()
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.color) {
activity.setupDialogStuff(binding.root, this, R.string.color) {
dialog = it
}

View file

@ -8,12 +8,11 @@ import android.widget.RadioGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.ManageEventTypesActivity
import com.simplemobiletools.calendar.pro.databinding.DialogSelectEventTypeBinding
import com.simplemobiletools.calendar.pro.databinding.RadioButtonWithColorBinding
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.calendar.pro.models.EventType
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.views.MyCompatRadioButton
import kotlinx.android.synthetic.main.dialog_select_event_type.view.*
import kotlinx.android.synthetic.main.radio_button_with_color.view.*
class SelectEventTypeDialog(
val activity: Activity, val currEventType: Long, val showCalDAVCalendars: Boolean, val showNewEventTypeOption: Boolean,
@ -27,10 +26,11 @@ class SelectEventTypeDialog(
private var wasInit = false
private var eventTypes = ArrayList<EventType>()
private val binding by activity.viewBinding(DialogSelectEventTypeBinding::inflate)
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_select_event_type, null) as ViewGroup
radioGroup = view.dialog_radio_group
view.dialog_manage_event_types.apply {
radioGroup = binding.dialogRadioGroup
binding.dialogManageEventTypes.apply {
beVisibleIf(showManageEventTypes)
setOnClickListener {
activity.startActivity(Intent(activity, ManageEventTypesActivity::class.java))
@ -38,16 +38,16 @@ class SelectEventTypeDialog(
}
}
view.dialog_radio_divider.beVisibleIf(showManageEventTypes)
binding.dialogRadioDivider.beVisibleIf(showManageEventTypes)
activity.eventsHelper.getEventTypes(activity, showOnlyWritable) {
eventTypes = it
activity.eventsHelper.getEventTypes(activity, showOnlyWritable) { eventTypes ->
this.eventTypes = eventTypes
activity.runOnUiThread {
if (addLastUsedOneAsFirstOption) {
val lastUsedEventType = EventType(LAST_USED_EVENT_TYPE_ID, activity.getString(R.string.last_used_one), Color.TRANSPARENT, 0)
addRadioButton(lastUsedEventType)
}
eventTypes.filter { showCalDAVCalendars || it.caldavCalendarId == 0 }.forEach {
this.eventTypes.filter { showCalDAVCalendars || it.caldavCalendarId == 0 }.forEach {
addRadioButton(it)
}
if (showNewEventTypeOption) {
@ -55,32 +55,32 @@ class SelectEventTypeDialog(
addRadioButton(newEventType)
}
wasInit = true
activity.updateTextColors(view.dialog_radio_holder)
activity.updateTextColors(binding.dialogRadioHolder)
}
}
activity.getAlertDialogBuilder()
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
}
}
}
private fun addRadioButton(eventType: EventType) {
val view = activity.layoutInflater.inflate(R.layout.radio_button_with_color, null)
(view.dialog_radio_button as MyCompatRadioButton).apply {
val radioBinding = RadioButtonWithColorBinding.inflate(activity.layoutInflater)
(radioBinding.dialogRadioButton).apply {
text = eventType.getDisplayTitle()
isChecked = eventType.id == currEventType
id = eventType.id!!.toInt()
}
if (eventType.color != Color.TRANSPARENT) {
view.dialog_radio_color.setFillWithStroke(eventType.color, activity.getProperBackgroundColor())
radioBinding.dialogRadioColor.setFillWithStroke(eventType.color, activity.getProperBackgroundColor())
}
view.setOnClickListener { viewClicked(eventType) }
radioGroup.addView(view, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
radioBinding.root.setOnClickListener { viewClicked(eventType) }
radioGroup.addView(radioBinding.root, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
}
private fun viewClicked(eventType: EventType) {

View file

@ -4,24 +4,25 @@ import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.adapters.FilterEventTypeAdapter
import com.simplemobiletools.calendar.pro.databinding.DialogFilterEventTypesBinding
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_filter_event_types.view.*
import com.simplemobiletools.commons.extensions.viewBinding
class SelectEventTypesDialog(val activity: SimpleActivity, selectedEventTypes: Set<String>, val callback: (HashSet<String>) -> Unit) {
private var dialog: AlertDialog? = null
private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_event_types, null)
private val binding by activity.viewBinding(DialogFilterEventTypesBinding::inflate)
init {
activity.eventsHelper.getEventTypes(activity, false) {
view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, it, selectedEventTypes)
binding.filterEventTypesList.adapter = FilterEventTypeAdapter(activity, it, selectedEventTypes)
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { _, _ -> confirmEventTypes() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
}
}
@ -29,7 +30,7 @@ class SelectEventTypesDialog(val activity: SimpleActivity, selectedEventTypes: S
}
private fun confirmEventTypes() {
val adapter = view.filter_event_types_list.adapter as FilterEventTypeAdapter
val adapter = binding.filterEventTypesList.adapter as FilterEventTypeAdapter
val selectedItems = adapter.getSelectedItemsList()
.map { it.toString() }
.toHashSet()

View file

@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.pro.dialogs
import android.view.View
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.DialogSetRemindersBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.ANNIVERSARY_EVENT
import com.simplemobiletools.calendar.pro.helpers.BIRTHDAY_EVENT
@ -10,7 +11,6 @@ import com.simplemobiletools.calendar.pro.helpers.OTHER_EVENT
import com.simplemobiletools.calendar.pro.helpers.REMINDER_OFF
import com.simplemobiletools.commons.dialogs.PermissionRequiredDialog
import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.dialog_set_reminders.view.*
class SetRemindersDialog(val activity: SimpleActivity, val eventType: Int, val callback: (reminders: ArrayList<Int>) -> Unit) {
private var mReminder1Minutes = REMINDER_OFF
@ -18,21 +18,23 @@ class SetRemindersDialog(val activity: SimpleActivity, val eventType: Int, val c
private var mReminder3Minutes = REMINDER_OFF
private var isAutomatic = false
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_set_reminders, null).apply {
set_reminders_image.applyColorFilter(context.getProperTextColor())
set_reminders_1.text = activity.getFormattedMinutes(mReminder1Minutes)
set_reminders_2.text = activity.getFormattedMinutes(mReminder1Minutes)
set_reminders_3.text = activity.getFormattedMinutes(mReminder1Minutes)
private val binding by activity.viewBinding(DialogSetRemindersBinding::inflate)
set_reminders_1.setOnClickListener {
init {
binding.apply {
setRemindersImage.applyColorFilter(activity.getProperTextColor())
setReminders1.text = activity.getFormattedMinutes(mReminder1Minutes)
setReminders2.text = activity.getFormattedMinutes(mReminder1Minutes)
setReminders3.text = activity.getFormattedMinutes(mReminder1Minutes)
setReminders1.setOnClickListener {
activity.handleNotificationPermission { granted ->
if (granted) {
activity.showPickSecondsDialogHelper(mReminder1Minutes, showDuringDayOption = true) {
mReminder1Minutes = if (it == -1 || it == 0) it else it / 60
set_reminders_1.text = activity.getFormattedMinutes(mReminder1Minutes)
setReminders1.text = activity.getFormattedMinutes(mReminder1Minutes)
if (mReminder1Minutes != REMINDER_OFF) {
set_reminders_2.beVisible()
setReminders2.beVisible()
}
}
} else {
@ -41,24 +43,24 @@ class SetRemindersDialog(val activity: SimpleActivity, val eventType: Int, val c
}
}
set_reminders_2.setOnClickListener {
setReminders2.setOnClickListener {
activity.showPickSecondsDialogHelper(mReminder2Minutes, showDuringDayOption = true) {
mReminder2Minutes = if (it == -1 || it == 0) it else it / 60
set_reminders_2.text = activity.getFormattedMinutes(mReminder2Minutes)
setReminders2.text = activity.getFormattedMinutes(mReminder2Minutes)
if (mReminder2Minutes != REMINDER_OFF) {
set_reminders_3.beVisible()
setReminders3.beVisible()
}
}
}
set_reminders_3.setOnClickListener {
setReminders3.setOnClickListener {
activity.showPickSecondsDialogHelper(mReminder3Minutes, showDuringDayOption = true) {
mReminder3Minutes = if (it == -1 || it == 0) it else it / 60
set_reminders_3.text = activity.getFormattedMinutes(mReminder3Minutes)
setReminders3.text = activity.getFormattedMinutes(mReminder3Minutes)
}
}
add_event_automatically_checkbox.apply {
addEventAutomaticallyCheckbox.apply {
visibility = if (eventType == OTHER_EVENT) View.GONE else View.VISIBLE
text = when (eventType) {
BIRTHDAY_EVENT -> activity.getString(R.string.add_birthdays_automatically)
@ -76,10 +78,10 @@ class SetRemindersDialog(val activity: SimpleActivity, val eventType: Int, val c
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.event_reminders)
activity.setupDialogStuff(binding.root, this, R.string.event_reminders)
}
}

View file

@ -17,10 +17,9 @@ import android.media.MediaScannerConnection
import android.net.Uri
import android.os.Bundle
import android.provider.CalendarContract
import android.view.View
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.app.AlarmManagerCompat
import androidx.core.app.NotificationCompat
import androidx.print.PrintHelper
@ -30,6 +29,7 @@ import com.simplemobiletools.calendar.pro.activities.EventTypePickerActivity
import com.simplemobiletools.calendar.pro.activities.SnoozeReminderActivity
import com.simplemobiletools.calendar.pro.activities.TaskActivity
import com.simplemobiletools.calendar.pro.databases.EventsDatabase
import com.simplemobiletools.calendar.pro.databinding.DayMonthlyEventViewBinding
import com.simplemobiletools.calendar.pro.helpers.*
import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.interfaces.EventTypesDao
@ -44,7 +44,6 @@ import com.simplemobiletools.calendar.pro.services.MarkCompletedService
import com.simplemobiletools.calendar.pro.services.SnoozeService
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import kotlinx.android.synthetic.main.day_monthly_event_view.view.*
import org.joda.time.DateTime
import org.joda.time.DateTimeConstants
import org.joda.time.LocalDate
@ -603,21 +602,21 @@ fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resou
textColor = textColor.adjustAlpha(0.25f)
}
(View.inflate(applicationContext, R.layout.day_monthly_event_view, null) as ConstraintLayout).apply {
background = backgroundDrawable
layoutParams = eventLayoutParams
linearLayout.addView(this)
DayMonthlyEventViewBinding.inflate(LayoutInflater.from(this)).apply {
root.background = backgroundDrawable
root.layoutParams = eventLayoutParams
linearLayout.addView(root)
day_monthly_event_id.apply {
dayMonthlyEventId.apply {
setTextColor(textColor)
text = it.title.replace(" ", "\u00A0") // allow word break by char
checkViewStrikeThrough(it.isTaskCompleted())
contentDescription = it.title
}
day_monthly_task_image.beVisibleIf(it.isTask())
dayMonthlyTaskImage.beVisibleIf(it.isTask())
if (it.isTask()) {
day_monthly_task_image.applyColorFilter(textColor)
dayMonthlyTaskImage.applyColorFilter(textColor)
}
}
}
@ -717,7 +716,7 @@ fun Context.refreshCalDAVCalendars(ids: String, showToasts: Boolean) {
Bundle().apply {
putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true)
if (showToasts) {
// Assume this is a manual synchronisation when we showToasts to the user (swipe_refresh, MainMenu->refresh_caldav_calendars, ...)
// Assume this is a manual synchronisation when we showToasts to the user (swipe refresh, MainMenu-> refresh caldav calendars, ...)
putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true)
}
accounts.forEach {

View file

@ -6,12 +6,13 @@ import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import androidx.fragment.app.Fragment
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.adapters.DayEventsAdapter
import com.simplemobiletools.calendar.pro.databinding.FragmentDayBinding
import com.simplemobiletools.calendar.pro.databinding.TopNavigationBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
import com.simplemobiletools.calendar.pro.extensions.getViewBitmap
@ -20,8 +21,6 @@ import com.simplemobiletools.calendar.pro.helpers.*
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
import com.simplemobiletools.calendar.pro.models.Event
import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.fragment_day.view.*
import kotlinx.android.synthetic.main.top_navigation.view.*
class DayFragment : Fragment() {
var mListener: NavigationListener? = null
@ -29,15 +28,15 @@ class DayFragment : Fragment() {
private var mDayCode = ""
private var lastHash = 0
private lateinit var mHolder: RelativeLayout
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_day, container, false)
mHolder = view.day_holder
private lateinit var binding: FragmentDayBinding
private lateinit var topNavigationBinding: TopNavigationBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentDayBinding.inflate(inflater, container, false)
topNavigationBinding = TopNavigationBinding.bind(binding.root)
mDayCode = requireArguments().getString(DAY_CODE)!!
setupButtons()
return view
return binding.root
}
override fun onResume() {
@ -48,7 +47,7 @@ class DayFragment : Fragment() {
private fun setupButtons() {
mTextColor = requireContext().getProperTextColor()
mHolder.top_left_arrow.apply {
topNavigationBinding.topLeftArrow.apply {
applyColorFilter(mTextColor)
background = null
setOnClickListener {
@ -60,7 +59,7 @@ class DayFragment : Fragment() {
setImageDrawable(pointerLeft)
}
mHolder.top_right_arrow.apply {
topNavigationBinding.topRightArrow.apply {
applyColorFilter(mTextColor)
background = null
setOnClickListener {
@ -73,7 +72,7 @@ class DayFragment : Fragment() {
}
val day = Formatter.getDayTitle(requireContext(), mDayCode)
mHolder.top_value.apply {
topNavigationBinding.topValue.apply {
text = day
contentDescription = text
setOnClickListener {
@ -112,14 +111,14 @@ class DayFragment : Fragment() {
if (activity == null)
return
DayEventsAdapter(activity as SimpleActivity, events, mHolder.day_events, mDayCode) {
DayEventsAdapter(activity as SimpleActivity, events, binding.dayEvents, mDayCode) {
editEvent(it as Event)
}.apply {
mHolder.day_events.adapter = this
binding.dayEvents.adapter = this
}
if (requireContext().areSystemAnimationsEnabled) {
mHolder.day_events.scheduleLayoutAnimation()
binding.dayEvents.scheduleLayoutAnimation()
}
}
@ -133,20 +132,20 @@ class DayFragment : Fragment() {
}
fun printCurrentView() {
mHolder.apply {
top_left_arrow.beGone()
top_right_arrow.beGone()
top_value.setTextColor(resources.getColor(R.color.theme_light_text_color))
(day_events.adapter as? DayEventsAdapter)?.togglePrintMode()
topNavigationBinding.apply {
topLeftArrow.beGone()
topRightArrow.beGone()
topValue.setTextColor(resources.getColor(R.color.theme_light_text_color))
(binding.dayEvents.adapter as? DayEventsAdapter)?.togglePrintMode()
Handler().postDelayed({
requireContext().printBitmap(day_holder.getViewBitmap())
requireContext().printBitmap(binding.dayHolder.getViewBitmap())
Handler().postDelayed({
top_left_arrow.beVisible()
top_right_arrow.beVisible()
top_value.setTextColor(requireContext().getProperTextColor())
(day_events.adapter as? DayEventsAdapter)?.togglePrintMode()
topLeftArrow.beVisible()
topRightArrow.beVisible()
topValue.setTextColor(requireContext().getProperTextColor())
(binding.dayEvents.adapter as? DayEventsAdapter)?.togglePrintMode()
}, 1000)
}, 1000)
}

View file

@ -10,6 +10,7 @@ import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.adapters.MyDayPagerAdapter
import com.simplemobiletools.calendar.pro.databinding.FragmentDaysHolderBinding
import com.simplemobiletools.calendar.pro.helpers.DAILY_VIEW
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
import com.simplemobiletools.calendar.pro.helpers.Formatter
@ -18,13 +19,12 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.views.MyViewPager
import kotlinx.android.synthetic.main.fragment_days_holder.view.*
import org.joda.time.DateTime
class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
private val PREFILLED_DAYS = 251
private var viewPager: MyViewPager? = null
private lateinit var viewPager: MyViewPager
private var defaultDailyPage = 0
private var todayDayCode = ""
private var currentDayCode = ""
@ -38,13 +38,13 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
todayDayCode = Formatter.getTodayCode()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_days_holder, container, false)
view.background = ColorDrawable(requireContext().getProperBackgroundColor())
viewPager = view.fragment_days_viewpager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val binding = FragmentDaysHolderBinding.inflate(inflater, container, false)
binding.root.background = ColorDrawable(requireContext().getProperBackgroundColor())
viewPager = binding.fragmentDaysViewpager
viewPager.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
return view
return binding.root
}
private fun setupFragment() {
@ -52,8 +52,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
val dailyAdapter = MyDayPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultDailyPage = codes.size / 2
viewPager!!.apply {
viewPager.apply {
adapter = dailyAdapter
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
@ -85,11 +84,11 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun goLeft() {
viewPager!!.currentItem = viewPager!!.currentItem - 1
viewPager.currentItem = viewPager.currentItem - 1
}
override fun goRight() {
viewPager!!.currentItem = viewPager!!.currentItem + 1
viewPager.currentItem = viewPager.currentItem + 1
}
override fun goToDateTime(dateTime: DateTime) {
@ -107,17 +106,15 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
return
}
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val datePicker = getDatePickerView()
val dateTime = getCurrentDate()!!
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
activity?.getAlertDialogBuilder()!!
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
.setPositiveButton(R.string.ok) { _, _ -> dateSelected(dateTime, datePicker) }
.apply {
activity?.setupDialogStuff(view, this)
activity?.setupDialogStuff(datePicker, this)
}
}
@ -130,7 +127,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun refreshEvents() {
(viewPager?.adapter as? MyDayPagerAdapter)?.updateCalendars(viewPager?.currentItem ?: 0)
(viewPager.adapter as? MyDayPagerAdapter)?.updateCalendars(viewPager.currentItem)
}
override fun shouldGoToTodayBeVisible() = currentDayCode != todayDayCode
@ -138,7 +135,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
override fun getNewEventDayCode() = currentDayCode
override fun printView() {
(viewPager?.adapter as? MyDayPagerAdapter)?.printCurrentView(viewPager?.currentItem ?: 0)
(viewPager.adapter as? MyDayPagerAdapter)?.printCurrentView(viewPager.currentItem)
}
override fun getCurrentDate(): DateTime? {

View file

@ -12,6 +12,7 @@ import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.adapters.EventListAdapter
import com.simplemobiletools.calendar.pro.databinding.FragmentEventListBinding
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.*
import com.simplemobiletools.calendar.pro.models.Event
@ -22,7 +23,6 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.views.MyLinearLayoutManager
import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.fragment_event_list.view.*
import org.joda.time.DateTime
class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
@ -35,15 +35,15 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
private var use24HourFormat = false
lateinit var mView: View
private lateinit var binding: FragmentEventListBinding
override val viewType = EVENTS_LIST_VIEW
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater.inflate(R.layout.fragment_event_list, container, false)
mView.background = ColorDrawable(requireContext().getProperBackgroundColor())
mView.calendar_events_list_holder?.id = (System.currentTimeMillis() % 100000).toInt()
mView.calendar_empty_list_placeholder_2.apply {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentEventListBinding.inflate(inflater, container, false)
binding.root.background = ColorDrawable(requireContext().getProperBackgroundColor())
binding.calendarEventsListHolder.id = (System.currentTimeMillis() % 100000).toInt()
binding.calendarEmptyListPlaceholder2.apply {
setTextColor(context.getProperPrimaryColor())
underlineText()
setOnClickListener {
@ -53,7 +53,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
}
use24HourFormat = requireContext().config.use24HourFormat
return mView
return binding.root
}
override fun onResume() {
@ -62,7 +62,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
val use24Hour = requireContext().config.use24HourFormat
if (use24Hour != use24HourFormat) {
use24HourFormat = use24Hour
(mView.calendar_events_list.adapter as? EventListAdapter)?.toggle24HourFormat(use24HourFormat)
(binding.calendarEventsList.adapter as? EventListAdapter)?.toggle24HourFormat(use24HourFormat)
}
}
@ -107,21 +107,21 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
return@runOnUiThread
}
val currAdapter = mView.calendar_events_list.adapter
val currAdapter = binding.calendarEventsList.adapter
if (currAdapter == null || forceRecreation) {
EventListAdapter(activity as SimpleActivity, listItems, true, this, mView.calendar_events_list) {
EventListAdapter(activity as SimpleActivity, listItems, true, this, binding.calendarEventsList) {
if (it is ListEvent) {
context?.editEvent(it)
}
}.apply {
mView.calendar_events_list.adapter = this
binding.calendarEventsList.adapter = this
}
if (requireContext().areSystemAnimationsEnabled) {
mView.calendar_events_list.scheduleLayoutAnimation()
binding.calendarEventsList.scheduleLayoutAnimation()
}
mView.calendar_events_list.endlessScrollListener = object : MyRecyclerView.EndlessScrollListener {
binding.calendarEventsList.endlessScrollListener = object : MyRecyclerView.EndlessScrollListener {
override fun updateTop() {
fetchPreviousPeriod()
}
@ -131,7 +131,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
}
}
mView.calendar_events_list.addOnScrollListener(object : RecyclerView.OnScrollListener() {
binding.calendarEventsList.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (!hasBeenScrolled) {
@ -146,10 +146,10 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
if (updateStatus == UPDATE_TOP) {
val item = listItems.indexOfFirst { it == bottomItemAtRefresh }
if (item != -1) {
mView.calendar_events_list.scrollToPosition(item)
binding.calendarEventsList.scrollToPosition(item)
}
} else if (updateStatus == UPDATE_BOTTOM) {
mView.calendar_events_list.smoothScrollBy(0, requireContext().resources.getDimension(R.dimen.endless_scroll_move_height).toInt())
binding.calendarEventsList.smoothScrollBy(0, requireContext().resources.getDimension(R.dimen.endless_scroll_move_height).toInt())
}
}
checkPlaceholderVisibility()
@ -157,11 +157,11 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
}
private fun checkPlaceholderVisibility() {
mView.calendar_empty_list_placeholder.beVisibleIf(mEvents.isEmpty())
mView.calendar_empty_list_placeholder_2.beVisibleIf(mEvents.isEmpty())
mView.calendar_events_list.beGoneIf(mEvents.isEmpty())
binding.calendarEmptyListPlaceholder.beVisibleIf(mEvents.isEmpty())
binding.calendarEmptyListPlaceholder2.beVisibleIf(mEvents.isEmpty())
binding.calendarEventsList.beGoneIf(mEvents.isEmpty())
if (activity != null) {
mView.calendar_empty_list_placeholder.setTextColor(requireActivity().getProperTextColor())
binding.calendarEmptyListPlaceholder.setTextColor(requireActivity().getProperTextColor())
if (mEvents.isEmpty()) {
val placeholderTextId = if (requireActivity().config.displayEventTypes.isEmpty()) {
R.string.everything_filtered_out
@ -169,14 +169,14 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
R.string.no_upcoming_events
}
mView.calendar_empty_list_placeholder.setText(placeholderTextId)
binding.calendarEmptyListPlaceholder.setText(placeholderTextId)
}
}
}
private fun fetchPreviousPeriod() {
val lastPosition = (mView.calendar_events_list.layoutManager as MyLinearLayoutManager).findLastVisibleItemPosition()
bottomItemAtRefresh = (mView.calendar_events_list.adapter as EventListAdapter).listItems[lastPosition]
val lastPosition = (binding.calendarEventsList.layoutManager as MyLinearLayoutManager).findLastVisibleItemPosition()
bottomItemAtRefresh = (binding.calendarEventsList.adapter as EventListAdapter).listItems[lastPosition]
val oldMinFetchedTS = minFetchedTS - 1
minFetchedTS -= FETCH_INTERVAL
@ -213,8 +213,8 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
val listItems = requireContext().getEventListItems(mEvents)
val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSectionDay && !it.isPastSection }
if (firstNonPastSectionIndex != -1) {
(mView.calendar_events_list.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(firstNonPastSectionIndex, 0)
mView.calendar_events_list.onGlobalLayout {
(binding.calendarEventsList.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(firstNonPastSectionIndex, 0)
binding.calendarEventsList.onGlobalLayout {
hasBeenScrolled = false
(activity as? MainActivity)?.refreshItems()
(activity as? MainActivity)?.refreshMenuItems()
@ -233,18 +233,18 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
override fun getNewEventDayCode() = Formatter.getTodayCode()
override fun printView() {
mView.apply {
if (calendar_events_list.isGone()) {
context.toast(R.string.no_items_found)
binding.apply {
if (calendarEventsList.isGone()) {
context?.toast(R.string.no_items_found)
return@apply
}
(calendar_events_list.adapter as? EventListAdapter)?.togglePrintMode()
(calendarEventsList.adapter as? EventListAdapter)?.togglePrintMode()
Handler().postDelayed({
requireContext().printBitmap(calendar_events_list.getViewBitmap())
requireContext().printBitmap(calendarEventsList.getViewBitmap())
Handler().postDelayed({
(calendar_events_list.adapter as? EventListAdapter)?.togglePrintMode()
(calendarEventsList.adapter as? EventListAdapter)?.togglePrintMode()
}, 1000)
}, 1000)
}

View file

@ -6,12 +6,11 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.Fragment
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.adapters.EventListAdapter
import com.simplemobiletools.calendar.pro.databinding.FragmentMonthDayBinding
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.Config
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
@ -27,8 +26,6 @@ import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import kotlinx.android.synthetic.main.fragment_month_day.month_day_events_list
import kotlinx.android.synthetic.main.fragment_month_day.view.*
import org.joda.time.DateTime
class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListener {
@ -42,19 +39,18 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
var listener: NavigationListener? = null
lateinit var mRes: Resources
lateinit var mHolder: ConstraintLayout
lateinit var mConfig: Config
private lateinit var mRes: Resources
private lateinit var binding: FragmentMonthDayBinding
private lateinit var mConfig: Config
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_month_day, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentMonthDayBinding.inflate(inflater, container, false)
mRes = resources
mPackageName = requireActivity().packageName
mHolder = view.month_day_calendar_holder
mDayCode = requireArguments().getString(DAY_CODE)!!
val shownMonthDateTime = Formatter.getDateTimeFromCode(mDayCode)
mHolder.month_day_selected_day_label.apply {
binding.monthDaySelectedDayLabel.apply {
text = getMonthLabel(shownMonthDateTime)
setOnClickListener {
(activity as MainActivity).showGoToDateDialog()
@ -65,7 +61,7 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
storeStateVariables()
setupButtons()
mCalendar = MonthlyCalendarImpl(this, requireContext())
return view
return binding.root
}
override fun onPause() {
@ -107,7 +103,7 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
mLastHash = newHash
activity?.runOnUiThread {
mHolder.month_day_view_wrapper.updateDays(days, false) {
binding.monthDayViewWrapper.updateDays(days, false) {
mSelectedDayCode = it.code
updateVisibleEvents()
}
@ -136,26 +132,26 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
val listItems = requireActivity().getEventListItems(filtered, mSelectedDayCode.isEmpty(), false)
if (mSelectedDayCode.isNotEmpty()) {
mHolder.month_day_selected_day_label.text = Formatter.getDateFromCode(requireActivity(), mSelectedDayCode, false)
binding.monthDaySelectedDayLabel.text = Formatter.getDateFromCode(requireActivity(), mSelectedDayCode, false)
}
activity?.runOnUiThread {
if (activity != null) {
mHolder.month_day_events_list.beVisibleIf(listItems.isNotEmpty())
mHolder.month_day_no_events_placeholder.beVisibleIf(listItems.isEmpty())
binding.monthDayEventsList.beVisibleIf(listItems.isNotEmpty())
binding.monthDayNoEventsPlaceholder.beVisibleIf(listItems.isEmpty())
val currAdapter = mHolder.month_day_events_list.adapter
val currAdapter = binding.monthDayEventsList.adapter
if (currAdapter == null) {
EventListAdapter(activity as SimpleActivity, listItems, true, this, month_day_events_list) {
EventListAdapter(activity as SimpleActivity, listItems, true, this, binding.monthDayEventsList) {
if (it is ListEvent) {
activity?.editEvent(it)
}
}.apply {
month_day_events_list.adapter = this
binding.monthDayEventsList.adapter = this
}
if (requireContext().areSystemAnimationsEnabled) {
month_day_events_list.scheduleLayoutAnimation()
binding.monthDayEventsList.scheduleLayoutAnimation()
}
} else {
(currAdapter as EventListAdapter).updateListItems(listItems)
@ -166,15 +162,15 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
private fun setupButtons() {
val textColor = requireContext().getProperTextColor()
mHolder.apply {
month_day_selected_day_label.setTextColor(textColor)
month_day_no_events_placeholder.setTextColor(textColor)
binding.apply {
monthDaySelectedDayLabel.setTextColor(textColor)
monthDayNoEventsPlaceholder.setTextColor(textColor)
}
}
fun printCurrentView() {}
fun getNewEventDayCode() = if (mSelectedDayCode.isEmpty()) null else mSelectedDayCode
fun getNewEventDayCode() = mSelectedDayCode.ifEmpty { null }
private fun getMonthLabel(shownMonthDateTime: DateTime): String {
var month = Formatter.getMonthName(requireActivity(), shownMonthDateTime.monthOfYear)

View file

@ -11,6 +11,7 @@ import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.adapters.MyMonthDayPagerAdapter
import com.simplemobiletools.calendar.pro.databinding.FragmentMonthsDaysHolderBinding
import com.simplemobiletools.calendar.pro.extensions.getMonthCode
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
import com.simplemobiletools.calendar.pro.helpers.Formatter
@ -21,13 +22,12 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.views.MyViewPager
import kotlinx.android.synthetic.main.fragment_months_days_holder.view.*
import org.joda.time.DateTime
class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
private val PREFILLED_MONTHS = 251
private var viewPager: MyViewPager? = null
private lateinit var viewPager: MyViewPager
private var defaultMonthlyPage = 0
private var todayDayCode = ""
private var currentDayCode = ""
@ -41,13 +41,13 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
todayDayCode = Formatter.getTodayCode()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_months_days_holder, container, false)
view.background = ColorDrawable(requireContext().getProperBackgroundColor())
viewPager = view.fragment_months_days_viewpager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val binding = FragmentMonthsDaysHolderBinding.inflate(inflater, container, false)
binding.root.background = ColorDrawable(requireContext().getProperBackgroundColor())
viewPager = binding.fragmentMonthsDaysViewpager
viewPager.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
return view
return binding.root
}
private fun setupFragment() {
@ -55,14 +55,12 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
val monthlyDailyAdapter = MyMonthDayPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultMonthlyPage = codes.size / 2
viewPager!!.apply {
viewPager.apply {
adapter = monthlyDailyAdapter
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
}
override fun onPageScrollStateChanged(state: Int) {}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
override fun onPageSelected(position: Int) {
currentDayCode = codes[position]
@ -88,11 +86,11 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun goLeft() {
viewPager!!.currentItem = viewPager!!.currentItem - 1
viewPager.currentItem = viewPager.currentItem - 1
}
override fun goRight() {
viewPager!!.currentItem = viewPager!!.currentItem + 1
viewPager.currentItem = viewPager.currentItem + 1
}
override fun goToDateTime(dateTime: DateTime) {
@ -110,8 +108,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
return
}
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val datePicker = getDatePickerView()
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
val dateTime = getCurrentDate()!!
@ -119,9 +116,9 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
activity?.getAlertDialogBuilder()!!
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) }
.setPositiveButton(R.string.ok) { _, _ -> datePicked(dateTime, datePicker) }
.apply {
activity?.setupDialogStuff(view, this)
activity?.setupDialogStuff(datePicker, this)
}
}
@ -133,12 +130,12 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun refreshEvents() {
(viewPager?.adapter as? MyMonthDayPagerAdapter)?.updateCalendars(viewPager?.currentItem ?: 0)
(viewPager.adapter as? MyMonthDayPagerAdapter)?.updateCalendars(viewPager.currentItem)
}
override fun shouldGoToTodayBeVisible() = currentDayCode.getMonthCode() != todayDayCode.getMonthCode()
override fun getNewEventDayCode() = (viewPager?.adapter as? MyMonthDayPagerAdapter)?.getNewEventDayCode(viewPager?.currentItem ?: 0)
override fun getNewEventDayCode() = (viewPager.adapter as? MyMonthDayPagerAdapter)?.getNewEventDayCode(viewPager.currentItem)
?: if (shouldGoToTodayBeVisible()) {
currentDayCode
} else {

View file

@ -6,10 +6,11 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import androidx.fragment.app.Fragment
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.databinding.FragmentMonthBinding
import com.simplemobiletools.calendar.pro.databinding.TopNavigationBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.getViewBitmap
import com.simplemobiletools.calendar.pro.extensions.printBitmap
@ -20,15 +21,11 @@ import com.simplemobiletools.calendar.pro.helpers.MonthlyCalendarImpl
import com.simplemobiletools.calendar.pro.interfaces.MonthlyCalendar
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
import com.simplemobiletools.calendar.pro.models.DayMonthly
import com.simplemobiletools.calendar.pro.views.MonthViewWrapper
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beGone
import com.simplemobiletools.commons.extensions.beVisible
import com.simplemobiletools.commons.extensions.getProperTextColor
import kotlinx.android.synthetic.main.fragment_month.view.month_calendar_holder
import kotlinx.android.synthetic.main.fragment_month.view.month_view_wrapper
import kotlinx.android.synthetic.main.top_navigation.view.top_left_arrow
import kotlinx.android.synthetic.main.top_navigation.view.top_right_arrow
import kotlinx.android.synthetic.main.top_navigation.view.top_value
import org.joda.time.DateTime
class MonthFragment : Fragment(), MonthlyCalendar {
@ -41,15 +38,18 @@ class MonthFragment : Fragment(), MonthlyCalendar {
var listener: NavigationListener? = null
lateinit var mRes: Resources
lateinit var mHolder: RelativeLayout
lateinit var mConfig: Config
private lateinit var mRes: Resources
private lateinit var mConfig: Config
private lateinit var binding: FragmentMonthBinding
private lateinit var topNavigationBinding: TopNavigationBinding
private lateinit var monthView: MonthViewWrapper
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_month, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentMonthBinding.inflate(inflater, container, false)
topNavigationBinding = TopNavigationBinding.bind(binding.root)
monthView = binding.monthViewWrapper
mRes = resources
mPackageName = requireActivity().packageName
mHolder = view.month_calendar_holder
mDayCode = requireArguments().getString(DAY_CODE)!!
mConfig = requireContext().config
storeStateVariables()
@ -57,7 +57,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
setupButtons()
mCalendar = MonthlyCalendarImpl(this, requireContext())
return view
return binding.root
}
override fun onPause() {
@ -99,7 +99,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
mLastHash = newHash
activity?.runOnUiThread {
mHolder.top_value.apply {
topNavigationBinding.topValue.apply {
text = month
contentDescription = text
@ -114,7 +114,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
private fun setupButtons() {
mTextColor = requireContext().getProperTextColor()
mHolder.top_left_arrow.apply {
topNavigationBinding.topLeftArrow.apply {
applyColorFilter(mTextColor)
background = null
setOnClickListener {
@ -126,7 +126,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
setImageDrawable(pointerLeft)
}
mHolder.top_right_arrow.apply {
topNavigationBinding.topRightArrow.apply {
applyColorFilter(mTextColor)
background = null
setOnClickListener {
@ -138,7 +138,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
setImageDrawable(pointerRight)
}
mHolder.top_value.apply {
topNavigationBinding.topValue.apply {
setTextColor(requireContext().getProperTextColor())
setOnClickListener {
(activity as MainActivity).showGoToDateDialog()
@ -147,24 +147,24 @@ class MonthFragment : Fragment(), MonthlyCalendar {
}
private fun updateDays(days: ArrayList<DayMonthly>) {
mHolder.month_view_wrapper.updateDays(days, true) {
binding.monthViewWrapper.updateDays(days, true) {
(activity as MainActivity).openDayFromMonthly(Formatter.getDateTimeFromCode(it.code))
}
}
fun printCurrentView() {
mHolder.apply {
top_left_arrow.beGone()
top_right_arrow.beGone()
top_value.setTextColor(resources.getColor(R.color.theme_light_text_color))
month_view_wrapper.togglePrintMode()
topNavigationBinding.apply {
topLeftArrow.beGone()
topRightArrow.beGone()
topValue.setTextColor(resources.getColor(R.color.theme_light_text_color))
binding.monthViewWrapper.togglePrintMode()
requireContext().printBitmap(month_calendar_holder.getViewBitmap())
requireContext().printBitmap(binding.monthCalendarHolder.getViewBitmap())
top_left_arrow.beVisible()
top_right_arrow.beVisible()
top_value.setTextColor(requireContext().getProperTextColor())
month_view_wrapper.togglePrintMode()
topLeftArrow.beVisible()
topRightArrow.beVisible()
topValue.setTextColor(requireContext().getProperTextColor())
binding.monthViewWrapper.togglePrintMode()
}
}
}

View file

@ -11,6 +11,7 @@ import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.adapters.MyMonthPagerAdapter
import com.simplemobiletools.calendar.pro.databinding.FragmentMonthsHolderBinding
import com.simplemobiletools.calendar.pro.extensions.getMonthCode
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
import com.simplemobiletools.calendar.pro.helpers.Formatter
@ -21,13 +22,12 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.views.MyViewPager
import kotlinx.android.synthetic.main.fragment_months_holder.view.*
import org.joda.time.DateTime
class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
private val PREFILLED_MONTHS = 251
private var viewPager: MyViewPager? = null
private lateinit var viewPager: MyViewPager
private var defaultMonthlyPage = 0
private var todayDayCode = ""
private var currentDayCode = ""
@ -41,13 +41,13 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
todayDayCode = Formatter.getTodayCode()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_months_holder, container, false)
view.background = ColorDrawable(requireContext().getProperBackgroundColor())
viewPager = view.fragment_months_viewpager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val binding = FragmentMonthsHolderBinding.inflate(inflater, container, false)
binding.root.background = ColorDrawable(requireContext().getProperBackgroundColor())
viewPager = binding.fragmentMonthsViewpager
viewPager.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
return view
return binding.root
}
private fun setupFragment() {
@ -55,7 +55,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
val monthlyAdapter = MyMonthPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultMonthlyPage = codes.size / 2
viewPager!!.apply {
viewPager.apply {
adapter = monthlyAdapter
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
@ -88,11 +88,11 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun goLeft() {
viewPager!!.currentItem = viewPager!!.currentItem - 1
viewPager.currentItem = viewPager.currentItem - 1
}
override fun goRight() {
viewPager!!.currentItem = viewPager!!.currentItem + 1
viewPager.currentItem = viewPager.currentItem + 1
}
override fun goToDateTime(dateTime: DateTime) {
@ -110,8 +110,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
return
}
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val datePicker = getDatePickerView()
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
val dateTime = getCurrentDate()!!
@ -119,9 +118,9 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
activity?.getAlertDialogBuilder()!!
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) }
.setPositiveButton(R.string.ok) { _, _ -> datePicked(dateTime, datePicker) }
.apply {
activity?.setupDialogStuff(view, this)
activity?.setupDialogStuff(datePicker, this)
}
}
@ -133,7 +132,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun refreshEvents() {
(viewPager?.adapter as? MyMonthPagerAdapter)?.updateCalendars(viewPager?.currentItem ?: 0)
(viewPager.adapter as? MyMonthPagerAdapter)?.updateCalendars(viewPager.currentItem)
}
override fun shouldGoToTodayBeVisible() = currentDayCode.getMonthCode() != todayDayCode.getMonthCode()
@ -141,7 +140,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
override fun getNewEventDayCode() = if (shouldGoToTodayBeVisible()) currentDayCode else todayDayCode
override fun printView() {
(viewPager?.adapter as? MyMonthPagerAdapter)?.printCurrentView(viewPager?.currentItem ?: 0)
(viewPager.adapter as? MyMonthPagerAdapter)?.printCurrentView(viewPager.currentItem)
}
override fun getCurrentDate(): DateTime? {

View file

@ -1,8 +1,10 @@
package com.simplemobiletools.calendar.pro.fragments
import android.graphics.Color
import android.widget.DatePicker
import androidx.fragment.app.Fragment
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.DatePickerDarkBinding
import com.simplemobiletools.calendar.pro.databinding.DatePickerLightBinding
import com.simplemobiletools.commons.extensions.getContrastColor
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
import org.joda.time.DateTime
@ -24,11 +26,11 @@ abstract class MyFragmentHolder : Fragment() {
abstract fun getCurrentDate(): DateTime?
fun getDatePickerDialogStyle(): Int {
fun getDatePickerView(): DatePicker {
return if (requireActivity().getProperBackgroundColor().getContrastColor() == Color.WHITE) {
R.layout.date_picker_dark
DatePickerDarkBinding.inflate(layoutInflater).datePicker
} else {
R.layout.date_picker_light
DatePickerLightBinding.inflate(layoutInflater).datePicker
}
}
}

View file

@ -13,11 +13,14 @@ import android.view.*
import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.collection.LongSparseArray
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.Fragment
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
import com.simplemobiletools.calendar.pro.databinding.AllDayEventsHolderLineBinding
import com.simplemobiletools.calendar.pro.databinding.FragmentWeekBinding
import com.simplemobiletools.calendar.pro.databinding.WeekAllDayEventMarkerBinding
import com.simplemobiletools.calendar.pro.databinding.WeekEventMarkerBinding
import com.simplemobiletools.calendar.pro.dialogs.EditRepeatingEventDialog
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.*
@ -32,9 +35,6 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.views.MyTextView
import kotlinx.android.synthetic.main.fragment_week.*
import kotlinx.android.synthetic.main.fragment_week.view.*
import kotlinx.android.synthetic.main.week_event_marker.view.*
import org.joda.time.DateTime
import org.joda.time.Days
import java.util.*
@ -43,7 +43,7 @@ import kotlin.math.min
import kotlin.math.roundToInt
class WeekFragment : Fragment(), WeeklyCalendar {
private val WEEKLY_EVENT_ID_LABEL = "event_id_label"
private val WEEKLY_EVENT_ID_LABEL = "eventIdLabel"
private val PLUS_FADEOUT_DELAY = 5000L
private val MIN_SCALE_FACTOR = 0.3f
private val MAX_SCALE_FACTOR = 5f
@ -83,8 +83,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
private var eventTimeRanges = LinkedHashMap<String, LinkedHashMap<Long, EventWeeklyView>>()
private var currentlyDraggedView: View? = null
private lateinit var inflater: LayoutInflater
private lateinit var mView: View
private lateinit var binding: FragmentWeekBinding
private lateinit var scrollView: MyScrollView
private lateinit var res: Resources
private lateinit var config: Config
@ -104,17 +103,15 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
@SuppressLint("ClickableViewAccessibility")
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
this.inflater = inflater
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val fullHeight = requireContext().getWeeklyViewItemHeight().toInt() * 24
mView = inflater.inflate(R.layout.fragment_week, container, false).apply {
scrollView = week_events_scrollview
week_horizontal_grid_holder.layoutParams.height = fullHeight
week_events_columns_holder.layoutParams.height = fullHeight
binding = FragmentWeekBinding.inflate(inflater, container, false).apply {
scrollView = weekEventsScrollview
weekHorizontalGridHolder.layoutParams.height = fullHeight
weekEventsColumnsHolder.layoutParams.height = fullHeight
val scaleDetector = getViewScaleDetector()
scrollView.setOnTouchListener { view, motionEvent ->
scrollView.setOnTouchListener { _, motionEvent ->
scaleDetector.onTouchEvent(motionEvent)
if (motionEvent.action == MotionEvent.ACTION_UP && wasScaled) {
scrollView.isScrollable = true
@ -143,7 +140,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
wasFragmentInit = true
return mView
return binding.root
}
override fun onResume() {
@ -157,7 +154,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
setupDayLabels()
updateCalendar()
if (rowHeight != 0f && mView.width != 0) {
if (rowHeight != 0f && binding.root.width != 0) {
addCurrentTimeIndicator()
}
}
@ -176,11 +173,11 @@ class WeekFragment : Fragment(), WeeklyCalendar {
super.setMenuVisibility(menuVisible)
isFragmentVisible = menuVisible
if (isFragmentVisible && wasFragmentInit) {
listener?.updateHoursTopMargin(mView.week_top_holder.height)
listener?.updateHoursTopMargin(binding.weekTopHolder.height)
checkScrollLimits(scrollView.scrollY)
// fix some glitches like at swiping from a fully scaled out fragment with all-day events to an empty one
val fullFragmentHeight = (listener?.getFullFragmentHeight() ?: 0) - mView.week_top_holder.height
val fullFragmentHeight = (listener?.getFullFragmentHeight() ?: 0) - binding.weekTopHolder.height
if (scrollView.height < fullFragmentHeight) {
config.weeklyViewItemHeightMultiplier = fullFragmentHeight / 24 / defaultRowHeight
updateViewScale()
@ -197,11 +194,11 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
private fun addDayColumns() {
mView.week_events_columns_holder.removeAllViews()
binding.weekEventsColumnsHolder.removeAllViews()
(0 until config.weeklyViewDays).forEach {
val column = inflater.inflate(R.layout.weekly_view_day_column, mView.week_events_columns_holder, false) as RelativeLayout
val column = layoutInflater.inflate(R.layout.weekly_view_day_column, binding.weekEventsColumnsHolder, false) as RelativeLayout
column.tag = Formatter.getDayCodeFromTS(weekTimestamp + it * DAY_SECONDS)
mView.week_events_columns_holder.addView(column)
binding.weekEventsColumnsHolder.addView(column)
dayColumns.add(column)
}
}
@ -213,7 +210,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val dayWidth = screenWidth / config.weeklyViewDays
val useLongerDayLabels = dayWidth > res.getDimension(R.dimen.weekly_view_min_day_label)
mView.week_letters_holder.removeAllViews()
binding.weekLettersHolder.removeAllViews()
for (i in 0 until config.weeklyViewDays) {
val dayCode = Formatter.getDayCodeFromDateTime(curDay)
val labelIDs = if (useLongerDayLabels) {
@ -235,14 +232,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
requireContext().getProperTextColor()
}
val label = inflater.inflate(R.layout.weekly_view_day_letter, mView.week_letters_holder, false) as MyTextView
val label = layoutInflater.inflate(R.layout.weekly_view_day_letter, binding.weekLettersHolder, false) as MyTextView
label.text = "$dayLetter\n${curDay.dayOfMonth}"
label.setTextColor(textColor)
if (todayCode == dayCode) {
todayColumnIndex = i
}
mView.week_letters_holder.addView(label)
binding.weekLettersHolder.addView(label)
curDay = curDay.plusDays(1)
}
}
@ -259,25 +256,26 @@ class WeekFragment : Fragment(), WeeklyCalendar {
layout.removeAllViews()
val gestureDetector = getViewGestureDetector(layout, index)
layout.setOnTouchListener { view, motionEvent ->
layout.setOnTouchListener { _, motionEvent ->
gestureDetector.onTouchEvent(motionEvent)
true
}
layout.setOnDragListener { view, dragEvent ->
layout.setOnDragListener { _, dragEvent ->
when (dragEvent.action) {
DragEvent.ACTION_DRAG_STARTED -> dragEvent.clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)
DragEvent.ACTION_DRAG_ENTERED,
DragEvent.ACTION_DRAG_EXITED,
DragEvent.ACTION_DRAG_LOCATION,
DragEvent.ACTION_DRAG_ENDED -> true
DragEvent.ACTION_DROP -> {
try {
val (eventId, originalStartTS, originalEndTS) = dragEvent.clipData.getItemAt(0).text.toString().split(";").map { it.toLong() }
val startHour = (dragEvent.y / rowHeight).toInt()
ensureBackgroundThread {
val event = context?.eventsDB?.getEventOrTaskWithId(eventId)
event?.let { event ->
event?.let {
val currentStartTime = Formatter.getDateTimeFromTS(event.startTS)
val startTime = Formatter.getDateTimeFromTS(weekTimestamp + index * DAY_SECONDS)
.withTime(
@ -302,17 +300,20 @@ class WeekFragment : Fragment(), WeeklyCalendar {
null -> {
revertDraggedEvent()
}
EDIT_SELECTED_OCCURRENCE -> {
context?.eventsHelper?.editSelectedOccurrence(newEvent, false) {
updateCalendar()
}
}
EDIT_FUTURE_OCCURRENCES -> {
context?.eventsHelper?.editFutureOccurrences(newEvent, originalStartTS, false) {
// we need to refresh all fragments because they can contain future occurrences
(activity as MainActivity).refreshItems()
}
}
EDIT_ALL_OCCURRENCES -> {
context?.eventsHelper?.editAllOccurrences(newEvent, originalStartTS, originalEndTS, false) {
(activity as MainActivity).refreshItems()
@ -337,6 +338,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
false
}
}
else -> false
}
}
@ -357,7 +359,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
selectedGrid?.beGone()
val hour = (event.y / rowHeight).toInt()
selectedGrid = (inflater.inflate(R.layout.week_grid_item, null, false) as ImageView).apply {
selectedGrid = (layoutInflater.inflate(R.layout.week_grid_item, null, false) as ImageView).apply {
view.addView(this)
background = ColorDrawable(primaryColor)
layoutParams.width = view.width
@ -472,8 +474,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val oneDp = res.getDimension(R.dimen.one_dp).toInt()
val fullHeight = max(rowHeight.toInt() * 24, scrollView.height + oneDp)
scrollView.layoutParams.height = fullHeight - oneDp
mView.week_horizontal_grid_holder.layoutParams.height = fullHeight
mView.week_events_columns_holder.layoutParams.height = fullHeight
binding.weekHorizontalGridHolder.layoutParams.height = fullHeight
binding.weekEventsColumnsHolder.layoutParams.height = fullHeight
addEvents(currEvents)
}
@ -483,7 +485,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
allDayRows.clear()
eventTimeRanges.clear()
allDayRows.add(HashSet())
week_all_day_holder?.removeAllViews()
binding.weekAllDayHolder.removeAllViews()
addNewLine()
allDayEventToRow.clear()
@ -538,7 +540,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
for ((eventId, eventWeeklyView) in eventDayList) {
if (eventWeeklyView.slot == 0) {
eventWeeklyView.slot = 1
eventWeeklyView.slot_max = 1
eventWeeklyView.slotMax = 1
}
eventsCollisionChecked.add(eventId)
@ -554,8 +556,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
if (areTouching && doHaveCommonMinutes) {
if (eventWeeklyViewToCheck.slot == 0) {
val nextSlot = eventWeeklyView.slot_max + 1
val slotRange = Array(eventWeeklyView.slot_max) { it + 1 }
val nextSlot = eventWeeklyView.slotMax + 1
val slotRange = Array(eventWeeklyView.slotMax) { it + 1 }
val collisionEventWeeklyViews = eventDayList.filter { eventWeeklyView.collisions.contains(it.key) }
for ((_, collisionEventWeeklyView) in collisionEventWeeklyViews) {
if (collisionEventWeeklyView.range.intersects(eventWeeklyViewToCheck.range)) {
@ -566,13 +568,13 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val slot = slotRange.minOrNull()
eventWeeklyViewToCheck.slot = slot!!
if (slot == nextSlot) {
eventWeeklyViewToCheck.slot_max = nextSlot
eventWeeklyView.slot_max = nextSlot
eventWeeklyViewToCheck.slotMax = nextSlot
eventWeeklyView.slotMax = nextSlot
for ((_, collisionEventWeeklyView) in collisionEventWeeklyViews) {
collisionEventWeeklyView.slot_max++
collisionEventWeeklyView.slotMax++
}
} else {
eventWeeklyViewToCheck.slot_max = eventWeeklyView.slot_max
eventWeeklyViewToCheck.slotMax = eventWeeklyView.slotMax
}
}
eventWeeklyView.collisions.add(toCheckId)
@ -606,7 +608,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
val dayColumn = dayColumns[dayOfWeek]
(inflater.inflate(R.layout.week_event_marker, null, false) as ConstraintLayout).apply {
WeekEventMarkerBinding.inflate(layoutInflater).apply {
var backgroundColor = if (event.color == 0) {
eventTypeColors.get(event.eventType, primaryColor)
} else {
@ -626,19 +628,19 @@ class WeekFragment : Fragment(), WeeklyCalendar {
textColor = textColor.adjustAlpha(HIGHER_ALPHA)
}
background = ColorDrawable(backgroundColor)
dayColumn.addView(this)
y = currentEventWeeklyView!!.range.lower * minuteHeight
root.background = ColorDrawable(backgroundColor)
dayColumn.addView(root)
root.y = currentEventWeeklyView!!.range.lower * minuteHeight
// compensate grid offset
y -= (currentEventWeeklyView.range.lower / 60) / 2
root.y -= (currentEventWeeklyView.range.lower / 60) / 2
week_event_task_image.beVisibleIf(event.isTask())
weekEventTaskImage.beVisibleIf(event.isTask())
if (event.isTask()) {
week_event_task_image.applyColorFilter(textColor)
weekEventTaskImage.applyColorFilter(textColor)
}
week_event_label.apply {
weekEventLabel.apply {
setTextColor(textColor)
maxLines = if (event.isTask() || event.startTS == event.endTS) {
1
@ -657,16 +659,16 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
}
(layoutParams as RelativeLayout.LayoutParams).apply {
width = (dayColumn.width - 1) / currentEventWeeklyView.slot_max
x = (width * (currentEventWeeklyView.slot - 1)).toFloat()
(root.layoutParams as RelativeLayout.LayoutParams).apply {
width = (dayColumn.width - 1) / currentEventWeeklyView.slotMax
root.x = (width * (currentEventWeeklyView.slot - 1)).toFloat()
if (currentEventWeeklyView.slot > 1) {
x += density
root.x += density
width -= density
}
}
setOnClickListener {
root.setOnClickListener {
Intent(context, getActivityToOpen(event.isTask())).apply {
putExtra(EVENT_ID, event.id!!)
putExtra(EVENT_OCCURRENCE_TS, event.startTS)
@ -675,7 +677,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
}
setOnLongClickListener { view ->
root.setOnLongClickListener { view ->
currentlyDraggedView = view
val shadowBuilder = View.DragShadowBuilder(view)
val clipData = ClipData.newPlainText(WEEKLY_EVENT_ID_LABEL, "${event.id};${event.startTS};${event.endTS}")
@ -687,7 +689,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
true
}
setOnDragListener(DragListener())
root.setOnDragListener(DragListener())
}
currentDateTime = currentDateTime.plusDays(1)
@ -701,8 +703,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
private fun addNewLine() {
val allDaysLine = inflater.inflate(R.layout.all_day_events_holder_line, null, false) as RelativeLayout
week_all_day_holder?.addView(allDaysLine)
val allDaysLine = AllDayEventsHolderLineBinding.inflate(layoutInflater).root
binding.weekAllDayHolder.addView(allDaysLine)
allDayHolders.add(allDaysLine)
}
@ -716,7 +718,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
if (currentTimeView != null) {
mView.week_events_holder.removeView(currentTimeView)
binding.weekEventsHolder.removeView(currentTimeView)
}
if (isPrintVersion) {
@ -724,21 +726,21 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
val weeklyViewDays = config.weeklyViewDays
currentTimeView = (inflater.inflate(R.layout.week_now_marker, null, false) as ImageView).apply {
currentTimeView = (layoutInflater.inflate(R.layout.week_now_marker, null, false) as ImageView).apply {
applyColorFilter(primaryColor)
mView.week_events_holder.addView(this, 0)
binding.weekEventsHolder.addView(this, 0)
val extraWidth = res.getDimension(R.dimen.activity_margin).toInt()
val markerHeight = res.getDimension(R.dimen.weekly_view_now_height).toInt()
val minuteHeight = rowHeight / 60
(layoutParams as RelativeLayout.LayoutParams).apply {
width = (mView.width / weeklyViewDays) + extraWidth
width = (binding.root.width / weeklyViewDays) + extraWidth
height = markerHeight
}
x = if (weeklyViewDays == 1) {
0f
} else {
(mView.width / weeklyViewDays * todayColumnIndex).toFloat() - extraWidth / 2f
(binding.root.width / weeklyViewDays * todayColumnIndex).toFloat() - extraWidth / 2f
}
y = minutes * minuteHeight - markerHeight / 2
@ -747,9 +749,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
private fun checkTopHolderHeight() {
mView.week_top_holder.onGlobalLayout {
binding.weekTopHolder.onGlobalLayout {
if (isFragmentVisible && activity != null && !mWasDestroyed) {
listener?.updateHoursTopMargin(mView.week_top_holder.height)
listener?.updateHoursTopMargin(binding.weekTopHolder.height)
}
}
}
@ -762,7 +764,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
@SuppressLint("NewApi")
private fun addAllDayEvent(event: Event) {
(inflater.inflate(R.layout.week_all_day_event_marker, null, false) as ConstraintLayout).apply {
WeekAllDayEventMarkerBinding.inflate(layoutInflater).apply {
var backgroundColor = if (event.color == 0) {
eventTypeColors.get(event.eventType, primaryColor)
} else {
@ -781,9 +783,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
textColor = textColor.adjustAlpha(HIGHER_ALPHA)
}
background = ColorDrawable(backgroundColor)
root.background = ColorDrawable(backgroundColor)
week_event_label.apply {
weekEventLabel.apply {
setTextColor(textColor)
maxLines = if (event.isTask()) 1 else 2
text = event.title
@ -791,9 +793,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
contentDescription = text
}
week_event_task_image.beVisibleIf(event.isTask())
weekEventTaskImage.beVisibleIf(event.isTask())
if (event.isTask()) {
week_event_task_image.applyColorFilter(textColor)
weekEventTaskImage.applyColorFilter(textColor)
}
val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
@ -870,9 +872,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
return
}
allDayHolders[drawAtLine].addView(this)
val dayWidth = mView.width / config.weeklyViewDays
(layoutParams as RelativeLayout.LayoutParams).apply {
allDayHolders[drawAtLine].addView(root)
val dayWidth = binding.root.width / config.weeklyViewDays
(root.layoutParams as RelativeLayout.LayoutParams).apply {
leftMargin = dayOfWeek * dayWidth
bottomMargin = 1
width = (dayWidth) * (daysCnt + 1)
@ -880,7 +882,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
calculateExtraHeight()
setOnClickListener {
root.setOnClickListener {
Intent(context, getActivityToOpen(event.isTask())).apply {
putExtra(EVENT_ID, event.id)
putExtra(EVENT_OCCURRENCE_TS, event.startTS)
@ -892,10 +894,10 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
private fun calculateExtraHeight() {
mView.week_top_holder.onGlobalLayout {
binding.weekTopHolder.onGlobalLayout {
if (activity != null && !mWasDestroyed) {
if (isFragmentVisible) {
listener?.updateHoursTopMargin(mView.week_top_holder.height)
listener?.updateHoursTopMargin(binding.weekTopHolder.height)
}
if (!wasExtraHeightAdded) {
@ -938,12 +940,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
view.beVisible()
true
}
DragEvent.ACTION_DRAG_ENDED -> {
if (!dragEvent.result) {
view.beVisible()
}
true
}
else -> false
}
}

View file

@ -14,6 +14,7 @@ import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.adapters.MyWeekPagerAdapter
import com.simplemobiletools.calendar.pro.databinding.FragmentWeekHolderBinding
import com.simplemobiletools.calendar.pro.extensions.*
import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.WEEKLY_VIEW
@ -23,15 +24,14 @@ import com.simplemobiletools.calendar.pro.views.MyScrollView
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.WEEK_SECONDS
import com.simplemobiletools.commons.views.MyViewPager
import kotlinx.android.synthetic.main.fragment_week_holder.view.*
import org.joda.time.DateTime
class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private val PREFILLED_WEEKS = 151
private val MAX_SEEKBAR_VALUE = 14
private var viewPager: MyViewPager? = null
private var weekHolder: ViewGroup? = null
private lateinit var binding: FragmentWeekHolderBinding
private lateinit var viewPager: MyViewPager
private var defaultWeeklyPage = 0
private var thisWeekTS = 0L
private var currentWeekTS = 0L
@ -47,27 +47,27 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
thisWeekTS = DateTime.parse(requireContext().getFirstDayOfWeek(DateTime())).seconds()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val textColor = requireContext().getProperTextColor()
weekHolder = inflater.inflate(R.layout.fragment_week_holder, container, false) as ViewGroup
weekHolder!!.background = ColorDrawable(requireContext().getProperBackgroundColor())
weekHolder!!.week_view_month_label.setTextColor(textColor)
weekHolder!!.week_view_week_number.setTextColor(textColor)
binding = FragmentWeekHolderBinding.inflate(inflater, container, false)
binding.root.background = ColorDrawable(requireContext().getProperBackgroundColor())
binding.weekViewMonthLabel.setTextColor(textColor)
binding.weekViewWeekNumber.setTextColor(textColor)
val itemHeight = requireContext().getWeeklyViewItemHeight().toInt()
weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, itemHeight)
binding.weekViewHoursHolder.setPadding(0, 0, 0, itemHeight)
viewPager = weekHolder!!.week_view_view_pager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
viewPager = binding.weekViewViewPager
viewPager.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
return weekHolder
return binding.root
}
override fun onResume() {
super.onResume()
context?.config?.allowCustomizeDayCount?.let { allow ->
weekHolder!!.week_view_days_count.beVisibleIf(allow)
weekHolder!!.week_view_seekbar.beVisibleIf(allow)
binding.weekViewDaysCount.beVisibleIf(allow)
binding.weekViewSeekbar.beVisibleIf(allow)
}
setupSeekbar()
}
@ -76,9 +76,9 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
addHours()
setupWeeklyViewPager()
weekHolder!!.week_view_hours_scrollview.setOnTouchListener { view, motionEvent -> true }
binding.weekViewHoursScrollview.setOnTouchListener { _, _ -> true }
weekHolder!!.week_view_seekbar.apply {
binding.weekViewSeekbar.apply {
progress = context?.config?.weeklyViewDays ?: 7
max = MAX_SEEKBAR_VALUE
@ -100,7 +100,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
defaultWeeklyPage = weekTSs.size / 2
viewPager!!.apply {
viewPager.apply {
adapter = weeklyAdapter
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {}
@ -121,17 +121,17 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
currentItem = defaultWeeklyPage
}
weekHolder!!.week_view_hours_scrollview.setOnScrollviewListener(object : MyScrollView.ScrollViewListener {
binding.weekViewHoursScrollview.setOnScrollviewListener(object : MyScrollView.ScrollViewListener {
override fun onScrollChanged(scrollView: MyScrollView, x: Int, y: Int, oldx: Int, oldy: Int) {
weekScrollY = y
weeklyAdapter.updateScrollY(viewPager!!.currentItem, y)
weeklyAdapter.updateScrollY(viewPager.currentItem, y)
}
})
}
private fun addHours(textColor: Int = requireContext().getProperTextColor()) {
val itemHeight = requireContext().getWeeklyViewItemHeight().toInt()
weekHolder!!.week_view_hours_holder.removeAllViews()
binding.weekViewHoursHolder.removeAllViews()
val hourDateTime = DateTime().withDate(2000, 1, 1).withTime(0, 0, 0, 0)
for (i in 1..23) {
val formattedHours = Formatter.getTime(requireContext(), hourDateTime.withHourOfDay(i))
@ -139,7 +139,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
text = formattedHours
setTextColor(textColor)
height = itemHeight
weekHolder!!.week_view_hours_holder.addView(this)
binding.weekViewHoursHolder.addView(this)
}
}
}
@ -159,9 +159,9 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun setupWeeklyActionbarTitle(timestamp: Long) {
val startDateTime = Formatter.getDateTimeFromTS(timestamp)
val month = Formatter.getShortMonthName(requireContext(), startDateTime.monthOfYear)
weekHolder!!.week_view_month_label.text = month
binding.weekViewMonthLabel.text = month
val weekNumber = startDateTime.plusDays(3).weekOfWeekyear
weekHolder!!.week_view_week_number.text = "${getString(R.string.week_number_short)} $weekNumber"
binding.weekViewWeekNumber.text = "${getString(R.string.week_number_short)} $weekNumber"
}
override fun goToToday() {
@ -174,17 +174,15 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
return
}
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val datePicker = getDatePickerView()
val dateTime = getCurrentDate()!!
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
activity?.getAlertDialogBuilder()!!
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
.setPositiveButton(R.string.ok) { _, _ -> dateSelected(dateTime, datePicker) }
.apply {
activity?.setupDialogStuff(view, this)
activity?.setupDialogStuff(datePicker, this)
}
}
@ -203,11 +201,11 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
}
// avoid seekbar width changing if the days count changes to 1, 10 etc
weekHolder!!.week_view_days_count.onGlobalLayout {
if (weekHolder!!.week_view_seekbar.width != 0) {
weekHolder!!.week_view_seekbar.layoutParams.width = weekHolder!!.week_view_seekbar.width
binding.weekViewDaysCount.onGlobalLayout {
if (binding.weekViewSeekbar.width != 0) {
binding.weekViewSeekbar.layoutParams.width = binding.weekViewSeekbar.width
}
(weekHolder!!.week_view_seekbar.layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.START_OF)
(binding.weekViewSeekbar.layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.START_OF)
}
updateDaysCount(context?.config?.weeklyViewDays ?: 7)
@ -220,11 +218,11 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
}
private fun updateDaysCount(cnt: Int) {
weekHolder!!.week_view_days_count.text = requireContext().resources.getQuantityString(R.plurals.days, cnt, cnt)
binding.weekViewDaysCount.text = requireContext().resources.getQuantityString(R.plurals.days, cnt, cnt)
}
override fun refreshEvents() {
(viewPager?.adapter as? MyWeekPagerAdapter)?.updateCalendars(viewPager!!.currentItem)
(viewPager.adapter as? MyWeekPagerAdapter)?.updateCalendars(viewPager.currentItem)
}
override fun shouldGoToTodayBeVisible() = currentWeekTS != thisWeekTS
@ -239,16 +237,16 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
}
override fun scrollTo(y: Int) {
weekHolder!!.week_view_hours_scrollview.scrollY = y
binding.weekViewHoursScrollview.scrollY = y
weekScrollY = y
}
override fun updateHoursTopMargin(margin: Int) {
weekHolder?.apply {
week_view_hours_divider?.layoutParams?.height = margin
week_view_hours_scrollview?.requestLayout()
week_view_hours_scrollview?.onGlobalLayout {
week_view_hours_scrollview.scrollY = weekScrollY
binding.apply {
weekViewHoursDivider.layoutParams?.height = margin
weekViewHoursScrollview.requestLayout()
weekViewHoursScrollview.onGlobalLayout {
weekViewHoursScrollview.scrollY = weekScrollY
}
}
}
@ -256,43 +254,43 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
override fun getCurrScrollY() = weekScrollY
override fun updateRowHeight(rowHeight: Int) {
val childCnt = weekHolder!!.week_view_hours_holder.childCount
val childCnt = binding.weekViewHoursHolder.childCount
for (i in 0..childCnt) {
val textView = weekHolder!!.week_view_hours_holder.getChildAt(i) as? TextView ?: continue
val textView = binding.weekViewHoursHolder.getChildAt(i) as? TextView ?: continue
textView.layoutParams.height = rowHeight
}
weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, rowHeight)
(viewPager!!.adapter as? MyWeekPagerAdapter)?.updateNotVisibleScaleLevel(viewPager!!.currentItem)
binding.weekViewHoursHolder.setPadding(0, 0, 0, rowHeight)
(viewPager.adapter as? MyWeekPagerAdapter)?.updateNotVisibleScaleLevel(viewPager.currentItem)
}
override fun getFullFragmentHeight() =
weekHolder!!.week_view_holder.height - weekHolder!!.week_view_seekbar.height - weekHolder!!.week_view_days_count_divider.height
binding.weekViewHolder.height - binding.weekViewSeekbar.height - binding.weekViewDaysCountDivider.height
override fun printView() {
val lightTextColor = resources.getColor(R.color.theme_light_text_color)
weekHolder!!.apply {
week_view_days_count_divider.beGone()
week_view_seekbar.beGone()
week_view_days_count.beGone()
binding.apply {
weekViewDaysCountDivider.beGone()
weekViewSeekbar.beGone()
weekViewDaysCount.beGone()
addHours(lightTextColor)
week_view_week_number.setTextColor(lightTextColor)
week_view_month_label.setTextColor(lightTextColor)
background = ColorDrawable(Color.WHITE)
(viewPager?.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager?.currentItem ?: 0)
weekViewWeekNumber.setTextColor(lightTextColor)
weekViewMonthLabel.setTextColor(lightTextColor)
root.background = ColorDrawable(Color.WHITE)
(viewPager.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager.currentItem)
Handler().postDelayed({
requireContext().printBitmap(weekHolder!!.week_view_holder.getViewBitmap())
requireContext().printBitmap(binding.weekViewHolder.getViewBitmap())
Handler().postDelayed({
week_view_days_count_divider.beVisible()
week_view_seekbar.beVisible()
week_view_days_count.beVisible()
week_view_week_number.setTextColor(requireContext().getProperTextColor())
week_view_month_label.setTextColor(requireContext().getProperTextColor())
weekViewDaysCountDivider.beVisible()
weekViewSeekbar.beVisible()
weekViewDaysCount.beVisible()
weekViewWeekNumber.setTextColor(requireContext().getProperTextColor())
weekViewMonthLabel.setTextColor(requireContext().getProperTextColor())
addHours()
background = ColorDrawable(requireContext().getProperBackgroundColor())
(viewPager?.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager?.currentItem ?: 0)
root.background = ColorDrawable(requireContext().getProperBackgroundColor())
(viewPager.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager.currentItem)
}, 1000)
}, 1000)
}

View file

@ -5,10 +5,12 @@ import android.util.SparseArray
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.databinding.FragmentYearBinding
import com.simplemobiletools.calendar.pro.databinding.SmallMonthViewHolderBinding
import com.simplemobiletools.calendar.pro.databinding.TopNavigationBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.extensions.getProperDayIndexInWeek
import com.simplemobiletools.calendar.pro.extensions.getViewBitmap
@ -18,16 +20,10 @@ import com.simplemobiletools.calendar.pro.helpers.YearlyCalendarImpl
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
import com.simplemobiletools.calendar.pro.interfaces.YearlyCalendar
import com.simplemobiletools.calendar.pro.models.DayYearly
import com.simplemobiletools.calendar.pro.views.SmallMonthView
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.updateTextColors
import kotlinx.android.synthetic.main.fragment_year.view.calendar_wrapper
import kotlinx.android.synthetic.main.fragment_year.view.month_2
import kotlinx.android.synthetic.main.top_navigation.view.top_left_arrow
import kotlinx.android.synthetic.main.top_navigation.view.top_right_arrow
import kotlinx.android.synthetic.main.top_navigation.view.top_value
import org.joda.time.DateTime
class YearFragment : Fragment(), YearlyCalendar {
@ -39,17 +35,34 @@ class YearFragment : Fragment(), YearlyCalendar {
var listener: NavigationListener? = null
lateinit var mView: View
private lateinit var binding: FragmentYearBinding
private lateinit var topNavigationBinding: TopNavigationBinding
private lateinit var monthHolders: List<SmallMonthViewHolderBinding>
private val monthIds = arrayOf(
R.string.january, R.string.february, R.string.march, R.string.april, R.string.may, R.string.june,
R.string.july, R.string.august, R.string.september, R.string.october, R.string.november, R.string.december
)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentYearBinding.inflate(inflater, container, false)
topNavigationBinding = TopNavigationBinding.bind(binding.root)
monthHolders = arrayListOf(
binding.month1Holder, binding.month2Holder, binding.month3Holder, binding.month4Holder, binding.month5Holder, binding.month6Holder,
binding.month7Holder, binding.month8Holder, binding.month9Holder, binding.month10Holder, binding.month11Holder, binding.month12Holder
).apply {
forEachIndexed { index, it ->
it.monthLabel.text = getString(monthIds[index])
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater.inflate(R.layout.fragment_year, container, false)
mYear = requireArguments().getInt(YEAR_LABEL)
requireContext().updateTextColors(mView.calendar_wrapper)
requireContext().updateTextColors(binding.calendarWrapper)
setupMonths()
setupButtons()
mCalendar = YearlyCalendarImpl(this, requireContext(), mYear)
return mView
return binding.root
}
override fun onPause() {
@ -72,37 +85,33 @@ class YearFragment : Fragment(), YearlyCalendar {
}
private fun setupMonths() {
val dateTime = DateTime().withDate(mYear, 2, 1).withHourOfDay(12)
val days = dateTime.dayOfMonth().maximumValue
mView.month_2.setDays(days)
val now = DateTime()
for (i in 1..12) {
val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", requireContext().packageName))
val dayOfWeek = requireContext().getProperDayIndexInWeek(dateTime.withMonthOfYear(i))
val monthLabel = mView.findViewById<TextView>(resources.getIdentifier("month_${i}_label", "id", requireContext().packageName))
val dateTime = DateTime().withYear(mYear).withHourOfDay(12)
monthHolders.forEachIndexed { index, monthHolder ->
val monthOfYear = index + 1
val monthView = monthHolder.smallMonthView
val curTextColor = when {
isPrintVersion -> resources.getColor(R.color.theme_light_text_color)
else -> requireContext().getProperTextColor()
}
monthLabel.setTextColor(curTextColor)
monthView.firstDay = dayOfWeek
monthHolder.monthLabel.setTextColor(curTextColor)
monthView.firstDay = requireContext().getProperDayIndexInWeek(dateTime.withMonthOfYear(monthOfYear))
val numberOfDays = dateTime.withMonthOfYear(monthOfYear).dayOfMonth().maximumValue
monthView.setDays(numberOfDays)
monthView.setOnClickListener {
(activity as MainActivity).openMonthFromYearly(DateTime().withDate(mYear, i, 1))
(activity as MainActivity).openMonthFromYearly(DateTime().withDate(mYear, monthOfYear, 1))
}
}
if (!isPrintVersion) {
val now = DateTime()
markCurrentMonth(now)
}
}
private fun setupButtons() {
val textColor = requireContext().getProperTextColor()
mView.top_left_arrow.apply {
topNavigationBinding.topLeftArrow.apply {
applyColorFilter(textColor)
background = null
setOnClickListener {
@ -114,7 +123,7 @@ class YearFragment : Fragment(), YearlyCalendar {
setImageDrawable(pointerLeft)
}
mView.top_right_arrow.apply {
topNavigationBinding.topRightArrow.apply {
applyColorFilter(textColor)
background = null
setOnClickListener {
@ -126,7 +135,7 @@ class YearFragment : Fragment(), YearlyCalendar {
setImageDrawable(pointerRight)
}
mView.top_value.apply {
topNavigationBinding.topValue.apply {
setTextColor(requireContext().getProperTextColor())
setOnClickListener {
(activity as MainActivity).showGoToDateDialog()
@ -136,11 +145,10 @@ class YearFragment : Fragment(), YearlyCalendar {
private fun markCurrentMonth(now: DateTime) {
if (now.year == mYear) {
val monthLabel = mView.findViewById<TextView>(resources.getIdentifier("month_${now.monthOfYear}_label", "id", requireContext().packageName))
monthLabel.setTextColor(requireContext().getProperPrimaryColor())
val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_${now.monthOfYear}", "id", requireContext().packageName))
monthView.todaysId = now.dayOfMonth
val monthOfYear = now.monthOfYear
val monthHolder = monthHolders[monthOfYear - 1]
monthHolder.monthLabel.setTextColor(requireContext().getProperPrimaryColor())
monthHolder.smallMonthView.todaysId = now.dayOfMonth
}
}
@ -154,13 +162,14 @@ class YearFragment : Fragment(), YearlyCalendar {
}
lastHash = hashCode
for (i in 1..12) {
val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", requireContext().packageName))
monthView.setEvents(events.get(i))
monthHolders.forEachIndexed { index, monthHolder ->
val monthView = monthHolder.smallMonthView
val monthOfYear = index + 1
monthView.setEvents(events.get(monthOfYear))
}
mView.top_value.post {
mView.top_value.text = mYear.toString()
topNavigationBinding.topValue.post {
topNavigationBinding.topValue.text = mYear.toString()
}
}
@ -169,7 +178,7 @@ class YearFragment : Fragment(), YearlyCalendar {
setupMonths()
toggleSmallMonthPrintModes()
requireContext().printBitmap(mView.calendar_wrapper.getViewBitmap())
requireContext().printBitmap(binding.calendarWrapper.getViewBitmap())
isPrintVersion = false
setupMonths()
@ -177,9 +186,8 @@ class YearFragment : Fragment(), YearlyCalendar {
}
private fun toggleSmallMonthPrintModes() {
for (i in 1..12) {
val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", requireContext().packageName))
monthView.togglePrintMode()
monthHolders.forEach {
it.smallMonthView.togglePrintMode()
}
}
}

View file

@ -11,6 +11,7 @@ import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.adapters.MyYearPagerAdapter
import com.simplemobiletools.calendar.pro.databinding.FragmentYearsHolderBinding
import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.YEARLY_VIEW
import com.simplemobiletools.calendar.pro.helpers.YEAR_TO_OPEN
@ -20,13 +21,12 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.views.MyViewPager
import kotlinx.android.synthetic.main.fragment_years_holder.view.*
import org.joda.time.DateTime
class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
private val PREFILLED_YEARS = 61
private var viewPager: MyViewPager? = null
private lateinit var viewPager: MyViewPager
private var defaultYearlyPage = 0
private var todayYear = 0
private var currentYear = 0
@ -41,13 +41,13 @@ class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
todayYear = DateTime().toString(Formatter.YEAR_PATTERN).toInt()
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_years_holder, container, false)
view.background = ColorDrawable(requireContext().getProperBackgroundColor())
viewPager = view.fragment_years_viewpager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val binding = FragmentYearsHolderBinding.inflate(inflater, container, false)
binding.root.background = ColorDrawable(requireContext().getProperBackgroundColor())
viewPager = binding.fragmentYearsViewpager
viewPager.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
return view
return binding.root
}
private fun setupFragment() {
@ -55,7 +55,7 @@ class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
val yearlyAdapter = MyYearPagerAdapter(requireActivity().supportFragmentManager, years, this)
defaultYearlyPage = years.size / 2
viewPager?.apply {
viewPager.apply {
adapter = yearlyAdapter
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {}
@ -82,11 +82,11 @@ class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun goLeft() {
viewPager!!.currentItem = viewPager!!.currentItem - 1
viewPager.currentItem = viewPager.currentItem - 1
}
override fun goRight() {
viewPager!!.currentItem = viewPager!!.currentItem + 1
viewPager.currentItem = viewPager.currentItem + 1
}
override fun goToDateTime(dateTime: DateTime) {}
@ -101,8 +101,7 @@ class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
return
}
val view = layoutInflater.inflate(getDatePickerDialogStyle(), null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val datePicker = getDatePickerView()
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("month", "id", "android")).beGone()
@ -111,9 +110,9 @@ class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
activity?.getAlertDialogBuilder()!!
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(datePicker) }
.setPositiveButton(R.string.ok) { _, _ -> datePicked(datePicker) }
.apply {
activity?.setupDialogStuff(view, this)
activity?.setupDialogStuff(datePicker, this)
}
}
@ -126,7 +125,7 @@ class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun refreshEvents() {
(viewPager?.adapter as? MyYearPagerAdapter)?.updateCalendars(viewPager?.currentItem ?: 0)
(viewPager.adapter as? MyYearPagerAdapter)?.updateCalendars(viewPager.currentItem)
}
override fun shouldGoToTodayBeVisible() = currentYear != todayYear
@ -134,7 +133,7 @@ class YearFragmentsHolder : MyFragmentHolder(), NavigationListener {
override fun getNewEventDayCode() = Formatter.getTodayCode()
override fun printView() {
(viewPager?.adapter as? MyYearPagerAdapter)?.printCurrentView(viewPager?.currentItem ?: 0)
(viewPager.adapter as? MyYearPagerAdapter)?.printCurrentView(viewPager.currentItem)
}
override fun getCurrentDate() = null

View file

@ -298,11 +298,11 @@ class CalDAVHelper(val context: Context) {
val offset = DateTimeZone.getDefault().getOffset(System.currentTimeMillis())
val dt = formatter.parseDateTime(it).plusMillis(offset)
val dayCode = Formatter.getDayCodeFromDateTime(dt)
event.repetitionExceptions.add(dayCode)
event.addRepetitionException(dayCode)
} else {
val potentialTS = it.substring(0, 8)
if (potentialTS.areDigitsOnly()) {
event.repetitionExceptions.add(potentialTS)
event.addRepetitionException(potentialTS)
}
}
}

View file

@ -9,7 +9,7 @@ class Converters {
private val stringType = object : TypeToken<List<String>>() {}.type
@TypeConverter
fun jsonToStringList(value: String): ArrayList<String> {
fun jsonToStringList(value: String): List<String> {
val newValue = if (value.isNotEmpty() && !value.startsWith("[")) {
"[$value]"
} else {
@ -19,10 +19,10 @@ class Converters {
return try {
gson.fromJson(newValue, stringType)
} catch (e: Exception) {
ArrayList()
emptyList()
}
}
@TypeConverter
fun stringListToJson(list: ArrayList<String>) = gson.toJson(list)
fun stringListToJson(list: List<String>) = gson.toJson(list)
}

View file

@ -29,7 +29,7 @@ data class Event(
@ColumnInfo(name = "repeat_interval") var repeatInterval: Int = 0,
@ColumnInfo(name = "repeat_rule") var repeatRule: Int = 0,
@ColumnInfo(name = "repeat_limit") var repeatLimit: Long = 0L,
@ColumnInfo(name = "repetition_exceptions") var repetitionExceptions: ArrayList<String> = ArrayList(),
@ColumnInfo(name = "repetition_exceptions") var repetitionExceptions: List<String> = emptyList(),
@ColumnInfo(name = "attendees") var attendees: String = "",
@ColumnInfo(name = "import_id") var importId: String = "",
@ColumnInfo(name = "time_zone") var timeZone: String = "",
@ -58,16 +58,19 @@ data class Event(
REPEAT_ORDER_WEEKDAY_USE_LAST -> addXthDayInterval(oldStart, original, true)
else -> addYearsWithSameDay(oldStart)
}
repeatInterval % MONTH == 0 -> when (repeatRule) {
REPEAT_SAME_DAY -> addMonthsWithSameDay(oldStart, original)
REPEAT_ORDER_WEEKDAY -> addXthDayInterval(oldStart, original, false)
REPEAT_ORDER_WEEKDAY_USE_LAST -> addXthDayInterval(oldStart, original, true)
else -> oldStart.plusMonths(repeatInterval / MONTH).dayOfMonth().withMaximumValue()
}
repeatInterval % WEEK == 0 -> {
// step through weekly repetition by days too, as events can trigger multiple times a week
oldStart.plusDays(1)
}
else -> oldStart.plusSeconds(repeatInterval)
}
}
@ -186,9 +189,9 @@ data class Event(
isPastEvent = endTSToCheck < getNowSeconds()
}
fun addRepetitionException(daycode: String) {
var newRepetitionExceptions = repetitionExceptions
newRepetitionExceptions.add(daycode)
fun addRepetitionException(dayCode: String) {
var newRepetitionExceptions = repetitionExceptions.toMutableList()
newRepetitionExceptions.add(dayCode)
newRepetitionExceptions = newRepetitionExceptions.distinct().toMutableList() as ArrayList<String>
repetitionExceptions = newRepetitionExceptions
}

View file

@ -2,4 +2,4 @@ package com.simplemobiletools.calendar.pro.models
import android.util.Range
data class EventWeeklyView(val range: Range<Int>, var slot: Int = 0, var slot_max: Int = 0, var collisions: ArrayList<Long> = ArrayList())
data class EventWeeklyView(val range: Range<Int>, var slot: Int = 0, var slotMax: Int = 0, var collisions: ArrayList<Long> = ArrayList())

View file

@ -5,12 +5,12 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.databinding.MonthViewBinding
import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.COLUMN_COUNT
import com.simplemobiletools.calendar.pro.helpers.ROW_COUNT
import com.simplemobiletools.calendar.pro.models.DayMonthly
import com.simplemobiletools.commons.extensions.onGlobalLayout
import kotlinx.android.synthetic.main.month_view.view.month_view
// used in the Monthly view fragment, 1 view per screen
class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : FrameLayout(context, attrs, defStyle) {
@ -22,7 +22,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
private var isMonthDayView = true
private var days = ArrayList<DayMonthly>()
private var inflater: LayoutInflater
private var monthView: MonthView
private var binding: MonthViewBinding
private var dayClickCallback: ((day: DayMonthly) -> Unit)? = null
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)
@ -32,14 +32,14 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
weekDaysLetterHeight = 2 * normalTextSize.toInt()
inflater = LayoutInflater.from(context)
monthView = inflater.inflate(R.layout.month_view, this).month_view
binding = MonthViewBinding.inflate(inflater, this, true)
setupHorizontalOffset()
onGlobalLayout {
if (!wereViewsAdded && days.isNotEmpty()) {
measureSizes()
addClickableBackgrounds()
monthView.updateDays(days, isMonthDayView)
binding.monthView.updateDays(days, isMonthDayView)
}
}
}
@ -94,7 +94,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
}
isMonthDayView = !addEvents
monthView.updateDays(days, isMonthDayView)
binding.monthView.updateDays(days, isMonthDayView)
}
private fun setupHorizontalOffset() {
@ -108,7 +108,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
private fun addClickableBackgrounds() {
removeAllViews()
monthView = inflater.inflate(R.layout.month_view, this).month_view
binding = MonthViewBinding.inflate(inflater, this, true)
wereViewsAdded = true
var curId = 0
for (y in 0 until ROW_COUNT) {
@ -139,7 +139,7 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
dayClickCallback?.invoke(day)
if (isMonthDayView) {
monthView.updateCurrentlySelectedDay(viewX, viewY)
binding.monthView.updateCurrentlySelectedDay(viewX, viewY)
}
}
addView(this)
@ -147,6 +147,6 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F
}
fun togglePrintMode() {
monthView.togglePrintMode()
binding.monthView.togglePrintMode()
}
}

View file

@ -12,7 +12,7 @@ import com.simplemobiletools.calendar.pro.extensions.getWeeklyViewItemHeight
class WeeklyViewGrid(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) {
private val ROWS_CNT = 24
private var paint = Paint(Paint.ANTI_ALIAS_FLAG)
var daysCount = context.config.weeklyViewDays
private var daysCount = context.config.weeklyViewDays
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)

View file

@ -1,334 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendar_holder"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/top_navigation" />
<TableLayout
<GridLayout
android:id="@+id/calendar_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/top_left_arrow"
android:padding="@dimen/yearly_padding_side">
android:columnCount="4"
android:padding="@dimen/yearly_padding_side"
android:rowCount="3">
<TableRow android:layout_weight="1">
<include
android:id="@+id/month_1_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<RelativeLayout
android:id="@+id/month_1_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<include
android:id="@+id/month_2_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<TextView
android:id="@+id/month_1_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/january"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<include
android:id="@+id/month_3_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_1_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
<include
android:id="@+id/month_4_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
</RelativeLayout>
<include
android:id="@+id/month_5_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<RelativeLayout
android:id="@+id/month_2_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half"
android:layout_weight="1">
<include
android:id="@+id/month_6_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<TextView
android:id="@+id/month_2_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/february"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<include
android:id="@+id/month_7_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_2_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
<include
android:id="@+id/month_8_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
</RelativeLayout>
<include
android:id="@+id/month_9_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginTop="0dp"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<RelativeLayout
android:id="@+id/month_3_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<include
android:id="@+id/month_10_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<TextView
android:id="@+id/month_3_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/march"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<include
android:id="@+id/month_11_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_3_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_4_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_4_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/april"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_4_label"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30" />
</RelativeLayout>
</TableRow>
<TableRow android:layout_weight="1">
<RelativeLayout
android:id="@+id/month_5_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half"
android:layout_weight="1">
<TextView
android:id="@+id/month_5_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/may"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_5_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_6_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_6_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/june"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_6_label"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_7_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_7_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/july"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_7_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_8_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half"
android:layout_weight="1">
<TextView
android:id="@+id/month_8_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/august"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_8_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
</RelativeLayout>
</TableRow>
<TableRow android:layout_weight="1">
<RelativeLayout
android:id="@+id/month_9_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_9_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/september"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_9_label"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_10_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_10_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/october"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_10_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_11_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half"
android:layout_weight="1">
<TextView
android:id="@+id/month_11_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/november"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_11_label"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_12_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_12_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/december"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_12_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
</RelativeLayout>
</TableRow>
</TableLayout>
<include
android:id="@+id/month_12_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
</GridLayout>
</RelativeLayout>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/january"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/small_month_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_label"
android:layout_marginStart="@dimen/yearly_month_padding" />
</RelativeLayout>

View file

@ -1,327 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendar_holder"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/top_navigation" />
<TableLayout
<GridLayout
android:id="@+id/calendar_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/top_left_arrow"
android:padding="@dimen/yearly_padding_side">
android:columnCount="3"
android:padding="@dimen/yearly_padding_side"
android:rowCount="4">
<TableRow android:layout_weight="1">
<include
android:id="@+id/month_1_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginEnd="@dimen/yearly_padding_full" />
<RelativeLayout
android:id="@+id/month_1_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<include
android:id="@+id/month_2_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<TextView
android:id="@+id/month_1_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/january"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<include
android:id="@+id/month_3_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_full" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_1_label"
android:layout_centerInParent="true" />
<include
android:id="@+id/month_4_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginEnd="@dimen/yearly_padding_full" />
</RelativeLayout>
<include
android:id="@+id/month_5_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<RelativeLayout
android:id="@+id/month_2_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half"
android:layout_weight="1">
<include
android:id="@+id/month_6_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_full" />
<TextView
android:id="@+id/month_2_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/february"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<include
android:id="@+id/month_7_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginEnd="@dimen/yearly_padding_full" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_2_label" />
<include
android:id="@+id/month_8_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
</RelativeLayout>
<include
android:id="@+id/month_9_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_full" />
<RelativeLayout
android:id="@+id/month_3_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<include
android:id="@+id/month_10_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginEnd="@dimen/yearly_padding_full" />
<TextView
android:id="@+id/month_3_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/march"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<include
android:id="@+id/month_11_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_3_label" />
</RelativeLayout>
</TableRow>
<TableRow android:layout_weight="1">
<RelativeLayout
android:id="@+id/month_4_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_4_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/april"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_4_label"
app:days="30" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_5_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half"
android:layout_weight="1">
<TextView
android:id="@+id/month_5_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/may"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_5_label" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_6_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_6_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/june"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_6_label"
app:days="30" />
</RelativeLayout>
</TableRow>
<TableRow android:layout_weight="1">
<RelativeLayout
android:id="@+id/month_7_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_7_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/july"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_7_label" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_8_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half"
android:layout_weight="1">
<TextView
android:id="@+id/month_8_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/august"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_8_label" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_9_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_9_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/september"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_9_label"
app:days="30" />
</RelativeLayout>
</TableRow>
<TableRow android:layout_weight="1">
<RelativeLayout
android:id="@+id/month_10_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_10_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/october"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_10_label" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_11_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_half"
android:layout_marginEnd="@dimen/yearly_padding_half"
android:layout_weight="1">
<TextView
android:id="@+id/month_11_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/november"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_11_label"
android:layout_marginStart="@dimen/yearly_month_padding"
app:days="30" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/month_12_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_12_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/december"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/month_12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/month_12_label" />
</RelativeLayout>
</TableRow>
</TableLayout>
<include
android:id="@+id/month_12_holder"
layout="@layout/small_month_view_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginStart="@dimen/yearly_padding_full" />
</GridLayout>
</RelativeLayout>

View file

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_autocomplete_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin">
<ImageView
android:id="@+id/item_autocomplete_image"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_margin="@dimen/tiny_margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_autocomplete_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:lines="1"
android:maxLines="1"
android:paddingStart="@dimen/medium_margin"
android:paddingEnd="@dimen/medium_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_autocomplete_image"
app:layout_constraintTop_toTopOf="parent"
tools:text="hello@simplemobiletools.com" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -19,7 +19,7 @@
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_autocomplete_name"
android:id="@+id/item_autocomplete_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:lines="1"
@ -28,7 +28,7 @@
android:paddingEnd="@dimen/medium_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"
app:layout_constraintBottom_toTopOf="@+id/item_autocomplete_email"
app:layout_constraintBottom_toTopOf="@+id/item_autocomplete_subtitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_autocomplete_image"
app:layout_constraintTop_toTopOf="parent"
@ -36,10 +36,10 @@
tools:text="Simple Mobile" />
<TextView
android:id="@+id/item_autocomplete_email"
android:id="@+id/item_autocomplete_subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/item_autocomplete_name"
android:layout_below="@+id/item_autocomplete_title"
android:layout_marginEnd="8dp"
android:alpha="0.8"
android:lines="1"
@ -51,7 +51,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_autocomplete_image"
app:layout_constraintTop_toBottomOf="@+id/item_autocomplete_name"
app:layout_constraintTop_toBottomOf="@+id/item_autocomplete_title"
tools:text="hello@simplemobiletools.com" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/yearly_padding_full"
android:layout_weight="1">
<TextView
android:id="@+id/month_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/january"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" />
<com.simplemobiletools.calendar.pro.views.SmallMonthView
android:id="@+id/small_month_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/month_label"
android:layout_centerInParent="true" />
</RelativeLayout>