Fix widget refresh intent
This commit is contained in:
parent
5176331e84
commit
06583197c7
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -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"
|
||||
|
@ -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"
|
||||
}
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user