diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 6aa9aed..e37d96c 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/build.gradle b/app/build.gradle index b4cc1c2..57c5094 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,7 +22,7 @@ android { applicationId "com.tommasoberlose.anotherwidget" minSdkVersion 23 targetSdkVersion 30 - versionCode 123 + versionCode 124 versionName "2.2.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Actions.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Actions.kt index 0adc3b7..3fd88ec 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/global/Actions.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/global/Actions.kt @@ -2,7 +2,6 @@ package com.tommasoberlose.anotherwidget.global object Actions { const val ACTION_EXTRA_OPEN_WEATHER_PROVIDER = "ACTION_EXTRA_OPEN_WEATHER_PROVIDER" - const val ACTION_EXTRA_DISABLE_GPS_NOTIFICATION = "ACTION_EXTRA_DISABLE_GPS_NOTIFICATION" const val ACTION_TIME_UPDATE = "com.tommasoberlose.anotherwidget.action.TIME_UPDATE" const val ACTION_ALARM_UPDATE = "com.tommasoberlose.anotherwidget.action.ALARM_UPDATE" @@ -14,4 +13,6 @@ object Actions { const val ACTION_REPORT_CRASH = "com.tommasoberlose.anotherwidget.action.REPORT_CRASH" const val ACTION_CLEAR_NOTIFICATION = "com.tommasoberlose.anotherwidget.action.CLEAR_NOTIFICATION" const val ACTION_UPDATE_GREETINGS = "com.tommasoberlose.anotherwidget.action.UPDATE_GREETINGS" + + const val ACTION_REFRESH = "com.tommasoberlose.anotherwidget.action.REFRESH" } \ No newline at end of file diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/IntentHelper.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/IntentHelper.kt index 5de9a74..036b570 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/IntentHelper.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/helpers/IntentHelper.kt @@ -12,8 +12,10 @@ import android.provider.CalendarContract import android.provider.CalendarContract.Events import android.util.Log import com.tommasoberlose.anotherwidget.R +import com.tommasoberlose.anotherwidget.global.Actions import com.tommasoberlose.anotherwidget.global.Preferences import com.tommasoberlose.anotherwidget.models.Event +import com.tommasoberlose.anotherwidget.receivers.UpdatesReceiver import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget import com.tommasoberlose.anotherwidget.utils.toast import java.util.* @@ -35,6 +37,12 @@ object IntentHelper { } } + private fun getWidgetRefreshIntent(context: Context): Intent { + return Intent(context, UpdatesReceiver::class.java).apply { + action = Actions.ACTION_REFRESH + } + } + fun getGoogleMapsIntentFromAddress(context: Context, address: String): Intent { val gmmIntentUri: Uri = Uri.parse("geo:0,0?q=$address") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) @@ -63,7 +71,7 @@ object IntentHelper { Intent() } REFRESH_WIDGET_OPTION -> { - getWidgetUpdateIntent(context) + getWidgetRefreshIntent(context) } else -> { val pm: PackageManager = context.packageManager @@ -95,7 +103,7 @@ object IntentHelper { Intent() } REFRESH_WIDGET_OPTION -> { - getWidgetUpdateIntent(context) + getWidgetRefreshIntent(context) } else -> { val pm: PackageManager = context.packageManager @@ -183,7 +191,7 @@ object IntentHelper { Intent() } REFRESH_WIDGET_OPTION -> { - getWidgetUpdateIntent(context) + getWidgetRefreshIntent(context) } else -> { val pm: PackageManager = context.packageManager diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/UpdatesReceiver.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/UpdatesReceiver.kt index 6244a7c..76066d8 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/UpdatesReceiver.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/receivers/UpdatesReceiver.kt @@ -12,12 +12,12 @@ import com.tommasoberlose.anotherwidget.db.EventRepository import com.tommasoberlose.anotherwidget.global.Actions import com.tommasoberlose.anotherwidget.global.Constants import com.tommasoberlose.anotherwidget.global.Preferences -import com.tommasoberlose.anotherwidget.helpers.ActiveNotificationsHelper -import com.tommasoberlose.anotherwidget.helpers.BatteryHelper -import com.tommasoberlose.anotherwidget.helpers.CalendarHelper -import com.tommasoberlose.anotherwidget.helpers.MediaPlayerHelper +import com.tommasoberlose.anotherwidget.helpers.* import com.tommasoberlose.anotherwidget.models.Event import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch import org.joda.time.Period import java.util.* @@ -55,6 +55,16 @@ class UpdatesReceiver : BroadcastReceiver() { Actions.ACTION_UPDATE_GREETINGS -> { MainWidget.updateWidget(context) } + + Actions.ACTION_REFRESH -> { + ActiveNotificationsHelper.clearLastNotification(context) + + GlobalScope.launch(Dispatchers.IO) { + CalendarHelper.updateEventList(context) + MediaPlayerHelper.updatePlayingMediaInfo(context) + WeatherHelper.updateWeather(context) + } + } } } diff --git a/app/src/main/java/com/tommasoberlose/anotherwidget/services/UpdateCalendarService.kt b/app/src/main/java/com/tommasoberlose/anotherwidget/services/UpdateCalendarService.kt index b17faaa..6830765 100644 --- a/app/src/main/java/com/tommasoberlose/anotherwidget/services/UpdateCalendarService.kt +++ b/app/src/main/java/com/tommasoberlose/anotherwidget/services/UpdateCalendarService.kt @@ -33,7 +33,7 @@ import kotlin.collections.ArrayList class UpdateCalendarService : Service() { companion object { - const val CALENDAR_SYNC_NOTIFICATION_ID = 28466 + const val CALENDAR_SYNC_NOTIFICATION_ID = 28468 fun enqueueWork(context: Context) { context.startService(Intent(context, UpdateCalendarService::class.java)) if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {