Merge branch 'dev' of https://github.com/nightscout/AndroidAPS into dev
This commit is contained in:
commit
89f822e003
|
@ -183,7 +183,10 @@ enum class JsonKeys(val key: String, val viewType: ViewType, @StringRes val comm
|
|||
FONT("font", ViewType.TEXTVIEW, null),
|
||||
FONTSTYLE("fontStyle", ViewType.TEXTVIEW, null),
|
||||
FONTCOLOR("fontColor", ViewType.TEXTVIEW, null),
|
||||
COLOR("color", ViewType.IMAGEVIEW, null)
|
||||
COLOR("color", ViewType.IMAGEVIEW, null),
|
||||
ALLCAPS("allCaps", ViewType.TEXTVIEW, null),
|
||||
DAYNAMEFORMAT("dayNameFormat", ViewType.NONE, null),
|
||||
MONTHFORMAT("monthFormat", ViewType.NONE, null)
|
||||
}
|
||||
|
||||
enum class JsonKeyValues(val key: String, val jsonKey: JsonKeys) {
|
||||
|
|
|
@ -171,17 +171,17 @@ class DateUtil @Inject constructor(private val context: Context) {
|
|||
fun amPm(mills: Long): String =
|
||||
DateTime(mills).toString(DateTimeFormat.forPattern("a"))
|
||||
|
||||
fun dayNameString(): String = dayNameString(now())
|
||||
fun dayNameString(mills: Long): String =
|
||||
DateTime(mills).toString(DateTimeFormat.forPattern("E"))
|
||||
fun dayNameString(format: String = "E"): String = dayNameString(now(), format)
|
||||
fun dayNameString(mills: Long, format: String = "E"): String =
|
||||
DateTime(mills).toString(DateTimeFormat.forPattern(format))
|
||||
|
||||
fun dayString(): String = dayString(now())
|
||||
fun dayString(mills: Long): String =
|
||||
DateTime(mills).toString(DateTimeFormat.forPattern("dd"))
|
||||
|
||||
fun monthString(): String = monthString(now())
|
||||
fun monthString(mills: Long): String =
|
||||
DateTime(mills).toString(DateTimeFormat.forPattern("MMM"))
|
||||
fun monthString(format: String = "MMM"): String = monthString(now(), format)
|
||||
fun monthString(mills: Long, format: String = "MMM"): String =
|
||||
DateTime(mills).toString(DateTimeFormat.forPattern(format))
|
||||
|
||||
fun weekString(): String = weekString(now())
|
||||
fun weekString(mills: Long): String =
|
||||
|
|
|
@ -157,6 +157,10 @@ class CustomWatchface : BaseWatchFace() {
|
|||
basalCenterColor = getColor(json.optString(BASALCENTERCOLOR.key), ContextCompat.getColor(this, R.color.basal_light))
|
||||
gridColor = getColor(json.optString(GRIDCOLOR.key), Color.WHITE)
|
||||
pointSize = json.optInt(POINTSIZE.key, 2)
|
||||
dayNameFormat = json.optString(DAYNAMEFORMAT.key, "E")
|
||||
.takeIf { it.matches(Regex("E{1,4}")) } ?: "E"
|
||||
monthFormat = json.optString(MONTHFORMAT.key, "MMM")
|
||||
.takeIf { it.matches(Regex("M{1,4}")) } ?: "MMM"
|
||||
bgColor = when (singleBg.sgvLevel) {
|
||||
1L -> highColor
|
||||
0L -> midColor
|
||||
|
@ -191,9 +195,9 @@ class CustomWatchface : BaseWatchFace() {
|
|||
StyleMap.style(viewJson.optString(FONTSTYLE.key, StyleMap.NORMAL.key))
|
||||
)
|
||||
view.setTextColor(getColor(viewJson.optString(FONTCOLOR.key)))
|
||||
|
||||
view.isAllCaps = viewJson.optBoolean(ALLCAPS.key)
|
||||
if (viewJson.has(TEXTVALUE.key))
|
||||
view.text = viewJson.getString(TEXTVALUE.key)
|
||||
view.text = viewJson.optString(TEXTVALUE.key)
|
||||
}
|
||||
|
||||
is ImageView -> {
|
||||
|
@ -204,14 +208,14 @@ class CustomWatchface : BaseWatchFace() {
|
|||
drawableDataMap[CwfDrawableFileMap.fromKey(id.key)]?.toDrawable(resources)
|
||||
drawable?.let {
|
||||
if (viewJson.has(COLOR.key))
|
||||
it.colorFilter = changeDrawableColor(getColor(viewJson.getString(COLOR.key)))
|
||||
it.colorFilter = changeDrawableColor(getColor(viewJson.optString(COLOR.key)))
|
||||
else
|
||||
it.clearColorFilter()
|
||||
view.setImageDrawable(it)
|
||||
} ?: apply {
|
||||
view.setImageDrawable(CwfDrawableFileMap.fromKey(id.key).icon?.let { context.getDrawable(it) })
|
||||
if (viewJson.has(COLOR.key))
|
||||
view.setColorFilter(getColor(viewJson.getString(COLOR.key)))
|
||||
view.setColorFilter(getColor(viewJson.optString(COLOR.key)))
|
||||
else
|
||||
view.clearColorFilter()
|
||||
}
|
||||
|
|
|
@ -88,6 +88,8 @@ abstract class BaseWatchFace : WatchFace() {
|
|||
var enableSecond = false
|
||||
var detailedIob = false
|
||||
var externalStatus = ""
|
||||
var dayNameFormat = "E"
|
||||
var monthFormat = "MMM"
|
||||
val showSecond: Boolean
|
||||
get() = enableSecond && currentWatchMode == WatchMode.INTERACTIVE
|
||||
|
||||
|
@ -317,7 +319,7 @@ abstract class BaseWatchFace : WatchFace() {
|
|||
binding.iob1?.text = if (detailedIob) status.iobSum else getString(R.string.activity_IOB)
|
||||
binding.iob2?.text = if (detailedIob) status.iobDetail else status.iobSum
|
||||
binding.timestamp.visibility = sp.getBoolean(R.string.key_show_ago, true).toVisibility()
|
||||
binding.timestamp.text = readingAge(if (binding.AAPSv2 != null) true else sp.getBoolean(R.string.key_show_external_status, true))
|
||||
binding.timestamp.text = readingAge(binding.AAPSv2 != null || sp.getBoolean(R.string.key_show_external_status, true))
|
||||
binding.uploaderBattery?.visibility = sp.getBoolean(R.string.key_show_uploader_battery, true).toVisibility()
|
||||
binding.uploaderBattery?.text =
|
||||
when {
|
||||
|
@ -371,9 +373,9 @@ 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()
|
||||
binding.dayName?.text = dateUtil.dayNameString(dayNameFormat)
|
||||
binding.day?.text = dateUtil.dayString()
|
||||
binding.month?.text = dateUtil.monthString()
|
||||
binding.month?.text = dateUtil.monthString(monthFormat)
|
||||
binding.timePeriod?.visibility = android.text.format.DateFormat.is24HourFormat(this).not().toVisibility()
|
||||
binding.timePeriod?.text = dateUtil.amPm()
|
||||
if (showSecond)
|
||||
|
|
Loading…
Reference in a new issue