-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make weather monitor state receiver more generic
- Loading branch information
1 parent
9cc5069
commit 9916f57
Showing
7 changed files
with
89 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/kylecorry/trail_sense/shared/automations/Automation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.kylecorry.trail_sense.shared.automations | ||
|
||
import android.os.Bundle | ||
|
||
data class Automation( | ||
val broadcast: String, | ||
val receivers: List<AutomationReceiver> | ||
) | ||
|
||
data class AutomationReceiver( | ||
val receiverId: String, | ||
// TODO: Make this more generic / easier to store in the DB | ||
val parameterTransform: (Bundle) -> Bundle = { it }, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../java/com/kylecorry/trail_sense/tools/weather/receivers/SetWeatherMonitorStateReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.kylecorry.trail_sense.tools.weather.receivers | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import com.kylecorry.trail_sense.tools.tools.infrastructure.Receiver | ||
import com.kylecorry.trail_sense.tools.weather.infrastructure.WeatherMonitorIsEnabled | ||
import com.kylecorry.trail_sense.tools.weather.infrastructure.WeatherUpdateScheduler | ||
|
||
// TODO: Add support for enable/disable weather monitor | ||
class SetWeatherMonitorStateReceiver : Receiver { | ||
override fun onReceive(context: Context, data: Bundle) { | ||
val desiredState = data.getBoolean(PARAM_WEATHER_MONITOR_STATE, false) | ||
|
||
if (desiredState && WeatherMonitorIsEnabled().isSatisfiedBy(context)) { | ||
WeatherUpdateScheduler.start(context) | ||
} else if (!desiredState) { | ||
WeatherUpdateScheduler.stop(context) | ||
} | ||
} | ||
|
||
companion object { | ||
const val PARAM_WEATHER_MONITOR_STATE = "state" | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
...om/kylecorry/trail_sense/tools/weather/receivers/WeatherMonitorPowerSavingModeReceiver.kt
This file was deleted.
Oops, something went wrong.