parent
48fcf1b693
commit
05032020ba
@ -15,8 +15,8 @@ android {
|
|||||||
applicationId = "de.timklge.karooheadwind"
|
applicationId = "de.timklge.karooheadwind"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 8
|
versionCode = 9
|
||||||
versionName = "1.2"
|
versionName = "1.2.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
"packageName": "de.timklge.karooheadwind",
|
"packageName": "de.timklge.karooheadwind",
|
||||||
"iconUrl": "https://github.com/timklge/karoo-headwind/releases/latest/download/karoo-headwind.png",
|
"iconUrl": "https://github.com/timklge/karoo-headwind/releases/latest/download/karoo-headwind.png",
|
||||||
"latestApkUrl": "https://github.com/timklge/karoo-headwind/releases/latest/download/app-release.apk",
|
"latestApkUrl": "https://github.com/timklge/karoo-headwind/releases/latest/download/app-release.apk",
|
||||||
"latestVersion": "1.2",
|
"latestVersion": "1.2.1",
|
||||||
"latestVersionCode": 8,
|
"latestVersionCode": 9,
|
||||||
"developer": "timklge",
|
"developer": "timklge",
|
||||||
"description": "Provides headwind direction, wind speed and other weather data fields",
|
"description": "Provides headwind direction, wind speed and other weather data fields",
|
||||||
"releaseNotes": "Add tailwind and ride speed data field, Add error indication in data fields, Add date on weather data fields, Add preview of data fields when editing profiles"
|
"releaseNotes": "Add tailwind and ride speed data field, reduce font size in tailwind indicators"
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ import kotlin.math.absoluteValue
|
|||||||
import kotlin.time.Duration.Companion.hours
|
import kotlin.time.Duration.Companion.hours
|
||||||
import kotlin.time.Duration.Companion.minutes
|
import kotlin.time.Duration.Companion.minutes
|
||||||
|
|
||||||
class KarooHeadwindExtension : KarooExtension("karoo-headwind", "1.2") {
|
class KarooHeadwindExtension : KarooExtension("karoo-headwind", "1.2.1") {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "karoo-headwind"
|
const val TAG = "karoo-headwind"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,7 +122,7 @@ class HeadwindDirectionDataType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val result = glance.compose(context, DpSize.Unspecified) {
|
val result = glance.compose(context, DpSize.Unspecified) {
|
||||||
HeadwindDirection(baseBitmap, windDirection.roundToInt(), config.textSize, text)
|
HeadwindDirection(baseBitmap, windDirection.roundToInt(), config.textSize, text, viewSize = config.viewSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
emitter.updateView(result.remoteViews)
|
emitter.updateView(result.remoteViews)
|
||||||
|
|||||||
@ -19,18 +19,15 @@ import androidx.glance.layout.Box
|
|||||||
import androidx.glance.layout.Column
|
import androidx.glance.layout.Column
|
||||||
import androidx.glance.layout.ContentScale
|
import androidx.glance.layout.ContentScale
|
||||||
import androidx.glance.layout.Row
|
import androidx.glance.layout.Row
|
||||||
import androidx.glance.layout.fillMaxHeight
|
|
||||||
import androidx.glance.layout.fillMaxSize
|
import androidx.glance.layout.fillMaxSize
|
||||||
import androidx.glance.layout.padding
|
import androidx.glance.layout.padding
|
||||||
import androidx.glance.layout.width
|
import androidx.glance.layout.size
|
||||||
import androidx.glance.preview.ExperimentalGlancePreviewApi
|
import androidx.glance.preview.ExperimentalGlancePreviewApi
|
||||||
import androidx.glance.preview.Preview
|
|
||||||
import androidx.glance.text.FontFamily
|
import androidx.glance.text.FontFamily
|
||||||
import androidx.glance.text.FontWeight
|
import androidx.glance.text.FontWeight
|
||||||
import androidx.glance.text.Text
|
import androidx.glance.text.Text
|
||||||
import androidx.glance.text.TextStyle
|
import androidx.glance.text.TextStyle
|
||||||
import de.timklge.karooheadwind.KarooHeadwindExtension
|
import de.timklge.karooheadwind.KarooHeadwindExtension
|
||||||
import de.timklge.karooheadwind.R
|
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
data class BitmapWithBearing(val bitmap: Bitmap, val bearing: Int)
|
data class BitmapWithBearing(val bitmap: Bitmap, val bearing: Int)
|
||||||
@ -69,9 +66,11 @@ fun getArrowBitmapByBearing(baseBitmap: Bitmap, bearing: Int): Bitmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalGlancePreviewApi::class)
|
@OptIn(ExperimentalGlancePreviewApi::class)
|
||||||
@Preview(widthDp = 200, heightDp = 150)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HeadwindDirection(baseBitmap: Bitmap, bearing: Int, fontSize: Int, overlayText: String, overlaySubText: String? = null, dayColor: Color = Color.Black, nightColor: Color = Color.White) {
|
fun HeadwindDirection(baseBitmap: Bitmap, bearing: Int, fontSize: Int,
|
||||||
|
overlayText: String, overlaySubText: String? = null,
|
||||||
|
dayColor: Color = Color.Black, nightColor: Color = Color.White,
|
||||||
|
viewSize: Pair<Int, Int>) {
|
||||||
Box(
|
Box(
|
||||||
modifier = GlanceModifier.fillMaxSize().padding(5.dp),
|
modifier = GlanceModifier.fillMaxSize().padding(5.dp),
|
||||||
contentAlignment = Alignment(
|
contentAlignment = Alignment(
|
||||||
@ -97,7 +96,8 @@ fun HeadwindDirection(baseBitmap: Bitmap, bearing: Int, fontSize: Int, overlayTe
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Row(modifier = GlanceModifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically) {
|
Row(modifier = GlanceModifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically) {
|
||||||
Column(modifier = GlanceModifier.defaultWeight()){
|
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
Column(modifier = GlanceModifier.size(40.dp)) {
|
||||||
Image(
|
Image(
|
||||||
provider = ImageProvider(getArrowBitmapByBearing(baseBitmap, bearing)),
|
provider = ImageProvider(getArrowBitmapByBearing(baseBitmap, bearing)),
|
||||||
contentDescription = "Relative wind direction indicator",
|
contentDescription = "Relative wind direction indicator",
|
||||||
@ -105,13 +105,13 @@ fun HeadwindDirection(baseBitmap: Bitmap, bearing: Int, fontSize: Int, overlayTe
|
|||||||
colorFilter = ColorFilter.tint(ColorProvider(dayColor, nightColor))
|
colorFilter = ColorFilter.tint(ColorProvider(dayColor, nightColor))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Column(modifier = GlanceModifier.defaultWeight(), horizontalAlignment = Alignment.Horizontal.CenterHorizontally) {
|
Column(modifier = GlanceModifier.defaultWeight(), horizontalAlignment = Alignment.Horizontal.CenterHorizontally) {
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
overlayText,
|
overlayText,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
style = TextStyle(ColorProvider(dayColor, nightColor), fontSize = (0.7 * fontSize).sp, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Bold),
|
style = TextStyle(ColorProvider(dayColor, nightColor), fontSize = (0.65 * fontSize).sp, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Bold),
|
||||||
modifier = GlanceModifier.background(Color(1f, 1f, 1f, 0.4f), Color(0f, 0f, 0f, 0.4f)).padding(1.dp)
|
modifier = GlanceModifier.background(Color(1f, 1f, 1f, 0.4f), Color(0f, 0f, 0f, 0.4f)).padding(1.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -200,7 +200,7 @@ class TailwindAndRideSpeedDataType(
|
|||||||
|
|
||||||
val result = glance.compose(context, DpSize.Unspecified) {
|
val result = glance.compose(context, DpSize.Unspecified) {
|
||||||
HeadwindDirection(baseBitmap, windDirection.roundToInt(), config.textSize, text, subtextWithSign,
|
HeadwindDirection(baseBitmap, windDirection.roundToInt(), config.textSize, text, subtextWithSign,
|
||||||
dayColor, nightColor)
|
dayColor, nightColor, viewSize = config.viewSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
emitter.updateView(result.remoteViews)
|
emitter.updateView(result.remoteViews)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user