diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CustomWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CustomWatchface.kt index d68ca3a619..a5c8be2026 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CustomWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CustomWatchface.kt @@ -19,6 +19,7 @@ import android.view.WindowManager import android.widget.FrameLayout import android.widget.ImageView import android.widget.TextView +import androidx.annotation.DrawableRes import androidx.annotation.IdRes import androidx.annotation.StringRes import androidx.core.content.ContextCompat @@ -74,11 +75,16 @@ class CustomWatchface : BaseWatchFace() { .build() } + override fun setDataFields() { + super.setDataFields() + binding.direction2.setImageDrawable(resources.getDrawable(TrendArrow.fromSymbol(singleBg.slopeArrow).icon)) + } override fun setColorDark() { setWatchfaceStyle() binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background)) binding.sgv.setTextColor(bgColor) binding.direction.setTextColor(bgColor) + binding.direction2.colorFilter = changeDrawableColor(bgColor) if (ageLevel != 1) binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) @@ -429,6 +435,7 @@ class CustomWatchface : BaseWatchFace() { MONTH("month", R.id.month, null), LOOP("loop", R.id.loop, R.string.key_show_external_status), DIRECTION("direction", R.id.direction, R.string.key_show_direction), + DIRECTION2("direction2", R.id.direction2, R.string.key_show_direction), TIMESTAMP("timestamp", R.id.timestamp, R.string.key_show_ago), SGV("sgv", R.id.sgv, R.string.key_show_bg), COVER_PLATE(CustomWatchfaceDrawableDataKey.COVERPLATE.key, R.id.cover_plate, null), @@ -460,8 +467,29 @@ class CustomWatchface : BaseWatchFace() { } } + fun visibility(sp: SP): Boolean = this.pref?.let { sp.getBoolean(it, true) } ?: true } + + enum class TrendArrow(val text: String, val symbol: String,@DrawableRes val icon: Int) { + NONE("NONE", "??", R.drawable.ic_invalid), + TRIPLE_UP("TripleUp", "X", R.drawable.ic_invalid), + DOUBLE_UP("DoubleUp", "\u21c8", R.drawable.ic_doubleup), + SINGLE_UP("SingleUp", "\u2191", R.drawable.ic_singleup), + FORTY_FIVE_UP("FortyFiveUp", "\u2197", R.drawable.ic_fortyfiveup), + FLAT("Flat", "\u2192", R.drawable.ic_flat), + FORTY_FIVE_DOWN("FortyFiveDown", "\u2198",R.drawable.ic_fortyfivedown), + SINGLE_DOWN("SingleDown", "\u2193", R.drawable.ic_singledown), + DOUBLE_DOWN("DoubleDown", "\u21ca", R.drawable.ic_doubledown), + TRIPLE_DOWN("TripleDown", "X",R.drawable.ic_invalid) + ; + + companion object { + fun fromSymbol(direction: String?) = + values().firstOrNull { it.symbol == direction } ?: NONE + } + } + } diff --git a/wear/src/main/res/drawable/ic_doubledown.xml b/wear/src/main/res/drawable/ic_doubledown.xml new file mode 100644 index 0000000000..6bccc9cb47 --- /dev/null +++ b/wear/src/main/res/drawable/ic_doubledown.xml @@ -0,0 +1,12 @@ + + + + diff --git a/wear/src/main/res/drawable/ic_doubleup.xml b/wear/src/main/res/drawable/ic_doubleup.xml new file mode 100644 index 0000000000..9c56d4cf85 --- /dev/null +++ b/wear/src/main/res/drawable/ic_doubleup.xml @@ -0,0 +1,12 @@ + + + + diff --git a/wear/src/main/res/drawable/ic_flat.xml b/wear/src/main/res/drawable/ic_flat.xml new file mode 100644 index 0000000000..487a647f10 --- /dev/null +++ b/wear/src/main/res/drawable/ic_flat.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_fortyfivedown.xml b/wear/src/main/res/drawable/ic_fortyfivedown.xml new file mode 100644 index 0000000000..673a965fe4 --- /dev/null +++ b/wear/src/main/res/drawable/ic_fortyfivedown.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_fortyfiveup.xml b/wear/src/main/res/drawable/ic_fortyfiveup.xml new file mode 100644 index 0000000000..930857ec66 --- /dev/null +++ b/wear/src/main/res/drawable/ic_fortyfiveup.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_invalid.xml b/wear/src/main/res/drawable/ic_invalid.xml new file mode 100644 index 0000000000..bdda131e7d --- /dev/null +++ b/wear/src/main/res/drawable/ic_invalid.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/wear/src/main/res/drawable/ic_singledown.xml b/wear/src/main/res/drawable/ic_singledown.xml new file mode 100644 index 0000000000..bc3a0e7501 --- /dev/null +++ b/wear/src/main/res/drawable/ic_singledown.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_singleup.xml b/wear/src/main/res/drawable/ic_singleup.xml new file mode 100644 index 0000000000..6dda71fc74 --- /dev/null +++ b/wear/src/main/res/drawable/ic_singleup.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/layout/activity_custom.xml b/wear/src/main/res/layout/activity_custom.xml index 553dc1fdae..a746ba2a8a 100644 --- a/wear/src/main/res/layout/activity_custom.xml +++ b/wear/src/main/res/layout/activity_custom.xml @@ -306,12 +306,23 @@ android:layout_height="52px" android:layout_marginTop="26px" android:layout_marginLeft="291px" + android:visibility="gone" android:gravity="left" android:textSize="39px" android:textStyle="bold" android:textColor="@color/light_grey" tools:text="--" /> + +