Remove direction from layout and add missing colors
This commit is contained in:
parent
a03ca40bef
commit
e658ba45bc
4 changed files with 27 additions and 102 deletions
|
@ -17,7 +17,7 @@ import java.util.zip.ZipEntry
|
||||||
import java.util.zip.ZipInputStream
|
import java.util.zip.ZipInputStream
|
||||||
import java.util.zip.ZipOutputStream
|
import java.util.zip.ZipOutputStream
|
||||||
|
|
||||||
val CUSTOM_VERSION = "0.3"
|
val CUSTOM_VERSION = "0.4"
|
||||||
enum class CustomWatchfaceDrawableDataKey(val key: String, @DrawableRes val icon: Int?, val fileName: String) {
|
enum class CustomWatchfaceDrawableDataKey(val key: String, @DrawableRes val icon: Int?, val fileName: String) {
|
||||||
UNKNOWN("unknown", null, "Unknown"),
|
UNKNOWN("unknown", null, "Unknown"),
|
||||||
CUSTOM_WATCHFACE("customWatchface", R.drawable.watchface_custom, "CustomWatchface"),
|
CUSTOM_WATCHFACE("customWatchface", R.drawable.watchface_custom, "CustomWatchface"),
|
||||||
|
@ -29,30 +29,10 @@ enum class CustomWatchfaceDrawableDataKey(val key: String, @DrawableRes val icon
|
||||||
SECONDHAND("second_hand", R.drawable.second_hand, "SecondHand");
|
SECONDHAND("second_hand", R.drawable.second_hand, "SecondHand");
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val keyToEnumMap = HashMap<String, CustomWatchfaceDrawableDataKey>()
|
|
||||||
private val fileNameToEnumMap = HashMap<String, CustomWatchfaceDrawableDataKey>()
|
|
||||||
|
|
||||||
init {
|
|
||||||
for (value in values()) keyToEnumMap[value.key] = value
|
|
||||||
for (value in values()) fileNameToEnumMap[value.fileName] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
fun fromKey(key: String): CustomWatchfaceDrawableDataKey =
|
fun fromKey(key: String): CustomWatchfaceDrawableDataKey =
|
||||||
if (keyToEnumMap.containsKey(key)) {
|
values().firstOrNull { it.key == key } ?: UNKNOWN
|
||||||
keyToEnumMap[key] ?: UNKNOWN
|
fun fromFileName(file: String): CustomWatchfaceDrawableDataKey = values().firstOrNull { it.fileName == file } ?: UNKNOWN
|
||||||
} else {
|
|
||||||
UNKNOWN
|
|
||||||
}
|
|
||||||
|
|
||||||
fun fromFileName(file: String): CustomWatchfaceDrawableDataKey =
|
|
||||||
if (fileNameToEnumMap.containsKey(file.substringBeforeLast("."))) {
|
|
||||||
fileNameToEnumMap[file.substringBeforeLast(".")] ?: UNKNOWN
|
|
||||||
} else {
|
|
||||||
UNKNOWN
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class DrawableFormat(val extension: String) {
|
enum class DrawableFormat(val extension: String) {
|
||||||
|
@ -64,19 +44,9 @@ enum class DrawableFormat(val extension: String) {
|
||||||
PNG("png");
|
PNG("png");
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val extensionToEnumMap = HashMap<String, DrawableFormat>()
|
|
||||||
|
|
||||||
init {
|
|
||||||
for (value in values()) extensionToEnumMap[value.extension] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
fun fromFileName(fileName: String): DrawableFormat =
|
fun fromFileName(fileName: String): DrawableFormat =
|
||||||
if (extensionToEnumMap.containsKey(fileName.substringAfterLast("."))) {
|
values().firstOrNull { it.extension == fileName.substringAfterLast(".") } ?: UNKNOWN
|
||||||
extensionToEnumMap[fileName.substringAfterLast(".")] ?: UNKNOWN
|
|
||||||
} else {
|
|
||||||
UNKNOWN
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,20 +96,8 @@ enum class CustomWatchfaceMetadataKey(val key: String, @StringRes val label: Int
|
||||||
CWF_VERSION("cwf_version", R.string.metadata_label_watchface_version);
|
CWF_VERSION("cwf_version", R.string.metadata_label_watchface_version);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val keyToEnumMap = HashMap<String, CustomWatchfaceMetadataKey>()
|
|
||||||
|
|
||||||
init {
|
|
||||||
for (value in values()) keyToEnumMap[value.key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
fun fromKey(key: String): CustomWatchfaceMetadataKey? =
|
fun fromKey(key: String): CustomWatchfaceMetadataKey? =
|
||||||
if (keyToEnumMap.containsKey(key)) {
|
values().firstOrNull { it.key == key }
|
||||||
keyToEnumMap[key]
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,12 +78,16 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
override fun setDataFields() {
|
override fun setDataFields() {
|
||||||
super.setDataFields()
|
super.setDataFields()
|
||||||
binding.direction2.setImageDrawable(resources.getDrawable(TrendArrow.fromSymbol(singleBg.slopeArrow).icon))
|
binding.direction2.setImageDrawable(resources.getDrawable(TrendArrow.fromSymbol(singleBg.slopeArrow).icon))
|
||||||
|
// rotate the second hand.
|
||||||
|
binding.secondHand.rotation = TimeOfDay().secondOfMinute * 6f
|
||||||
|
// rotate the minute hand.
|
||||||
|
binding.minuteHand.rotation = TimeOfDay().minuteOfHour * 6f
|
||||||
|
// rotate the hour hand.
|
||||||
|
binding.hourHand.rotation = TimeOfDay().hourOfDay * 30f + TimeOfDay().minuteOfHour * 0.5f
|
||||||
}
|
}
|
||||||
override fun setColorDark() {
|
override fun setColorDark() {
|
||||||
setWatchfaceStyle()
|
setWatchfaceStyle()
|
||||||
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
|
|
||||||
binding.sgv.setTextColor(bgColor)
|
binding.sgv.setTextColor(bgColor)
|
||||||
binding.direction.setTextColor(bgColor)
|
|
||||||
binding.direction2.colorFilter = changeDrawableColor(bgColor)
|
binding.direction2.colorFilter = changeDrawableColor(bgColor)
|
||||||
|
|
||||||
if (ageLevel != 1)
|
if (ageLevel != 1)
|
||||||
|
@ -96,16 +100,6 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
else -> binding.loop.setBackgroundResource(R.drawable.loop_red_25)
|
else -> binding.loop.setBackgroundResource(R.drawable.loop_red_25)
|
||||||
}
|
}
|
||||||
|
|
||||||
basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark)
|
|
||||||
basalCenterColor = ContextCompat.getColor(this, R.color.basal_light)
|
|
||||||
|
|
||||||
// rotate the second hand.
|
|
||||||
binding.secondHand.rotation = TimeOfDay().secondOfMinute * 6f
|
|
||||||
// rotate the minute hand.
|
|
||||||
binding.minuteHand.rotation = TimeOfDay().minuteOfHour * 6f
|
|
||||||
// rotate the hour hand.
|
|
||||||
binding.hourHand.rotation = TimeOfDay().hourOfDay * 30f + TimeOfDay().minuteOfHour * 0.5f
|
|
||||||
|
|
||||||
setupCharts()
|
setupCharts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +137,9 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
lowColor = if (json.has("lowColor")) Color.parseColor(json.getString("lowColor")) else ContextCompat.getColor(this, R.color.low)
|
lowColor = if (json.has("lowColor")) Color.parseColor(json.getString("lowColor")) else ContextCompat.getColor(this, R.color.low)
|
||||||
lowBatColor = if (json.has("lowBatColor")) Color.parseColor(json.getString("lowBatColor")) else ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)
|
lowBatColor = if (json.has("lowBatColor")) Color.parseColor(json.getString("lowBatColor")) else ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)
|
||||||
carbColor = if (json.has("carbColor")) Color.parseColor(json.getString("carbColor")) else ContextCompat.getColor(this, R.color.carbs)
|
carbColor = if (json.has("carbColor")) Color.parseColor(json.getString("carbColor")) else ContextCompat.getColor(this, R.color.carbs)
|
||||||
gridColor = if (json.has("gridColor")) Color.parseColor(json.getString("gridColor")) else ContextCompat.getColor(this, R.color.carbs)
|
basalBackgroundColor = if (json.has("basalBackgroundColor")) Color.parseColor(json.getString("basalBackgroundColor")) else ContextCompat.getColor(this, R.color.basal_dark)
|
||||||
|
basalCenterColor = if (json.has("basalCenterColor")) Color.parseColor(json.getString("basalCenterColor")) else ContextCompat.getColor(this, R.color.basal_light)
|
||||||
|
gridColor = if (json.has("gridColor")) Color.parseColor(json.getString("gridColor")) else Color.WHITE
|
||||||
pointSize = if (json.has("pointSize")) json.getInt("pointSize") else 2
|
pointSize = if (json.has("pointSize")) json.getInt("pointSize") else 2
|
||||||
bgColor = when (singleBg.sgvLevel) {
|
bgColor = when (singleBg.sgvLevel) {
|
||||||
1L -> highColor
|
1L -> highColor
|
||||||
|
@ -224,6 +220,8 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
.put("lowColor", String.format("#%06X", 0xFFFFFF and lowColor))
|
.put("lowColor", String.format("#%06X", 0xFFFFFF and lowColor))
|
||||||
.put("lowBatColor", String.format("#%06X", 0xFFFFFF and lowBatColor))
|
.put("lowBatColor", String.format("#%06X", 0xFFFFFF and lowBatColor))
|
||||||
.put("carbColor", String.format("#%06X", 0xFFFFFF and carbColor))
|
.put("carbColor", String.format("#%06X", 0xFFFFFF and carbColor))
|
||||||
|
.put("basalBackgroundColor", String.format("#%06X", 0xFFFFFF and basalBackgroundColor))
|
||||||
|
.put("basalCenterColor", String.format("#%06X", 0xFFFFFF and basalCenterColor))
|
||||||
.put("gridColor", String.format("#%06X", 0xFFFFFF and Color.WHITE))
|
.put("gridColor", String.format("#%06X", 0xFFFFFF and Color.WHITE))
|
||||||
.put("pointSize",2)
|
.put("pointSize",2)
|
||||||
.put("enableSecond", true)
|
.put("enableSecond", true)
|
||||||
|
@ -287,6 +285,8 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
midColor = Color.parseColor("#00FF00")
|
midColor = Color.parseColor("#00FF00")
|
||||||
lowColor = Color.parseColor("#FF0000")
|
lowColor = Color.parseColor("#FF0000")
|
||||||
carbColor = ContextCompat.getColor(this, R.color.carbs)
|
carbColor = ContextCompat.getColor(this, R.color.carbs)
|
||||||
|
basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark)
|
||||||
|
basalCenterColor = ContextCompat.getColor(this, R.color.basal_light)
|
||||||
lowBatColor = ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)
|
lowBatColor = ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)
|
||||||
gridColor = Color.WHITE
|
gridColor = Color.WHITE
|
||||||
}
|
}
|
||||||
|
@ -434,8 +434,7 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
DAY("day", R.id.day, null),
|
DAY("day", R.id.day, null),
|
||||||
MONTH("month", R.id.month, null),
|
MONTH("month", R.id.month, null),
|
||||||
LOOP("loop", R.id.loop, R.string.key_show_external_status),
|
LOOP("loop", R.id.loop, R.string.key_show_external_status),
|
||||||
DIRECTION("direction", R.id.direction, R.string.key_show_direction),
|
DIRECTION("direction", R.id.direction2, 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),
|
TIMESTAMP("timestamp", R.id.timestamp, R.string.key_show_ago),
|
||||||
SGV("sgv", R.id.sgv, R.string.key_show_bg),
|
SGV("sgv", R.id.sgv, R.string.key_show_bg),
|
||||||
COVER_PLATE(CustomWatchfaceDrawableDataKey.COVERPLATE.key, R.id.cover_plate, null),
|
COVER_PLATE(CustomWatchfaceDrawableDataKey.COVERPLATE.key, R.id.cover_plate, null),
|
||||||
|
@ -444,27 +443,8 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
SECOND_HAND(CustomWatchfaceDrawableDataKey.SECONDHAND.key, R.id.second_hand, R.string.key_show_seconds);
|
SECOND_HAND(CustomWatchfaceDrawableDataKey.SECONDHAND.key, R.id.second_hand, R.string.key_show_seconds);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
fun fromKey(key: String): CustomViews? = values().firstOrNull { it.key == key }
|
||||||
private val keyToEnumMap = HashMap<String, CustomViews>()
|
fun fromId(id: Int): CustomViews? = values().firstOrNull { it.id == id }
|
||||||
private val idToEnumMap = HashMap<Int, CustomViews>()
|
|
||||||
|
|
||||||
init {
|
|
||||||
for (value in values()) keyToEnumMap[value.key] = value
|
|
||||||
for (value in values()) idToEnumMap[value.id] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
fun fromKey(key: String): CustomViews? =
|
|
||||||
if (keyToEnumMap.containsKey(key)) {
|
|
||||||
keyToEnumMap[key]
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
fun fromId(id: Int): CustomViews? =
|
|
||||||
if (idToEnumMap.containsKey(id)) {
|
|
||||||
idToEnumMap[id]
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -475,7 +455,7 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
|
|
||||||
enum class TrendArrow(val text: String, val symbol: String,@DrawableRes val icon: Int) {
|
enum class TrendArrow(val text: String, val symbol: String,@DrawableRes val icon: Int) {
|
||||||
NONE("NONE", "??", R.drawable.ic_invalid),
|
NONE("NONE", "??", R.drawable.ic_invalid),
|
||||||
TRIPLE_UP("TripleUp", "X", R.drawable.ic_invalid),
|
TRIPLE_UP("TripleUp", "X", R.drawable.ic_doubleup),
|
||||||
DOUBLE_UP("DoubleUp", "\u21c8", R.drawable.ic_doubleup),
|
DOUBLE_UP("DoubleUp", "\u21c8", R.drawable.ic_doubleup),
|
||||||
SINGLE_UP("SingleUp", "\u2191", R.drawable.ic_singleup),
|
SINGLE_UP("SingleUp", "\u2191", R.drawable.ic_singleup),
|
||||||
FORTY_FIVE_UP("FortyFiveUp", "\u2197", R.drawable.ic_fortyfiveup),
|
FORTY_FIVE_UP("FortyFiveUp", "\u2197", R.drawable.ic_fortyfiveup),
|
||||||
|
@ -483,7 +463,7 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
FORTY_FIVE_DOWN("FortyFiveDown", "\u2198",R.drawable.ic_fortyfivedown),
|
FORTY_FIVE_DOWN("FortyFiveDown", "\u2198",R.drawable.ic_fortyfivedown),
|
||||||
SINGLE_DOWN("SingleDown", "\u2193", R.drawable.ic_singledown),
|
SINGLE_DOWN("SingleDown", "\u2193", R.drawable.ic_singledown),
|
||||||
DOUBLE_DOWN("DoubleDown", "\u21ca", R.drawable.ic_doubledown),
|
DOUBLE_DOWN("DoubleDown", "\u21ca", R.drawable.ic_doubledown),
|
||||||
TRIPLE_DOWN("TripleDown", "X",R.drawable.ic_invalid)
|
TRIPLE_DOWN("TripleDown", "X",R.drawable.ic_doubledown)
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -47,7 +47,7 @@ class WatchfaceViewAdapter(
|
||||||
|
|
||||||
// Optional attributes
|
// Optional attributes
|
||||||
val sgv = aL?.sgv ?: a2?.sgv ?: aa?.sgv ?: bC?.sgv ?: bC?.sgv ?: cp?.sgv ?: ds?.sgv ?: nC?.sgv ?: cU?.sgv
|
val sgv = aL?.sgv ?: a2?.sgv ?: aa?.sgv ?: bC?.sgv ?: bC?.sgv ?: cp?.sgv ?: ds?.sgv ?: nC?.sgv ?: cU?.sgv
|
||||||
val direction = aL?.direction ?: a2?.direction ?: aa?.direction ?: cp?.direction ?: ds?.direction ?: cU?.direction
|
val direction = aL?.direction ?: a2?.direction ?: aa?.direction ?: cp?.direction ?: ds?.direction
|
||||||
val loop = a2?.loop ?: cp?.loop ?: sP?.loop ?: cU?.loop
|
val loop = a2?.loop ?: cp?.loop ?: sP?.loop ?: cU?.loop
|
||||||
val delta = aL?.delta ?: a2?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: cp?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
|
val delta = aL?.delta ?: a2?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: cp?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
|
||||||
val avgDelta = a2?.avgDelta ?: bC?.avgDelta ?: bC?.avgDelta ?: cp?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta
|
val avgDelta = a2?.avgDelta ?: bC?.avgDelta ?: bC?.avgDelta ?: cp?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta
|
||||||
|
|
|
@ -300,27 +300,14 @@
|
||||||
android:textColor="@color/light_grey"
|
android:textColor="@color/light_grey"
|
||||||
tools:text="--'" />
|
tools:text="--'" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/direction"
|
|
||||||
android:layout_width="52px"
|
|
||||||
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="--" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/direction2"
|
android:id="@+id/direction2"
|
||||||
android:layout_width="52px"
|
android:layout_width="52px"
|
||||||
android:layout_height="52px"
|
android:layout_height="52px"
|
||||||
android:layout_marginTop="26px"
|
android:layout_marginTop="28px"
|
||||||
android:layout_marginLeft="291px"
|
android:layout_marginLeft="291px"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
android:src="@drawable/ic_flat"
|
android:src="@drawable/ic_invalid"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
Loading…
Reference in a new issue