Wear: Watchface cleanup

This commit is contained in:
Milos Kozak 2022-04-24 19:58:22 +02:00
parent 9c17c075f4
commit db4b1d261b
4 changed files with 34 additions and 71 deletions

View file

@ -139,16 +139,10 @@ class AapsV2Watchface : BaseWatchFace() {
mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor))
} }
} }
if (ageLevel == 1) { if (ageLevel == 1) mTimestamp?.setTextColor(Color.BLACK)
mTimestamp?.setTextColor(Color.BLACK) else mTimestamp?.setTextColor(Color.RED)
} else { if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(dividerTxtColor)
mTimestamp?.setTextColor(Color.RED) else mUploaderBattery?.setTextColor(Color.RED)
}
if (status.batteryLevel == 1) {
mUploaderBattery?.setTextColor(dividerTxtColor)
} else {
mUploaderBattery?.setTextColor(Color.RED)
}
mRigBattery?.setTextColor(dividerTxtColor) mRigBattery?.setTextColor(dividerTxtColor)
mDelta?.setTextColor(dividerTxtColor) mDelta?.setTextColor(dividerTxtColor)
mAvgDelta?.setTextColor(dividerTxtColor) mAvgDelta?.setTextColor(dividerTxtColor)

View file

@ -32,16 +32,10 @@ class AapsWatchface : BaseWatchFace() {
mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor)) mDirection?.setTextColor(ContextCompat.getColor(this, R.color.dark_lowColor))
} }
} }
if (ageLevel == 1) { if (ageLevel == 1) mTimestamp?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home))
mTimestamp?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home)) else mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld))
} else { if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery))
mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) else mUploaderBattery?.setTextColor(ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty))
}
if (status.batteryLevel == 1) {
mUploaderBattery?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery))
} else {
mUploaderBattery?.setTextColor(ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty))
}
mStatus?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home)) mStatus?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home))
if (chart != null) { if (chart != null) {
highColor = ContextCompat.getColor(this, R.color.dark_highColor) highColor = ContextCompat.getColor(this, R.color.dark_highColor)
@ -96,16 +90,10 @@ class AapsWatchface : BaseWatchFace() {
mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor)) mDirection?.setTextColor(ContextCompat.getColor(this, R.color.light_lowColor))
} }
} }
if (ageLevel == 1) { if (ageLevel == 1) mTimestamp?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE)
mTimestamp?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) else mTimestamp?.setTextColor(Color.RED)
} else { if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE)
mTimestamp?.setTextColor(Color.RED) else mUploaderBattery?.setTextColor(Color.RED)
}
if (status.batteryLevel == 1) {
mUploaderBattery?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE)
} else {
mUploaderBattery?.setTextColor(Color.RED)
}
mStatus?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE) mStatus?.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE)
mTime?.setTextColor(Color.BLACK) mTime?.setTextColor(Color.BLACK)
if (chart != null) { if (chart != null) {

View file

@ -130,9 +130,4 @@ class DigitalStyleWatchface : BaseWatchFace() {
override fun setColorBright() { override fun setColorBright() {
setColorDark() /* getCurrentWatchMode() == WatchMode.AMBIENT or WatchMode.INTERACTIVE */ setColorDark() /* getCurrentWatchMode() == WatchMode.AMBIENT or WatchMode.INTERACTIVE */
} }
companion object {
private const val TIME_TAP_THRESHOLD: Long = 800
}
} }

View file

@ -32,43 +32,29 @@ class SteampunkWatchface : BaseWatchFace() {
mLinearLayout2?.setBackgroundResource(0) mLinearLayout2?.setBackgroundResource(0)
mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.black_86p)) mTimestamp?.setTextColor(ContextCompat.getColor(this, R.color.black_86p))
} }
if (loopLevel == 0) { mLoop?.setTextColor(ContextCompat.getColor(this, if (loopLevel == 0) R.color.red_600 else R.color.black_86p))
mLoop?.setTextColor(ContextCompat.getColor(this, R.color.red_600))
} else {
mLoop?.setTextColor(ContextCompat.getColor(this, R.color.black_86p))
}
if (singleBg.sgvString != "---") { if (singleBg.sgvString != "---") {
var rotationAngle = 0f //by default, show ? on the dial (? is at 0 degrees on the dial) var rotationAngle = 0f //by default, show ? on the dial (? is at 0 degrees on the dial)
if (singleBg.glucoseUnits != "-") { if (singleBg.glucoseUnits != "-") {
//ensure the glucose dial is the correct units //ensure the glucose dial is the correct units
if (singleBg.glucoseUnits == "mmol") { mGlucoseDial?.setImageResource(if (singleBg.glucoseUnits == "mmol") R.drawable.steampunk_dial_mmol else R.drawable.steampunk_dial_mgdl)
mGlucoseDial?.setImageResource(R.drawable.steampunk_dial_mmol)
} else {
mGlucoseDial?.setImageResource(R.drawable.steampunk_dial_mgdl)
}
//convert the Sgv to degrees of rotation //convert the Sgv to degrees of rotation
rotationAngle = if (singleBg.glucoseUnits == "mmol") { rotationAngle =
stringToFloat(singleBg.sgvString) * 18f //convert to if (singleBg.glucoseUnits == "mmol") stringToFloat(singleBg.sgvString) * 18f //convert to mg/dL, which is equivalent to degrees
// mg/dL, which is equivalent to degrees else stringToFloat(singleBg.sgvString) //if glucose a value is received, use it to determine the amount of rotation of the dial.
} else {
stringToFloat(singleBg.sgvString) //if glucose a value is received, use it to determine the amount of rotation of the dial.
}
} }
if (rotationAngle > 330) rotationAngle = 330f //if the glucose value is higher than 330 then show "HIGH" on the dial. ("HIGH" is at 330 degrees on the dial) if (rotationAngle > 330) rotationAngle = 330f //if the glucose value is higher than 330 then show "HIGH" on the dial. ("HIGH" is at 330 degrees on the dial)
if (rotationAngle != 0f && rotationAngle < 30) rotationAngle = 30f //if the glucose value is lower than 30 show "LOW" on the dial. ("LOW" is at 30 degrees on the dial) if (rotationAngle != 0f && rotationAngle < 30) rotationAngle = 30f //if the glucose value is lower than 30 show "LOW" on the dial. ("LOW" is at 30 degrees on the dial)
if (lastEndDegrees == 0f) lastEndDegrees = rotationAngle if (lastEndDegrees == 0f) lastEndDegrees = rotationAngle
//rotate glucose dial //rotate glucose dial
val rotate = RotateAnimation( val rotate = RotateAnimation(lastEndDegrees, rotationAngle - lastEndDegrees, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f).apply {
lastEndDegrees, rotationAngle - lastEndDegrees, fillAfter = true
Animation.RELATIVE_TO_SELF, 0.5f, interpolator = LinearInterpolator()
Animation.RELATIVE_TO_SELF, 0.5f duration = 1
) }
rotate.fillAfter = true
rotate.interpolator = LinearInterpolator()
rotate.duration = 1
mGlucoseDial?.startAnimation(rotate) mGlucoseDial?.startAnimation(rotate)
lastEndDegrees = rotationAngle //store the final angle as a starting point for the next rotation. lastEndDegrees = rotationAngle //store the final angle as a starting point for the next rotation.
} }
@ -85,12 +71,12 @@ class SteampunkWatchface : BaseWatchFace() {
if (singleBg.glucoseUnits != "-") { if (singleBg.glucoseUnits != "-") {
if (singleBg.glucoseUnits == "mmol") { if (singleBg.glucoseUnits == "mmol") {
if (sp.getString("delta_granularity", "2") == "4") { //Auto granularity if (sp.getString("delta_granularity", "2") == "4") { //Auto granularity
autoGranularity = "1" // low (init) autoGranularity =
if (absAvgDelta < 0.3) { when {
autoGranularity = "3" // high if below 0.3 mmol/l absAvgDelta < 0.3 -> "3" // high if below 0.3 mmol/l
} else if (absAvgDelta < 0.5) { absAvgDelta < 0.5 -> "2" // medium if below 0.5 mmol/l
autoGranularity = "2" // medium if below 0.5 mmol/l else -> "1" // low (init)
} }
} }
if (sp.getString("delta_granularity", "2") == "1" || autoGranularity == "1") { //low if (sp.getString("delta_granularity", "2") == "1" || autoGranularity == "1") { //low
mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mmol_10) mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mmol_10)
@ -106,12 +92,12 @@ class SteampunkWatchface : BaseWatchFace() {
} }
} else { } else {
if (sp.getString("delta_granularity", "2") == "4") { //Auto granularity if (sp.getString("delta_granularity", "2") == "4") { //Auto granularity
autoGranularity = "1" // low (init) autoGranularity =
if (absAvgDelta < 5) { when {
autoGranularity = "3" // high if below 5 mg/dl absAvgDelta < 5 -> "3" // high if below 5 mg/dl
} else if (absAvgDelta < 10) { absAvgDelta < 10 -> "2" // medium if below 10 mg/dl
autoGranularity = "2" // medium if below 10 mg/dl else -> "1" // low (init)
} }
} }
if (sp.getString("delta_granularity", "2") == "1" || autoGranularity == "1") { //low if (sp.getString("delta_granularity", "2") == "1" || autoGranularity == "1") { //low
mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_20) mLinearLayout?.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_20)