This commit is contained in:
Tommaso Berlose 2020-05-03 19:33:46 +02:00
parent f3f9291f6c
commit 5b9ef9abc7
5 changed files with 68 additions and 57 deletions

Binary file not shown.

View File

@ -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.

View File

@ -54,6 +54,7 @@ object CalendarHelper {
) { ) {
eventRepository.resetNextEventData() eventRepository.resetNextEventData()
} else { } else {
try {
val provider = CalendarProvider(context) val provider = CalendarProvider(context)
val data = provider.getInstances(now.timeInMillis, limit.timeInMillis) val data = provider.getInstances(now.timeInMillis, limit.timeInMillis)
if (data != null) { if (data != null) {
@ -61,14 +62,19 @@ object CalendarHelper {
for (instance in instances) { for (instance in instances) {
try { try {
val e = provider.getEvent(instance.eventId) val e = provider.getEvent(instance.eventId)
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)) { 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)
) {
if (e.allDay) { if (e.allDay) {
val start = Calendar.getInstance() val start = Calendar.getInstance()
start.timeInMillis = instance.begin start.timeInMillis = instance.begin
val end = Calendar.getInstance() val end = Calendar.getInstance()
end.timeInMillis = instance.end end.timeInMillis = instance.end
instance.begin = start.timeInMillis - start.timeZone.getOffset(start.timeInMillis) instance.begin =
instance.end = end.timeInMillis - end.timeZone.getOffset(end.timeInMillis) start.timeInMillis - start.timeZone.getOffset(start.timeInMillis)
instance.end =
end.timeInMillis - end.timeZone.getOffset(end.timeInMillis)
} }
eventList.add( eventList.add(
Event( Event(
@ -83,7 +89,8 @@ object CalendarHelper {
) )
) )
} }
} catch (ignored: Exception) {} } catch (ignored: Exception) {
}
} }
} }
@ -110,6 +117,9 @@ object CalendarHelper {
eventList[0] eventList[0]
) )
} }
} catch (ignored: java.lang.Exception) {
}
} }
} else { } else {
eventRepository.resetNextEventData() eventRepository.resetNextEventData()

View File

@ -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))
} }
} }
} }