diff --git a/app-wear-shared/shared/src/main/java/info/nightscout/rx/weardata/CustomWatchfaceFormat.kt b/app-wear-shared/shared/src/main/java/info/nightscout/rx/weardata/CustomWatchfaceFormat.kt
index 15ec1802d5..dc659d29f5 100644
--- a/app-wear-shared/shared/src/main/java/info/nightscout/rx/weardata/CustomWatchfaceFormat.kt
+++ b/app-wear-shared/shared/src/main/java/info/nightscout/rx/weardata/CustomWatchfaceFormat.kt
@@ -12,7 +12,6 @@ import info.nightscout.shared.R
import kotlinx.serialization.Serializable
import org.json.JSONObject
import java.io.BufferedOutputStream
-import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.FileOutputStream
@@ -77,7 +76,7 @@ enum class ResFormat(val extension: String) {
@Serializable
data class ResData(val value: ByteArray, val format: ResFormat) {
- fun toDrawable(resources: Resources): Drawable? {
+ fun toDrawable(resources: Resources, width: Int? = null, height: Int? = null): Drawable? {
try {
return when (format) {
ResFormat.PNG, ResFormat.JPG -> {
@@ -86,7 +85,9 @@ data class ResData(val value: ByteArray, val format: ResFormat) {
}
ResFormat.SVG -> {
- val svg = SVG.getFromInputStream(ByteArrayInputStream(value))
+ val svg = SVG.getFromString(String(value))
+ svg.documentWidth = width?.toFloat() ?: svg.documentWidth
+ svg.documentHeight = height?.toFloat() ?: svg.documentHeight
val picture = svg.renderToPicture()
PictureDrawable(picture).apply {
setBounds(0, 0, svg.documentWidth.toInt(), svg.documentHeight.toInt())
@@ -160,7 +161,8 @@ enum class CwfMetadataKey(val key: String, @StringRes val label: Int, val isPref
CWF_PREF_WATCH_SHOW_DIRECTION("key_show_direction", R.string.pref_show_direction_arrow, true),
CWF_PREF_WATCH_SHOW_AGO("key_show_ago", R.string.pref_show_ago, true),
CWF_PREF_WATCH_SHOW_BG("key_show_bg", R.string.pref_show_bg, true),
- CWF_PREF_WATCH_SHOW_LOOP_STATUS("key_show_loop_status", R.string.pref_show_loop_status, true);
+ CWF_PREF_WATCH_SHOW_LOOP_STATUS("key_show_loop_status", R.string.pref_show_loop_status, true),
+ CWF_PREF_WATCH_SHOW_WEEK_NUMBER("key_show_week_number", R.string.pref_show_week_number, true);
companion object {
@@ -195,6 +197,7 @@ enum class ViewKeys(val key: String, @StringRes val comment: Int) {
TIMEPERIOD("timePeriod", R.string.cwf_comment_timePeriod),
DAY_NAME("day_name", R.string.cwf_comment_day_name),
DAY("day", R.string.cwf_comment_day),
+ WEEKNUMBER("week_number",R.string.cwf_comment_week_number),
MONTH("month", R.string.cwf_comment_month),
LOOP("loop", R.string.cwf_comment_loop),
DIRECTION("direction", R.string.cwf_comment_direction),
@@ -233,7 +236,8 @@ enum class JsonKeys(val key: String) {
COLOR("color"),
ALLCAPS("allCaps"),
DAYNAMEFORMAT("dayNameFormat"),
- MONTHFORMAT("monthFormat")
+ MONTHFORMAT("monthFormat"),
+ BACKGROUND("background")
}
enum class JsonKeyValues(val key: String) {
diff --git a/app-wear-shared/shared/src/main/res/values/strings.xml b/app-wear-shared/shared/src/main/res/values/strings.xml
index 50f3869b5d..6198eb283a 100644
--- a/app-wear-shared/shared/src/main/res/values/strings.xml
+++ b/app-wear-shared/shared/src/main/res/values/strings.xml
@@ -62,6 +62,7 @@
Show BGI
Show Direction Arrow
Show Ago
+ Show Week number
Default watchface, you can click on EXPORT WATCHFACE button to generate a template
Default Watchface
Background image
@@ -88,12 +89,13 @@
AM or PM
Name of day of the week
Day (DD)
+ Week number (ww)
Month name (short)
Loop status and ago
Direction arrow
Mintutes ago for last received BG
BG value
- Cover image in front of text (dials...)
+ Cover image in front of text (dials…)
Image of hour hand (Analog Watch)
Image of minute hand (Analog Watch)
Image of second hand (Analog Watch)
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 e82642e0a1..cfb1765d17 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CustomWatchface.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CustomWatchface.kt
@@ -164,8 +164,8 @@ class CustomWatchface : BaseWatchFace() {
.takeIf { it.matches(Regex("E{1,4}")) } ?: "E"
monthFormat = json.optString(MONTHFORMAT.key, "MMM")
.takeIf { it.matches(Regex("M{1,4}")) } ?: "MMM"
- binding.dayName.text = dateUtil.dayNameString(dayNameFormat) // Update daynName and month according to format on cwf loading
- binding.month.text = dateUtil.monthString(monthFormat)
+ binding.dayName.text = dateUtil.dayNameString(dayNameFormat).substringBeforeLast(".") // Update daynName and month according to format on cwf loading
+ binding.month.text = dateUtil.monthString(monthFormat).substringBeforeLast(".")
bgColor = when (singleBg.sgvLevel) {
1L -> highColor
0L -> midColor
@@ -196,6 +196,7 @@ class CustomWatchface : BaseWatchFace() {
view.isAllCaps = viewJson.optBoolean(ALLCAPS.key)
if (viewJson.has(TEXTVALUE.key))
view.text = viewJson.optString(TEXTVALUE.key)
+ view.background = resDataMap[viewJson.optString(BACKGROUND.key)]?.toDrawable(resources, width, height)
}
is ImageView -> {
@@ -437,6 +438,7 @@ class CustomWatchface : BaseWatchFace() {
TIMEPERIOD(ViewKeys.TIMEPERIOD.key, R.id.timePeriod, null, null, null, null, null),
DAY_NAME(ViewKeys.DAY_NAME.key, R.id.day_name, null, null, null, null, null),
DAY(ViewKeys.DAY.key, R.id.day, null, null, null, null, null),
+ WEEKNUMBER(ViewKeys.WEEKNUMBER.key, R.id.week_number, R.string.key_show_week_number, null, null, null, null),
MONTH(ViewKeys.MONTH.key, R.id.month, null, null, null, null, null),
LOOP(ViewKeys.LOOP.key, R.id.loop, R.string.key_show_external_status, null, null, null, null),
DIRECTION(ViewKeys.DIRECTION.key, R.id.direction2, R.string.key_show_direction, null, null, null, null),
@@ -594,7 +596,8 @@ private enum class PrefMap(val key: String, @StringRes val prefKey: Int) {
SHOW_AGO(CwfMetadataKey.CWF_PREF_WATCH_SHOW_AGO.key, R.string.key_show_ago),
SHOW_BG(CwfMetadataKey.CWF_PREF_WATCH_SHOW_BG.key, R.string.key_show_bg),
SHOW_BGI(CwfMetadataKey.CWF_PREF_WATCH_SHOW_BGI.key, R.string.key_show_bgi),
- SHOW_LOOP_STATUS(CwfMetadataKey.CWF_PREF_WATCH_SHOW_LOOP_STATUS.key, R.string.key_show_external_status)
+ SHOW_LOOP_STATUS(CwfMetadataKey.CWF_PREF_WATCH_SHOW_LOOP_STATUS.key, R.string.key_show_external_status),
+ SHOW_WEEK_NUMBER(CwfMetadataKey.CWF_PREF_WATCH_SHOW_WEEK_NUMBER.key, R.string.key_show_week_number)
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt
index af2fb397cb..b9db42cdd9 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt
@@ -113,11 +113,6 @@ class DigitalStyleWatchface : BaseWatchFace() {
binding.minute.textSize = 26f
binding.hour.letterSpacing = 0.toFloat()
binding.minute.letterSpacing = 0.toFloat()
-
- /* display week number */
- val mWeekNumber = layoutView?.findViewById(R.id.week_number)
- mWeekNumber?.visibility = sp.getBoolean(R.string.key_show_week_number, false).toVisibility()
- mWeekNumber?.text = "(" + dateUtil.weekString() + ")"
}
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BaseWatchFace.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BaseWatchFace.kt
index 97820a23f5..8c8d4fdbe9 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BaseWatchFace.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/BaseWatchFace.kt
@@ -373,11 +373,13 @@ abstract class BaseWatchFace : WatchFace() {
binding.hour?.text = dateUtil.hourString()
binding.minute?.text = dateUtil.minuteString()
binding.dateTime?.visibility = sp.getBoolean(R.string.key_show_date, false).toVisibility()
- binding.dayName?.text = dateUtil.dayNameString(dayNameFormat)
+ binding.dayName?.text = dateUtil.dayNameString(dayNameFormat).substringBeforeLast(".")
binding.day?.text = dateUtil.dayString()
- binding.month?.text = dateUtil.monthString(monthFormat)
+ binding.month?.text = dateUtil.monthString(monthFormat).substringBeforeLast(".")
binding.timePeriod?.visibility = android.text.format.DateFormat.is24HourFormat(this).not().toVisibility()
binding.timePeriod?.text = dateUtil.amPm()
+ binding.weekNumber?.visibility = sp.getBoolean(R.string.key_show_week_number, false).toVisibility()
+ binding.weekNumber?.text = "(" + dateUtil.weekString() + ")"
if (showSecond)
setSecond()
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/WatchfaceViewAdapter.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/WatchfaceViewAdapter.kt
index 0498c48637..9ccd931586 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/WatchfaceViewAdapter.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/utils/WatchfaceViewAdapter.kt
@@ -73,6 +73,7 @@ class WatchfaceViewAdapter(
val mainMenuTap = ds?.mainMenuTap ?: sP?.mainMenuTap
val chartZoomTap = ds?.chartZoomTap ?: sP?.chartZoomTap
val dateTime = ds?.dateTime ?: a2?.dateTime
+ val weekNumber = ds?.weekNumber ?: cU?.weekNumber
// val minuteHand = sP?.minuteHand
// val secondaryLayout = aL?.secondaryLayout ?: a2?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout ?: sP?.secondaryLayout
// val tertiaryLayout = a2?.tertiaryLayout ?: sP?.tertiaryLayout
diff --git a/wear/src/main/res/layout/activity_custom.xml b/wear/src/main/res/layout/activity_custom.xml
index 293c06d248..95c231dbcb 100644
--- a/wear/src/main/res/layout/activity_custom.xml
+++ b/wear/src/main/res/layout/activity_custom.xml
@@ -282,7 +282,7 @@
android:textStyle="bold"
android:textColor="@color/white"
android:visibility="visible"
- tools:text="day." />
+ tools:text="day" />
+
+
+
+