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