Add vector arrows for precise direction positioning
This commit is contained in:
parent
9cd166f802
commit
f4f79b1220
10 changed files with 126 additions and 0 deletions
|
@ -19,6 +19,7 @@ import android.view.WindowManager
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.IdRes
|
import androidx.annotation.IdRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
@ -74,11 +75,16 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setDataFields() {
|
||||||
|
super.setDataFields()
|
||||||
|
binding.direction2.setImageDrawable(resources.getDrawable(TrendArrow.fromSymbol(singleBg.slopeArrow).icon))
|
||||||
|
}
|
||||||
override fun setColorDark() {
|
override fun setColorDark() {
|
||||||
setWatchfaceStyle()
|
setWatchfaceStyle()
|
||||||
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
|
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
|
||||||
binding.sgv.setTextColor(bgColor)
|
binding.sgv.setTextColor(bgColor)
|
||||||
binding.direction.setTextColor(bgColor)
|
binding.direction.setTextColor(bgColor)
|
||||||
|
binding.direction2.colorFilter = changeDrawableColor(bgColor)
|
||||||
|
|
||||||
if (ageLevel != 1)
|
if (ageLevel != 1)
|
||||||
binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld))
|
binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld))
|
||||||
|
@ -429,6 +435,7 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
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.direction, 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),
|
||||||
|
@ -460,8 +467,29 @@ class CustomWatchface : BaseWatchFace() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun visibility(sp: SP): Boolean = this.pref?.let { sp.getBoolean(it, true) }
|
fun visibility(sp: SP): Boolean = this.pref?.let { sp.getBoolean(it, true) }
|
||||||
?: true
|
?: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
FLAT("Flat", "\u2192", R.drawable.ic_flat),
|
||||||
|
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)
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun fromSymbol(direction: String?) =
|
||||||
|
values().firstOrNull { it.symbol == direction } ?: NONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
12
wear/src/main/res/drawable/ic_doubledown.xml
Normal file
12
wear/src/main/res/drawable/ic_doubledown.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M2.702,16.281c1.952,1.81 4.279,4.076 5.31,5.654v0.002c0,0 0.001,-0.001 0.001,-0.001c0,0 0.001,0.001 0.001,0.001v-0.002c1.032,-1.578 3.359,-3.844 5.31,-5.654l-1.325,-1.821c0,0 -1.578,1.408 -2.934,2.728V2.063H6.961l0,15.125c-1.356,-1.319 -2.934,-2.728 -2.934,-2.728L2.702,16.281z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M10.676,16.281c1.952,1.81 4.279,4.076 5.31,5.654v0.002c0,0 0.001,-0.001 0.001,-0.001c0,0 0.001,0.001 0.001,0.001v-0.002c1.032,-1.578 3.359,-3.844 5.31,-5.654l-1.325,-1.821c0,0 -1.578,1.408 -2.934,2.728V2.063h-2.104v15.125c-1.356,-1.319 -2.934,-2.728 -2.934,-2.728L10.676,16.281z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
</vector>
|
12
wear/src/main/res/drawable/ic_doubleup.xml
Normal file
12
wear/src/main/res/drawable/ic_doubleup.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M2.702,7.719c1.952,-1.81 4.279,-4.076 5.31,-5.654V2.063c0,0 0.001,0.001 0.001,0.001c0,0 0.001,-0.001 0.001,-0.001v0.002c1.032,1.578 3.359,3.844 5.31,5.654L11.999,9.54c0,0 -1.578,-1.408 -2.934,-2.728v15.125H6.961l0,-15.125C5.605,8.132 4.027,9.54 4.027,9.54L2.702,7.719z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M10.676,7.719c1.952,-1.81 4.279,-4.076 5.31,-5.654V2.063c0,0 0.001,0.001 0.001,0.001c0,0 0.001,-0.001 0.001,-0.001v0.002c1.032,1.578 3.359,3.844 5.31,5.654L19.973,9.54c0,0 -1.578,-1.408 -2.934,-2.728v15.125h-2.104V6.813c-1.356,1.319 -2.934,2.728 -2.934,2.728L10.676,7.719z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
</vector>
|
9
wear/src/main/res/drawable/ic_flat.xml
Normal file
9
wear/src/main/res/drawable/ic_flat.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M16.281,17.311c1.81,-1.952 4.076,-4.279 5.654,-5.31h0.002c0,0 -0.001,-0.001 -0.001,-0.001c0,0 0.001,-0.001 0.001,-0.001h-0.002c-1.578,-1.032 -3.844,-3.359 -5.654,-5.31L14.46,8.014c0,0 1.408,1.578 2.728,2.934H2.063v2.104h15.125c-1.319,1.356 -2.728,2.934 -2.728,2.934L16.281,17.311z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
</vector>
|
9
wear/src/main/res/drawable/ic_fortyfivedown.xml
Normal file
9
wear/src/main/res/drawable/ic_fortyfivedown.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M11.272,18.783c2.66,-0.1 5.908,-0.143 7.753,0.243l0.001,0.001c0,0 0,-0.001 0,-0.001c0,0 0.001,0 0.001,0l-0.001,-0.001c-0.386,-1.845 -0.343,-5.093 -0.243,-7.753l-2.225,-0.351c0,0 -0.12,2.111 -0.146,4.003L5.717,4.229L4.229,5.717l10.695,10.695c-1.892,0.026 -4.003,0.146 -4.003,0.146L11.272,18.783z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
</vector>
|
9
wear/src/main/res/drawable/ic_fortyfiveup.xml
Normal file
9
wear/src/main/res/drawable/ic_fortyfiveup.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M18.783,12.728c-0.1,-2.66 -0.143,-5.908 0.243,-7.753l0.001,-0.001c0,0 -0.001,0 -0.001,0c0,0 0,-0.001 0,-0.001l-0.001,0.001c-1.845,0.386 -5.093,0.343 -7.753,0.243l-0.351,2.225c0,0 2.111,0.12 4.003,0.146L4.229,18.283l1.488,1.488L16.412,9.076c0.026,1.892 0.146,4.003 0.146,4.003L18.783,12.728z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
</vector>
|
18
wear/src/main/res/drawable/ic_invalid.xml
Normal file
18
wear/src/main/res/drawable/ic_invalid.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M17.35,19.561m-1.147,0a1.147,1.147 0,1 1,2.294 0a1.147,1.147 0,1 1,-2.294 0"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M17.301,16.804c-0.459,0 -0.83,-0.372 -0.83,-0.831c0,-2.985 1.391,-4.027 2.51,-4.864c0.937,-0.702 1.614,-1.209 1.614,-2.849c0,-2.262 -2.173,-2.965 -2.964,-2.965c-1.705,0 -3.083,1.022 -3.778,2.804c-0.167,0.427 -0.65,0.64 -1.075,0.471c-0.427,-0.167 -0.638,-0.648 -0.471,-1.075c0.944,-2.417 2.935,-3.86 5.325,-3.86c1.865,0 4.626,1.47 4.626,4.626c0,2.472 -1.264,3.418 -2.28,4.178c-1.031,0.772 -1.844,1.38 -1.844,3.535C18.131,16.432 17.76,16.804 17.301,16.804z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M6.846,19.561m-1.147,0a1.147,1.147 0,1 1,2.294 0a1.147,1.147 0,1 1,-2.294 0"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M6.797,16.804c-0.459,0 -0.83,-0.372 -0.83,-0.831c0,-2.985 1.391,-4.027 2.51,-4.864c0.937,-0.702 1.614,-1.209 1.614,-2.849c0,-2.262 -2.173,-2.965 -2.964,-2.965c-1.705,0 -3.083,1.022 -3.778,2.804c-0.167,0.427 -0.65,0.64 -1.075,0.471C1.845,8.403 1.635,7.922 1.801,7.495c0.944,-2.417 2.935,-3.86 5.325,-3.86c1.865,0 4.626,1.47 4.626,4.626c0,2.472 -1.264,3.418 -2.28,4.178c-1.031,0.772 -1.844,1.38 -1.844,3.535C7.627,16.432 7.256,16.804 6.797,16.804z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
</vector>
|
9
wear/src/main/res/drawable/ic_singledown.xml
Normal file
9
wear/src/main/res/drawable/ic_singledown.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M6.689,16.281c1.952,1.81 4.279,4.076 5.31,5.654v0.002c0,0 0.001,-0.001 0.001,-0.001c0,0 0.001,0.001 0.001,0.001v-0.002c1.032,-1.578 3.359,-3.844 5.31,-5.654l-1.325,-1.821c0,0 -1.578,1.408 -2.934,2.728V2.063h-2.104v15.125c-1.356,-1.319 -2.934,-2.728 -2.934,-2.728L6.689,16.281z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
</vector>
|
9
wear/src/main/res/drawable/ic_singleup.xml
Normal file
9
wear/src/main/res/drawable/ic_singleup.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M17.102,7.719c-1.952,-1.81 -4.279,-4.076 -5.31,-5.654V2.063c0,0 -0.001,0.001 -0.001,0.001c0,0 -0.001,-0.001 -0.001,-0.001v0.002c-1.032,1.578 -3.359,3.844 -5.31,5.654L7.805,9.54c0,0 1.578,-1.408 2.934,-2.728v15.125h2.104V6.813c1.356,1.319 2.934,2.728 2.934,2.728L17.102,7.719z"
|
||||||
|
android:fillColor="@color/white"/>
|
||||||
|
</vector>
|
|
@ -306,12 +306,23 @@
|
||||||
android:layout_height="52px"
|
android:layout_height="52px"
|
||||||
android:layout_marginTop="26px"
|
android:layout_marginTop="26px"
|
||||||
android:layout_marginLeft="291px"
|
android:layout_marginLeft="291px"
|
||||||
|
android:visibility="gone"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:textSize="39px"
|
android:textSize="39px"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/light_grey"
|
android:textColor="@color/light_grey"
|
||||||
tools:text="--" />
|
tools:text="--" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/direction2"
|
||||||
|
android:layout_width="52px"
|
||||||
|
android:layout_height="52px"
|
||||||
|
android:layout_marginTop="26px"
|
||||||
|
android:layout_marginLeft="291px"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:src="@drawable/ic_flat"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/timestamp"
|
android:id="@+id/timestamp"
|
||||||
android:layout_width="52px"
|
android:layout_width="52px"
|
||||||
|
|
Loading…
Reference in a new issue