Merge pull request #1811 from Naveen3Singh/caldav_issues
CalDAV refresh improvement
This commit is contained in:
commit
f845567698
|
@ -197,6 +197,7 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.EventTypePickerActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.Transparent" />
|
||||
|
||||
|
|
|
@ -206,6 +206,10 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
main_toolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
if (config.caldavSync) {
|
||||
updateCalDAVEvents()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
@ -561,14 +565,22 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateCalDAVEvents() {
|
||||
ensureBackgroundThread {
|
||||
calDAVHelper.refreshCalendars(showToasts = false, scheduleNextSync = true) {
|
||||
refreshViewPager()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshCalDAVCalendars(showRefreshToast: Boolean) {
|
||||
showCalDAVRefreshToast = showRefreshToast
|
||||
if (showRefreshToast) {
|
||||
toast(R.string.refreshing)
|
||||
}
|
||||
|
||||
updateCalDAVEvents()
|
||||
syncCalDAVCalendars {
|
||||
calDAVHelper.refreshCalendars(true, true) {
|
||||
calDAVHelper.refreshCalendars(showToasts = true, scheduleNextSync = true) {
|
||||
calDAVChanged()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
syncCalDAVCalendars {
|
||||
calDAVHelper.refreshCalendars(true, true) {
|
||||
calDAVHelper.refreshCalendars(showToasts = true, scheduleNextSync = true) {
|
||||
if (settings_caldav_sync.isChecked) {
|
||||
toast(R.string.synchronization_completed)
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.widget.Toast
|
|||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.app.AlarmManagerCompat
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.print.PrintHelper
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.EventActivity
|
||||
|
@ -57,6 +58,8 @@ val Context.completedTasksDB: TasksDao get() = EventsDatabase.getInstance(applic
|
|||
val Context.eventsHelper: EventsHelper get() = EventsHelper(this)
|
||||
val Context.calDAVHelper: CalDAVHelper get() = CalDAVHelper(this)
|
||||
|
||||
val Context.localBroadcastManager: LocalBroadcastManager get() = LocalBroadcastManager.getInstance(this)
|
||||
|
||||
fun Context.updateWidgets() {
|
||||
val widgetIDs = AppWidgetManager.getInstance(applicationContext)?.getAppWidgetIds(ComponentName(applicationContext, MyWidgetMonthlyProvider::class.java))
|
||||
?: return
|
||||
|
@ -603,6 +606,7 @@ fun Context.refreshCalDAVCalendars(ids: String, showToasts: Boolean) {
|
|||
|
||||
Bundle().apply {
|
||||
putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true)
|
||||
putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true)
|
||||
accounts.forEach {
|
||||
ContentResolver.requestSync(it, uri.authority, this)
|
||||
}
|
||||
|
|
|
@ -227,6 +227,7 @@ const val IS_NEW_EVENT = "IS_NEW_EVENT"
|
|||
|
||||
// actions
|
||||
const val ACTION_MARK_COMPLETED = "ACTION_MARK_COMPLETED"
|
||||
const val ACTION_REFRESH_EVENTS = "ACTION_REFRESH_EVENTS"
|
||||
|
||||
fun getNowSeconds() = System.currentTimeMillis() / 1000L
|
||||
|
||||
|
|
Loading…
Reference in New Issue