diff --git a/.gitignore b/.gitignore index 70ca726e9..1afb99c0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,6 @@ -# Temp files -*~ -*.bak -*.backup -\#* -.\#* -*\# -*.swp -*.swap -*.sav -*.save -*.autosav -*.autosave - *.iml .gradle /local.properties -/gradle.properties /.idea/ .DS_Store /build diff --git a/CHANGELOG.md b/CHANGELOG.md index 89b1dc86f..85d6c0550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,33 @@ Changelog ========== +Version 5.1.1 *(2018-10-25)* +---------------------------- + + * Fixing a crash related to pull-to-refresh swiping + +Version 5.1.0 *(2018-10-24)* +---------------------------- + + * Add optional pull-to-refresh for refreshing CalDAV events on some views (by azisuazusa) + * Allow setting a default view to be opened from the Event List widget (by knusprjg) + * Apply selected filters on all views, including widgets + * Allow changing any CalDAV calendars color, even if only locally + * Fix some glitches related to saving CalDAV events in a wrong calendar + * Some performance improvements related to fetching events + * Couple other smaller stability/ux improvements + +Version 5.0.1 *(2018-10-17)* +---------------------------- + + * Fixed transparent date/time picker backgrounds + +Version 5.0.0 *(2018-10-16)* +---------------------------- + + * Increased the minimal required Android OS version to 5 + * Some translation and stability improvements + Version 4.2.1 *(2018-09-22)* ---------------------------- diff --git a/app/build.gradle b/app/build.gradle index 6b3a8c331..e84d5c7ab 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,14 +4,14 @@ apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 - buildToolsVersion "28.0.2" + buildToolsVersion "28.0.3" defaultConfig { applicationId "com.simplemobiletools.calendar" - minSdkVersion 16 + minSdkVersion 21 targetSdkVersion 28 - versionCode 129 - versionName "4.2.1" + versionCode 133 + versionName "5.1.1" multiDexEnabled true setProperty("archivesBaseName", "calendar") } @@ -42,10 +42,10 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:4.7.17' + implementation 'com.simplemobiletools:commons:5.2.6' implementation 'joda-time:joda-time:2.9.9' implementation 'com.facebook.stetho:stetho:1.5.0' - implementation 'com.android.support:multidex:1.0.3' + implementation 'androidx.multidex:multidex:2.0.0' } Properties props = new Properties() diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e0025a967..3b7fd718f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -184,7 +184,7 @@ diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/App.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/App.kt index 48f52c694..40a843618 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/App.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/App.kt @@ -1,6 +1,6 @@ package com.simplemobiletools.calendar -import android.support.multidex.MultiDexApplication +import androidx.multidex.MultiDexApplication import com.facebook.stetho.Stetho import com.simplemobiletools.commons.extensions.checkUseEnglish diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index c3dc37a78..8f0a0769f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -1,16 +1,15 @@ package com.simplemobiletools.calendar.activities -import android.annotation.SuppressLint import android.app.DatePickerDialog import android.app.TimePickerDialog import android.content.Intent import android.net.Uri import android.os.Bundle -import android.support.v4.app.NotificationManagerCompat import android.text.method.LinkMovementMethod import android.view.Menu import android.view.MenuItem import android.view.WindowManager +import androidx.core.app.NotificationManagerCompat import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.dialogs.* import com.simplemobiletools.calendar.extensions.* @@ -94,9 +93,11 @@ class EventActivity : SimpleActivity() { cancelNotification(mEvent.id) } else { mEvent = Event() - mReminder1Minutes = if (config.usePreviousEventReminders) config.lastEventReminderMinutes else config.defaultReminder1 - mReminder2Minutes = if (config.usePreviousEventReminders) config.lastEventReminderMinutes2 else config.defaultReminder2 - mReminder3Minutes = if (config.usePreviousEventReminders) config.lastEventReminderMinutes3 else config.defaultReminder3 + config.apply { + mReminder1Minutes = if (usePreviousEventReminders) lastEventReminderMinutes1 else defaultReminder1 + mReminder2Minutes = if (usePreviousEventReminders) lastEventReminderMinutes2 else defaultReminder2 + mReminder3Minutes = if (usePreviousEventReminders) lastEventReminderMinutes3 else defaultReminder3 + } if (savedInstanceState == null) { setupNewEvent() @@ -121,7 +122,7 @@ class EventActivity : SimpleActivity() { event_repetition_limit_holder.setOnClickListener { showRepetitionTypePicker() } event_reminder_1.setOnClickListener { - handleNotificationAvailability() { + handleNotificationAvailability { if (config.wasAlarmWarningShown) { showReminder1Dialog() } else { @@ -243,6 +244,7 @@ class EventActivity : SimpleActivity() { private fun setupNewEvent() { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) + event_title.requestFocus() updateActionBarTitle(getString(R.string.new_event)) val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId.toString()) mEventCalendarId = if (isLastCaldavCalendarOK) config.lastUsedCaldavCalendarId else STORED_LOCALLY_ONLY @@ -620,6 +622,7 @@ class EventActivity : SimpleActivity() { event_type_holder.beVisibleIf(currentCalendar == null) event_caldav_calendar_divider.beVisibleIf(currentCalendar == null) event_caldav_calendar_email.beGoneIf(currentCalendar == null) + event_caldav_calendar_color.beGoneIf(currentCalendar == null) if (currentCalendar == null) { mEventCalendarId = STORED_LOCALLY_ONLY @@ -634,6 +637,10 @@ class EventActivity : SimpleActivity() { } } else { event_caldav_calendar_email.text = currentCalendar.accountName + + val calendarColor = dbHelper.getEventTypeWithCalDAVCalendarId(currentCalendar.id)?.color ?: currentCalendar.color + event_caldav_calendar_color.setFillWithStroke(calendarColor, config.backgroundColor) + event_caldav_calendar_name.apply { text = currentCalendar.displayName setPadding(paddingLeft, paddingTop, paddingRight, resources.getDimension(R.dimen.tiny_margin).toInt()) @@ -699,10 +706,10 @@ class EventActivity : SimpleActivity() { val newEventType = if (!config.caldavSync || config.lastUsedCaldavCalendarId == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) { mEventTypeId } else { - dbHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendarId)?.id ?: config.lastUsedLocalEventTypeId + dbHelper.getEventTypeWithCalDAVCalendarId(mEventCalendarId)?.id ?: config.lastUsedLocalEventTypeId } - val newSource = if (!config.caldavSync || config.lastUsedCaldavCalendarId == 0 || mEventCalendarId == STORED_LOCALLY_ONLY) { + val newSource = if (!config.caldavSync || mEventCalendarId == STORED_LOCALLY_ONLY) { config.lastUsedLocalEventTypeId = newEventType SOURCE_SIMPLE_CALENDAR } else { @@ -716,7 +723,7 @@ class EventActivity : SimpleActivity() { config.apply { if (usePreviousEventReminders) { - lastEventReminderMinutes = reminder1 + lastEventReminderMinutes1 = reminder1 lastEventReminderMinutes2 = reminder2 lastEventReminderMinutes3 = reminder3 } @@ -856,17 +863,13 @@ class EventActivity : SimpleActivity() { } } - @SuppressLint("NewApi") private fun setupStartDate() { hideKeyboard() config.backgroundColor.getContrastColor() val datepicker = DatePickerDialog(this, mDialogTheme, startDateSetListener, mEventStartDateTime.year, mEventStartDateTime.monthOfYear - 1, mEventStartDateTime.dayOfMonth) - if (isLollipopPlus()) { - datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY - } - + datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY datepicker.show() } @@ -875,16 +878,12 @@ class EventActivity : SimpleActivity() { TimePickerDialog(this, mDialogTheme, startTimeSetListener, mEventStartDateTime.hourOfDay, mEventStartDateTime.minuteOfHour, config.use24HourFormat).show() } - @SuppressLint("NewApi") private fun setupEndDate() { hideKeyboard() val datepicker = DatePickerDialog(this, mDialogTheme, endDateSetListener, mEventEndDateTime.year, mEventEndDateTime.monthOfYear - 1, mEventEndDateTime.dayOfMonth) - if (isLollipopPlus()) { - datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY - } - + datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY datepicker.show() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt index d4ed72a8e..69b3a6d07 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -11,13 +11,14 @@ import android.net.Uri import android.os.Bundle import android.os.Handler import android.provider.ContactsContract -import android.support.v4.view.MenuItemCompat -import android.support.v7.widget.SearchView import android.view.Menu import android.view.MenuItem import android.widget.Toast +import androidx.appcompat.widget.SearchView +import androidx.core.view.MenuItemCompat import com.simplemobiletools.calendar.BuildConfig import com.simplemobiletools.calendar.R +import com.simplemobiletools.calendar.R.id.* import com.simplemobiletools.calendar.adapters.EventListAdapter import com.simplemobiletools.calendar.dialogs.ExportEventsDialog import com.simplemobiletools.calendar.dialogs.FilterEventTypesDialog @@ -70,9 +71,6 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { setContentView(R.layout.activity_main) appLaunched(BuildConfig.APPLICATION_ID) - // just get a reference to the database to make sure it is created properly - dbHelper - checkWhatsNewDialog() calendar_fab.beVisibleIf(config.storedView != YEARLY_VIEW) calendar_fab.setOnClickListener { @@ -92,6 +90,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { refreshCalDAVCalendars(false) } + swipe_refresh_layout.setOnRefreshListener { + refreshCalDAVCalendars(false) + } + if (!checkViewIntents()) { return } @@ -129,6 +131,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { search_placeholder_2.setTextColor(config.textColor) calendar_fab.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor) search_holder.background = ColorDrawable(config.backgroundColor) + checkSwipeRefreshAvailability() } override fun onPause() { @@ -183,6 +186,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } override fun onBackPressed() { + swipe_refresh_layout.isRefreshing = false + checkSwipeRefreshAvailability() if (currentFragments.size > 1) { removeTopFragment() } else { @@ -251,12 +256,14 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private fun checkOpenIntents(): Boolean { val dayCodeToOpen = intent.getStringExtra(DAY_CODE) ?: "" - val openMonth = intent.getBooleanExtra(OPEN_MONTH, false) - intent.removeExtra(OPEN_MONTH) + val viewToOpen = intent.getIntExtra(VIEW_TO_OPEN, DAILY_VIEW) + intent.removeExtra(VIEW_TO_OPEN) intent.removeExtra(DAY_CODE) if (dayCodeToOpen.isNotEmpty()) { calendar_fab.beVisible() - config.storedView = if (openMonth) MONTHLY_VIEW else DAILY_VIEW + if (viewToOpen != LAST_VIEW) { + config.storedView = viewToOpen + } updateViewPager(dayCodeToOpen) return true } @@ -337,6 +344,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private fun showFilterDialog() { FilterEventTypesDialog(this) { refreshViewPager() + updateWidgets() } } @@ -368,6 +376,9 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { if (showCalDAVRefreshToast) { toast(R.string.refreshing_complete) } + runOnUiThread { + swipe_refresh_layout.isRefreshing = false + } } }, CALDAV_SYNC_DELAY) } @@ -527,6 +538,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private fun updateView(view: Int) { calendar_fab.beVisibleIf(view != YEARLY_VIEW) config.storedView = view + checkSwipeRefreshAvailability() updateViewPager() if (goToTodayButton?.isVisible == true) { shouldGoToTodayBeVisible = false @@ -578,8 +590,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { val bundle = Bundle() bundle.putString(DAY_CODE, Formatter.getDayCodeFromDateTime(dateTime)) fragment.arguments = bundle - supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow() - supportActionBar?.setDisplayHomeAsUpEnabled(true) + try { + supportFragmentManager.beginTransaction().add(R.id.fragments_holder, fragment).commitNow() + supportActionBar?.setDisplayHomeAsUpEnabled(true) + } catch (e: Exception) { + } } private fun getThisWeekDateTime(): String { @@ -612,7 +627,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private fun refreshViewPager() { runOnUiThread { - if (!isActivityDestroyed()) { + if (!isDestroyed) { currentFragments.last().refreshEvents() } } @@ -695,7 +710,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } private fun launchAbout() { - val licenses = LICENSE_JODA or LICENSE_STETHO or LICENSE_MULTISELECT or LICENSE_LEAK_CANARY + val licenses = LICENSE_JODA or LICENSE_STETHO val faqItems = arrayListOf( FAQItem(R.string.faq_1_title_commons, R.string.faq_1_text_commons), @@ -737,6 +752,13 @@ 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 + } + } + // only used at active search override fun refreshItems() { searchQueryChanged(mLatestSearchQuery) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/ManageEventTypesActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/ManageEventTypesActivity.kt index 808c50369..2526f2560 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/ManageEventTypesActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/ManageEventTypesActivity.kt @@ -5,7 +5,7 @@ import android.view.Menu import android.view.MenuItem import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.adapters.ManageEventTypesAdapter -import com.simplemobiletools.calendar.dialogs.UpdateEventTypeDialog +import com.simplemobiletools.calendar.dialogs.EditEventTypeDialog import com.simplemobiletools.calendar.extensions.dbHelper import com.simplemobiletools.calendar.interfaces.DeleteEventTypesListener import com.simplemobiletools.calendar.models.EventType @@ -24,7 +24,7 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteEventTypesListener { } private fun showEventTypeDialog(eventType: EventType? = null) { - UpdateEventTypeDialog(this, eventType?.copy()) { + EditEventTypeDialog(this, eventType?.copy()) { getEventTypes() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt index c0e6f56d4..6e62dad67 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt @@ -7,7 +7,10 @@ import android.os.Bundle import android.text.TextUtils import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.dialogs.SelectCalendarsDialog -import com.simplemobiletools.calendar.extensions.* +import com.simplemobiletools.calendar.extensions.config +import com.simplemobiletools.calendar.extensions.dbHelper +import com.simplemobiletools.calendar.extensions.getSyncedCalDAVCalendars +import com.simplemobiletools.calendar.extensions.updateWidgets import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.calendar.models.EventType import com.simplemobiletools.commons.dialogs.ConfirmationDialog @@ -35,7 +38,6 @@ class SettingsActivity : SimpleActivity() { setContentView(R.layout.activity_settings) res = resources mStoredPrimaryColor = config.primaryColor - setupCaldavSync() } override fun onResume() { @@ -60,6 +62,9 @@ class SettingsActivity : SimpleActivity() { setupUseSameSnooze() setupLoopReminders() setupSnoozeTime() + setupCaldavSync() + setupManageSyncedCalendars() + setupPullToRefresh() setupDefaultReminder() setupDefaultReminder1() setupDefaultReminder2() @@ -67,6 +72,7 @@ class SettingsActivity : SimpleActivity() { setupDisplayPastEvents() setupFontSize() setupCustomizeWidgetColors() + setupViewToOpenFromListWidget() setupDimEvents() updateTextColors(settings_holder) checkPrimaryColor() @@ -159,7 +165,18 @@ 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 setupManageSyncedCalendars() { settings_manage_synced_calendars_holder.beVisibleIf(config.caldavSync) settings_manage_synced_calendars_holder.setOnClickListener { showCalendarPicker() @@ -173,6 +190,7 @@ class SettingsActivity : SimpleActivity() { settings_caldav_sync.isChecked = false config.caldavSync = false settings_manage_synced_calendars_holder.beGone() + settings_caldav_pull_to_refresh_holder.beGone() config.getSyncedCalendarIdsAsList().forEach { CalDAVHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong()) } @@ -190,6 +208,7 @@ class SettingsActivity : SimpleActivity() { } settings_manage_synced_calendars_holder.beVisibleIf(newCalendarIds.isNotEmpty()) + settings_caldav_pull_to_refresh_holder.beVisibleIf(newCalendarIds.isNotEmpty()) settings_caldav_sync.isChecked = newCalendarIds.isNotEmpty() config.caldavSync = newCalendarIds.isNotEmpty() if (settings_caldav_sync.isChecked) { @@ -481,7 +500,6 @@ class SettingsActivity : SimpleActivity() { config.fontSize = it as Int settings_font_size.text = getFontSizeText() updateWidgets() - updateListWidget() } } } @@ -501,6 +519,34 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupViewToOpenFromListWidget() { + settings_list_widget_view_to_open.text = getDefaultViewText() + settings_list_widget_view_to_open_holder.setOnClickListener { + val items = arrayListOf( + RadioItem(DAILY_VIEW, res.getString(R.string.daily_view)), + RadioItem(WEEKLY_VIEW, res.getString(R.string.weekly_view)), + RadioItem(MONTHLY_VIEW, res.getString(R.string.monthly_view)), + RadioItem(YEARLY_VIEW, res.getString(R.string.yearly_view)), + RadioItem(EVENTS_LIST_VIEW, res.getString(R.string.simple_event_list)), + RadioItem(LAST_VIEW, res.getString(R.string.last_view))) + + RadioGroupDialog(this@SettingsActivity, items, config.listWidgetViewToOpen) { + config.listWidgetViewToOpen = it as Int + settings_list_widget_view_to_open.text = getDefaultViewText() + updateWidgets() + } + } + } + + private fun getDefaultViewText() = getString(when (config.listWidgetViewToOpen) { + DAILY_VIEW -> R.string.daily_view + WEEKLY_VIEW -> R.string.weekly_view + MONTHLY_VIEW -> R.string.monthly_view + YEARLY_VIEW -> R.string.yearly_view + EVENTS_LIST_VIEW -> R.string.simple_event_list + else -> R.string.last_view + }) + private fun setupDimEvents() { settings_dim_past_events.isChecked = config.dimPastEvents settings_dim_past_events_holder.setOnClickListener { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SnoozeReminderActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SnoozeReminderActivity.kt index 455a6313d..4499eba94 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SnoozeReminderActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SnoozeReminderActivity.kt @@ -1,7 +1,7 @@ package com.simplemobiletools.calendar.activities import android.os.Bundle -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper import com.simplemobiletools.calendar.extensions.rescheduleReminder diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SplashActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SplashActivity.kt index 34025f507..b89b88d15 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SplashActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SplashActivity.kt @@ -1,10 +1,7 @@ package com.simplemobiletools.calendar.activities import android.content.Intent -import com.simplemobiletools.calendar.helpers.DAY_CODE -import com.simplemobiletools.calendar.helpers.EVENT_ID -import com.simplemobiletools.calendar.helpers.EVENT_OCCURRENCE_TS -import com.simplemobiletools.calendar.helpers.OPEN_MONTH +import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.commons.activities.BaseSplashActivity class SplashActivity : BaseSplashActivity() { @@ -12,7 +9,7 @@ class SplashActivity : BaseSplashActivity() { when { intent.extras?.containsKey(DAY_CODE) == true -> Intent(this, MainActivity::class.java).apply { putExtra(DAY_CODE, intent.getStringExtra(DAY_CODE)) - putExtra(OPEN_MONTH, intent.getBooleanExtra(OPEN_MONTH, false)) + putExtra(VIEW_TO_OPEN, intent.getIntExtra(VIEW_TO_OPEN, LAST_VIEW)) startActivity(this) } intent.extras?.containsKey(EVENT_ID) == true -> Intent(this, MainActivity::class.java).apply { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetMonthlyConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetMonthlyConfigureActivity.kt index 07bca80ff..6c15eb6b2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetMonthlyConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetMonthlyConfigureActivity.kt @@ -89,7 +89,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar { config_bg_seekbar.progress = (mBgAlpha * 100).toInt() updateBgColor() - MonthlyCalendarImpl(this, applicationContext).updateMonthlyCalendar(DateTime().withDayOfMonth(1), false) + MonthlyCalendarImpl(this, applicationContext).updateMonthlyCalendar(DateTime().withDayOfMonth(1)) } private fun saveConfig() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt index a2b94f3f9..d5a5a8663 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt @@ -38,12 +38,6 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r override fun prepareActionMode(menu: Menu) {} - override fun prepareItemSelection(viewHolder: ViewHolder) {} - - override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) { - viewHolder?.itemView?.event_item_frame?.isSelected = select - } - override fun actionItemPressed(id: Int) { when (id) { R.id.cab_share -> shareEvents() @@ -55,6 +49,10 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r override fun getIsItemSelectable(position: Int) = true + override fun getItemSelectionKey(position: Int) = events.getOrNull(position)?.id + + override fun getItemKeyPosition(key: Int) = events.indexOfFirst { it.id == key } + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyRecyclerViewAdapter.ViewHolder { val layoutId = when (viewType) { ITEM_EVENT -> R.layout.event_item_day_view @@ -65,10 +63,10 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) { val event = events[position] - val view = holder.bindView(event, true, true) { itemView, layoutPosition -> + holder.bindView(event, true, true) { itemView, layoutPosition -> setupView(itemView, event) } - bindViewHolder(holder, position, view) + bindViewHolder(holder) } override fun getItemCount() = events.size @@ -76,8 +74,18 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r override fun getItemViewType(position: Int): Int { val event = events[position] val detailField = if (replaceDescriptionWithLocation) event.location else event.description - return if (event.startTS == event.endTS && detailField.isEmpty()) { + return if (detailField.isNotEmpty()) { + ITEM_EVENT + } else if (event.startTS == event.endTS) { ITEM_EVENT_SIMPLE + } else if (event.getIsAllDay()) { + val startCode = Formatter.getDayCodeFromTS(event.startTS) + val endCode = Formatter.getDayCodeFromTS(event.endTS) + if (startCode == endCode) { + ITEM_EVENT_SIMPLE + } else { + ITEM_EVENT + } } else { ITEM_EVENT } @@ -85,6 +93,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r private fun setupView(view: View, event: Event) { view.apply { + event_item_frame.isSelected = selectedKeys.contains(event.id) event_item_title.text = event.title event_item_description?.text = if (replaceDescriptionWithLocation) event.location else event.description event_item_start.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS) @@ -95,7 +104,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r val startCode = Formatter.getDayCodeFromTS(event.startTS) val endCode = Formatter.getDayCodeFromTS(event.endTS) - event_item_end.apply { + event_item_end?.apply { text = Formatter.getTimeFromTS(context, event.endTS) if (startCode != endCode) { if (event.getIsAllDay()) { @@ -121,35 +130,24 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r } } - private fun shareEvents() { - val eventIds = ArrayList(selectedPositions.size) - selectedPositions.forEach { - eventIds.add(events[it].id) - } - activity.shareEvents(eventIds.distinct()) - } + private fun shareEvents() = activity.shareEvents(selectedKeys.distinct()) private fun askConfirmDelete() { - val eventIds = ArrayList(selectedPositions.size) - val timestamps = ArrayList(selectedPositions.size) - val eventsToDelete = ArrayList(selectedPositions.size) - selectedPositions.forEach { - val event = events[it] - eventsToDelete.add(event) - eventIds.add(event.id) - timestamps.add(event.startTS) - } + val eventIds = selectedKeys.toMutableList() + val eventsToDelete = events.filter { selectedKeys.contains(it.id) } + val timestamps = eventsToDelete.map { it.startTS } + val positions = getSelectedItemPositions() val hasRepeatableEvent = eventsToDelete.any { it.repeatInterval > 0 } - DeleteEventDialog(activity, eventIds, hasRepeatableEvent) { + DeleteEventDialog(activity, eventIds, hasRepeatableEvent) { it -> events.removeAll(eventsToDelete) - val nonRepeatingEventIDs = eventsToDelete.filter { it.repeatInterval == 0 }.map { it.id.toString() }.toTypedArray() + val nonRepeatingEventIDs = eventsToDelete.asSequence().filter { it.repeatInterval == 0 }.map { it.id.toString() }.toList().toTypedArray() activity.dbHelper.deleteEvents(nonRepeatingEventIDs, true) - val repeatingEventIDs = eventsToDelete.filter { it.repeatInterval != 0 }.map { it.id } + val repeatingEventIDs = eventsToDelete.asSequence().filter { it.repeatInterval != 0 }.map { it.id }.toList() activity.handleEventDeleting(repeatingEventIDs, timestamps, it) - removeSelectedItems() + removeSelectedItems(positions) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt index 98429174d..db7280446 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt @@ -38,6 +38,7 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList if (firstNonPastSectionIndex == -1 && listItem is ListSection) { @@ -58,12 +59,6 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList shareEvents() @@ -75,6 +70,10 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList R.layout.event_list_item @@ -86,14 +85,14 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList + holder.bindView(listItem, true, allowLongClick) { itemView, layoutPosition -> if (listItem is ListSection) { setupListSection(itemView, listItem, position) } else if (listItem is ListEvent) { setupListEvent(itemView, listItem) } } - bindViewHolder(holder, position, view) + bindViewHolder(holder) } override fun getItemCount() = listItems.size @@ -101,8 +100,18 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList(selectedPositions.size) - selectedPositions.forEach { - val item = listItems[it] - if (item is ListEvent) { - eventIds.add(item.id) - } - } - activity.shareEvents(eventIds.distinct()) - } + private fun shareEvents() = activity.shareEvents(selectedKeys.distinct()) private fun askConfirmDelete() { - val eventIds = ArrayList(selectedPositions.size) - val timestamps = ArrayList(selectedPositions.size) - val eventsToDelete = ArrayList(selectedPositions.size) - - selectedPositions.sortedDescending().forEach { - val item = listItems[it] - if (item is ListEvent) { - eventIds.add(item.id) - timestamps.add(item.startTS) - eventsToDelete.add(item) - } - } + val eventIds = selectedKeys.toMutableList() + val eventsToDelete = listItems.filter { selectedKeys.contains((it as? ListEvent)?.id) } as List + val timestamps = eventsToDelete.mapNotNull { (it as? ListEvent)?.startTS } val hasRepeatableEvent = eventsToDelete.any { it.isRepeatable } DeleteEventDialog(activity, eventIds, hasRepeatableEvent) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt index 982f3c981..a6a0966f9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt @@ -41,8 +41,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi if (type == ITEM_EVENT) { val event = events[position] as ListEvent - val detailField = if (replaceDescription) event.location else event.description - val layout = if (event.startTS == event.endTS && detailField.isEmpty()) R.layout.event_list_item_widget_simple else R.layout.event_list_item_widget + val layout = getItemViewLayout(event) remoteView = RemoteViews(context.packageName, layout) setupListEvent(remoteView, event) } else { @@ -53,6 +52,25 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi return remoteView } + private fun getItemViewLayout(event: ListEvent): Int { + val detailField = if (replaceDescription) event.location else event.description + return if (detailField.isNotEmpty()) { + R.layout.event_list_item_widget + } else if (event.startTS == event.endTS) { + R.layout.event_list_item_widget_simple + } else if (event.isAllDay) { + val startCode = Formatter.getDayCodeFromTS(event.startTS) + val endCode = Formatter.getDayCodeFromTS(event.endTS) + if (startCode == endCode) { + R.layout.event_list_item_widget_simple + } else { + R.layout.event_list_item_widget + } + } else { + R.layout.event_list_item_widget + } + } + private fun setupListEvent(remoteView: RemoteViews, item: ListEvent) { var curTextColor = textColor remoteView.apply { @@ -116,6 +134,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi Intent().apply { putExtra(DAY_CODE, item.code) + putExtra(VIEW_TO_OPEN, context.config.listWidgetViewToOpen) setOnClickFillInIntent(event_section_title, this) } } @@ -137,7 +156,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi mediumFontSize = context.config.getFontSize() val fromTS = DateTime().seconds() - context.config.displayPastEvents * 60 val toTS = DateTime().plusYears(1).seconds() - context.dbHelper.getEventsInBackground(fromTS, toTS) { + context.dbHelper.getEventsInBackground(fromTS, toTS, applyTypeFilter = true) { val listItems = ArrayList(it.size) val replaceDescription = context.config.replaceDescription val sorted = it.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description })) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/FilterEventTypeAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/FilterEventTypeAdapter.kt index 30f9006ff..64d15ba24 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/FilterEventTypeAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/FilterEventTypeAdapter.kt @@ -1,87 +1,69 @@ package com.simplemobiletools.calendar.adapters -import android.support.v7.widget.RecyclerView -import android.util.SparseArray import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.SimpleActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.models.EventType import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor import com.simplemobiletools.commons.extensions.setFillWithStroke -import com.simplemobiletools.commons.interfaces.MyAdapterListener import kotlinx.android.synthetic.main.filter_event_type_view.view.* import java.util.* class FilterEventTypeAdapter(val activity: SimpleActivity, val eventTypes: List, val displayEventTypes: Set) : RecyclerView.Adapter() { - private val itemViews = SparseArray() - private val selectedPositions = HashSet() + private val selectedKeys = HashSet() init { eventTypes.forEachIndexed { index, eventType -> if (displayEventTypes.contains(eventType.id.toString())) { - selectedPositions.add(index) + selectedKeys.add(eventType.id) } } } - private fun toggleItemSelection(select: Boolean, pos: Int) { + private fun toggleItemSelection(select: Boolean, eventType: EventType, pos: Int) { if (select) { - if (itemViews[pos] != null) { - selectedPositions.add(pos) - } + selectedKeys.add(eventType.id) } else { - selectedPositions.remove(pos) + selectedKeys.remove(eventType.id) } - itemViews[pos]?.filter_event_type_checkbox?.isChecked = select + notifyItemChanged(pos) } - private val adapterListener = object : MyAdapterListener { - override fun toggleItemSelectionAdapter(select: Boolean, position: Int) { - toggleItemSelection(select, position) - } - - override fun getSelectedPositions() = selectedPositions - - override fun itemLongClicked(position: Int) {} - } - - fun getSelectedItemsSet(): HashSet { - val selectedItemsSet = HashSet(selectedPositions.size) - selectedPositions.forEach { selectedItemsSet.add(eventTypes[it].id.toString()) } - return selectedItemsSet - } + fun getSelectedItemsSet() = selectedKeys.asSequence().map { it.toString() }.toHashSet() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val view = activity.layoutInflater.inflate(R.layout.filter_event_type_view, parent, false) - return ViewHolder(view, adapterListener, activity) + return ViewHolder(view) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val eventType = eventTypes[position] - itemViews.put(position, holder.bindView(eventType)) - toggleItemSelection(selectedPositions.contains(position), position) + holder.bindView(eventType) } override fun getItemCount() = eventTypes.size - class ViewHolder(view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity) : RecyclerView.ViewHolder(view) { + inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { fun bindView(eventType: EventType): View { + val isSelected = selectedKeys.contains(eventType.id) itemView.apply { + filter_event_type_checkbox.isChecked = isSelected filter_event_type_checkbox.setColors(activity.config.textColor, activity.getAdjustedPrimaryColor(), activity.config.backgroundColor) filter_event_type_checkbox.text = eventType.getDisplayTitle() filter_event_type_color.setFillWithStroke(eventType.color, activity.config.backgroundColor) - filter_event_type_holder.setOnClickListener { viewClicked(!filter_event_type_checkbox.isChecked) } + filter_event_type_holder.setOnClickListener { viewClicked(!isSelected, eventType) } } return itemView } - private fun viewClicked(select: Boolean) { - adapterListener.toggleItemSelectionAdapter(select, adapterPosition) + private fun viewClicked(select: Boolean, eventType: EventType) { + toggleItemSelection(select, eventType, adapterPosition) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/ManageEventTypesAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/ManageEventTypesAdapter.kt index d8fcf08bb..caf946efe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/ManageEventTypesAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/ManageEventTypesAdapter.kt @@ -31,12 +31,6 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis override fun prepareActionMode(menu: Menu) {} - override fun prepareItemSelection(viewHolder: ViewHolder) {} - - override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) { - viewHolder?.itemView?.event_item_frame?.isSelected = select - } - override fun actionItemPressed(id: Int) { when (id) { R.id.cab_delete -> askConfirmDelete() @@ -47,20 +41,29 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis override fun getIsItemSelectable(position: Int) = true + override fun getItemSelectionKey(position: Int) = eventTypes.getOrNull(position)?.id + + override fun getItemKeyPosition(key: Int) = eventTypes.indexOfFirst { it.id == key } + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_event_type, parent) override fun onBindViewHolder(holder: ViewHolder, position: Int) { val eventType = eventTypes[position] - val view = holder.bindView(eventType, true, true) { itemView, layoutPosition -> + holder.bindView(eventType, true, true) { itemView, layoutPosition -> setupView(itemView, eventType) } - bindViewHolder(holder, position, view) + bindViewHolder(holder) } override fun getItemCount() = eventTypes.size + private fun getItemWithKey(key: Int): EventType? = eventTypes.firstOrNull { it.id == key } + + private fun getSelectedItems() = eventTypes.filter { selectedKeys.contains(it.id) } as ArrayList + private fun setupView(view: View, eventType: EventType) { view.apply { + event_item_frame.isSelected = selectedKeys.contains(eventType.id) event_type_title.text = eventType.getDisplayTitle() event_type_color.setFillWithStroke(eventType.color, activity.config.backgroundColor) event_type_title.setTextColor(textColor) @@ -68,8 +71,7 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis } private fun askConfirmDelete() { - val eventTypes = ArrayList(selectedPositions.size) - selectedPositions.forEach { eventTypes.add(this.eventTypes[it]) } + val eventTypes = eventTypes.filter { selectedKeys.contains(it.id) } as ArrayList if (activity.dbHelper.doEventTypesContainEvent(eventTypes)) { val MOVE_EVENTS = 0 @@ -90,25 +92,22 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis } private fun deleteEventTypes(deleteEvents: Boolean) { - val eventTypesToDelete = ArrayList(selectedPositions.size) + val eventTypesToDelete = getSelectedItems() - for (pos in selectedPositions) { - if (eventTypes[pos].id == DBHelper.REGULAR_EVENT_TYPE_ID) { + for (key in selectedKeys) { + val type = getItemWithKey(key) ?: continue + if (type.id == DBHelper.REGULAR_EVENT_TYPE_ID) { activity.toast(R.string.cannot_delete_default_type) - selectedPositions.remove(pos) - toggleItemSelection(false, pos) + eventTypesToDelete.remove(type) + toggleItemSelection(false, getItemKeyPosition(type.id)) break } } - selectedPositions.sortedDescending().forEach { - val eventType = eventTypes[it] - eventTypesToDelete.add(eventType) - } - - eventTypes.removeAll(eventTypesToDelete) if (listener?.deleteEventTypes(eventTypesToDelete, deleteEvents) == true) { - removeSelectedItems() + val positions = getSelectedItemPositions() + eventTypes.removeAll(eventTypesToDelete) + removeSelectedItems(positions) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyDayPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyDayPagerAdapter.kt index f81e802df..94f82ca18 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyDayPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyDayPagerAdapter.kt @@ -1,10 +1,10 @@ package com.simplemobiletools.calendar.adapters import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentStatePagerAdapter import android.util.SparseArray +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentStatePagerAdapter import com.simplemobiletools.calendar.fragments.DayFragment import com.simplemobiletools.calendar.helpers.DAY_CODE import com.simplemobiletools.calendar.interfaces.NavigationListener diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyMonthPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyMonthPagerAdapter.kt index 17ed299cb..00e35ce8f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyMonthPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyMonthPagerAdapter.kt @@ -1,10 +1,10 @@ package com.simplemobiletools.calendar.adapters import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentStatePagerAdapter import android.util.SparseArray +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentStatePagerAdapter import com.simplemobiletools.calendar.fragments.MonthFragment import com.simplemobiletools.calendar.helpers.DAY_CODE import com.simplemobiletools.calendar.interfaces.NavigationListener diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyWeekPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyWeekPagerAdapter.kt index b403dbc58..6f9b0dacc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyWeekPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyWeekPagerAdapter.kt @@ -1,10 +1,10 @@ package com.simplemobiletools.calendar.adapters import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentStatePagerAdapter import android.util.SparseArray +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentStatePagerAdapter import com.simplemobiletools.calendar.fragments.WeekFragment import com.simplemobiletools.calendar.helpers.WEEK_START_TIMESTAMP import com.simplemobiletools.calendar.interfaces.WeekFragmentListener diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyYearPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyYearPagerAdapter.kt index 8434a056e..c93d6613a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyYearPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/MyYearPagerAdapter.kt @@ -1,10 +1,10 @@ package com.simplemobiletools.calendar.adapters import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v4.app.FragmentManager -import android.support.v4.app.FragmentStatePagerAdapter import android.util.SparseArray +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentStatePagerAdapter import com.simplemobiletools.calendar.fragments.YearFragment import com.simplemobiletools.calendar.helpers.YEAR_LABEL diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/CustomEventRepeatIntervalDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/CustomEventRepeatIntervalDialog.kt index 18d1fd8b0..6545a0727 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/CustomEventRepeatIntervalDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/CustomEventRepeatIntervalDialog.kt @@ -1,8 +1,8 @@ package com.simplemobiletools.calendar.dialogs import android.app.Activity -import android.support.v7.app.AlertDialog import android.view.ViewGroup +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.helpers.DAY import com.simplemobiletools.calendar.helpers.MONTH @@ -22,7 +22,7 @@ class CustomEventRepeatIntervalDialog(val activity: Activity, val callback: (sec view.dialog_radio_view.check(R.id.dialog_radio_days) dialog = AlertDialog.Builder(activity) - .setPositiveButton(R.string.ok, { dialogInterface, i -> confirmRepeatInterval() }) + .setPositiveButton(R.string.ok) { dialogInterface, i -> confirmRepeatInterval() } .setNegativeButton(R.string.cancel, null) .create().apply { activity.setupDialogStuff(view, this) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/DeleteEventDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/DeleteEventDialog.kt index dde07d6d7..deaefd849 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/DeleteEventDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/DeleteEventDialog.kt @@ -1,8 +1,8 @@ package com.simplemobiletools.calendar.dialogs import android.app.Activity -import android.support.v7.app.AlertDialog import android.view.ViewGroup +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.helpers.DELETE_ALL_OCCURRENCES import com.simplemobiletools.calendar.helpers.DELETE_FUTURE_OCCURRENCES @@ -28,7 +28,7 @@ class DeleteEventDialog(val activity: Activity, eventIds: List, hasRepeatab } dialog = AlertDialog.Builder(activity) - .setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed(view as ViewGroup) }) + .setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed(view as ViewGroup) } .setNegativeButton(R.string.no, null) .create().apply { activity.setupDialogStuff(view, this) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/UpdateEventTypeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/EditEventTypeDialog.kt similarity index 95% rename from app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/UpdateEventTypeDialog.kt rename to app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/EditEventTypeDialog.kt index 5fcecafd5..8b9b88a4b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/UpdateEventTypeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/EditEventTypeDialog.kt @@ -1,8 +1,8 @@ package com.simplemobiletools.calendar.dialogs import android.app.Activity -import android.support.v7.app.AlertDialog import android.widget.ImageView +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper @@ -11,7 +11,7 @@ import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.extensions.* import kotlinx.android.synthetic.main.dialog_event_type.view.* -class UpdateEventTypeDialog(val activity: Activity, var eventType: EventType? = null, val callback: (eventType: EventType) -> Unit) { +class EditEventTypeDialog(val activity: Activity, var eventType: EventType? = null, val callback: (eventType: EventType) -> Unit) { var isNewEvent = eventType == null init { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/EditRepeatingEventDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/EditRepeatingEventDialog.kt index 8edae6610..7c64cde60 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/EditRepeatingEventDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/EditRepeatingEventDialog.kt @@ -1,7 +1,7 @@ package com.simplemobiletools.calendar.dialogs -import android.support.v7.app.AlertDialog import android.view.ViewGroup +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.SimpleActivity import com.simplemobiletools.commons.extensions.hideKeyboard diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ExportEventsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ExportEventsDialog.kt index 37f487556..ad4defc50 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ExportEventsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ExportEventsDialog.kt @@ -1,8 +1,8 @@ package com.simplemobiletools.calendar.dialogs -import android.support.v7.app.AlertDialog import android.view.ViewGroup import android.widget.LinearLayout +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.SimpleActivity import com.simplemobiletools.calendar.adapters.FilterEventTypeAdapter @@ -17,11 +17,11 @@ class ExportEventsDialog(val activity: SimpleActivity, val path: String, val cal init { val view = (activity.layoutInflater.inflate(R.layout.dialog_export_events, null) as ViewGroup).apply { export_events_folder.text = activity.humanizePath(path) - export_events_filename.setText("events_${activity.getCurrentFormattedDateTime()}") + export_events_filename.setText("${activity.getString(R.string.events)}_${activity.getCurrentFormattedDateTime()}") activity.dbHelper.getEventTypes { val eventTypes = HashSet() - it.mapTo(eventTypes, { it.id.toString() }) + it.mapTo(eventTypes) { it.id.toString() } activity.runOnUiThread { export_events_types_list.adapter = FilterEventTypeAdapter(activity, it, eventTypes) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/FilterEventTypesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/FilterEventTypesDialog.kt index 7ca3bb924..559ededca 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/FilterEventTypesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/FilterEventTypesDialog.kt @@ -1,6 +1,6 @@ package com.simplemobiletools.calendar.dialogs -import android.support.v7.app.AlertDialog +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.SimpleActivity import com.simplemobiletools.calendar.adapters.FilterEventTypeAdapter @@ -19,7 +19,7 @@ class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> U view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, eventTypes, displayEventTypes) dialog = AlertDialog.Builder(activity) - .setPositiveButton(R.string.ok, { dialogInterface, i -> confirmEventTypes() }) + .setPositiveButton(R.string.ok) { dialogInterface, i -> confirmEventTypes() } .setNegativeButton(R.string.cancel, null) .create().apply { activity.setupDialogStuff(view, this, R.string.filter_events_by_type) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ImportEventsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ImportEventsDialog.kt index b74a93420..51c8afed8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ImportEventsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/ImportEventsDialog.kt @@ -1,7 +1,7 @@ package com.simplemobiletools.calendar.dialogs -import android.support.v7.app.AlertDialog import android.view.ViewGroup +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.SimpleActivity import com.simplemobiletools.calendar.extensions.config diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatLimitTypePickerDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatLimitTypePickerDialog.kt index e7cbe8e98..e14b1dec8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatLimitTypePickerDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatLimitTypePickerDialog.kt @@ -1,10 +1,9 @@ package com.simplemobiletools.calendar.dialogs -import android.annotation.SuppressLint import android.app.Activity import android.app.DatePickerDialog -import android.support.v7.app.AlertDialog import android.view.View +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.seconds @@ -13,7 +12,6 @@ import com.simplemobiletools.calendar.helpers.getNowSeconds import com.simplemobiletools.commons.extensions.getDialogTheme import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.value -import com.simplemobiletools.commons.helpers.isLollipopPlus import kotlinx.android.synthetic.main.dialog_repeat_limit_type_picker.view.* import org.joda.time.DateTime import java.util.* @@ -25,14 +23,18 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Int, init { view = activity.layoutInflater.inflate(R.layout.dialog_repeat_limit_type_picker, null).apply { repeat_type_date.setOnClickListener { showRepetitionLimitDialog() } - repeat_type_forever.setOnClickListener { callback(0); dialog.dismiss() } repeat_type_count.setOnClickListener { dialog_radio_view.check(R.id.repeat_type_x_times) } + repeat_type_forever.setOnClickListener { + callback(0) + dialog.dismiss() + } } view.dialog_radio_view.check(getCheckedItem()) - if (repeatLimit in 1..startTS) + if (repeatLimit in 1..startTS) { repeatLimit = startTS + } updateRepeatLimitText() @@ -80,16 +82,12 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Int, dialog.dismiss() } - @SuppressLint("NewApi") private fun showRepetitionLimitDialog() { val repeatLimitDateTime = Formatter.getDateTimeFromTS(if (repeatLimit != 0) repeatLimit else getNowSeconds()) val datepicker = DatePickerDialog(activity, activity.getDialogTheme(), repetitionLimitDateSetListener, repeatLimitDateTime.year, repeatLimitDateTime.monthOfYear - 1, repeatLimitDateTime.dayOfMonth) - if (isLollipopPlus()) { - datepicker.datePicker.firstDayOfWeek = if (activity.config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY - } - + datepicker.datePicker.firstDayOfWeek = if (activity.config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY datepicker.show() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatRuleWeeklyDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatRuleWeeklyDialog.kt index b6d303990..06c852633 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatRuleWeeklyDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/RepeatRuleWeeklyDialog.kt @@ -1,7 +1,7 @@ package com.simplemobiletools.calendar.dialogs import android.app.Activity -import android.support.v7.app.AlertDialog +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.commons.extensions.setupDialogStuff diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt index 44b9915e1..12c7ec603 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectCalendarsDialog.kt @@ -1,10 +1,10 @@ package com.simplemobiletools.calendar.dialogs -import android.support.v7.app.AlertDialog -import android.support.v7.widget.SwitchCompat import android.text.TextUtils import android.view.ViewGroup import android.widget.RelativeLayout +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.widget.SwitchCompat import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.SimpleActivity import com.simplemobiletools.calendar.extensions.config @@ -33,7 +33,7 @@ class SelectCalendarsDialog(val activity: SimpleActivity, val callback: () -> Un } dialog = AlertDialog.Builder(activity) - .setPositiveButton(R.string.ok, { dialogInterface, i -> confirmSelection() }) + .setPositiveButton(R.string.ok) { dialogInterface, i -> confirmSelection() } .setNegativeButton(R.string.cancel, null) .create().apply { activity.setupDialogStuff(view, this, R.string.select_caldav_calendars) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventCalendarDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventCalendarDialog.kt index c8d175f49..f7e182f22 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventCalendarDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventCalendarDialog.kt @@ -2,10 +2,10 @@ package com.simplemobiletools.calendar.dialogs import android.app.Activity import android.graphics.Color -import android.support.v7.app.AlertDialog import android.view.ViewGroup import android.widget.RadioButton import android.widget.RadioGroup +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper @@ -29,6 +29,11 @@ class SelectEventCalendarDialog(val activity: Activity, val calendars: List Unit) { @@ -22,8 +22,11 @@ class SelectEventTypeColorDialog(val activity: Activity, val eventType: EventTyp private val colors = CalDAVHandler(activity.applicationContext).getAvailableCalDAVCalendarColors(eventType) init { - val view = activity.layoutInflater.inflate(R.layout.dialog_select_radio_group, null) as ViewGroup - radioGroup = view.dialog_radio_group + val view = activity.layoutInflater.inflate(R.layout.dialog_select_event_type_color, null) as ViewGroup + radioGroup = view.dialog_select_event_type_color_radio + view.dialog_select_event_type_other_value.setOnClickListener { + showCustomColorPicker() + } colors.forEachIndexed { index, value -> addRadioButton(index, value) @@ -33,21 +36,25 @@ class SelectEventTypeColorDialog(val activity: Activity, val eventType: EventTyp dialog = AlertDialog.Builder(activity) .create().apply { activity.setupDialogStuff(view, this) + + if (colors.isEmpty()) { + showCustomColorPicker() + } } } private fun addRadioButton(colorKey: Int, color: Int) { val view = activity.layoutInflater.inflate(R.layout.radio_button_with_color, null) (view.dialog_radio_button as RadioButton).apply { - text = String.format("#%06X", 0xFFFFFF and color) + text = if (color == 0) activity.getString(R.string.transparent) else String.format("#%06X", 0xFFFFFF and color) isChecked = color == eventType.color id = colorKey } - if (color != Color.TRANSPARENT) - view.dialog_radio_color.setFillWithStroke(color, activity.config.backgroundColor) - - view.setOnClickListener { viewClicked(colorKey) } + view.dialog_radio_color.setFillWithStroke(color, activity.config.backgroundColor) + view.setOnClickListener { + viewClicked(colorKey) + } radioGroup.addView(view, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)) } @@ -58,4 +65,13 @@ class SelectEventTypeColorDialog(val activity: Activity, val eventType: EventTyp callback(colors[colorKey]) dialog?.dismiss() } + + private fun showCustomColorPicker() { + ColorPickerDialog(activity, activity.config.primaryColor) { wasPositivePressed, color -> + if (wasPositivePressed) { + callback(color) + } + dialog?.dismiss() + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventTypeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventTypeDialog.kt index 047f3d9b8..ecdda2f5f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventTypeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/dialogs/SelectEventTypeDialog.kt @@ -2,9 +2,9 @@ package com.simplemobiletools.calendar.dialogs import android.app.Activity import android.graphics.Color -import android.support.v7.app.AlertDialog import android.view.ViewGroup import android.widget.RadioGroup +import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper @@ -72,7 +72,7 @@ class SelectEventTypeDialog(val activity: Activity, val currEventType: Int, val } if (eventType.id == NEW_TYPE_ID) { - UpdateEventTypeDialog(activity) { + EditEventTypeDialog(activity) { callback(it) activity.hideKeyboard() dialog?.dismiss() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Activity.kt index 600770afb..d0605eacc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Activity.kt @@ -55,9 +55,9 @@ fun Activity.showEventRepeatIntervalDialog(curSeconds: Int, callback: (minutes: } val items = ArrayList(seconds.size + 1) - seconds.mapIndexedTo(items, { index, value -> + seconds.mapIndexedTo(items) { index, value -> RadioItem(index, getRepetitionText(value), value) - }) + } var selectedIndex = 0 seconds.forEachIndexed { index, value -> diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index c03dde088..db932745c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -14,13 +14,13 @@ import android.media.AudioAttributes import android.net.Uri import android.os.Bundle import android.provider.CalendarContract -import android.support.v4.app.AlarmManagerCompat -import android.support.v4.app.NotificationCompat import android.view.Gravity import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView +import androidx.core.app.AlarmManagerCompat +import androidx.core.app.NotificationCompat import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.EventActivity import com.simplemobiletools.calendar.activities.SimpleActivity @@ -85,7 +85,7 @@ fun Context.scheduleNextEventReminder(event: Event, dbHelper: DBHelper, activity val now = getNowSeconds() val reminderSeconds = event.getReminders().reversed().map { it * 60 } - dbHelper.getEvents(now, now + YEAR, event.id) { + dbHelper.getEvents(now, now + YEAR, event.id, false) { if (it.isNotEmpty()) { for (curEvent in it) { for (curReminder in reminderSeconds) { @@ -146,11 +146,6 @@ fun Context.getRepetitionText(seconds: Int) = when (seconds) { } } -fun Context.getFilteredEvents(events: List): ArrayList { - val displayEventTypes = config.displayEventTypes - return events.filter { displayEventTypes.contains(it.eventType.toString()) } as ArrayList -} - fun Context.notifyRunningEvents() { dbHelper.getRunningEvents().filter { it.getReminders().isNotEmpty() }.forEach { notifyEvent(it) @@ -453,7 +448,7 @@ fun Context.handleEventDeleting(eventIds: List, timestamps: List, acti } } DELETE_ALL_OCCURRENCES -> { - val eventIDs = Array(eventIds.size, { i -> (eventIds[i].toString()) }) + val eventIDs = Array(eventIds.size) { i -> (eventIds[i].toString()) } dbHelper.deleteEvents(eventIDs, true) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt index 84ede6be3..94fe46231 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragment.kt @@ -2,20 +2,19 @@ package com.simplemobiletools.calendar.fragments import android.content.Intent import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.DatePicker import android.widget.RelativeLayout +import androidx.appcompat.app.AlertDialog +import androidx.fragment.app.Fragment import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.EventActivity import com.simplemobiletools.calendar.activities.SimpleActivity import com.simplemobiletools.calendar.adapters.DayEventsAdapter import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper -import com.simplemobiletools.calendar.extensions.getFilteredEvents import com.simplemobiletools.calendar.helpers.DAY_CODE import com.simplemobiletools.calendar.helpers.EVENT_ID import com.simplemobiletools.calendar.helpers.EVENT_OCCURRENCE_TS @@ -106,21 +105,20 @@ class DayFragment : Fragment() { fun updateCalendar() { val startTS = Formatter.getDayStartTS(mDayCode) val endTS = Formatter.getDayEndTS(mDayCode) - context?.dbHelper?.getEvents(startTS, endTS) { + context?.dbHelper?.getEvents(startTS, endTS, applyTypeFilter = true) { receivedEvents(it) } } private fun receivedEvents(events: List) { - val filtered = context?.getFilteredEvents(events) ?: ArrayList() - val newHash = filtered.hashCode() + val newHash = events.hashCode() if (newHash == lastHash || !isAdded) { return } lastHash = newHash val replaceDescription = context!!.config.replaceDescription - val sorted = ArrayList(filtered.sortedWith(compareBy({ !it.getIsAllDay() }, { it.startTS }, { it.endTS }, { it.title }, { + val sorted = ArrayList(events.sortedWith(compareBy({ !it.getIsAllDay() }, { it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragmentsHolder.kt index dd39768f5..6d53d763f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/DayFragmentsHolder.kt @@ -2,10 +2,10 @@ package com.simplemobiletools.calendar.fragments import android.graphics.drawable.ColorDrawable import android.os.Bundle -import android.support.v4.view.ViewPager import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.viewpager.widget.ViewPager import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.MainActivity import com.simplemobiletools.calendar.adapters.MyDayPagerAdapter diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt index 1bec543f7..087064724 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt @@ -76,7 +76,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener { maxFetchedTS = DateTime().plusMonths(6).seconds() } - context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS) { + context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS, applyTypeFilter = true) { if (it.size >= MIN_EVENTS_TRESHOLD) { receivedEvents(it, false) } else { @@ -84,7 +84,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener { minFetchedTS -= FETCH_INTERVAL maxFetchedTS += FETCH_INTERVAL } - context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS) { + context!!.dbHelper.getEvents(minFetchedTS, maxFetchedTS, applyTypeFilter = true) { mEvents = it receivedEvents(mEvents, false, !wereInitialEventsAdded) } @@ -98,7 +98,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener { return } - mEvents = context!!.getFilteredEvents(events) + mEvents = events val listItems = context!!.getEventListItems(mEvents) activity?.runOnUiThread { @@ -150,7 +150,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener { private fun fetchPreviousPeriod() { val oldMinFetchedTS = minFetchedTS - 1 minFetchedTS -= FETCH_INTERVAL - context!!.dbHelper.getEvents(minFetchedTS, oldMinFetchedTS) { + context!!.dbHelper.getEvents(minFetchedTS, oldMinFetchedTS, applyTypeFilter = true) { mEvents.addAll(0, it) receivedEvents(mEvents, false) } @@ -159,7 +159,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener { private fun fetchNextPeriod(scrollAfterUpdating: Boolean) { val oldMaxFetchedTS = maxFetchedTS + 1 maxFetchedTS += FETCH_INTERVAL - context!!.dbHelper.getEvents(oldMaxFetchedTS, maxFetchedTS) { + context!!.dbHelper.getEvents(oldMaxFetchedTS, maxFetchedTS, applyTypeFilter = true) { mEvents.addAll(it) receivedEvents(mEvents, scrollAfterUpdating) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt index 00bb4c80f..3d5e4762b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt @@ -3,8 +3,8 @@ package com.simplemobiletools.calendar.fragments import android.content.Context import android.content.res.Resources import android.os.Bundle -import android.support.v4.app.Fragment -import android.support.v7.app.AlertDialog +import androidx.fragment.app.Fragment +import androidx.appcompat.app.AlertDialog import android.view.LayoutInflater import android.view.View import android.view.ViewGroup diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragmentsHolder.kt index 6d9d22815..8e634f487 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragmentsHolder.kt @@ -2,10 +2,10 @@ package com.simplemobiletools.calendar.fragments import android.graphics.drawable.ColorDrawable import android.os.Bundle -import android.support.v4.view.ViewPager import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.viewpager.widget.ViewPager import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.MainActivity import com.simplemobiletools.calendar.adapters.MyMonthPagerAdapter diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MyFragmentHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MyFragmentHolder.kt index f8c477db7..cc4d8452c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MyFragmentHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MyFragmentHolder.kt @@ -1,6 +1,6 @@ package com.simplemobiletools.calendar.fragments -import android.support.v4.app.Fragment +import androidx.fragment.app.Fragment abstract class MyFragmentHolder : Fragment() { abstract fun goToToday() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt index 8105e60f7..f2b75a78a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt @@ -5,17 +5,19 @@ import android.content.res.Resources import android.graphics.Rect import android.graphics.drawable.ColorDrawable import android.os.Bundle -import android.support.v4.app.Fragment import android.util.SparseIntArray -import android.view.* +import android.view.LayoutInflater +import android.view.MotionEvent +import android.view.View +import android.view.ViewGroup import android.widget.ImageView import android.widget.RelativeLayout import android.widget.TextView +import androidx.fragment.app.Fragment import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.EventActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper -import com.simplemobiletools.calendar.extensions.getFilteredEvents import com.simplemobiletools.calendar.extensions.seconds import com.simplemobiletools.calendar.helpers.* import com.simplemobiletools.calendar.helpers.Formatter @@ -61,6 +63,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { lateinit var mScrollView: MyScrollView lateinit var mCalendar: WeeklyCalendarImpl lateinit var mRes: Resources + lateinit var mConfig: Config override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -68,12 +71,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { it.map { eventTypeColors.put(it.id, it.color) } } - mRowHeight = context!!.resources.getDimension(R.dimen.weekly_view_row_height) - minScrollY = (mRowHeight * context!!.config.startWeeklyAt).toInt() + mRes = context!!.resources + mConfig = context!!.config + mRowHeight = mRes.getDimension(R.dimen.weekly_view_row_height) + minScrollY = (mRowHeight * mConfig.startWeeklyAt).toInt() mWeekTimestamp = arguments!!.getInt(WEEK_START_TIMESTAMP) - dimPastEvents = context!!.config.dimPastEvents + dimPastEvents = mConfig.dimPastEvents primaryColor = context!!.getAdjustedPrimaryColor() - mRes = resources allDayRows.add(HashSet()) mCalendar = WeeklyCalendarImpl(this, context!!) } @@ -97,11 +101,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { return mView } - override fun onPause() { - super.onPause() - wasExtraHeightAdded = true - } - override fun onResume() { super.onResume() setupDayLabels() @@ -112,8 +111,8 @@ class WeekFragment : Fragment(), WeeklyCalendar { return@onGlobalLayout } - minScrollY = (mRowHeight * context!!.config.startWeeklyAt).toInt() - maxScrollY = (mRowHeight * context!!.config.endWeeklyAt).toInt() + minScrollY = (mRowHeight * mConfig.startWeeklyAt).toInt() + maxScrollY = (mRowHeight * mConfig.endWeeklyAt).toInt() val bounds = Rect() week_events_holder.getGlobalVisibleRect(bounds) @@ -125,6 +124,16 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + override fun onPause() { + super.onPause() + wasExtraHeightAdded = true + } + + override fun onDestroyView() { + super.onDestroyView() + mWasDestroyed = true + } + override fun setMenuVisibility(menuVisible: Boolean) { super.setMenuVisibility(menuVisible) isFragmentVisible = menuVisible @@ -140,11 +149,11 @@ class WeekFragment : Fragment(), WeeklyCalendar { private fun setupDayLabels() { var curDay = Formatter.getDateTimeFromTS(mWeekTimestamp) - val textColor = context!!.config.textColor + val textColor = mConfig.textColor val todayCode = Formatter.getDayCodeFromDateTime(DateTime()) for (i in 0..6) { val dayCode = Formatter.getDayCodeFromDateTime(curDay) - val dayLetters = mRes.getStringArray(R.array.week_day_letters).toList() as ArrayList + val dayLetters = mRes.getStringArray(R.array.week_day_letters).toMutableList() as ArrayList val dayLetter = dayLetters[curDay.dayOfWeek - 1] mView.findViewById(mRes.getIdentifier("week_day_label_$i", "id", context!!.packageName)).apply { @@ -187,7 +196,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { selectedGrid?.animation?.cancel() selectedGrid?.beGone() - //val rowHeight = resources.getDimension(R.dimen.weekly_view_row_height) val hour = (event.y / mRowHeight).toInt() selectedGrid = (inflater.inflate(R.layout.week_grid_item, null, false) as ImageView).apply { view.addView(this) @@ -215,25 +223,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { } override fun updateWeeklyCalendar(events: ArrayList) { - if (context == null) { - return - } - - val newEvents = context!!.getFilteredEvents(events) - val newHash = newEvents.hashCode() - if (newHash == lastHash) { + val newHash = events.hashCode() + if (newHash == lastHash || mWasDestroyed || context == null) { return } lastHash = newHash - this.events = newEvents - updateEvents() - } - - private fun updateEvents() { - if (mWasDestroyed) { - return - } + this.events = events activity!!.runOnUiThread { if (context != null && activity != null && isAdded) { @@ -256,7 +252,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val minimalHeight = mRes.getDimension(R.dimen.weekly_view_minimal_event_height).toInt() var hadAllDayEvent = false - val replaceDescription = context!!.config.replaceDescription + val replaceDescription = mConfig.replaceDescription val sorted = events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description })) for (event in sorted) { if (event.getIsAllDay() || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) { @@ -265,7 +261,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { } else { val startDateTime = Formatter.getDateTimeFromTS(event.startTS) val endDateTime = Formatter.getDateTimeFromTS(event.endTS) - val dayOfWeek = startDateTime.plusDays(if (context!!.config.isSundayFirst) 1 else 0).dayOfWeek - 1 + val dayOfWeek = startDateTime.plusDays(if (mConfig.isSundayFirst) 1 else 0).dayOfWeek - 1 val layout = getColumnWithId(dayOfWeek) val startMinutes = startDateTime.minuteOfDay @@ -320,7 +316,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { applyColorFilter(primaryColor) mView.week_events_holder.addView(this, 0) val extraWidth = (todayColumn.width * 0.3).toInt() - val markerHeight = resources.getDimension(R.dimen.weekly_view_now_height).toInt() + val markerHeight = mRes.getDimension(R.dimen.weekly_view_now_height).toInt() (layoutParams as RelativeLayout.LayoutParams).apply { width = todayColumn.width + extraWidth height = markerHeight @@ -332,14 +328,11 @@ class WeekFragment : Fragment(), WeeklyCalendar { } private fun checkTopHolderHeight() { - mView.week_top_holder.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { - override fun onGlobalLayout() { - mView.week_top_holder.viewTreeObserver.removeOnGlobalLayoutListener(this) - if (isFragmentVisible && activity != null) { - mListener?.updateHoursTopMargin(mView.week_top_holder.height) - } + mView.week_top_holder.onGlobalLayout { + if (isFragmentVisible && activity != null && !mWasDestroyed) { + mListener?.updateHoursTopMargin(mView.week_top_holder.height) } - }) + } } private fun addAllDayEvent(event: Event) { @@ -363,7 +356,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val daysCnt = Days.daysBetween(Formatter.getDateTimeFromTS(minTS).toLocalDate(), Formatter.getDateTimeFromTS(maxTS).toLocalDate()).days val startDateTimeInWeek = Formatter.getDateTimeFromTS(minTS) - val firstDayIndex = (startDateTimeInWeek.dayOfWeek - if (context!!.config.isSundayFirst) 0 else 1) % 7 + val firstDayIndex = (startDateTimeInWeek.dayOfWeek - if (mConfig.isSundayFirst) 0 else 1) % 7 var doesEventFit: Boolean val cnt = allDayRows.size - 1 var wasEventHandled = false @@ -417,12 +410,8 @@ class WeekFragment : Fragment(), WeeklyCalendar { } private fun calculateExtraHeight() { - mView.week_top_holder.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { - override fun onGlobalLayout() { - if (activity == null) - return - - mView.week_top_holder.viewTreeObserver.removeOnGlobalLayoutListener(this) + mView.week_top_holder.onGlobalLayout { + if (activity != null && !mWasDestroyed) { if (isFragmentVisible) { mListener?.updateHoursTopMargin(mView.week_top_holder.height) } @@ -432,12 +421,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { wasExtraHeightAdded = true } } - }) - } - - override fun onDestroyView() { - super.onDestroyView() - mWasDestroyed = true + } } private fun getColumnWithId(id: Int) = mView.findViewById(mRes.getIdentifier("week_column_$id", "id", context!!.packageName)) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragmentsHolder.kt index a2e431d24..049cd03eb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragmentsHolder.kt @@ -2,11 +2,11 @@ package com.simplemobiletools.calendar.fragments import android.graphics.drawable.ColorDrawable import android.os.Bundle -import android.support.v4.view.ViewPager import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView +import androidx.viewpager.widget.ViewPager import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.activities.MainActivity import com.simplemobiletools.calendar.adapters.MyWeekPagerAdapter @@ -67,11 +67,9 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { weekHolder!!.week_view_view_pager.apply { adapter = weeklyAdapter 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) { currentWeekTS = weekTSs[position] diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt index 38d9a2ce6..d17350ab9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt @@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.fragments import android.content.res.Resources import android.os.Bundle -import android.support.v4.app.Fragment +import androidx.fragment.app.Fragment import android.util.SparseArray import android.view.LayoutInflater import android.view.View diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragmentsHolder.kt index d2740d8a5..7e6e69cf9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragmentsHolder.kt @@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.fragments import android.graphics.drawable.ColorDrawable import android.os.Bundle -import android.support.v4.view.ViewPager +import androidx.viewpager.widget.ViewPager import android.view.LayoutInflater import android.view.View import android.view.ViewGroup diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt index 8c95e8904..fd999139f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/CalDAVHandler.kt @@ -30,7 +30,6 @@ class CalDAVHandler(val context: Context) { title = calendar.displayName caldavDisplayName = calendar.displayName caldavEmail = calendar.accountName - color = calendar.color context.dbHelper.updateLocalEventType(this) } @@ -81,14 +80,13 @@ class CalDAVHandler(val context: Context) { return calendars } - fun updateCalDAVCalendar(eventType: EventType): Boolean { + fun updateCalDAVCalendar(eventType: EventType) { val uri = CalendarContract.Calendars.CONTENT_URI val values = fillCalendarContentValues(eventType) val newUri = ContentUris.withAppendedId(uri, eventType.caldavCalendarId.toLong()) - return try { - context.contentResolver.update(newUri, values, null, null) == 1 + try { + context.contentResolver.update(newUri, values, null, null) } catch (e: IllegalArgumentException) { - false } } @@ -119,53 +117,6 @@ class CalDAVHandler(val context: Context) { return -1 } - // it doesnt work properly, needs better SyncAdapter handling - private fun insertNewColor(eventType: EventType): Int { - val maxId = getMaxColorId(eventType) + 1 - - val values = ContentValues().apply { - put(CalendarContract.Colors.COLOR_KEY, maxId) - put(CalendarContract.Colors.COLOR, eventType.color) - put(CalendarContract.Colors.ACCOUNT_NAME, eventType.caldavEmail) - put(CalendarContract.Colors.ACCOUNT_TYPE, "com.google") - put(CalendarContract.Colors.COLOR_TYPE, CalendarContract.Colors.TYPE_CALENDAR) - } - - val uri = CalendarContract.Colors.CONTENT_URI.buildUpon() - .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true") - .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, eventType.caldavEmail) - .appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, "com.google") - .build() - - return if (context.contentResolver.insert(uri, values) != null) { - maxId - } else { - 0 - } - } - - private fun getMaxColorId(eventType: EventType): Int { - val uri = CalendarContract.Colors.CONTENT_URI - val projection = arrayOf(CalendarContract.Colors.COLOR_KEY, CalendarContract.Colors.COLOR) - val selection = "${CalendarContract.Colors.COLOR_TYPE} = ? AND ${CalendarContract.Colors.ACCOUNT_NAME} = ?" - val selectionArgs = arrayOf(CalendarContract.Colors.TYPE_CALENDAR.toString(), eventType.caldavEmail) - var maxId = 1 - - var cursor: Cursor? = null - try { - cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null) - if (cursor != null && cursor.moveToFirst()) { - do { - maxId = Math.max(maxId, cursor.getIntValue(CalendarContract.Colors.COLOR_KEY)) - } while (cursor.moveToNext()) - } - } finally { - cursor?.close() - } - - return maxId - } - fun getAvailableCalDAVCalendarColors(eventType: EventType): ArrayList { val colors = SparseIntArray() val uri = CalendarContract.Colors.CONTENT_URI @@ -309,9 +260,7 @@ class CalDAVHandler(val context: Context) { } } - eventIdsToDelete.forEach { - context.dbHelper.deleteEvents(eventIdsToDelete.toTypedArray(), false) - } + context.dbHelper.deleteEvents(eventIdsToDelete.toTypedArray(), false) } fun insertCalDAVEvent(event: Event) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt index 021c78bdf..f020cd363 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt @@ -52,7 +52,7 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getInt(VIEW, MONTHLY_VIEW) set(view) = prefs.edit().putInt(VIEW, view).apply() - var lastEventReminderMinutes: Int + var lastEventReminderMinutes1: Int get() = prefs.getInt(LAST_EVENT_REMINDER_MINUTES, 10) set(lastEventReminderMinutes) = prefs.edit().putInt(LAST_EVENT_REMINDER_MINUTES, lastEventReminderMinutes).apply() @@ -76,6 +76,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getInt(FONT_SIZE, FONT_SIZE_MEDIUM) set(size) = prefs.edit().putInt(FONT_SIZE, size).apply() + var listWidgetViewToOpen: Int + get() = prefs.getInt(LIST_WIDGET_VIEW_TO_OPEN, DAILY_VIEW) + set(viewToOpenFromListWidget) = prefs.edit().putInt(LIST_WIDGET_VIEW_TO_OPEN, viewToOpenFromListWidget).apply() + var caldavSync: Boolean get() = prefs.getBoolean(CALDAV_SYNC, false) set(caldavSync) { @@ -158,4 +162,8 @@ class Config(context: Context) : BaseConfig(context) { var defaultReminder3: Int get() = prefs.getInt(DEFAULT_REMINDER_3, REMINDER_OFF) set(defaultReminder3) = prefs.edit().putInt(DEFAULT_REMINDER_3, defaultReminder3).apply() + + var pullToRefresh: Boolean + get() = prefs.getBoolean(PULL_TO_REFRESH, false) + set(pullToRefresh) = prefs.edit().putBoolean(PULL_TO_REFRESH, pullToRefresh).apply() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt index ce736e0e7..af6b78735 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -14,13 +14,14 @@ const val WEEK_START_TIMESTAMP = "week_start_timestamp" const val NEW_EVENT_SET_HOUR_DURATION = "new_event_set_hour_duration" const val WEEK_START_DATE_TIME = "week_start_date_time" const val CALDAV = "Caldav" -const val OPEN_MONTH = "open_month" +const val VIEW_TO_OPEN = "view_to_open" const val MONTHLY_VIEW = 1 const val YEARLY_VIEW = 2 const val EVENTS_LIST_VIEW = 3 const val WEEKLY_VIEW = 4 const val DAILY_VIEW = 5 +const val LAST_VIEW = 6 const val REMINDER_OFF = -1 @@ -46,6 +47,7 @@ const val LAST_EVENT_REMINDER_MINUTES_2 = "reminder_minutes_2" const val LAST_EVENT_REMINDER_MINUTES_3 = "reminder_minutes_3" const val DISPLAY_EVENT_TYPES = "display_event_types" const val FONT_SIZE = "font_size" +const val LIST_WIDGET_VIEW_TO_OPEN = "list_widget_view_to_open" const val CALDAV_SYNC = "caldav_sync" const val CALDAV_SYNCED_CALENDAR_IDS = "caldav_synced_calendar_ids" const val LAST_USED_CALDAV_CALENDAR = "last_used_caldav_calendar" @@ -62,6 +64,7 @@ const val USE_PREVIOUS_EVENT_REMINDERS = "use_previous_event_reminders" const val DEFAULT_REMINDER_1 = "default_reminder_1" const val DEFAULT_REMINDER_2 = "default_reminder_2" const val DEFAULT_REMINDER_3 = "default_reminder_3" +const val PULL_TO_REFRESH = "pull_to_refresh" // repeat_rule for monthly and yearly repetition const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index a7299e313..d1879c862 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -320,15 +320,11 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } fun updateEventType(eventType: EventType): Int { - return if (eventType.caldavCalendarId != 0) { - if (CalDAVHandler(context).updateCalDAVCalendar(eventType)) { - updateLocalEventType(eventType) - } else { - -1 - } - } else { - updateLocalEventType(eventType) + if (eventType.caldavCalendarId != 0) { + CalDAVHandler(context).updateCalDAVCalendar(eventType) } + + return updateLocalEventType(eventType) } fun updateLocalEventType(eventType: EventType): Int { @@ -573,7 +569,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } fun deleteEventTypes(eventTypes: ArrayList, deleteEvents: Boolean, callback: (deletedCnt: Int) -> Unit) { - var deleteIds = eventTypes.filter { it.caldavCalendarId == 0 }.map { it.id } + var deleteIds = eventTypes.asSequence().filter { it.caldavCalendarId == 0 }.map { it.id }.toList() deleteIds = deleteIds.filter { it != DBHelper.REGULAR_EVENT_TYPE_ID } as ArrayList val deletedSet = HashSet() @@ -606,7 +602,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val selectionArgs = arrayOf(eventTypeId.toString()) val cursor = getEventsCursor(selection, selectionArgs) val events = fillEvents(cursor) - val eventIDs = Array(events.size, { i -> (events[i].id.toString()) }) + val eventIDs = Array(events.size) { i -> (events[i].id.toString()) } deleteEvents(eventIDs, true) } @@ -681,37 +677,58 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont }.start() } - fun getEvents(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: ArrayList) -> Unit) { + fun getEvents(fromTS: Int, toTS: Int, eventId: Int = -1, applyTypeFilter: Boolean = false, callback: (events: ArrayList) -> Unit) { Thread { - getEventsInBackground(fromTS, toTS, eventId, callback) + getEventsInBackground(fromTS, toTS, eventId, applyTypeFilter, callback) }.start() } - fun getEventsInBackground(fromTS: Int, toTS: Int, eventId: Int = -1, callback: (events: ArrayList) -> Unit) { - val events = ArrayList() + fun getEventsInBackground(fromTS: Int, toTS: Int, eventId: Int = -1, applyTypeFilter: Boolean, callback: (events: ArrayList) -> Unit) { + var events = ArrayList() var selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS NULL AND $COL_START_TS != 0" if (eventId != -1) selection += " AND $MAIN_TABLE_NAME.$COL_ID = $eventId" + + if (applyTypeFilter) { + val displayEventTypes = context.config.displayEventTypes + if (displayEventTypes.isNotEmpty()) { + val types = TextUtils.join(",", displayEventTypes) + selection += " AND $COL_EVENT_TYPE IN ($types)" + } + } + val selectionArgs = arrayOf(toTS.toString(), fromTS.toString()) val cursor = getEventsCursor(selection, selectionArgs) events.addAll(fillEvents(cursor)) - events.addAll(getRepeatableEventsFor(fromTS, toTS, eventId)) + events.addAll(getRepeatableEventsFor(fromTS, toTS, eventId, applyTypeFilter)) - events.addAll(getAllDayEvents(fromTS, eventId)) + events.addAll(getAllDayEvents(fromTS, eventId, applyTypeFilter)) - val filtered = events.distinct().filterNot { it.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) } as ArrayList - callback(filtered) + events = events + .asSequence() + .distinct() + .filterNot { it.ignoreEventOccurrences.contains(Formatter.getDayCodeFromTS(it.startTS).toInt()) } + .toMutableList() as ArrayList + callback(events) } - fun getRepeatableEventsFor(fromTS: Int, toTS: Int, eventId: Int = -1): List { + fun getRepeatableEventsFor(fromTS: Int, toTS: Int, eventId: Int = -1, applyTypeFilter: Boolean = false): List { val newEvents = ArrayList() - // get repeatable events var selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS <= $toTS AND $COL_START_TS != 0" if (eventId != -1) selection += " AND $MAIN_TABLE_NAME.$COL_ID = $eventId" + + if (applyTypeFilter) { + val displayEventTypes = context.config.displayEventTypes + if (displayEventTypes.isNotEmpty()) { + val types = TextUtils.join(",", displayEventTypes) + selection += " AND $COL_EVENT_TYPE IN ($types)" + } + } + val events = getEvents(selection) val startTimes = SparseIntArray(events.size) events.forEach { @@ -792,19 +809,27 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont return events } - private fun getAllDayEvents(fromTS: Int, eventId: Int = -1): List { + private fun getAllDayEvents(fromTS: Int, eventId: Int = -1, applyTypeFilter: Boolean = false): List { val events = ArrayList() var selection = "($COL_FLAGS & $FLAG_ALL_DAY) != 0" if (eventId != -1) selection += " AND $MAIN_TABLE_NAME.$COL_ID = $eventId" + if (applyTypeFilter) { + val displayEventTypes = context.config.displayEventTypes + if (displayEventTypes.isNotEmpty()) { + val types = TextUtils.join(",", displayEventTypes) + selection += " AND $COL_EVENT_TYPE IN ($types)" + } + } + val dayCode = Formatter.getDayCodeFromTS(fromTS) val cursor = getEventsCursor(selection) events.addAll(fillEvents(cursor).filter { dayCode == Formatter.getDayCodeFromTS(it.startTS) }) return events } - // check if its the proper week, for events repeating by x weeks + // check if its the proper week, for events repeating every x weeks private fun isOnProperWeek(event: Event, startTimes: SparseIntArray): Boolean { val initialWeekOfYear = Formatter.getDateTimeFromTS(startTimes[event.id]).weekOfWeekyear val currentWeekOfYear = Formatter.getDateTimeFromTS(event.startTS).weekOfWeekyear @@ -959,7 +984,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } fun getEventTypesSync(): ArrayList { - val eventTypes = ArrayList(4) + val eventTypes = ArrayList() val cols = arrayOf(COL_TYPE_ID, COL_TYPE_TITLE, COL_TYPE_COLOR, COL_TYPE_CALDAV_CALENDAR_ID, COL_TYPE_CALDAV_DISPLAY_NAME, COL_TYPE_CALDAV_EMAIL) var cursor: Cursor? = null try { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt index 00ab84218..352dbdb56 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt @@ -15,7 +15,7 @@ object Formatter { const val TIME_PATTERN = "HHmmss" private const val DAY_PATTERN = "d" private const val DAY_OF_WEEK_PATTERN = "EEE" - private const val LONGEST_PATTERN = "MMMM dd YYYY (EEEE)" + private const val LONGEST_PATTERN = "MMMM d YYYY (EEEE)" private const val PATTERN_TIME_12 = "hh:mm a" private const val PATTERN_TIME_24 = "HH:mm" @@ -26,7 +26,7 @@ object Formatter { val dateTime = getDateTimeFromCode(dayCode) val day = dateTime.toString(DAY_PATTERN) val year = dateTime.toString(YEAR_PATTERN) - val monthIndex = Integer.valueOf(dayCode.substring(4, 6))!! + val monthIndex = Integer.valueOf(dayCode.substring(4, 6)) var month = getMonthName(context, monthIndex) if (shortMonth) month = month.substring(0, Math.min(month.length, 3)) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt index 74b928f2c..d9a5b2c9d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt @@ -140,8 +140,8 @@ class IcsImporter(val activity: SimpleActivity) { val eventType = eventTypes.firstOrNull { it.id == curEventTypeId } val source = if (calDAVCalendarId == 0 || eventType?.isSyncedEventType() == false) SOURCE_IMPORTED_ICS else "$CALDAV-$calDAVCalendarId" - val event = Event(0, curStart, curEnd, curTitle, curDescription, curReminderMinutes.getOrElse(0, { -1 }), - curReminderMinutes.getOrElse(1, { -1 }), curReminderMinutes.getOrElse(2, { -1 }), curRepeatInterval, + val event = Event(0, curStart, curEnd, curTitle, curDescription, curReminderMinutes.getOrElse(0) { -1 }, + curReminderMinutes.getOrElse(1) { -1 }, curReminderMinutes.getOrElse(2) { -1 }, curRepeatInterval, curImportId, curFlags, curRepeatLimit, curRepeatRule, curEventTypeId, lastUpdated = curLastModified, source = source, location = curLocation) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MonthlyCalendarImpl.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MonthlyCalendarImpl.kt index 1a8fc6847..ab30af79b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MonthlyCalendarImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MonthlyCalendarImpl.kt @@ -3,7 +3,6 @@ package com.simplemobiletools.calendar.helpers import android.content.Context import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper -import com.simplemobiletools.calendar.extensions.getFilteredEvents import com.simplemobiletools.calendar.extensions.seconds import com.simplemobiletools.calendar.interfaces.MonthlyCalendar import com.simplemobiletools.calendar.models.DayMonthly @@ -12,22 +11,20 @@ import org.joda.time.DateTime import java.util.* import kotlin.collections.ArrayList -class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context) { +class MonthlyCalendarImpl(val callback: MonthlyCalendar, val context: Context) { private val DAYS_CNT = 42 private val YEAR_PATTERN = "YYYY" private val mToday: String = DateTime().toString(Formatter.DAYCODE_PATTERN) private var mEvents = ArrayList() - private var mFilterEventTypes = true lateinit var mTargetDate: DateTime - fun updateMonthlyCalendar(targetDate: DateTime, filterEventTypes: Boolean = true) { - mFilterEventTypes = filterEventTypes + fun updateMonthlyCalendar(targetDate: DateTime) { mTargetDate = targetDate val startTS = mTargetDate.minusDays(7).seconds() val endTS = mTargetDate.plusDays(43).seconds() - mContext.dbHelper.getEvents(startTS, endTS) { + context.dbHelper.getEvents(startTS, endTS, applyTypeFilter = true) { gotEvents(it) } } @@ -40,7 +37,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context) val days = ArrayList(DAYS_CNT) val currMonthDays = mTargetDate.dayOfMonth().maximumValue var firstDayIndex = mTargetDate.withDayOfMonth(1).dayOfWeek - if (!mContext.config.isSundayFirst) + if (!context.config.isSundayFirst) firstDayIndex -= 1 val prevMonthDays = mTargetDate.minusMonths(1).dayOfMonth().maximumValue @@ -79,13 +76,13 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context) if (markDaysWithEvents) { markDaysWithEvents(days) } else { - mCallback.updateMonthlyCalendar(mContext, monthName, days, false, mTargetDate) + callback.updateMonthlyCalendar(context, monthName, days, false, mTargetDate) } } // it works more often than not, dont touch private fun markDaysWithEvents(days: ArrayList) { - mContext.dbHelper.getEventTypes { + context.dbHelper.getEventTypes { val dayEvents = HashMap>() mEvents.forEach { val startDateTime = Formatter.getDateTimeFromTS(it.startTS) @@ -110,7 +107,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context) days.filter { dayEvents.keys.contains(it.code) }.forEach { it.dayEvents = dayEvents[it.code]!! } - mCallback.updateMonthlyCalendar(mContext, monthName, days, true, mTargetDate) + callback.updateMonthlyCalendar(context, monthName, days, true, mTargetDate) } } @@ -121,7 +118,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context) private val monthName: String get() { - var month = Formatter.getMonthName(mContext, mTargetDate.monthOfYear) + var month = Formatter.getMonthName(context, mTargetDate.monthOfYear) val targetYear = mTargetDate.toString(YEAR_PATTERN) if (targetYear != DateTime().toString(YEAR_PATTERN)) { month += " $targetYear" @@ -130,12 +127,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context) } private fun gotEvents(events: ArrayList) { - mEvents = if (mFilterEventTypes) { - mContext.getFilteredEvents(events) - } else { - events - } - + mEvents = events getDays(true) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt index 2e2903d86..320aaca6a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt @@ -18,7 +18,7 @@ import org.joda.time.DateTime class MyWidgetListProvider : AppWidgetProvider() { private val NEW_EVENT = "new_event" - private val LAUNCH_TODAY = "launch_today" + private val LAUNCH_CAL = "launch_cal" override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) { performUpdate(context) @@ -44,7 +44,7 @@ class MyWidgetListProvider : AppWidgetProvider() { views.setImageViewBitmap(R.id.widget_event_new_event, context.resources.getColoredBitmap(R.drawable.ic_plus, textColor)) setupIntent(context, views, NEW_EVENT, R.id.widget_event_new_event) - setupIntent(context, views, LAUNCH_TODAY, R.id.widget_event_list_today) + setupIntent(context, views, LAUNCH_CAL, R.id.widget_event_list_today) Intent(context, WidgetService::class.java).apply { data = Uri.parse(this.toUri(Intent.URI_INTENT_SCHEME)) @@ -74,14 +74,15 @@ class MyWidgetListProvider : AppWidgetProvider() { override fun onReceive(context: Context, intent: Intent) { when (intent.action) { NEW_EVENT -> context.launchNewEventIntent() - LAUNCH_TODAY -> launchDayActivity(context) + LAUNCH_CAL -> launchCalenderInDefaultView(context) else -> super.onReceive(context, intent) } } - private fun launchDayActivity(context: Context) { + private fun launchCalenderInDefaultView(context: Context) { (context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)).apply { putExtra(DAY_CODE, Formatter.getDayCodeFromDateTime(DateTime())) + putExtra(VIEW_TO_OPEN, context.config.listWidgetViewToOpen) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(this) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt index 06ca36113..ce1b699cf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetMonthlyProvider.kt @@ -49,7 +49,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() { private fun setupAppOpenIntent(context: Context, views: RemoteViews, id: Int, dayCode: String) { (context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)).apply { putExtra(DAY_CODE, dayCode) - putExtra(OPEN_MONTH, true) + putExtra(VIEW_TO_OPEN, MONTHLY_VIEW) val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode.substring(0, 6)), this, 0) views.setOnClickPendingIntent(id, pendingIntent) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/WeeklyCalendarImpl.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/WeeklyCalendarImpl.kt index ef777f8c1..3b2dfd4e6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/WeeklyCalendarImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/WeeklyCalendarImpl.kt @@ -7,15 +7,14 @@ import com.simplemobiletools.calendar.models.Event import com.simplemobiletools.commons.helpers.WEEK_SECONDS import java.util.* -class WeeklyCalendarImpl(val mCallback: WeeklyCalendar, val mContext: Context) { +class WeeklyCalendarImpl(val callback: WeeklyCalendar, val context: Context) { var mEvents = ArrayList() fun updateWeeklyCalendar(weekStartTS: Int) { - val startTS = weekStartTS - val endTS = startTS + WEEK_SECONDS - mContext.dbHelper.getEvents(startTS, endTS) { + val endTS = weekStartTS + WEEK_SECONDS + context.dbHelper.getEvents(weekStartTS, endTS, applyTypeFilter = true) { mEvents = it - mCallback.updateWeeklyCalendar(it) + callback.updateWeeklyCalendar(it) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/YearlyCalendarImpl.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/YearlyCalendarImpl.kt index ab1974cc3..3b8e34d5e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/YearlyCalendarImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/YearlyCalendarImpl.kt @@ -3,7 +3,6 @@ package com.simplemobiletools.calendar.helpers import android.content.Context import android.util.SparseArray import com.simplemobiletools.calendar.extensions.dbHelper -import com.simplemobiletools.calendar.extensions.getFilteredEvents import com.simplemobiletools.calendar.extensions.seconds import com.simplemobiletools.calendar.interfaces.YearlyCalendar import com.simplemobiletools.calendar.models.DayYearly @@ -17,16 +16,15 @@ class YearlyCalendarImpl(val callback: YearlyCalendar, val context: Context, val val startDateTime = DateTime().withTime(0, 0, 0, 0).withDate(year, 1, 1) val startTS = startDateTime.seconds() val endTS = startDateTime.plusYears(1).minusSeconds(1).seconds() - context.dbHelper.getEvents(startTS, endTS) { + context.dbHelper.getEvents(startTS, endTS, applyTypeFilter = true) { gotEvents(it) } } private fun gotEvents(events: MutableList) { - val filtered = context.getFilteredEvents(events) val arr = SparseArray>(12) - filtered.forEach { + events.forEach { val startDateTime = Formatter.getDateTimeFromTS(it.startTS) markDay(arr, startDateTime, it) @@ -41,7 +39,7 @@ class YearlyCalendarImpl(val callback: YearlyCalendar, val context: Context, val } } } - callback.updateYearlyCalendar(arr, filtered.hashCode()) + callback.updateYearlyCalendar(arr, events.hashCode()) } private fun markDay(arr: SparseArray>, dateTime: DateTime, event: Event) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/CalDAVCalendar.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/CalDAVCalendar.kt index b1f13316a..618cfd252 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/CalDAVCalendar.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/CalDAVCalendar.kt @@ -1,7 +1,7 @@ package com.simplemobiletools.calendar.models data class CalDAVCalendar(val id: Int, val displayName: String, val accountName: String, val accountType: String, val ownerName: String, - val color: Int, val accessLevel: Int) { + var color: Int, val accessLevel: Int) { fun canWrite() = accessLevel >= 500 fun getFullTitle() = "$displayName ($accountName)" diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/receivers/CalDAVSyncReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/receivers/CalDAVSyncReceiver.kt index 1bc2cbb96..f30cbe17c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/receivers/CalDAVSyncReceiver.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/receivers/CalDAVSyncReceiver.kt @@ -4,9 +4,12 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import com.simplemobiletools.calendar.extensions.recheckCalDAVCalendars +import com.simplemobiletools.calendar.extensions.updateWidgets class CalDAVSyncReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { - context.recheckCalDAVCalendars {} + context.recheckCalDAVCalendars { + context.updateWidgets() + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthView.kt index 39ed95476..5605953d8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthView.kt @@ -32,6 +32,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con private var paint: Paint private var eventTitlePaint: TextPaint private var gridPaint: Paint + private var config = context.config private var dayWidth = 0f private var dayHeight = 0f private var primaryColor = 0 @@ -54,9 +55,9 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con init { primaryColor = context.getAdjustedPrimaryColor() - textColor = context.config.textColor - showWeekNumbers = context.config.showWeekNumbers - dimPastEvents = context.config.dimPastEvents + textColor = config.textColor + showWeekNumbers = config.showWeekNumbers + dimPastEvents = config.dimPastEvents smallPadding = resources.displayMetrics.density.toInt() val normalTextSize = resources.getDimensionPixelSize(R.dimen.normal_text_size) @@ -86,7 +87,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con fun updateDays(newDays: ArrayList) { days = newDays - showWeekNumbers = context.config.showWeekNumbers + showWeekNumbers = config.showWeekNumbers horizontalOffset = if (showWeekNumbers) eventTitleHeight * 2 else 0 initWeekDayLetters() setupCurrentDayOfWeekIndex() @@ -111,7 +112,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con } } - allEvents = allEvents.sortedWith(compareBy({ -it.daysCnt }, { !it.isAllDay }, { it.startTS }, { it.startDayIndex }, { it.title })).toMutableList() as ArrayList + allEvents = allEvents.asSequence().sortedWith(compareBy({ -it.daysCnt }, { !it.isAllDay }, { it.startTS }, { it.startDayIndex }, { it.title })) + .toMutableList() as ArrayList } override fun onDraw(canvas: Canvas) { @@ -119,7 +121,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con dayVerticalOffsets.clear() measureDaySize(canvas) - if (context.config.showGrid) { + if (config.showGrid) { drawGrid(canvas) } @@ -149,7 +151,9 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con } } - drawEvents(canvas) + for (event in allEvents) { + drawEvent(event, canvas) + } } private fun drawGrid(canvas: Canvas) { @@ -188,7 +192,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con val weekDays = days.subList(i * 7, i * 7 + 7) weekNumberPaint.color = if (weekDays.any { it.isToday }) primaryColor else textColor - // fourth day of the week matters + // fourth day of the week determines the week of the year number val weekOfYear = days.getOrNull(i * 7 + 3)?.weekOfYear ?: 1 val id = "$weekOfYear:" val yPos = i * dayHeight + weekDaysLetterHeight @@ -203,12 +207,6 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con maxEventsPerDay = availableHeightForEvents / eventTitleHeight } - private fun drawEvents(canvas: Canvas) { - for (event in allEvents) { - drawEvent(event, canvas) - } - } - private fun drawEvent(event: MonthViewEvent, canvas: Canvas) { val verticalOffset = dayVerticalOffsets[event.startDayIndex] val xPos = event.startDayIndex % 7 * dayWidth + horizontalOffset @@ -302,8 +300,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con } private fun initWeekDayLetters() { - dayLetters = context.resources.getStringArray(R.array.week_day_letters).toList() as ArrayList - if (context.config.isSundayFirst) { + dayLetters = context.resources.getStringArray(R.array.week_day_letters).toMutableList() as ArrayList + if (config.isSundayFirst) { dayLetters.moveLastItemToFront() } } @@ -315,7 +313,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con } currDayOfWeek = DateTime().dayOfWeek - if (context.config.isSundayFirst) { + if (config.isSundayFirst) { currDayOfWeek %= 7 } else { currDayOfWeek-- diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthViewWrapper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthViewWrapper.kt index 0a3ff142d..a1ccea43e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthViewWrapper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/views/MonthViewWrapper.kt @@ -15,11 +15,11 @@ class MonthViewWrapper(context: Context, attrs: AttributeSet, defStyle: Int) : F private var dayWidth = 0f private var dayHeight = 0f private var weekDaysLetterHeight = 0 + private var horizontalOffset = 0 private var wereViewsAdded = false private var days = ArrayList() private var inflater: LayoutInflater private var monthView: MonthView - private var horizontalOffset = 0 private var dayClickCallback: ((day: DayMonthly) -> Unit)? = null constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/views/SmallMonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/views/SmallMonthView.kt index af53d3b8c..1ec5c8bfc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/views/SmallMonthView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/views/SmallMonthView.kt @@ -69,9 +69,9 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie super.onDraw(canvas) if (dayWidth == 0f) { dayWidth = if (isLandscape) { - (canvas.width / 9).toFloat() + width / 9f } else { - (canvas.width / 7).toFloat() + width / 7f } } diff --git a/app/src/main/res/layout/activity_day.xml b/app/src/main/res/layout/activity_day.xml index b484be2ad..84de6d093 100644 --- a/app/src/main/res/layout/activity_day.xml +++ b/app/src/main/res/layout/activity_day.xml @@ -1,5 +1,5 @@ - - + diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index c62364dfd..eac7ec4f2 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -17,8 +17,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/activity_margin" - android:layout_marginRight="@dimen/activity_margin" android:layout_marginTop="@dimen/activity_margin" + android:layout_marginRight="@dimen/activity_margin" android:hint="@string/title" android:inputType="textCapSentences" android:maxLength="180" @@ -45,15 +45,15 @@ @@ -64,8 +64,8 @@ android:layout_height="wrap_content" android:layout_below="@+id/event_location" android:layout_marginLeft="@dimen/activity_margin" - android:layout_marginRight="@dimen/activity_margin" android:layout_marginTop="@dimen/activity_margin" + android:layout_marginRight="@dimen/activity_margin" android:autoLink="all" android:gravity="top" android:hint="@string/description" @@ -80,8 +80,8 @@ android:layout_width="match_parent" android:layout_height="1px" android:layout_below="@+id/event_description" - android:layout_marginBottom="@dimen/normal_margin" android:layout_marginTop="@dimen/activity_margin" + android:layout_marginBottom="@dimen/normal_margin" android:background="@color/divider_grey" android:importantForAccessibility="no"/> @@ -89,11 +89,11 @@ android:id="@+id/event_time_image" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_alignBottom="@+id/event_all_day" - android:layout_alignTop="@+id/event_all_day" android:layout_below="@+id/event_description_divider" - android:layout_marginLeft="@dimen/normal_margin" + android:layout_alignTop="@+id/event_all_day" + android:layout_alignBottom="@+id/event_all_day" android:layout_marginStart="@dimen/normal_margin" + android:layout_marginLeft="@dimen/normal_margin" android:alpha="0.8" android:padding="@dimen/medium_margin" android:src="@drawable/ic_clock"/> @@ -102,17 +102,17 @@ android:id="@+id/event_all_day" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_below="@+id/event_description_divider" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" - android:layout_below="@+id/event_description_divider" - android:layout_marginEnd="@dimen/normal_margin" - android:layout_marginLeft="@dimen/small_margin" - android:layout_marginRight="@dimen/normal_margin" android:layout_marginStart="@dimen/small_margin" + android:layout_marginLeft="@dimen/small_margin" + android:layout_marginEnd="@dimen/normal_margin" + android:layout_marginRight="@dimen/normal_margin" android:layout_toEndOf="@+id/event_time_image" android:layout_toRightOf="@+id/event_time_image" - android:paddingBottom="@dimen/normal_margin" android:paddingTop="@dimen/normal_margin" + android:paddingBottom="@dimen/normal_margin" android:text="@string/all_day" android:textSize="@dimen/day_text_size" app:switchPadding="@dimen/small_margin"/> @@ -121,14 +121,14 @@ android:id="@+id/event_start_date" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignLeft="@+id/event_all_day" - android:layout_alignStart="@+id/event_all_day" android:layout_below="@+id/event_time_image" + android:layout_alignStart="@+id/event_all_day" + android:layout_alignLeft="@+id/event_all_day" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin" android:paddingEnd="@dimen/activity_margin" android:paddingRight="@dimen/activity_margin" - android:paddingTop="@dimen/activity_margin" + android:paddingBottom="@dimen/activity_margin" android:textSize="@dimen/day_text_size" tools:text="January 1 1970"/> @@ -136,9 +136,9 @@ android:id="@+id/event_start_time" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_below="@+id/event_time_image" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" - android:layout_below="@+id/event_time_image" android:background="?attr/selectableItemBackground" android:padding="@dimen/activity_margin" android:textSize="@dimen/day_text_size" @@ -148,14 +148,14 @@ android:id="@+id/event_end_date" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignLeft="@+id/event_all_day" - android:layout_alignStart="@+id/event_all_day" android:layout_below="@+id/event_start_date" + android:layout_alignStart="@+id/event_all_day" + android:layout_alignLeft="@+id/event_all_day" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" + android:paddingTop="@dimen/activity_margin" android:paddingEnd="@dimen/activity_margin" android:paddingRight="@dimen/activity_margin" - android:paddingTop="@dimen/activity_margin" + android:paddingBottom="@dimen/activity_margin" android:textSize="@dimen/day_text_size" tools:text="January 1 1970"/> @@ -163,9 +163,9 @@ android:id="@+id/event_end_time" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_below="@+id/event_start_time" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" - android:layout_below="@+id/event_start_time" android:background="?attr/selectableItemBackground" android:padding="@dimen/activity_margin" android:textSize="@dimen/day_text_size" @@ -176,8 +176,8 @@ android:layout_width="match_parent" android:layout_height="1px" android:layout_below="@+id/event_end_date" - android:layout_marginBottom="@dimen/medium_margin" android:layout_marginTop="@dimen/medium_margin" + android:layout_marginBottom="@dimen/medium_margin" android:background="@color/divider_grey" android:importantForAccessibility="no"/> @@ -185,11 +185,11 @@ android:id="@+id/event_reminder_image" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_alignBottom="@+id/event_reminder_1" - android:layout_alignTop="@+id/event_reminder_1" android:layout_below="@+id/event_date_time_divider" - android:layout_marginLeft="@dimen/normal_margin" + android:layout_alignTop="@+id/event_reminder_1" + android:layout_alignBottom="@+id/event_reminder_1" android:layout_marginStart="@dimen/normal_margin" + android:layout_marginLeft="@dimen/normal_margin" android:alpha="0.8" android:padding="@dimen/medium_margin" android:src="@drawable/ic_bell"/> @@ -199,26 +199,26 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/event_date_time_divider" - android:layout_marginLeft="@dimen/small_margin" android:layout_marginStart="@dimen/small_margin" + android:layout_marginLeft="@dimen/small_margin" android:layout_toEndOf="@+id/event_reminder_image" android:layout_toRightOf="@+id/event_reminder_image" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin" + android:paddingBottom="@dimen/activity_margin" android:textSize="@dimen/day_text_size"/> @@ -227,13 +227,13 @@ android:id="@+id/event_reminder_3" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignLeft="@+id/event_reminder_1" - android:layout_alignStart="@+id/event_reminder_1" android:layout_below="@+id/event_reminder_2" + android:layout_alignStart="@+id/event_reminder_1" + android:layout_alignLeft="@+id/event_reminder_1" android:alpha="0.4" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin" + android:paddingBottom="@dimen/activity_margin" android:text="@string/add_another_reminder" android:textSize="@dimen/day_text_size" android:visibility="gone"/> @@ -243,8 +243,8 @@ android:layout_width="match_parent" android:layout_height="1px" android:layout_below="@+id/event_reminder_3" - android:layout_marginBottom="@dimen/medium_margin" android:layout_marginTop="@dimen/medium_margin" + android:layout_marginBottom="@dimen/medium_margin" android:background="@color/divider_grey" android:importantForAccessibility="no"/> @@ -252,11 +252,11 @@ android:id="@+id/event_repetition_image" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_alignBottom="@+id/event_repetition" - android:layout_alignTop="@+id/event_repetition" android:layout_below="@+id/event_date_time_divider" - android:layout_marginLeft="@dimen/normal_margin" + android:layout_alignTop="@+id/event_repetition" + android:layout_alignBottom="@+id/event_repetition" android:layout_marginStart="@dimen/normal_margin" + android:layout_marginLeft="@dimen/normal_margin" android:alpha="0.8" android:padding="@dimen/medium_margin" android:src="@drawable/ic_repeat"/> @@ -266,22 +266,22 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/event_reminder_divider" - android:layout_marginLeft="@dimen/small_margin" android:layout_marginStart="@dimen/small_margin" + android:layout_marginLeft="@dimen/small_margin" android:layout_toEndOf="@+id/event_repetition_image" android:layout_toRightOf="@+id/event_repetition_image" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/normal_margin" android:paddingTop="@dimen/normal_margin" + android:paddingBottom="@dimen/normal_margin" android:textSize="@dimen/day_text_size"/> @@ -290,8 +290,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="false" - android:paddingBottom="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin" + android:paddingBottom="@dimen/activity_margin" android:text="@string/repeat_on" android:textSize="@dimen/day_text_size"/> @@ -314,9 +314,9 @@ android:id="@+id/event_repetition_limit_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignLeft="@+id/event_repetition" - android:layout_alignStart="@+id/event_repetition" android:layout_below="@+id/event_repetition_rule_holder" + android:layout_alignStart="@+id/event_repetition" + android:layout_alignLeft="@+id/event_repetition" android:background="?attr/selectableItemBackground" android:visibility="gone"> @@ -324,11 +324,11 @@ android:id="@+id/event_repetition_limit_label" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_toLeftOf="@+id/event_repetition_limit" android:layout_toStartOf="@+id/event_repetition_limit" + android:layout_toLeftOf="@+id/event_repetition_limit" android:clickable="false" - android:paddingBottom="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin" + android:paddingBottom="@dimen/activity_margin" android:text="@string/repeat_till" android:textSize="@dimen/day_text_size"/> @@ -357,11 +357,11 @@ android:id="@+id/event_caldav_calendar_image" android:layout_width="wrap_content" android:layout_height="match_parent" - android:layout_alignBottom="@+id/event_caldav_calendar_holder" - android:layout_alignTop="@+id/event_caldav_calendar_holder" android:layout_below="@+id/event_repetition_divider" - android:layout_marginLeft="@dimen/normal_margin" + android:layout_alignTop="@+id/event_caldav_calendar_holder" + android:layout_alignBottom="@+id/event_caldav_calendar_holder" android:layout_marginStart="@dimen/normal_margin" + android:layout_marginLeft="@dimen/normal_margin" android:alpha="0.8" android:padding="@dimen/medium_margin" android:src="@drawable/ic_calendar" @@ -381,12 +381,12 @@ android:id="@+id/event_caldav_calendar_name" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/small_margin" android:layout_marginStart="@dimen/small_margin" + android:layout_marginLeft="@dimen/small_margin" android:ellipsize="end" android:maxLines="1" - android:paddingBottom="@dimen/tiny_margin" android:paddingTop="@dimen/medium_margin" + android:paddingBottom="@dimen/tiny_margin" android:textSize="@dimen/day_text_size" tools:text="My calendar"/> @@ -395,14 +395,25 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/event_caldav_calendar_name" - android:layout_marginLeft="@dimen/small_margin" android:layout_marginStart="@dimen/small_margin" + android:layout_marginLeft="@dimen/small_margin" android:ellipsize="end" android:maxLines="1" android:paddingBottom="@dimen/medium_margin" android:textSize="@dimen/meta_text_size" tools:text="hello@simplemobiletools.com"/> + + @@ -433,6 +444,7 @@ android:layout_height="wrap_content" android:layout_below="@+id/event_caldav_calendar_divider" android:layout_marginTop="@dimen/medium_margin" + android:layout_marginBottom="@dimen/medium_margin" android:layout_toEndOf="@+id/event_type_image" android:layout_toRightOf="@+id/event_type_image" android:background="?attr/selectableItemBackground"> @@ -441,12 +453,12 @@ android:id="@+id/event_type" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginStart="@dimen/small_margin" android:layout_marginLeft="@dimen/small_margin" android:layout_marginRight="@dimen/medium_margin" - android:layout_marginStart="@dimen/small_margin" android:layout_toLeftOf="@+id/event_type_color" - android:paddingBottom="@dimen/normal_margin" android:paddingTop="@dimen/normal_margin" + android:paddingBottom="@dimen/normal_margin" android:textSize="@dimen/day_text_size"/> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index e486b4871..e31f79318 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,15 +1,22 @@ - - + android:layout_height="match_parent"> + + + + - + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 14f5c73fa..6510f94e8 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -17,18 +17,18 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -39,18 +39,18 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -61,18 +61,18 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -83,10 +83,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -106,10 +106,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -129,10 +129,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -152,10 +152,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -180,8 +180,8 @@ android:id="@+id/reminders_label" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginStart="@dimen/bigger_margin" + android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginTop="@dimen/activity_margin" android:text="@string/event_reminders" android:textAllCaps="true" @@ -193,10 +193,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -216,10 +216,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -239,18 +239,18 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> @@ -273,18 +273,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -308,10 +308,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -331,18 +331,18 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> @@ -366,10 +366,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -389,18 +389,18 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> @@ -424,18 +424,18 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> @@ -459,18 +459,18 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> @@ -499,8 +499,8 @@ android:id="@+id/caldav_label" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginStart="@dimen/bigger_margin" + android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginTop="@dimen/activity_margin" android:text="@string/caldav" android:textAllCaps="true" @@ -512,10 +512,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> + + + + + + + android:paddingBottom="@dimen/bigger_margin"> @@ -609,18 +632,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> @@ -649,8 +672,8 @@ android:id="@+id/monthly_view_label" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginStart="@dimen/bigger_margin" + android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginTop="@dimen/activity_margin" android:text="@string/monthly_view" android:textAllCaps="true" @@ -662,10 +685,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -684,10 +707,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -712,8 +735,8 @@ android:id="@+id/simple_event_list_label" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginStart="@dimen/bigger_margin" + android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginTop="@dimen/activity_margin" android:text="@string/event_lists" android:textAllCaps="true" @@ -725,10 +748,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -747,18 +770,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> @@ -787,8 +810,8 @@ android:id="@+id/widgets_label" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginStart="@dimen/bigger_margin" + android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginTop="@dimen/activity_margin" android:text="@string/widgets" android:textAllCaps="true" @@ -799,18 +822,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -828,23 +851,57 @@ + + + + + + + + + android:paddingBottom="@dimen/activity_margin"> @@ -860,8 +917,8 @@ android:id="@+id/events_label" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginStart="@dimen/bigger_margin" + android:layout_marginLeft="@dimen/bigger_margin" android:layout_marginTop="@dimen/activity_margin" android:text="@string/events" android:textAllCaps="true" @@ -873,10 +930,10 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/activity_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/activity_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/activity_margin"> + android:paddingBottom="@dimen/activity_margin"> @@ -895,10 +952,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" - android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/normal_margin" + android:paddingTop="@dimen/bigger_margin" android:paddingRight="@dimen/normal_margin" - android:paddingTop="@dimen/bigger_margin"> + android:paddingBottom="@dimen/bigger_margin"> + android:paddingTop="@dimen/activity_margin" + android:paddingRight="@dimen/activity_margin"> + android:paddingBottom="@dimen/small_margin"/> @@ -80,7 +80,7 @@ android:text="@string/include_event_types" android:textSize="@dimen/smaller_text_size"/> - - + + + + + + + + + + + diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index bd7261da2..9d011d54a 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -5,7 +5,7 @@ android:id="@+id/search" android:icon="@drawable/ic_search" android:title="@string/search" - app:actionViewClass="android.support.v7.widget.SearchView" + app:actionViewClass="androidx.appcompat.widget.SearchView" app:showAsAction="collapseActionView|ifRoom"/> Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Təqvimi dəyişmək alınmadı Sinxronlaşdırılır… Sinxronlaşma bitdi + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-br/strings.xml b/app/src/main/res/values-br/strings.xml index f2f959e06..c95a1cc82 100644 --- a/app/src/main/res/values-br/strings.xml +++ b/app/src/main/res/values-br/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ C\'hwitadenn en ur embann an deiziataer O c\'houbredañ… Echuet gant ar goubredañ + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index dcccd881d..ea686370f 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -25,7 +25,7 @@ Konec události nemůže být dříve než začátek Událost úspěšně přidána Událost úspěšně změněna - Filtrovat události podle typu + Filtrovat události Vyplňte prosím místo, které se zobrazí na mapě Událost právě nastává @@ -86,27 +86,27 @@ Narozeniny byly úspěšně přidány - Anniversaries - Add contact anniversaries - No anniversaries have been found - Anniversaries added successfully + Výročí + Přidat výročí + Žádné výročí nebylo nalezeno + Výročí bylo úspěšně přidáno - Připomenutí + Připomínka před - Přidat další připomenutí - Event reminders + Přidat další připomínku + Připomínky událostí Import událostí Export událostí Importovat kalendář ze souboru .ics Exportovat kalendář do souboru .ics - Defaultní typ události - Export i minulých událostí + Přednastavený typ události + Exportovat i uplynulé události Zahrnout typy událostí Název souboru (bez .ics) - Override event types in the file + Přepsat typ události v souboru Název @@ -141,8 +141,8 @@ Správa typů událostí - Počátek dne v - Konec dne v + Počátek dne + Konec dne Zobrazovat číslo týdne Vibrovat Tón oznámení @@ -155,19 +155,21 @@ Nahradit popis udalosti lokací Smazat všechny události Opravdu chcete smazat všechny události? Typy událostí a ostatní nastavení zůstanou neporušené. - Zobrazit mřížku + Zobrazovat mřížku Připomínat až do vypnutí Smazat minulé události Události Zvuk upomínky - Systémový + Systém Budík Notifikace - Zvonek - Use the last events\' reminders as the default for new event - Default reminder 1 - Default reminder 2 - Default reminder 3 + Vyzvánění + Použij poslední připomenutou událost jako výchozí pro novou událost + Výchozí připomenutí 1 + Výchozí připomenutí 2 + Výchozí připomenutí 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Editování kalendáře se nezdařilo Synchronizuji… Synchronizace dokončena + Select a different color (might be applied locally only) @@ -202,15 +205,15 @@ na kafe - How can I remove the holidays imported via the \"Add holidays\" button? - Holidays created that way are inserted in a new event type called \"Holidays\". You can go in Settings -> Manage Event Types, - long press the given event type and delete it by selecting the trashbin. - Can I sync my events via Google Calendar, or other service supporting CalDAV? - Yes, just toggle \"CalDAV sync\" in the app settings and select the calendars you want to sync. However, you will need some third party app handling the synchronization between the device and servers. - In case you want to synchronize a Google calendar, their official Calendar app will do the job. For other calendars you will need a third party sync adapter, for example DAVdroid. - I see the visual reminders, but hear no audio. What can I do? - Not just displaying the actual reminder, but playing the audio is hugely affected by the system too. If you can\'t hear any sound, try going in the app settings, - pressing the \"Audio stream used by reminders\" option and changing it to a different value. If it still won\'t work, check your sound settings, if the particular stream isn\'t muted. + Jak mohu odstranit svátky importované přes tlačítko \"Přidat svátek\"? + Svátky vytvořené touto cestou jsou vloženy s novým typem události \"Svátky\". Odstranit jej můžete přes: Nastavení -> Správa typů událostí -> + dlouze podržte daný typ události a stisknete tlačítko s ikonou koše pro odstranění. + Mohu synchronizovat své události přes Google Kalendář nebo přes jinou službu podporující CalDav? + Ano, zapnutím \"CalDAV sync\" v nastavení aplikace a vybráním kalendáře se kterým se chcete synchronizovat. Budete ovšem potřebovat nějakou aplikaci třetí strany pro samotné synchronizovaní mezi zařízením a servery. + Pokud chcete synchronizovat Google kalendář, tak oficiální aplikace Google toto zvládne. Pro jiné kalendáře potřebujete synchronizační adaptér třetí strany, například DAVdroid. + Vizuálně vidím připomínku, ale neslyším žádný zvuk. Co mám dělat? + Nejenom zobrazování aktuální připomínky, ale i přehrávání zvuku je dost ovlivněno operačním systémem. Pokud neslyšíte žádný zvuk, zkuste jít do nastavení aplikace, + vyberte: \"Zvuk upomínky\" a změňte na něco jiného. Pokud zvuk stále nefunguje, zkontrolujte zda není zvuk vypnut v nastavení vašeho systému. diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index ff980b4a1..4c034c272 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -168,6 +168,8 @@ Påmindelse 1 Påmindelse 2 Påmindelse 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Redigering af kalenderen mislykkedes Synkroniserer… Synkronisering gennemført + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 10328f900..937242a91 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -168,6 +168,8 @@ Standarderinnerung 1 Standarderinnerung 2 Standarderinnerung 3 + Standardansicht + Letzte Ansicht CalDAV @@ -180,6 +182,7 @@ Ändern des Kalenders fehlgeschlagen Wird synchronisiert… Synchronisation erfolgreich + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 6786b0bd4..5b24ea7e2 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Η επεξεργασία του ημερολογίου απέτυχε Συγχρονισμός… Ο συγχρονισμός ολοκληρώθηκε + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index ccdcedc79..4df453bf1 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Edición de calendario fallida Sincronizando… Sincronización completa + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index db7adb867..3c2dd738a 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Édition du calendrier échouée Synchronisation… Synchronisation terminée + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index 6b80a0c72..70f94bad3 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Fallou a edición do calendario Sincronizando… Sincronización completa + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-hi-rIN/strings.xml b/app/src/main/res/values-hi-rIN/strings.xml index 74b686969..67494f83c 100644 --- a/app/src/main/res/values-hi-rIN/strings.xml +++ b/app/src/main/res/values-hi-rIN/strings.xml @@ -169,6 +169,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -181,6 +183,7 @@ Editing calendar failed Syncing… Sync completed + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index ab52a489f..84fc916d6 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Uređivanje kalendara nije uspjelo Sinkronizacija… Sinkronizacija završena + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 35037d3e9..d14070583 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Editing calendar failed Syncing… Sync completed + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 5b4d0b7bb..24caba283 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -19,15 +19,15 @@ Evento Modifica evento Nuovo evento - Create a new event - Duplicate event + Crea un nuovo evento + Duplica evento Il titolo non può essere vuoto - L\'evento non può terminare prima del suo inizio + L\'evento non può terminare prima del suo ianizio Evento aggiunto correttamente Evento aggiornato correttamente Filtra eventi per tipologia - Please fill in a location to be shown on a map - An event is upcoming + Riempire la posizione per essere mostrata su una mappa + Un evento è imminente Ripeti @@ -44,24 +44,24 @@ L\'evento è ripetibile La selezione contiene eventi ripetuti Elimina solamente l\'occorenza selezionata - Delete this and all future occurrences + Rimuovi questo e tutte le future occorrenze Elimina tutte le occorrenze Aggiorna solamente l\'occorenza selezionata Aggiorna tutte le occorenze Ripeti fino a una data - Stop repeating after x occurrences + Smetti di ripetere dopo x occorrenze Ripeti per sempre volte Ripeti - Repeat on + Ripeti Ogni giorno On selected days Lo stesso giorno L\'ultimo giorno Ripeti lo stesso giorno ogni mese - Repeat on the last day of the month - Repeat on the same day every year - Repeat every + Ripeti l\'ultimo giorno del mese + Ripeti lo stesso giorno ogni anno + Ripeti ogni Tutti primo secondo @@ -106,13 +106,13 @@ Esporta anche eventi passati Includi tipi evento Nome file (senza .ics) - Override event types in the file + Sovrascrivi i tipi di eventi nel file Titolo Posizione Descrizione - All-day + Tutto il giorno Settimana @@ -126,8 +126,8 @@ Evento regolare Il tipo di evento predefinito non può essere cancellato Seleziona un tipo di evento - Move affected events into the default event type - Permanently remove affected events + Muovi gli eventi segnati con il tipo di eventi predefinito + Rimuovi in maniera permanente gli eventi segnati Per rimuovere un calendario CalDAV devi desincronizzarlo @@ -141,92 +141,95 @@ Gestisci tipi evento - Start day at - End day at + Il giorno inizia alle + Il giorno finisce alle Mostra numero settimane - Vibrate on reminder notification + Vibra per le notifiche di promemoria Suoneria promemoria - No app capable of setting ringtone found - None + Non è stata trovata nessuna applicazione per impostare la suoneria + Nessuna Il giorno non può finire prima che cominci - CalDAV sync - Event lists + Sincronizzazione CalDAV + Liste degli eventi Mostra eventi passati Sostituisci la descrizione con la posizione Cancella tutti gli eventi Vuoi cancellare tutti gli eventi? Questo lascerà i tuoi tipi evento e le altre impostazioni invariate. - Show a grid - Loop reminders until dismissed - Dim past events - Events - Audio stream used by reminders - System - Alarm - Notification - Ring - Use the last events\' reminders as the default for new event - Default reminder 1 - Default reminder 2 - Default reminder 3 + Mostra una griglia + Manda in loop i promemoria finchè non vengono rimossi + Rimuovi gli eventi passati + Eventi + Canale audio utilizzato per i promomemoria + Sistema + Allarme + Notitica + Squillo + Utilizza l\'ultimo promemoria come predefinito per nuovi eventi + Promemoria predefinito 1 + Promemoria predefinito 2 + Promemoria predefinito 3 + Vista da aprire dalla lista degli eventi del widget + Ultima vista CalDAV - Select calendars to sync - Manage synced calendars - Store locally only - Refresh CalDAV calendars - Refreshing… - Refreshing complete - Editing calendar failed - Syncing… - Sync completed + Seleziona un calendario da sincronizzare + Gestisci i calendari sincronizzati + Salva solamente in locale + Aggiorna i calendari CalDAV + Aggiornamento in corso… + Aggiornamento completato + Impossibile modificare il calendario + Sincronizzazione in corso… + Sincronizzazione completata + Seleziona un colore differente (potrebbe essere applicato solamente in locale) - Monday - Tuesday - Wednesday - Thursday - Friday - Saturday - Sunday + Lunedì + Martedì + Mercoledì + Giovedì + Venerdì + Sabato + Domenica - Workout - Leg day - Meeting with John - In Rockstone garden - Library - Lunch with Mary - In the Plaza - Coffee time + Allenamento + Gambe + Incontro con Giovanni + Nel giardino di Milano + Liberia + Pranzo con Maria + Nel ristorante Magione + Pausa caffè - How can I remove the holidays imported via the \"Add holidays\" button? - Holidays created that way are inserted in a new event type called \"Holidays\". You can go in Settings -> Manage Event Types, - long press the given event type and delete it by selecting the trashbin. - Can I sync my events via Google Calendar, or other service supporting CalDAV? - Yes, just toggle \"CalDAV sync\" in the app settings and select the calendars you want to sync. However, you will need some third party app handling the synchronization between the device and servers. - In case you want to synchronize a Google calendar, their official Calendar app will do the job. For other calendars you will need a third party sync adapter, for example DAVdroid. - I see the visual reminders, but hear no audio. What can I do? - Not just displaying the actual reminder, but playing the audio is hugely affected by the system too. If you can\'t hear any sound, try going in the app settings, - pressing the \"Audio stream used by reminders\" option and changing it to a different value. If it still won\'t work, check your sound settings, if the particular stream isn\'t muted. + Come posso rimuovere i le festività importate tramite il pulsante \"Aggiungi festività\"? + Le festività create in questo modo sono inseriti in eventi di tipo \"Festività\". Puoi andare in Impostazioni -> Gestisci tipi di eventi, + tenere premuto sul tipo desiderato ed eliminaro selezionando il cestino. + Posso sincronizzare i miei eventi tramite Google Calendar, od altri servizi che supportano CalDAV? + Sì, basta commutare l\'opzione \"Sincronizzazione CalDAV\" nelle impostazioni dell\'applicazione e selezionare i calendari da sincronizzare. Comunque è necessaria un\'applicazione di terze parti per gestire la sincronizzazione tra dispositivo e server. + In caso si voglia sincronizzare con Google Calendar, la loro applicazione ufficiale effettua questo lavoro. Per altri calendari è necessario un adattatore di terze parti, per esempio DAVdroid. + Visualizzo i promemoria, ma non sento l\'audio. Cosa posso fare? + Non solo visualizzare l\'attuale promemoria, ma anche riprodurre l\'audio è un lavoro prettamente del sistema. Se non senti alcun suono, prova ad andare nelle impostazioni dell\'applicazione, + premi l\'opzione \"Canale audio utilizzato per il promemoria\" e cambia il canale. Se ancora non funziona, controlla le tue impostazioni dell\'audio, in particolare se il canale è stato mutato. - A simple calendar with events, customizable widget and no ads. + Un semplice calendario con eventi, widget personalizzabili e senza pubblicità. - A simple calendar with optional CalDAV synchronization. You can easily create recurring events and setup reminders, it can also display week numbers. + Un semplice calendario con l\'opzione di sincronizzazione CalDAV. Puoi facilmente creare eventi ricorrenti ed impostare promemoria, mostra anche il numero di settimana. - Contains a monthly view and an event list widget where you can customize the color of the text, as well as the alpha and the color of the background. + Contiene una vista mensile ed un widget con la lista degli eventi, con il colore del testo personalizzabile, come per la trasparenza ed il colore dello sfondo, - Contains no ads or unnecessary permissions. It is fully opensource, provides customizable colors. + Non contiene pubblicità o permessi non necessari. È completamente opensource, fornisce anche colori personalizzabili. - The Storage permission is needed only for exporting or importing events from .ics files. + Il permesso di archiviazione è necesario solamente per esportare od importare venti da file .ics. - The Contacts permission is used only at importing contact birthdays and anniversaries. + Il permesso dei contatti è usato solamente per importare i compleanni e gli anniversari. - This app is just one piece of a bigger series of apps. You can find the rest of them at https://www.simplemobiletools.com + Questa applicazione è solamente una di una serie. Puoi trovare le altre su https://www.simplemobiletools.com CalDAV @@ -181,6 +183,7 @@ Editing calendar failed Syncing… Sync completed + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 6d625c422..481966cfa 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ カレンダーを編集できませんでした 同期中… 同期が完了しました + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 1b00ee085..264f6ae28 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ 변경 실패 동기화중… 동기화 완료 + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 615fe9048..f4c0aa9e0 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Kalendoriaus redagavimas nepavyko Sinchronizuojama… Sinchronizacija baigta + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index b5aa6d84f..cd5144eeb 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Redigering av kalender feilet Synkroniserer… Synkronisering fullført + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 861a53c42..664049a0d 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -168,6 +168,8 @@ Standaardherinnering 1 Standaardherinnering 2 Standaardherinnering 3 + Weergave bij openen vanuit widget met afsprakenlijst + Last view CalDAV @@ -180,6 +182,7 @@ Agenda bijwerken mislukt Synchroniseren… Synchroniseren voltooid + Kies een andere kleur (mogelijk alleen voor dit apparaat) diff --git a/app/src/main/res/values-no/strings.xml b/app/src/main/res/values-no/strings.xml index b8e43aaf8..618996121 100644 --- a/app/src/main/res/values-no/strings.xml +++ b/app/src/main/res/values-no/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Redigering av kalender feilet Synkroniserer… Synkronisering fullført + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 9b289c1f9..a741af3d9 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Edytowanie kalendarza nie powiodło się Synchronizowanie… Synchronizacja zakończona + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index ded2b08d8..abd11c4a5 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ A edição do calendário falhou Sincronizando… Sincronização completa + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 558daf055..0316f9f08 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -164,10 +164,12 @@ Alarme Notificação Toque - Use the last events\' reminders as the default for new event - Default reminder 1 - Default reminder 2 - Default reminder 3 + Utilize os lembretes dos últimos eventos como definição para os novos eventos + Lembrete 1 + Lembrete 2 + Lembrete 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Falha ao editar o calendário A sincronizar… Sincronização terminada + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index d8e730162..3ab1eaf20 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -168,6 +168,8 @@ Напоминание по умолчанию 1 Напоминание по умолчанию 2 Напоминание по умолчанию 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Не удалось изменить календарь Синхронизация… Синхронизация завершена + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 0a5d783a6..e32e57b3b 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -168,6 +168,8 @@ Predvolená pripomienka 1 Predvolená pripomienka 2 Predvolená pripomienka 3 + Otvoriť pohľad po kliknutí na widget so zoznamom udalostí + Posledný pohľad CalDAV @@ -180,6 +182,7 @@ Úprava kalendára zlyhala Synchronizujem… Synchronizácia ukončená + Zvoliť inú farbu (možno bude aplikovaná iba lokálne) diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 0b4b540bb..466a0ac9a 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Det gick inte att redigera kalendern Synkroniserar… Synkroniseringen är klar + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index ec742e565..859e8697c 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Takvim düzenlenme başarısız Senkronize ediliyor… Senkronizasyon tamamlandı + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml deleted file mode 100644 index 88dcfd806..000000000 --- a/app/src/main/res/values-v21/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 715e32a4c..3fd0b36f2 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -49,7 +49,7 @@ 只更新選擇的事件 更新全部事件 重複直到某日 - Stop repeating after x occurrences + 經過x次後停止重複 永遠重複 重複 @@ -164,10 +164,12 @@ 鬧鐘 通知 鈴聲 - Use the last events\' reminders as the default for new event - Default reminder 1 - Default reminder 2 - Default reminder 3 + 使用最後活動的提醒作為新活動的預設 + 預設提醒1 + 預設提醒2 + 預設提醒3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ 編輯行事曆失敗 同步中… 同步完成 + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b1de5682b..edf383596 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -168,6 +168,8 @@ Default reminder 1 Default reminder 2 Default reminder 3 + View to open from the event list widget + Last view CalDAV @@ -180,6 +182,7 @@ Editing calendar failed Syncing… Sync completed + Select a different color (might be applied locally only) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 987325f52..3f41654af 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -23,10 +23,10 @@ diff --git a/build.gradle b/build.gradle index 8a3727559..0b0dbc07b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.61' + ext.kotlin_version = '1.2.71' repositories { google() @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.1.4' + classpath 'com.android.tools.build:gradle:3.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..dbb7bf70d --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +android.enableJetifier=true +android.useAndroidX=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 65417b390..3cecad9ae 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Nov 07 14:52:59 CET 2017 +#Fri Oct 05 20:16:57 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip