Merge pull request #2939 from Philoul/wear/new_custom_watchface

Wear CWF Several improvement for preferences integration + AAPS V2 replacement
This commit is contained in:
Milos Kozak 2023-10-19 07:50:54 +02:00 committed by GitHub
commit 9b2473fa1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 76 additions and 578 deletions

View file

@ -170,7 +170,8 @@ enum class CwfMetadataKey(val key: String, @StringRes val label: Int, val isPref
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_WEEK_NUMBER("key_show_week_number", R.string.pref_show_week_number, true);
CWF_PREF_WATCH_SHOW_WEEK_NUMBER("key_show_week_number", R.string.pref_show_week_number, true),
CWF_PREF_WATCH_SHOW_DATE("key_show_date", R.string.pref_show_date, true);
companion object {
@ -260,6 +261,7 @@ enum class JsonKeys(val key: String) {
INVALIDIMAGE("invalidImage"),
INVALIDCOLOR("invalidColor"),
INVALIDFONTCOLOR("invalidFontColor"),
INVALIDTEXTSIZE("invalidTextSize"),
TWINVIEW("twinView"),
TOPOFFSETTWINHIDDEN("topOffsetTwinHidden"),
LEFTOFFSETTWINHIDDEN("leftOffsetTwinHidden"),

View file

@ -66,6 +66,7 @@
<string name="pref_show_direction_arrow">Show Direction Arrow</string>
<string name="pref_show_ago">Show Ago</string>
<string name="pref_show_week_number">Show Week number</string>
<string name="pref_show_date">Show Date</string>
<string name="default_custom_watchface_comment">Default watchface, you can click on EXPORT WATCHFACE button to generate a template</string>
<string name="wear_default_watchface">Default Watchface</string>
<string name="cwf_comment_background">Background image</string>

Binary file not shown.

View file

@ -95,31 +95,6 @@
</intent-filter>
</service>
<service
android:name=".watchfaces.AapsV2Watchface"
android:allowEmbedded="true"
android:exported="false"
android:label="@string/label_watchface_v2"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="@drawable/watchface_graph_2" />
<meta-data
android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
android:value="watch_face_configuration_home2" />
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</service>
<service
android:name=".watchfaces.AapsLargeWatchface"
android:allowEmbedded="true"
@ -602,7 +577,6 @@
<action android:name="watch_face_configuration_custom" />
<action android:name="watch_face_configuration_digitalstyle" />
<action android:name="watch_face_configuration_home" />
<action android:name="watch_face_configuration_home2" />
<action android:name="watch_face_configuration_largehome" />
<action android:name="watch_face_configuration_nochart" />

View file

@ -20,7 +20,6 @@ import app.aaps.wear.tile.QuickWizardTileService
import app.aaps.wear.tile.TempTargetTileService
import app.aaps.wear.tile.TileBase
import app.aaps.wear.watchfaces.AapsLargeWatchface
import app.aaps.wear.watchfaces.AapsV2Watchface
import app.aaps.wear.watchfaces.AapsWatchface
import app.aaps.wear.watchfaces.BigChartWatchface
import app.aaps.wear.watchfaces.CircleWatchface
@ -53,7 +52,6 @@ abstract class WearServicesModule {
@ContributesAndroidInjector abstract fun contributesBaseWatchFace(): BaseWatchFace
@ContributesAndroidInjector abstract fun contributesAapsWatchface(): AapsWatchface
@ContributesAndroidInjector abstract fun contributesAapsV2Watchface(): AapsV2Watchface
@ContributesAndroidInjector abstract fun contributesAapsLargeWatchface(): AapsLargeWatchface
@ContributesAndroidInjector abstract fun contributesDigitalStyleWatchface(): DigitalStyleWatchface
@ContributesAndroidInjector abstract fun contributesBIGChart(): BigChartWatchface

View file

@ -1,172 +0,0 @@
package app.aaps.wear.watchfaces
import android.graphics.Color
import android.view.LayoutInflater
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding
import app.aaps.wear.R
import app.aaps.wear.databinding.ActivityHome2Binding
import app.aaps.wear.watchfaces.utils.BaseWatchFace
import com.ustwo.clockwise.common.WatchMode
class AapsV2Watchface : BaseWatchFace() {
private lateinit var binding: ActivityHome2Binding
override fun inflateLayout(inflater: LayoutInflater): ViewBinding {
binding = ActivityHome2Binding.inflate(inflater)
return binding
}
override fun setColorDark() {
@ColorInt val dividerTxtColor = if (dividerMatchesBg) ContextCompat.getColor(this, R.color.dark_midColor) else Color.BLACK
@ColorInt val dividerBatteryOkColor = ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery)
@ColorInt val dividerBgColor = ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_statusView)
binding.secondaryLayout.setBackgroundColor(dividerBgColor)
binding.tertiaryLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.iob1.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.iob2.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.cob1.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.cob2.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.day.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.month.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.loop.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
setTextSizes()
val color = when (singleBg.sgvLevel) {
1L -> R.color.dark_highColor
0L -> R.color.dark_midColor
-1L -> R.color.dark_lowColor
else -> R.color.dark_midColor
}
binding.sgv.setTextColor(ContextCompat.getColor(this, color))
binding.direction.setTextColor(ContextCompat.getColor(this, color))
val colorTime = if (ageLevel == 1) R.color.dark_midColor else R.color.dark_TimestampOld
binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime))
val colourBat = if (status.batteryLevel == 1) dividerBatteryOkColor else ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)
binding.uploaderBattery.setTextColor(colourBat)
binding.rigBattery.setTextColor(dividerTxtColor)
binding.delta.setTextColor(dividerTxtColor)
binding.avgDelta.setTextColor(dividerTxtColor)
binding.basalRate.setTextColor(dividerTxtColor)
binding.bgi.setTextColor(dividerTxtColor)
when (loopLevel) {
-1 -> binding.loop.setBackgroundResource(R.drawable.loop_grey_25)
1 -> binding.loop.setBackgroundResource(R.drawable.loop_green_25)
else -> binding.loop.setBackgroundResource(R.drawable.loop_red_25)
}
highColor = ContextCompat.getColor(this, R.color.dark_highColor)
lowColor = ContextCompat.getColor(this, R.color.dark_lowColor)
midColor = ContextCompat.getColor(this, R.color.dark_midColor)
gridColor = ContextCompat.getColor(this, R.color.dark_gridColor)
basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark)
basalCenterColor = ContextCompat.getColor(this, R.color.basal_light)
pointSize = 2
setupCharts()
}
override fun setColorLowRes() {
@ColorInt val dividerTxtColor = if (dividerMatchesBg) ContextCompat.getColor(this, R.color.dark_midColor) else Color.BLACK
@ColorInt val dividerBgColor = ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_statusView)
binding.secondaryLayout.setBackgroundColor(dividerBgColor)
binding.tertiaryLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
binding.loop.setBackgroundResource(R.drawable.loop_grey_25)
binding.loop.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.sgv.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.direction.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp))
binding.delta.setTextColor(dividerTxtColor)
binding.avgDelta.setTextColor(dividerTxtColor)
binding.rigBattery.setTextColor(dividerTxtColor)
binding.uploaderBattery.setTextColor(dividerTxtColor)
binding.basalRate.setTextColor(dividerTxtColor)
binding.bgi.setTextColor(dividerTxtColor)
binding.iob1.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.iob2.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.cob1.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.cob2.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.day.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.month.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime))
highColor = ContextCompat.getColor(this, R.color.dark_midColor)
lowColor = ContextCompat.getColor(this, R.color.dark_midColor)
midColor = ContextCompat.getColor(this, R.color.dark_midColor)
gridColor = ContextCompat.getColor(this, R.color.dark_gridColor)
basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark_lowres)
basalCenterColor = ContextCompat.getColor(this, R.color.basal_light_lowres)
pointSize = 2
setupCharts()
setTextSizes()
}
override fun setColorBright() {
if (currentWatchMode == WatchMode.INTERACTIVE) {
@ColorInt val dividerTxtColor = if (dividerMatchesBg) Color.BLACK else ContextCompat.getColor(this, R.color.dark_midColor)
@ColorInt val dividerBgColor = ContextCompat.getColor(this, if (dividerMatchesBg) R.color.light_background else R.color.light_stripe_background)
binding.secondaryLayout.setBackgroundColor(dividerBgColor)
binding.tertiaryLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background))
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background))
binding.time.setTextColor(Color.BLACK)
binding.iob1.setTextColor(Color.BLACK)
binding.iob2.setTextColor(Color.BLACK)
binding.cob1.setTextColor(Color.BLACK)
binding.cob2.setTextColor(Color.BLACK)
binding.day.setTextColor(Color.BLACK)
binding.month.setTextColor(Color.BLACK)
binding.loop.setTextColor(Color.BLACK)
setTextSizes()
val color = when (singleBg.sgvLevel) {
1L -> R.color.light_highColor
0L -> R.color.light_midColor
-1L -> R.color.light_lowColor
else -> R.color.light_midColor
}
binding.sgv.setTextColor(ContextCompat.getColor(this, color))
binding.direction.setTextColor(ContextCompat.getColor(this, color))
val colorTime = if (ageLevel == 1) Color.BLACK else Color.RED
binding.timestamp.setTextColor(colorTime)
val colourBat = if (status.batteryLevel == 1) dividerTxtColor else Color.RED
binding.uploaderBattery.setTextColor(colourBat)
binding.rigBattery.setTextColor(dividerTxtColor)
binding.delta.setTextColor(dividerTxtColor)
binding.avgDelta.setTextColor(dividerTxtColor)
binding.basalRate.setTextColor(dividerTxtColor)
binding.bgi.setTextColor(dividerTxtColor)
when (loopLevel) {
-1 -> binding.loop.setBackgroundResource(R.drawable.loop_grey_25)
1 -> binding.loop.setBackgroundResource(R.drawable.loop_green_25)
else -> binding.loop.setBackgroundResource(R.drawable.loop_red_25)
}
highColor = ContextCompat.getColor(this, R.color.light_highColor)
lowColor = ContextCompat.getColor(this, R.color.light_lowColor)
midColor = ContextCompat.getColor(this, R.color.light_midColor)
gridColor = ContextCompat.getColor(this, R.color.light_gridColor)
basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_light)
basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark)
pointSize = 2
setupCharts()
} else {
setColorDark()
}
}
private fun setTextSizes() {
if (detailedIob) {
binding.iob1.textSize = 14f
binding.iob2.textSize = 10f
} else {
binding.iob1.textSize = 10f
binding.iob2.textSize = 14f
}
}
}

