parent
63bda81fbe
commit
aa764bd0a8
@ -27,6 +27,7 @@ class CustomProgressBar @JvmOverloads constructor(
|
||||
var location: PowerbarLocation = PowerbarLocation.BOTTOM
|
||||
var label: String = ""
|
||||
var showLabel: Boolean = true
|
||||
var barBackground: Boolean = false
|
||||
@ColorInt var progressColor: Int = 0xFF2b86e6.toInt()
|
||||
|
||||
var size = CustomProgressBarSize.MEDIUM
|
||||
@ -102,7 +103,9 @@ class CustomProgressBar @JvmOverloads constructor(
|
||||
15f + size.barHeight
|
||||
)
|
||||
|
||||
canvas.drawRect(0f, 15f, canvas.width.toFloat(), 15f + size.barHeight, backgroundPaint)
|
||||
if (barBackground){
|
||||
canvas.drawRect(0f, 15f, canvas.width.toFloat(), 15f + size.barHeight, backgroundPaint)
|
||||
}
|
||||
|
||||
if (progress != null) {
|
||||
canvas.drawRoundRect(rect, 2f, 2f, blurPaint)
|
||||
@ -138,7 +141,9 @@ class CustomProgressBar @JvmOverloads constructor(
|
||||
canvas.height.toFloat()
|
||||
)
|
||||
|
||||
canvas.drawRect(0f, canvas.height.toFloat() - size.barHeight, canvas.width.toFloat(), canvas.height.toFloat(), backgroundPaint)
|
||||
if (barBackground){
|
||||
canvas.drawRect(0f, canvas.height.toFloat() - size.barHeight, canvas.width.toFloat(), canvas.height.toFloat(), backgroundPaint)
|
||||
}
|
||||
|
||||
if (progress != null) {
|
||||
canvas.drawRoundRect(rect, 2f, 2f, blurPaint)
|
||||
|
||||
@ -53,7 +53,7 @@ class ForegroundService : Service() {
|
||||
windows.clear()
|
||||
|
||||
if (settings.source != SelectedSource.NONE && showBars) {
|
||||
Window(this@ForegroundService, PowerbarLocation.BOTTOM, settings.showLabelOnBars, settings.barSize).apply {
|
||||
Window(this@ForegroundService, PowerbarLocation.BOTTOM, settings.showLabelOnBars, settings.barBackground, settings.barSize).apply {
|
||||
selectedSource = settings.source
|
||||
windows.add(this)
|
||||
open()
|
||||
@ -61,7 +61,7 @@ class ForegroundService : Service() {
|
||||
}
|
||||
|
||||
if (settings.topBarSource != SelectedSource.NONE && showBars){
|
||||
Window(this@ForegroundService, PowerbarLocation.TOP, settings.showLabelOnBars, settings.barSize).apply {
|
||||
Window(this@ForegroundService, PowerbarLocation.TOP, settings.showLabelOnBars, settings.barBackground, settings.barSize).apply {
|
||||
selectedSource = settings.topBarSource
|
||||
open()
|
||||
windows.add(this)
|
||||
|
||||
@ -21,6 +21,7 @@ data class PowerbarSettings(
|
||||
val onlyShowWhileRiding: Boolean = true,
|
||||
val showLabelOnBars: Boolean = true,
|
||||
val useZoneColors: Boolean = true,
|
||||
val barBackground: Boolean = false,
|
||||
val barSize: CustomProgressBarSize = CustomProgressBarSize.MEDIUM,
|
||||
|
||||
val minCadence: Int = defaultMinCadence, val maxCadence: Int = defaultMaxCadence,
|
||||
|
||||
@ -46,6 +46,7 @@ class Window(
|
||||
private val context: Context,
|
||||
val powerbarLocation: PowerbarLocation = PowerbarLocation.BOTTOM,
|
||||
val showLabel: Boolean,
|
||||
val barBackground: Boolean,
|
||||
val powerbarSize: CustomProgressBarSize
|
||||
) {
|
||||
private val rootView: View
|
||||
@ -122,6 +123,7 @@ class Window(
|
||||
powerbar.progress = null
|
||||
powerbar.location = powerbarLocation
|
||||
powerbar.showLabel = showLabel
|
||||
powerbar.barBackground = barBackground
|
||||
powerbar.size = powerbarSize
|
||||
powerbar.invalidate()
|
||||
|
||||
|
||||
@ -66,8 +66,6 @@ import de.timklge.karoopowerbar.settingsKey
|
||||
import de.timklge.karoopowerbar.streamSettings
|
||||
import de.timklge.karoopowerbar.streamUserProfile
|
||||
import io.hammerhead.karooext.KarooSystemService
|
||||
import io.hammerhead.karooext.models.HardwareType
|
||||
import io.hammerhead.karooext.models.PlayBeepPattern
|
||||
import io.hammerhead.karooext.models.UserProfile
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.combine
|
||||
@ -147,6 +145,7 @@ fun MainScreen(onFinish: () -> Unit) {
|
||||
var colorBasedOnZones by remember { mutableStateOf(false) }
|
||||
var showLabelOnBars by remember { mutableStateOf(true) }
|
||||
var barSize by remember { mutableStateOf(CustomProgressBarSize.MEDIUM) }
|
||||
var barBackground by remember { mutableStateOf(false) }
|
||||
|
||||
var minCadence by remember { mutableStateOf("0") }
|
||||
var maxCadence by remember { mutableStateOf("0") }
|
||||
@ -176,6 +175,7 @@ fun MainScreen(onFinish: () -> Unit) {
|
||||
val newSettings = PowerbarSettings(
|
||||
source = bottomSelectedSource, topBarSource = topSelectedSource,
|
||||
onlyShowWhileRiding = onlyShowWhileRiding, showLabelOnBars = showLabelOnBars,
|
||||
barBackground = barBackground,
|
||||
useZoneColors = colorBasedOnZones,
|
||||
minCadence = minCadence.toIntOrNull() ?: PowerbarSettings.defaultMinCadence,
|
||||
maxCadence = maxCadence.toIntOrNull() ?: PowerbarSettings.defaultMaxCadence,
|
||||
@ -227,6 +227,7 @@ fun MainScreen(onFinish: () -> Unit) {
|
||||
showLabelOnBars = settings.showLabelOnBars
|
||||
colorBasedOnZones = settings.useZoneColors
|
||||
barSize = settings.barSize
|
||||
barBackground = settings.barBackground
|
||||
minCadence = settings.minCadence.toString()
|
||||
maxCadence = settings.maxCadence.toString()
|
||||
isImperial = profile.preferredUnit.distance == UserProfile.PreferredUnit.UnitType.IMPERIAL
|
||||
@ -470,6 +471,15 @@ fun MainScreen(onFinish: () -> Unit) {
|
||||
Text("Show value on bars")
|
||||
}
|
||||
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Switch(checked = barBackground, onCheckedChange = {
|
||||
barBackground = it
|
||||
coroutineScope.launch { updateSettings() }
|
||||
})
|
||||
Spacer(modifier = Modifier.width(10.dp))
|
||||
Text("Opaque background")
|
||||
}
|
||||
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Switch(checked = onlyShowWhileRiding, onCheckedChange = {
|
||||
onlyShowWhileRiding = it
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user