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.ZipOutputStream
|
||||
|
||||
val CUSTOM_VERSION = "0.3"
|
||||
val CUSTOM_VERSION = "0.4"
|
||||
enum class CustomWatchfaceDrawableDataKey(val key: String, @DrawableRes val icon: Int?, val fileName: String) {
|
||||
UNKNOWN("unknown", null, "Unknown"),
|
||||
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");
|
||||
|
||||
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 =
|
||||
if (keyToEnumMap.containsKey(key)) {
|
||||
keyToEnumMap[key] ?: UNKNOWN
|
||||
} else {
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
fun fromFileName(file: String): CustomWatchfaceDrawableDataKey =
|
||||
if (fileNameToEnumMap.containsKey(file.substringBeforeLast("."))) {
|
||||
fileNameToEnumMap[file.substringBeforeLast(".")] ?: UNKNOWN
|
||||
} else {
|
||||
UNKNOWN
|
||||
}
|
||||
values().firstOrNull { it.key == key } ?: UNKNOWN
|
||||
fun fromFileName(file: String): CustomWatchfaceDrawableDataKey = values().firstOrNull { it.fileName == file } ?: UNKNOWN
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum class DrawableFormat(val extension: String) {
|
||||
|
@ -64,19 +44,9 @@ enum class DrawableFormat(val extension: String) {
|
|||
PNG("png");
|
||||
|
||||
companion object {
|
||||
|
||||
private val extensionToEnumMap = HashMap<String, DrawableFormat>()
|
||||
|
||||
init {
|
||||
for (value in values()) extensionToEnumMap[value.extension] = value
|
||||
}
|
||||
|
||||
fun fromFileName(fileName: String): DrawableFormat =
|
||||
if (extensionToEnumMap.containsKey(fileName.substringAfterLast("."))) {
|
||||
extensionToEnumMap[fileName.substringAfterLast(".")] ?: UNKNOWN
|
||||
} else {
|
||||
UNKNOWN
|
||||
}
|
||||
values().firstOrNull { it.extension == fileName.substringAfterLast(".") } ?: 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);
|
||||
|
||||
companion object {
|
||||
|
||||
private val keyToEnumMap = HashMap<String, CustomWatchfaceMetadataKey>()
|
||||
|
||||
init {
|
||||
for (value in values()) keyToEnumMap[value.key] = value
|
||||
}
|
||||
|
||||
fun fromKey(key: String): CustomWatchfaceMetadataKey? =
|
||||
if (keyToEnumMap.containsKey(key)) {
|
||||
keyToEnumMap[key]
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
values().firstOrNull { it.key == key }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -78,12 +78,16 @@ class CustomWatchface : BaseWatchFace() {
|
|||
override fun setDataFields() {
|
||||
super.setDataFields()
|
||||
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() {
|
||||
setWatchfaceStyle()
|
||||
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
|
||||
binding.sgv.setTextColor(bgColor)
|
||||
binding.direction.setTextColor(bgColor)
|
||||
binding.direction2.colorFilter = changeDrawableColor(bgColor)
|
||||
|
||||
if (ageLevel != 1)
|
||||
|
@ -96,16 +100,6 @@ class CustomWatchface : BaseWatchFace() {
|
|||
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()
|
||||
}
|
||||
|
||||
|
@ -143,7 +137,9 @@ class CustomWatchface : BaseWatchFace() {
|
|||
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)
|
||||
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
|
||||
bgColor = when (singleBg.sgvLevel) {
|
||||
1L -> highColor
|
||||
|
@ -224,6 +220,8 @@ class CustomWatchface : BaseWatchFace() {
|
|||
.put("lowColor", String.format("#%06X", 0xFFFFFF and lowColor))
|
||||
.put("lowBatColor", String.format("#%06X", 0xFFFFFF and lowBatColor))
|
||||
.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("pointSize",2)
|
||||
.put("enableSecond", true)
|
||||
|
@ -287,6 +285,8 @@ class CustomWatchface : BaseWatchFace() {
|
|||
midColor = Color.parseColor("#00FF00")
|
||||
lowColor = Color.parseColor("#FF0000")
|
||||
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)
|
||||
gridColor = Color.WHITE
|
||||
}
|
||||
|
@ -434,8 +434,7 @@ class CustomWatchface : BaseWatchFace() {
|
|||
DAY("day", R.id.day, null),
|
||||
MONTH("month", R.id.month, null),
|
||||
LOOP("loop", R.id.loop, R.string.key_show_external_status),
|
||||
DIRECTION("direction", R.id.direction, R.string.key_show_direction),
|
||||
DIRECTION2("direction2", R.id.direction2, R.string.key_show_direction),
|
||||
DIRECTION("direction", R.id.direction2, R.string.key_show_direction),
|
||||
TIMESTAMP("timestamp", R.id.timestamp, R.string.key_show_ago),
|
||||
SGV("sgv", R.id.sgv, R.string.key_show_bg),
|
||||
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);
|
||||
|
||||
companion object {
|
||||
|
||||
private val keyToEnumMap = HashMap<String, CustomViews>()
|
||||
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
|
||||
}
|
||||
fun fromKey(key: String): CustomViews? = values().firstOrNull { it.key == key }
|
||||
fun fromId(id: Int): CustomViews? = values().firstOrNull { it.id == id }
|
||||
}
|
||||
|
||||
|
||||
|
@ -475,7 +455,7 @@ class CustomWatchface : BaseWatchFace() {
|
|||
|
||||
enum class TrendArrow(val text: String, val symbol: String,@DrawableRes val icon: Int) {
|
||||
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),
|
||||
SINGLE_UP("SingleUp", "\u2191", R.drawable.ic_singleup),
|
||||
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),
|
||||
SINGLE_DOWN("SingleDown", "\u2193", R.drawable.ic_singledown),
|
||||
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 {
|
||||
|
|
|
@ -47,7 +47,7 @@ class WatchfaceViewAdapter(
|
|||
|
||||
// Optional attributes
|
||||
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 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
|
||||
|
|
|
@ -300,27 +300,14 @@
|
|||
android:textColor="@color/light_grey"
|
||||
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
|
||||
android:id="@+id/direction2"
|
||||
android:layout_width="52px"
|
||||
android:layout_height="52px"
|
||||
android:layout_marginTop="26px"
|
||||
android:layout_marginTop="28px"
|
||||
android:layout_marginLeft="291px"
|
||||
android:visibility="visible"
|
||||
android:src="@drawable/ic_flat"
|
||||
android:src="@drawable/ic_invalid"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<TextView
|
||||
|
|
Loading…
Reference in a new issue