Bugfix
This commit is contained in:
parent
f3f9291f6c
commit
5b9ef9abc7
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -18,8 +18,8 @@ android {
|
|||||||
applicationId "com.tommasoberlose.anotherwidget"
|
applicationId "com.tommasoberlose.anotherwidget"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 48
|
versionCode 51
|
||||||
versionName "2.0.1"
|
versionName "2.0.2"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -54,61 +54,71 @@ object CalendarHelper {
|
|||||||
) {
|
) {
|
||||||
eventRepository.resetNextEventData()
|
eventRepository.resetNextEventData()
|
||||||
} else {
|
} else {
|
||||||
val provider = CalendarProvider(context)
|
try {
|
||||||
val data = provider.getInstances(now.timeInMillis, limit.timeInMillis)
|
val provider = CalendarProvider(context)
|
||||||
if (data != null) {
|
val data = provider.getInstances(now.timeInMillis, limit.timeInMillis)
|
||||||
val instances = data.list
|
if (data != null) {
|
||||||
for (instance in instances) {
|
val instances = data.list
|
||||||
try {
|
for (instance in instances) {
|
||||||
val e = provider.getEvent(instance.eventId)
|
try {
|
||||||
if (e != null && !e.deleted && instance.begin <= limit.timeInMillis && (Preferences.calendarAllDay || !e.allDay) && !getFilteredCalendarIdList().contains(e.calendarId) && (Preferences.showDeclinedEvents || e.selfAttendeeStatus.toInt() != CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED)) {
|
val e = provider.getEvent(instance.eventId)
|
||||||
if (e.allDay) {
|
if (e != null && !e.deleted && instance.begin <= limit.timeInMillis && (Preferences.calendarAllDay || !e.allDay) && !getFilteredCalendarIdList().contains(
|
||||||
val start = Calendar.getInstance()
|
e.calendarId
|
||||||
start.timeInMillis = instance.begin
|
) && (Preferences.showDeclinedEvents || e.selfAttendeeStatus.toInt() != CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED)
|
||||||
val end = Calendar.getInstance()
|
) {
|
||||||
end.timeInMillis = instance.end
|
if (e.allDay) {
|
||||||
instance.begin = start.timeInMillis - start.timeZone.getOffset(start.timeInMillis)
|
val start = Calendar.getInstance()
|
||||||
instance.end = end.timeInMillis - end.timeZone.getOffset(end.timeInMillis)
|
start.timeInMillis = instance.begin
|
||||||
}
|
val end = Calendar.getInstance()
|
||||||
eventList.add(
|
end.timeInMillis = instance.end
|
||||||
Event(
|
instance.begin =
|
||||||
instance.id,
|
start.timeInMillis - start.timeZone.getOffset(start.timeInMillis)
|
||||||
e.id,
|
instance.end =
|
||||||
e.title ?: "",
|
end.timeInMillis - end.timeZone.getOffset(end.timeInMillis)
|
||||||
instance.begin,
|
}
|
||||||
instance.end,
|
eventList.add(
|
||||||
e.calendarId.toInt(),
|
Event(
|
||||||
e.allDay,
|
instance.id,
|
||||||
e.eventLocation ?: ""
|
e.id,
|
||||||
|
e.title ?: "",
|
||||||
|
instance.begin,
|
||||||
|
instance.end,
|
||||||
|
e.calendarId.toInt(),
|
||||||
|
e.allDay,
|
||||||
|
e.eventLocation ?: ""
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
} catch (ignored: Exception) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eventList.isEmpty()) {
|
|
||||||
eventRepository.resetNextEventData()
|
|
||||||
} else {
|
|
||||||
eventList.sortWith(Comparator { event: Event, event1: Event ->
|
|
||||||
if (event.allDay && event1.allDay) {
|
|
||||||
event.startDate.compareTo(event1.startDate)
|
|
||||||
} else if (event.allDay) {
|
|
||||||
1
|
|
||||||
} else if (event1.allDay) {
|
|
||||||
-1
|
|
||||||
} else {
|
|
||||||
event1.startDate.compareTo(event.startDate)
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
eventList.reverse()
|
|
||||||
Log.d("ciao", "list: $eventList")
|
if (eventList.isEmpty()) {
|
||||||
eventRepository.saveEvents(
|
eventRepository.resetNextEventData()
|
||||||
eventList
|
} else {
|
||||||
)
|
eventList.sortWith(Comparator { event: Event, event1: Event ->
|
||||||
eventRepository.saveNextEventData(
|
if (event.allDay && event1.allDay) {
|
||||||
eventList[0]
|
event.startDate.compareTo(event1.startDate)
|
||||||
)
|
} else if (event.allDay) {
|
||||||
|
1
|
||||||
|
} else if (event1.allDay) {
|
||||||
|
-1
|
||||||
|
} else {
|
||||||
|
event1.startDate.compareTo(event.startDate)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
eventList.reverse()
|
||||||
|
Log.d("ciao", "list: $eventList")
|
||||||
|
eventRepository.saveEvents(
|
||||||
|
eventList
|
||||||
|
)
|
||||||
|
eventRepository.saveNextEventData(
|
||||||
|
eventList[0]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (ignored: java.lang.Exception) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,15 +4,16 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import com.tommasoberlose.anotherwidget.R
|
||||||
import com.tommasoberlose.anotherwidget.global.Actions
|
import com.tommasoberlose.anotherwidget.global.Actions
|
||||||
import com.tommasoberlose.anotherwidget.helpers.IntentHelper
|
import com.tommasoberlose.anotherwidget.helpers.IntentHelper
|
||||||
|
import com.tommasoberlose.anotherwidget.utils.toast
|
||||||
|
|
||||||
|
|
||||||
class WidgetClickListenerReceiver : BroadcastReceiver() {
|
class WidgetClickListenerReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
if (intent.action == Actions.ACTION_OPEN_WEATHER_INTENT) {
|
if (intent.action == Actions.ACTION_OPEN_WEATHER_INTENT) {
|
||||||
context.sendBroadcast(Intent(Actions.ACTION_WEATHER_UPDATE))
|
|
||||||
try {
|
try {
|
||||||
context.startActivity(IntentHelper.getWeatherIntent(context))
|
context.startActivity(IntentHelper.getWeatherIntent(context))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -24,8 +25,8 @@ class WidgetClickListenerReceiver : BroadcastReceiver() {
|
|||||||
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
try {
|
try {
|
||||||
context.startActivity(i)
|
context.startActivity(i)
|
||||||
} catch (e: Exception) {
|
} catch (ignored: Exception) {
|
||||||
context.applicationContext.startActivity(i)
|
context.toast(context.getString(R.string.error_opening_app))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user