AndroidAPS/wear/src/main/java/info/nightscout/androidaps/tile/ActionSource.kt

72 lines
2.7 KiB
Kotlin
Raw Normal View History

2021-12-14 12:17:04 +01:00
package info.nightscout.androidaps.tile
2022-04-23 12:35:09 +02:00
import android.content.Context
2022-01-18 20:54:39 +01:00
import android.content.res.Resources
2021-12-14 12:17:04 +01:00
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interaction.actions.*
2022-04-23 12:35:09 +02:00
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
import javax.inject.Singleton
2021-12-14 12:17:04 +01:00
2022-04-23 12:35:09 +02:00
@Singleton
class ActionSource @Inject constructor(context: Context, sp : SP, aapsLogger: AAPSLogger) : StaticTileSource(context, sp, aapsLogger) {
2021-12-14 12:17:04 +01:00
2022-01-18 20:54:39 +01:00
override val preferencePrefix = "tile_action_"
override fun getActions(resources: Resources): List<StaticAction> {
2021-12-14 12:17:04 +01:00
return listOf(
2022-01-18 20:54:39 +01:00
StaticAction(
2022-01-12 12:22:53 +01:00
settingName = "wizard",
2022-01-18 20:54:39 +01:00
buttonText = resources.getString(R.string.menu_wizard_short),
2021-12-14 12:17:04 +01:00
iconRes = R.drawable.ic_calculator_green,
2022-01-12 12:22:53 +01:00
activityClass = WizardActivity::class.java.name,
2021-12-14 12:17:04 +01:00
),
2022-01-18 20:54:39 +01:00
StaticAction(
2022-01-11 23:19:20 +01:00
settingName = "treatment",
2022-01-18 20:54:39 +01:00
buttonText = resources.getString(R.string.menu_treatment_short),
2021-12-14 12:17:04 +01:00
iconRes = R.drawable.ic_bolus_carbs,
2022-01-12 12:22:53 +01:00
activityClass = TreatmentActivity::class.java.name,
2021-12-14 12:17:04 +01:00
),
2022-01-18 20:54:39 +01:00
StaticAction(
2022-01-11 23:19:20 +01:00
settingName = "bolus",
2022-01-18 20:54:39 +01:00
buttonText = resources.getString(R.string.action_insulin),
2022-01-11 23:19:20 +01:00
iconRes = R.drawable.ic_bolus,
2022-01-12 12:22:53 +01:00
activityClass = BolusActivity::class.java.name,
2022-01-11 23:19:20 +01:00
),
2022-01-18 20:54:39 +01:00
StaticAction(
settingName = "carbs",
2022-01-18 20:54:39 +01:00
buttonText = resources.getString(R.string.action_carbs),
2021-12-14 12:17:04 +01:00
iconRes = R.drawable.ic_carbs_orange,
activityClass = CarbActivity::class.java.name,
),
StaticAction(
settingName = "ecarbs",
buttonText = resources.getString(R.string.action_ecarbs),
iconRes = R.drawable.ic_carbs_orange,
2022-01-12 12:22:53 +01:00
activityClass = ECarbActivity::class.java.name,
2021-12-14 12:17:04 +01:00
),
2022-01-18 20:54:39 +01:00
StaticAction(
settingName = "temp_target",
2022-01-18 20:54:39 +01:00
buttonText = resources.getString(R.string.menu_tempt),
2021-12-14 12:17:04 +01:00
iconRes = R.drawable.ic_temptarget_flat,
2022-01-12 12:22:53 +01:00
activityClass = TempTargetActivity::class.java.name,
2021-12-14 12:17:04 +01:00
)
)
}
2022-01-11 10:38:20 +01:00
2022-01-18 20:54:39 +01:00
override fun getResourceReferences(resources: Resources): List<Int> {
return getActions(resources).map { it.iconRes }
}
2022-01-11 10:38:20 +01:00
override fun getDefaultConfig(): Map<String, String> {
return mapOf(
2022-01-12 12:22:53 +01:00
"tile_action_1" to "wizard",
2022-01-11 23:19:20 +01:00
"tile_action_2" to "treatment",
"tile_action_3" to "ecarbs",
2022-01-11 10:38:20 +01:00
"tile_action_4" to "temp_target"
)
}
2021-12-14 12:17:04 +01:00
}