fix build

This commit is contained in:
Milos Kozak 2023-09-21 18:13:10 +02:00
parent 58887a0886
commit 7c7879e0b0

View file

@ -270,7 +270,7 @@ class CustomWatchface : BaseWatchFace() {
} }
val metadataMap = ZipWatchfaceFormat.loadMetadata(json) val metadataMap = ZipWatchfaceFormat.loadMetadata(json)
val drawableDataMap: CwfResDataMap = mutableMapOf() val drawableDataMap: CwfResDataMap = mutableMapOf()
getResourceByteArray(info.nightscout.shared.impl.R.drawable.watchface_custom)?.let { getResourceByteArray(app.aaps.shared.impl.R.drawable.watchface_custom)?.let {
drawableDataMap[ResFileMap.CUSTOM_WATCHFACE.fileName] = ResData(it, ResFormat.PNG) drawableDataMap[ResFileMap.CUSTOM_WATCHFACE.fileName] = ResData(it, ResFormat.PNG)
} }
return EventData.ActionSetCustomWatchface(CwfData(json.toString(4), metadataMap, drawableDataMap)) return EventData.ActionSetCustomWatchface(CwfData(json.toString(4), metadataMap, drawableDataMap))
@ -288,13 +288,13 @@ class CustomWatchface : BaseWatchFace() {
} }
private fun setVisibility(visibility: String, pref: Boolean = true): Int = when (visibility) { private fun setVisibility(visibility: String, pref: Boolean = true): Int = when (visibility) {
JsonKeyValues.VISIBLE.key -> pref.toVisibility() JsonKeyValues.VISIBLE.key -> pref.toVisibility()
else -> View.GONE else -> View.GONE
} }
private fun getVisibility(visibility: Int): String = when (visibility) { private fun getVisibility(visibility: Int): String = when (visibility) {
View.VISIBLE -> JsonKeyValues.VISIBLE.key View.VISIBLE -> JsonKeyValues.VISIBLE.key
else -> JsonKeyValues.GONE.key else -> JsonKeyValues.GONE.key
} }
private fun getResourceByteArray(resourceId: Int): ByteArray? { private fun getResourceByteArray(resourceId: Int): ByteArray? {
@ -366,7 +366,7 @@ class CustomWatchface : BaseWatchFace() {
BACKGROUND( BACKGROUND(
key = ViewKeys.BACKGROUND.key, key = ViewKeys.BACKGROUND.key,
id = R.id.background, id = R.id.background,
defaultDrawable = info.nightscout.shared.impl.R.drawable.background, defaultDrawable = app.aaps.shared.impl.R.drawable.background,
customDrawable = ResFileMap.BACKGROUND, customDrawable = ResFileMap.BACKGROUND,
customHigh = ResFileMap.BACKGROUND_HIGH, customHigh = ResFileMap.BACKGROUND_HIGH,
customLow = ResFileMap.BACKGROUND_LOW customLow = ResFileMap.BACKGROUND_LOW
@ -409,7 +409,7 @@ class CustomWatchface : BaseWatchFace() {
COVER_PLATE( COVER_PLATE(
key = ViewKeys.COVER_PLATE.key, key = ViewKeys.COVER_PLATE.key,
id = R.id.cover_plate, id = R.id.cover_plate,
defaultDrawable = info.nightscout.shared.impl.R.drawable.simplified_dial, defaultDrawable = app.aaps.shared.impl.R.drawable.simplified_dial,
customDrawable = ResFileMap.COVER_PLATE, customDrawable = ResFileMap.COVER_PLATE,
customHigh = ResFileMap.COVER_PLATE_HIGH, customHigh = ResFileMap.COVER_PLATE_HIGH,
customLow = ResFileMap.COVER_PLATE_LOW customLow = ResFileMap.COVER_PLATE_LOW
@ -417,7 +417,7 @@ class CustomWatchface : BaseWatchFace() {
HOUR_HAND( HOUR_HAND(
key = ViewKeys.HOUR_HAND.key, key = ViewKeys.HOUR_HAND.key,
id = R.id.hour_hand, id = R.id.hour_hand,
defaultDrawable = info.nightscout.shared.impl.R.drawable.hour_hand, defaultDrawable = app.aaps.shared.impl.R.drawable.hour_hand,
customDrawable = ResFileMap.HOUR_HAND, customDrawable = ResFileMap.HOUR_HAND,
customHigh = ResFileMap.HOUR_HAND_HIGH, customHigh = ResFileMap.HOUR_HAND_HIGH,
customLow = ResFileMap.HOUR_HAND_LOW customLow = ResFileMap.HOUR_HAND_LOW
@ -425,7 +425,7 @@ class CustomWatchface : BaseWatchFace() {
MINUTE_HAND( MINUTE_HAND(
key = ViewKeys.MINUTE_HAND.key, key = ViewKeys.MINUTE_HAND.key,
id = R.id.minute_hand, id = R.id.minute_hand,
defaultDrawable = info.nightscout.shared.impl.R.drawable.minute_hand, defaultDrawable = app.aaps.shared.impl.R.drawable.minute_hand,
customDrawable = ResFileMap.MINUTE_HAND, customDrawable = ResFileMap.MINUTE_HAND,
customHigh = ResFileMap.MINUTE_HAND_HIGH, customHigh = ResFileMap.MINUTE_HAND_HIGH,
customLow = ResFileMap.MINUTE_HAND_LOW customLow = ResFileMap.MINUTE_HAND_LOW
@ -434,13 +434,14 @@ class CustomWatchface : BaseWatchFace() {
key = ViewKeys.SECOND_HAND.key, key = ViewKeys.SECOND_HAND.key,
id = R.id.second_hand, id = R.id.second_hand,
pref = R.string.key_show_seconds, pref = R.string.key_show_seconds,
defaultDrawable = info.nightscout.shared.impl.R.drawable.second_hand, defaultDrawable = app.aaps.shared.impl.R.drawable.second_hand,
customDrawable = ResFileMap.SECOND_HAND, customDrawable = ResFileMap.SECOND_HAND,
customHigh = ResFileMap.SECOND_HAND_HIGH, customHigh = ResFileMap.SECOND_HAND_HIGH,
customLow = ResFileMap.SECOND_HAND_LOW customLow = ResFileMap.SECOND_HAND_LOW
); );
companion object { companion object {
fun init(cwf: CustomWatchface) = values().forEach { it.cwf = cwf } fun init(cwf: CustomWatchface) = values().forEach { it.cwf = cwf }
fun fromId(id: Int): ViewMap? = values().firstOrNull { it.id == id } fun fromId(id: Int): ViewMap? = values().firstOrNull { it.id == id }
} }
@ -458,7 +459,10 @@ class CustomWatchface : BaseWatchFace() {
0L -> { 0L -> {
cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources) cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources)
}-1L -> { customLow?.let { resFileMap -> cwf.resDataMap[resFileMap.fileName] }?.toDrawable(cwf.resources) ?: cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources) }
-1L -> {
customLow?.let { resFileMap -> cwf.resDataMap[resFileMap.fileName] }?.toDrawable(cwf.resources) ?: cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources)
} }
else -> cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources) else -> cwf.resDataMap[cd.fileName]?.toDrawable(cwf.resources)