Release v2.0.1

This commit is contained in:
Tommaso Berlose
2020-05-03 17:54:35 +02:00
parent 3aecf9851a
commit 9a978ac8d3
135 changed files with 2368 additions and 1221 deletions

View File

@ -4,22 +4,25 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.tommasoberlose.anotherwidget.db.EventRepository
import com.tommasoberlose.anotherwidget.global.Actions
import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.utils.CalendarUtil
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
class NewCalendarEventReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when {
intent.action.equals(Intent.ACTION_PROVIDER_CHANGED) -> {
CalendarUtil.updateEventList(context)
val eventRepository = EventRepository(context)
Log.d("ciao", "nuovo evento")
when (intent.action) {
Intent.ACTION_PROVIDER_CHANGED,
Intent.ACTION_TIME_CHANGED -> {
CalendarHelper.updateEventList(context)
}
intent.action == Actions.ACTION_GO_TO_NEXT_EVENT -> {
CalendarUtil.goToNextEvent(context)
Actions.ACTION_GO_TO_NEXT_EVENT -> {
eventRepository.goToNextEvent()
}
intent.action == Actions.ACTION_GO_TO_PREVIOUS_EVENT -> {
CalendarUtil.goToPreviousEvent(context)
Actions.ACTION_GO_TO_PREVIOUS_EVENT -> {
eventRepository.goToPreviousEvent()
}
}
}

View File

@ -5,12 +5,13 @@ import android.content.Context
import android.content.Intent
import android.app.AlarmManager
import android.app.PendingIntent
import com.tommasoberlose.anotherwidget.components.events.Event
import android.util.Log
import com.tommasoberlose.anotherwidget.db.EventRepository
import com.tommasoberlose.anotherwidget.global.Actions
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.utils.CalendarUtil
import com.tommasoberlose.anotherwidget.utils.Util
import com.tommasoberlose.anotherwidget.helpers.CalendarHelper
import com.tommasoberlose.anotherwidget.ui.widgets.MainWidget
import org.joda.time.Period
import java.text.DateFormat
import java.util.*
@ -20,11 +21,11 @@ class UpdatesReceiver : BroadcastReceiver() {
when (intent.action) {
Intent.ACTION_BOOT_COMPLETED,
Intent.ACTION_MY_PACKAGE_REPLACED,
Actions.ACTION_CALENDAR_UPDATE -> CalendarUtil.updateEventList(context)
Actions.ACTION_CALENDAR_UPDATE -> CalendarHelper.updateEventList(context)
"com.sec.android.widgetapp.APPWIDGET_RESIZE",
Intent.ACTION_DATE_CHANGED,
AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED -> Util.updateWidget(context)
AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED -> MainWidget.updateWidget(context)
}
}
@ -32,8 +33,9 @@ class UpdatesReceiver : BroadcastReceiver() {
fun setUpdates(context: Context) {
removeUpdates(context)
val eventRepository = EventRepository(context)
with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
CalendarUtil.getEvents().forEach { event ->
eventRepository.getEvents().forEach { event ->
val hoursDiff = Period(Calendar.getInstance().timeInMillis, event.startDate).hours
// Update the widget every hour till the event

View File

@ -7,18 +7,19 @@ import android.content.Context
import android.content.Intent
import com.tommasoberlose.anotherwidget.global.Actions
import com.tommasoberlose.anotherwidget.global.Preferences
import com.tommasoberlose.anotherwidget.utils.Util
import com.tommasoberlose.anotherwidget.utils.WeatherUtil
import com.tommasoberlose.anotherwidget.helpers.WeatherHelper
import java.util.*
class WeatherReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == Intent.ACTION_BOOT_COMPLETED || intent.action == Intent.ACTION_MY_PACKAGE_REPLACED) {
setUpdates(context)
} else if (intent.action == Actions.ACTION_WEATHER_UPDATE) {
WeatherUtil.updateWeather(context)
when (intent.action) {
Intent.ACTION_BOOT_COMPLETED,
Intent.ACTION_MY_PACKAGE_REPLACED,
Intent.ACTION_TIME_CHANGED -> setUpdates(context)
Actions.ACTION_WEATHER_UPDATE -> WeatherHelper.updateWeather(context)
}
}
@ -27,7 +28,7 @@ class WeatherReceiver : BroadcastReceiver() {
removeUpdates(context)
if (Preferences.showWeather && Preferences.weatherProviderApi != "") {
WeatherUtil.updateWeather(context)
WeatherHelper.updateWeather(context)
with(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) {
val pi = PendingIntent.getBroadcast(

View File

@ -5,8 +5,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import com.tommasoberlose.anotherwidget.global.Actions
import com.tommasoberlose.anotherwidget.utils.Util
import com.tommasoberlose.anotherwidget.global.Constants
import com.tommasoberlose.anotherwidget.helpers.IntentHelper
class WidgetClickListenerReceiver : BroadcastReceiver() {
@ -15,10 +14,10 @@ class WidgetClickListenerReceiver : BroadcastReceiver() {
if (intent.action == Actions.ACTION_OPEN_WEATHER_INTENT) {
context.sendBroadcast(Intent(Actions.ACTION_WEATHER_UPDATE))
try {
context.startActivity(Util.getWeatherIntent(context))
context.startActivity(IntentHelper.getWeatherIntent(context))
} catch (e: Exception) {
try {
context.applicationContext.startActivity(Util.getWeatherIntent(context.applicationContext))
context.applicationContext.startActivity(IntentHelper.getWeatherIntent(context.applicationContext))
} catch (e: Exception) {
val uri = Uri.parse("http://www.google.com/#q=weather")
val i = Intent(Intent.ACTION_VIEW, uri)