View file

@ -106,15 +106,15 @@ class CustomWatchface : BaseWatchFace() {
override fun setColorDark() {
setWatchfaceStyle()
if ((ViewMap.SGV.dynData?.stepFontColor ?: 0) == 0)
if ((ViewMap.SGV.dynData?.stepFontColor ?: 0) <= 0)
binding.sgv.setTextColor(bgColor)
if ((ViewMap.DIRECTION.dynData?.stepColor ?: 0) == 0)
if ((ViewMap.DIRECTION.dynData?.stepColor ?: 0) <= 0)
binding.direction2.colorFilter = changeDrawableColor(bgColor)
if (ageLevel != 1 && (ViewMap.TIMESTAMP.dynData?.stepFontColor ?: 0) == 0)
if (ageLevel != 1 && (ViewMap.TIMESTAMP.dynData?.stepFontColor ?: 0) <= 0)
binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld))
if (status.batteryLevel != 1 && (ViewMap.UPLOADER_BATTERY.dynData?.stepFontColor ?: 0) == 0)
if (status.batteryLevel != 1 && (ViewMap.UPLOADER_BATTERY.dynData?.stepFontColor ?: 0) <= 0)
binding.uploaderBattery.setTextColor(lowBatColor)
if ((ViewMap.LOOP.dynData?.stepDraw ?: 0) == 0) // Apply automatic background image only if no dynData or no step images
if ((ViewMap.LOOP.dynData?.stepDraw ?: 0) <= 0) // Apply automatic background image only if no dynData or no step images
when (loopLevel) {
-1 -> binding.loop.setBackgroundResource(R.drawable.loop_grey_25)
1 -> binding.loop.setBackgroundResource(R.drawable.loop_green_25)
@ -393,10 +393,10 @@ class CustomWatchface : BaseWatchFace() {
MINUTE(ViewKeys.MINUTE.key, R.id.minute),
SECOND(ViewKeys.SECOND.key, R.id.second, R.string.key_show_seconds),
TIMEPERIOD(ViewKeys.TIMEPERIOD.key, R.id.timePeriod),
DAY_NAME(ViewKeys.DAY_NAME.key, R.id.day_name),
DAY(ViewKeys.DAY.key, R.id.day),
DAY_NAME(ViewKeys.DAY_NAME.key, R.id.day_name, R.string.key_show_date),
DAY(ViewKeys.DAY.key, R.id.day, R.string.key_show_date),
WEEKNUMBER(ViewKeys.WEEKNUMBER.key, R.id.week_number, R.string.key_show_week_number),
MONTH(ViewKeys.MONTH.key, R.id.month),
MONTH(ViewKeys.MONTH.key, R.id.month, R.string.key_show_date),
LOOP(ViewKeys.LOOP.key, R.id.loop, R.string.key_show_external_status),
DIRECTION(ViewKeys.DIRECTION.key, R.id.direction2, R.string.key_show_direction),
TIMESTAMP(ViewKeys.TIMESTAMP.key, R.id.timestamp, R.string.key_show_ago),
@ -507,7 +507,7 @@ class CustomWatchface : BaseWatchFace() {
fun customizeTextView(view: TextView) {
customizeViewCommon(view)
viewJson?.let { viewJson ->
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, (viewJson.optInt(TEXTSIZE.key, 22) * cwf.zoomFactor).toFloat())
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, ((dynData?.getTextSize() ?: viewJson.optInt(TEXTSIZE.key, 22)) * cwf.zoomFactor).toFloat())
view.gravity = GravityMap.gravity(viewJson.optString(GRAVITY.key, GravityMap.CENTER.key))
view.setTypeface(
FontMap.font(viewJson.optString(FONT.key, FontMap.DEFAULT.key)),
@ -673,6 +673,7 @@ class CustomWatchface : BaseWatchFace() {
SHOW_BGI(CwfMetadataKey.CWF_PREF_WATCH_SHOW_BGI.key, R.string.key_show_bgi, true),
SHOW_LOOP_STATUS(CwfMetadataKey.CWF_PREF_WATCH_SHOW_LOOP_STATUS.key, R.string.key_show_external_status, true),
SHOW_WEEK_NUMBER(CwfMetadataKey.CWF_PREF_WATCH_SHOW_WEEK_NUMBER.key, R.string.key_show_week_number, true),
SHOW_DATE(CwfMetadataKey.CWF_PREF_WATCH_SHOW_DATE.key, R.string.key_show_date, true),
PREF_UNITS(JsonKeyValues.PREF_UNITS.key, R.string.key_units_mgdl, true),
PREF_DARK(JsonKeyValues.PREF_DARK.key, R.string.key_dark, true),
PREF_MATCH_DIVIDER(JsonKeyValues.PREF_MATCH_DIVIDER.key, R.string.key_match_divider, true);
@ -727,16 +728,19 @@ class CustomWatchface : BaseWatchFace() {
private val dynDrawable = mutableMapOf<Int, Drawable?>()
private val dynColor = mutableMapOf<Int, Int>()
private val dynFontColor = mutableMapOf<Int, Int>()
private val dynTextSize = mutableMapOf<Int, Int>()
private var dataRange: DataRange? = null
private var topRange: DataRange? = null
private var leftRange: DataRange? = null
private var rotationRange: DataRange? = null
val stepDraw: Int
get() = dynDrawable[0]?.let { dynDrawable.size - 1 } ?: dynDrawable.size
get() = dynDrawable.size - 1
val stepColor: Int
get() = dynColor[0]?.let { dynColor.size - 1 } ?: dynColor.size
val stepFontColor: Int
get() = dynFontColor[0]?.let { dynFontColor.size - 1 } ?: dynFontColor.size
val stepTextSize: Int
get() = dynTextSize[0]?.let { dynTextSize.size - 1 } ?: dynTextSize.size
val dataValue: Double?
get() = when (valueMap) {
@ -761,8 +765,9 @@ class CustomWatchface : BaseWatchFace() {
fun getLeftOffset(): Int = dataRange?.let { dataRange -> leftRange?.let { leftRange -> dataValue?.let { (valueMap.dynValue(it, dataRange, leftRange) * cwf.zoomFactor).toInt() }
?: (leftRange.invalidData * cwf.zoomFactor).toInt() } } ?: 0
fun getRotationOffset(): Int = dataRange?.let { dataRange -> rotationRange?.let { rotRange -> dataValue?.let { valueMap.dynValue(it, dataRange, rotRange) } ?: rotRange.invalidData } } ?: 0
fun getDrawable() = dataRange?.let { dataRange -> dataValue?.let { dynDrawable[valueMap.stepValue(it, dataRange, stepDraw)] } ?: dynDrawable[0] ?: dynDrawable[1] }
fun getDrawable() = dataRange?.let { dataRange -> dataValue?.let { dynDrawable[valueMap.stepValue(it, dataRange, stepDraw)] } ?: dynDrawable[0] }
fun getFontColor() = if (stepFontColor > 0) dataRange?.let { dataRange -> dataValue?.let { dynFontColor[valueMap.stepValue(it, dataRange, stepFontColor)] } ?: dynFontColor[0] ?: dynFontColor[1] } else null
fun getTextSize() = if (stepTextSize > 0) dataRange?.let { dataRange -> dataValue?.let { dynTextSize[valueMap.stepValue(it, dataRange, stepTextSize)] } ?: dynTextSize[0] ?: dynTextSize[1] } else null
fun getColor() = if (stepColor > 0) dataRange?.let { dataRange -> dataValue?.let { dynColor[valueMap.stepValue(it, dataRange, stepColor)] } ?: dynColor[0] ?: dynColor[1] } else null
private fun load() {
DataRange(dataJson.optDouble(MINDATA.key, valueMap.min), dataJson.optDouble(MAXDATA.key, valueMap.max)).let { defaultRange ->
@ -792,6 +797,13 @@ class CustomWatchface : BaseWatchFace() {
dynFontColor[idx] = cwf.getColor(dataJson.optString("${FONTCOLOR.key}$idx"))
idx++
}
if (dataJson.has(INVALIDTEXTSIZE.key))
dynTextSize[0] = cwf.getColor(dataJson.optString(INVALIDTEXTSIZE.key))
idx = 1
while (dataJson.has("${TEXTSIZE.key}$idx")) {
dynTextSize[idx] = dataJson.optInt("${TEXTSIZE.key}$idx", 22)
idx++
}
}
companion object {
@ -845,11 +857,12 @@ class CustomWatchface : BaseWatchFace() {
valPref.clear()
dynPref.clear()
dynJson?.keys()?.forEach { key ->
dynJson.optJSONObject(key)?.let { buildDynPrefs(dynJson, it, key, mutableSetOf()) }
val targetJson = JSONObject()
dynJson.optJSONObject(key)?.let { buildDynPrefs(dynJson, targetJson, it, key, mutableSetOf()) }
}
}
private fun buildDynPrefs(dynJson: JSONObject, json: JSONObject, key: String, visitedKeys: MutableSet<String>) {
private fun buildDynPrefs(dynJson: JSONObject, targetJson: JSONObject, json: JSONObject, key: String, visitedKeys: MutableSet<String>) {
val prefKey = json.optString(PREFKEY.key)
PrefMap.fromKey(prefKey)?.let { prefMap ->
val value = valPref[prefMap.key]
@ -858,16 +871,23 @@ class CustomWatchface : BaseWatchFace() {
}
json.optJSONObject(value)?.let { nextJson ->
if (nextJson.has(DYNPREF.key)) {
nextJson.keys().forEach { key ->
if ( key != DYNPREF.key)
targetJson.putOpt(key, nextJson.opt(key))
}
val nextKey = nextJson.optString(DYNPREF.key)
if (nextKey.isNotEmpty() && nextKey !in visitedKeys) {
visitedKeys += nextKey
dynJson.optJSONObject(nextKey)?.let {
buildDynPrefs(dynJson, it, key, visitedKeys)
buildDynPrefs(dynJson, targetJson, it, key, visitedKeys)
}
}
} else {
//aapsLogger.debug("XXXXX dynKey json $key $nextJson")
dynPref[key] = nextJson
nextJson.keys().forEach { key ->
if ( key != DYNPREF.key)
targetJson.putOpt(key, nextJson.opt(key))
}
dynPref[key] = targetJson
}
}
}

View file

@ -4,7 +4,6 @@ import androidx.viewbinding.ViewBinding
import app.aaps.wear.databinding.ActivityBigchartBinding
import app.aaps.wear.databinding.ActivityCustomBinding
import app.aaps.wear.databinding.ActivityDigitalstyleBinding
import app.aaps.wear.databinding.ActivityHome2Binding
import app.aaps.wear.databinding.ActivityHomeBinding
import app.aaps.wear.databinding.ActivityHomeLargeBinding
import app.aaps.wear.databinding.ActivityNochartBinding
@ -15,7 +14,6 @@ import app.aaps.wear.databinding.ActivityNochartBinding
*/
class WatchfaceViewAdapter(
aL: ActivityHomeLargeBinding? = null,
a2: ActivityHome2Binding? = null,
aa: ActivityHomeBinding? = null,
bC: ActivityBigchartBinding? = null,
ds: ActivityDigitalstyleBinding? = null,
@ -24,7 +22,7 @@ class WatchfaceViewAdapter(
) {
init {
if (aL == null && a2 == null && aa == null && bC == null && ds == null && nC == null && cU == null) {
if (aL == null && aa == null && bC == null && ds == null && nC == null && cU == null) {
throw IllegalArgumentException("Require at least on Binding parameter")
}
}
@ -33,47 +31,46 @@ class WatchfaceViewAdapter(
// Required attributes
val mainLayout =
aL?.mainLayout ?: a2?.mainLayout ?: aa?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: cU?.mainLayout
aL?.mainLayout ?: aa?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: cU?.mainLayout
?: throw IllegalArgumentException(errorMessage)
val timestamp =
aL?.timestamp ?: a2?.timestamp ?: aa?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: cU?.timestamp
aL?.timestamp ?: aa?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: cU?.timestamp
?: throw IllegalArgumentException(errorMessage)
val root =
aL?.root ?: a2?.root ?: aa?.root ?: bC?.root ?: bC?.root ?: ds?.root ?: nC?.root ?: cU?.root
aL?.root ?: aa?.root ?: bC?.root ?: bC?.root ?: ds?.root ?: nC?.root ?: cU?.root
?: throw IllegalArgumentException(errorMessage)
// Optional attributes
val sgv = aL?.sgv ?: a2?.sgv ?: aa?.sgv ?: bC?.sgv ?: bC?.sgv ?: ds?.sgv ?: nC?.sgv ?: cU?.sgv
val direction = aL?.direction ?: a2?.direction ?: aa?.direction ?: ds?.direction
val loop = a2?.loop ?: cU?.loop
val delta = aL?.delta ?: a2?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
val avgDelta = a2?.avgDelta ?: bC?.avgDelta ?: bC?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta
val uploaderBattery = aL?.uploaderBattery ?: a2?.uploaderBattery ?: aa?.uploaderBattery ?: ds?.uploaderBattery ?: cU?.uploaderBattery
val rigBattery = a2?.rigBattery ?: ds?.rigBattery ?: cU?.rigBattery
val basalRate = a2?.basalRate ?: ds?.basalRate ?: cU?.basalRate
val bgi = a2?.bgi ?: ds?.bgi ?: cU?.bgi
val AAPSv2 = a2?.AAPSv2 ?: ds?.AAPSv2 ?: cU?.AAPSv2
val cob1 = a2?.cob1 ?: ds?.cob1 ?: cU?.cob1
val cob2 = a2?.cob2 ?: ds?.cob2 ?: cU?.cob2
val time = aL?.time ?: a2?.time ?: aa?.time ?: bC?.time ?: bC?.time ?: nC?.time ?: cU?.time
val sgv = aL?.sgv ?: aa?.sgv ?: bC?.sgv ?: bC?.sgv ?: ds?.sgv ?: nC?.sgv ?: cU?.sgv
val direction = aL?.direction ?: aa?.direction ?: ds?.direction
val loop = cU?.loop
val delta = aL?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
val avgDelta = bC?.avgDelta ?: bC?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta
val uploaderBattery = aL?.uploaderBattery ?: aa?.uploaderBattery ?: ds?.uploaderBattery ?: cU?.uploaderBattery
val rigBattery = ds?.rigBattery ?: cU?.rigBattery
val basalRate = ds?.basalRate ?: cU?.basalRate
val bgi = ds?.bgi ?: cU?.bgi
val AAPSv2 = ds?.AAPSv2 ?: cU?.AAPSv2
val cob1 = ds?.cob1 ?: cU?.cob1
val cob2 = ds?.cob2 ?: cU?.cob2
val time = aL?.time ?: aa?.time ?: bC?.time ?: bC?.time ?: nC?.time ?: cU?.time
val second = cU?.second
val minute = ds?.minute ?: cU?.minute
val hour = ds?.hour ?: cU?.hour
val day = a2?.day ?: ds?.day ?: cU?.day
val month = a2?.month ?: ds?.month ?: cU?.month
val iob1 = a2?.iob1 ?: ds?.iob1 ?: cU?.iob1
val iob2 = a2?.iob2 ?: ds?.iob2 ?: cU?.iob2
val chart = a2?.chart ?: aa?.chart ?: bC?.chart ?: bC?.chart ?: ds?.chart ?: cU?.chart
val day = ds?.day ?: cU?.day
val month = ds?.month ?: cU?.month
val iob1 = ds?.iob1 ?: cU?.iob1
val iob2 = ds?.iob2 ?: cU?.iob2
val chart = aa?.chart ?: bC?.chart ?: bC?.chart ?: ds?.chart ?: cU?.chart
val status = aL?.status ?: aa?.status ?: bC?.status ?: bC?.status ?: nC?.status
val timePeriod = ds?.timePeriod ?: aL?.timePeriod ?: nC?.timePeriod ?: bC?.timePeriod ?: cU?.timePeriod
val dayName = ds?.dayName ?: cU?.dayName
val mainMenuTap = ds?.mainMenuTap
val chartZoomTap = ds?.chartZoomTap
val dateTime = ds?.dateTime ?: a2?.dateTime
val dateTime = ds?.dateTime
val weekNumber = ds?.weekNumber ?: cU?.weekNumber
// val minuteHand = cU?.minuteHand
// val secondaryLayout = aL?.secondaryLayout ?: a2?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout
// val tertiaryLayout = a2?.tertiaryLayout
// val secondaryLayout = aL?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout
// val hourHand = cU?.hourHand
companion object {
@ -81,12 +78,11 @@ class WatchfaceViewAdapter(
fun getBinding(bindLayout: ViewBinding): WatchfaceViewAdapter {
return when (bindLayout) {
is ActivityHomeLargeBinding -> WatchfaceViewAdapter(bindLayout)
is ActivityHome2Binding -> WatchfaceViewAdapter(null, bindLayout)
is ActivityHomeBinding -> WatchfaceViewAdapter(null, null, bindLayout)
is ActivityBigchartBinding -> WatchfaceViewAdapter(null, null, null, bindLayout)
is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout)
is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, null, null, bindLayout)
is ActivityCustomBinding -> WatchfaceViewAdapter(null, null, null, null, null, null, bindLayout)
is ActivityHomeBinding -> WatchfaceViewAdapter(null, bindLayout)
is ActivityBigchartBinding -> WatchfaceViewAdapter(null, null, bindLayout)
is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, null, bindLayout)
is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout)
is ActivityCustomBinding -> WatchfaceViewAdapter(null, null, null, null, null, bindLayout)
else -> throw IllegalArgumentException("ViewBinding is not implement in WatchfaceViewAdapter")
}
}

View file

@ -1,285 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".watchfaces.AapsV2Watchface">
<LinearLayout
android:id="@+id/primary_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
app:layout_constraintBottom_toTopOf="@+id/secondary_layout"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/loop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/loop_grey_25"
android:gravity="center"
android:textSize="14sp"
android:textStyle="bold"
tools:text="--'" />
<TextView
android:id="@+id/sgv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity=""
android:layout_marginBottom="-2dp"
android:paddingHorizontal="5dp"
android:textSize="38sp"
tools:text="---" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/direction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:textStyle="bold"
tools:text="--" />
<TextView
android:id="@+id/timestamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="14sp"
android:textStyle="bold"
tools:text="--'" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/secondary_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?android:colorForeground"
android:paddingVertical="1dp"
app:layout_constraintBottom_toTopOf="@+id/tertiary_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="5dp">
<TextView
android:id="@+id/delta"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="13sp"
android:textStyle="bold"
tools:text="+/-" />
<TextView
android:id="@+id/avg_delta"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="13sp"
android:textStyle="bold"
tools:text="@string/abbreviation_average" />
<TextView
android:id="@+id/uploader_battery"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:textAlignment="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="13sp"
android:textStyle="bold"
tools:text="--%" />
<TextView
android:id="@+id/rig_battery"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:textAlignment="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="13sp"
android:textStyle="bold"
android:visibility="visible"
tools:text="--%" />
<TextView
android:id="@+id/basalRate"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1.7"
android:gravity="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="13sp"
android:textStyle="bold"
tools:text="@string/no_tmp_basal_u_h" />
<TextView
android:id="@+id/bgi"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="13sp"
android:textStyle="bold"
android:visibility="visible"
tools:text="bgi" />
<View
android:id="@+id/AAPSv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:weightSum="7"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/cob1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/activity_carb"
android:textSize="11sp" />
<TextView
android:id="@+id/cob2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_cob_g"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1"
tools:ignore="NestedWeights" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="30sp"
tools:text="12:00" />
<LinearLayout
android:id="@+id/date_time"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/day"
android:layout_width="23dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textAlignment="center"
android:textSize="12sp"
tools:text="day" />
<TextView
android:id="@+id/month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textSize="12sp"
tools:text="mth" />
</LinearLayout>
<View
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
android:textAlignment="center">
<TextView
android:id="@+id/iob1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textAlignment="center"
android:textSize="11sp"
tools:text="@string/activity_IOB" />
<TextView
android:id="@+id/iob2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textSize="14sp"
android:textStyle="bold"
tools:text="@string/no_iob_u" />
</LinearLayout>
</LinearLayout>
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="-5dp"
android:layout_marginBottom="7dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tertiary_layout" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -7,7 +7,6 @@
<string name="label_watchface_big_chart">AAPS(BigChart)</string>
<string name="label_watchface_no_chart">AAPS(NoChart)</string>
<string name="label_watchface_circle">AAPS(Circle)</string>
<string name="label_watchface_v2">AAPS(v2)</string>
<string name="label_watchface_digital_style">AAPS(DigitalStyle)</string>
<string name="label_watchface_custom">AAPS(Custom)</string>
<string name="label_actions_tile">AAPS(Actions)</string>

View file

@ -31,6 +31,13 @@
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_show_date"
android:title="@string/pref_show_date"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_vibrate_hourly"

View file

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/key_dark"
android:title="@string/pref_dark"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_match_divider"
android:summary="Status bar divider background matches watchface background"
android:title="@string/pref_matching_divider"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_show_date"
android:title="@string/pref_show_date"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_vibrate_hourly"
android:title="@string/pref_vibrate_hourly"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<ListPreference
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
android:key="@string/key_simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
</PreferenceScreen>