Skip to content

Commit ec2f726

Browse files
committed
Tile: Show an applying hint while a policy write settles
The QS tile's subtitle covered the plug-latched replug hint but not the ordinary settling window - a policy tapped elsewhere read as already final when QS was opened mid-transition. The subtitle now prefers the two pending states (mutually exclusive by construction) over the static access/adapter label, with the same QS-open staleness the replug hint already accepts.
1 parent 2b1db02 commit ec2f726

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

app/src/main/java/eu/darken/amply/main/ui/tile/ChargeTileService.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import dagger.hilt.android.AndroidEntryPoint
1313
import eu.darken.amply.R
1414
import eu.darken.amply.charging.core.ChargingRepository
1515
import eu.darken.amply.charging.core.isAwaitingReplug
16+
import eu.darken.amply.charging.core.isSettling
1617
import eu.darken.amply.common.debug.logging.Logging
1718
import eu.darken.amply.common.debug.logging.log
1819
import eu.darken.amply.common.debug.logging.logTag
@@ -56,12 +57,16 @@ class ChargeTileService : TileService() {
5657
render(
5758
active = sessionActive,
5859
available = state.canApply,
59-
// Plug-latched pending beats the static access/adapter label: opening QS is
60-
// the tile's refresh cadence, so this is exactly when the hint is fresh.
61-
detail = if (state.isAwaitingReplug()) {
62-
getString(R.string.tile_replug_hint)
63-
} else {
64-
(state.access?.label ?: state.adapterName).get(this@ChargeTileService)
60+
// Pending states beat the static access/adapter label: opening QS is the
61+
// tile's refresh cadence, so this is exactly when they are fresh. The two
62+
// pending kinds are mutually exclusive by construction (a latched request is
63+
// never "settling"); the order documents intent, not a real priority.
64+
detail = when {
65+
state.isAwaitingReplug() -> getString(R.string.tile_replug_hint)
66+
state.isSettling(System.currentTimeMillis()) ->
67+
getString(R.string.tile_applying)
68+
else -> (state.access?.label ?: state.adapterName)
69+
.get(this@ChargeTileService)
6570
},
6671
)
6772
}

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<string name="tile_active">Restore limit</string>
55
<string name="tile_override_active">Temporary override active</string>
66
<string name="tile_replug_hint">Replug to apply</string>
7+
<string name="tile_applying">Applying…</string>
78
<string name="widget_description">Amply charge controls</string>
89
<string name="session_channel_name">Full charge and restore</string>
910
<string name="session_channel_description" formatted="false">Shows while Amply is allowing a full charge, and while it restores your limit afterwards</string>

0 commit comments

Comments
 (0)