forked from Blendman974/faceclaw
Battery indicators and other places no longer say "G2" when a G1 or iO is paired
This commit is contained in:
1 parent
ac68ba5991
commit
e103b89510
21 files changed
+101
-46
No files matched your search
+6
-4
@@ -62,7 +62,7 @@ dashboard state, re-sent whenever it changes (and at least every 30 s):
|
||||
"protocol": 1, "version": "…",
|
||||
"phase": "connected", "status": "…", "connected": true, "preview": false,
|
||||
"screenOn": true, "locked": false, "worn": true, "listening": false,
|
||||
"battery": 78, "charging": false, "silentMode": false,
|
||||
"battery": 78, "glassesModel": "G2", "charging": false, "silentMode": false,
|
||||
"caseBattery": 64, "caseCharging": true,
|
||||
"foreground": {"appId": "music", "title": "Music"},
|
||||
"windows": [{"windowId": "…", "title": "…", "appId": "…", "focused": true, "closeable": true, "acceptsText": false}],
|
||||
@@ -74,9 +74,11 @@ dashboard state, re-sent whenever it changes (and at least every 30 s):
|
||||
}
|
||||
```
|
||||
|
||||
`battery` is the current or last-known G2 percentage. `charging` and
|
||||
`silentMode` identify the two states in which the glasses display is not
|
||||
visible even though the BLE session remains available.
|
||||
`battery` is the glasses' current or last-known percentage, and `glassesModel`
|
||||
is what the charging line calls them: `G2`, `G1` or `iO` (a watch treats a
|
||||
missing one, from an older phone app, as `G2`). `charging` and `silentMode`
|
||||
identify the two states in which the glasses display is not visible even though
|
||||
the BLE session remains available.
|
||||
|
||||
`caseBattery` is the last-known charging-case percentage, or null until the
|
||||
glasses have reported one; the case only reports while the glasses are docked,
|
||||
|
||||
@@ -92,8 +92,10 @@ data class PhoneState(
|
||||
val locked: Boolean,
|
||||
val worn: Boolean?,
|
||||
val listening: Boolean,
|
||||
/** Current or last-known G2 charge percentage. */
|
||||
/** The glasses' current or last-known charge percentage. */
|
||||
val battery: Int?,
|
||||
/** The paired glasses' model, as the charging line names it. */
|
||||
val glassesModel: String,
|
||||
val charging: Boolean,
|
||||
/** Last-known charging-case percentage; live only while the glasses are docked. */
|
||||
val caseBattery: Int?,
|
||||
@@ -126,6 +128,7 @@ data class PhoneState(
|
||||
worn = if (o.isNull("worn")) null else o.optBoolean("worn"),
|
||||
listening = o.optBoolean("listening", false),
|
||||
battery = if (o.isNull("battery")) null else o.optInt("battery", -1).takeIf { it in 0..100 },
|
||||
glassesModel = o.optString("glassesModel", "G2"),
|
||||
charging = o.optBoolean("charging", false),
|
||||
caseBattery = if (o.isNull("caseBattery")) null else o.optInt("caseBattery", -1).takeIf { it in 0..100 },
|
||||
caseCharging = if (o.isNull("caseCharging")) null else o.optBoolean("caseCharging"),
|
||||
|
||||
@@ -81,7 +81,7 @@ fun padLine(state: PhoneState?, link: LinkStatus): StatusLine = when {
|
||||
state.remoteEnabled == false -> StatusLine("Watch control off", StatusTone.PROBLEM)
|
||||
state.connected -> when {
|
||||
state.charging || state.phase == "charging" ->
|
||||
StatusLine(chargingLine(state.battery), StatusTone.BUSY, caseLine(state))
|
||||
StatusLine(chargingLine(state), StatusTone.BUSY, caseLine(state))
|
||||
state.silentMode -> StatusLine("Silent mode", StatusTone.OFF)
|
||||
state.locked -> StatusLine("Locked", StatusTone.OFF)
|
||||
!state.screenOn -> StatusLine("●● Wake", StatusTone.OFF)
|
||||
@@ -93,8 +93,8 @@ fun padLine(state: PhoneState?, link: LinkStatus): StatusLine = when {
|
||||
else -> StatusLine("Disconnected", StatusTone.OFF)
|
||||
}
|
||||
|
||||
private fun chargingLine(battery: Int?): String =
|
||||
if (battery != null) "Charging · G2 $battery%" else "Charging"
|
||||
private fun chargingLine(state: PhoneState): String =
|
||||
state.battery?.let { "Charging: ${state.glassesModel} $it%" } ?: "Charging"
|
||||
|
||||
/**
|
||||
* "Case 64%", with ⚡ while the case is on USB; null when the level is
|
||||
|
||||
Reference in new issue
Block a user