@@ -12,12 +12,10 @@ import eu.darken.amply.charging.core.ChargeObservation
1212import eu.darken.amply.charging.core.ChargePolicy
1313import eu.darken.amply.charging.core.ChargingState
1414import eu.darken.amply.charging.core.DeviceInfo
15- import eu.darken.amply.charging.core.SettingProbe
1615import eu.darken.amply.charging.core.access.AccessSnapshot
1716import eu.darken.amply.charging.core.access.BackendStatus
1817import eu.darken.amply.common.ca.toCaString
1918import eu.darken.amply.common.compose.PreviewWrapper
20- import eu.darken.amply.common.theming.ThemeState
2119import eu.darken.amply.battery.core.BatteryReadout
2220import eu.darken.amply.fullcharge.core.ChargeSessionRecord
2321import eu.darken.amply.main.ui.dashboard.DashboardScreen
@@ -26,7 +24,13 @@ import eu.darken.amply.main.ui.dashboard.StatsDashboardState
2624import eu.darken.amply.stats.core.ChargeCurvePoint
2725import eu.darken.amply.stats.core.StatsLiveSession
2826import eu.darken.amply.main.ui.settings.ChargingSettingsScreen
29- import eu.darken.amply.main.ui.settings.GeneralSettingsScreen
27+ import eu.darken.amply.rules.core.ChargeRule
28+ import eu.darken.amply.rules.core.PlugKind
29+ import eu.darken.amply.rules.core.RuleCondition
30+ import eu.darken.amply.rules.core.policy
31+ import eu.darken.amply.rules.ui.ChargeRuleRow
32+ import eu.darken.amply.rules.ui.ChargeRulesScreen
33+ import eu.darken.amply.rules.ui.ChargeRulesUiState
3034
3135// Device spec shared by every Play Store screenshot. 1080x1920 (9:16) is Play's recommended phone
3236// size and stays within its "longest side may not exceed 2x the shorter side" rule — 1080x2400
@@ -44,20 +48,67 @@ internal fun DashboardReadyContent() = DashboardShot(readyState())
4448@Composable
4549internal fun DashboardActiveContent () = DashboardShot (sessionState())
4650
47- @Composable
48- internal fun SamsungMultiModeContent () = DashboardShot (samsungState())
49-
5051@Composable
5152internal fun SetupGuideContent () = DashboardShot (setupNeededState())
5253
54+ // Three healthy rules covering both condition kinds, with the topmost one currently matching — the
55+ // list IS the priority editor, so the shot has to show more than one row to mean anything.
5356@Composable
54- internal fun SettingsContent () = PreviewWrapper {
55- GeneralSettingsScreen (
56- state = ThemeState (),
57+ internal fun ChargeConditionsContent () = PreviewWrapper {
58+ ChargeRulesScreen (
59+ state = ChargeRulesUiState (
60+ rows = listOf (
61+ ruleRow(
62+ id = " car" ,
63+ label = " Car" ,
64+ condition = RuleCondition .BluetoothDevice (" AA:BB:CC:DD:EE:FF" , " Car audio" ),
65+ policy = ChargePolicy .Unrestricted ,
66+ active = true ,
67+ canMoveUp = false ,
68+ ),
69+ ruleRow(
70+ id = " dock" ,
71+ label = " Desk dock" ,
72+ condition = RuleCondition .ChargerType (setOf (PlugKind .DOCK , PlugKind .WIRELESS )),
73+ policy = ChargePolicy .FixedLimit (80 ),
74+ ),
75+ ruleRow(
76+ id = " bedside" ,
77+ label = " Overnight" ,
78+ condition = RuleCondition .BluetoothDevice (" 11:22:33:44:55:66" , " Bedside speaker" ),
79+ policy = ChargePolicy .Adaptive ,
80+ canMoveDown = false ,
81+ ),
82+ ),
83+ ),
5784 onBack = {},
58- onModeChange = {},
59- onStyleChange = {},
60- onColorChange = {},
85+ onAdd = {},
86+ onEdit = {},
87+ onDelete = {},
88+ onEnabledChange = { _, _ -> },
89+ onMove = { _, _ -> },
90+ onFixBluetoothPermission = {},
91+ )
92+ }
93+
94+ private fun ruleRow (
95+ id : String ,
96+ label : String ,
97+ condition : RuleCondition ,
98+ policy : ChargePolicy ,
99+ active : Boolean = false,
100+ canMoveUp : Boolean = true,
101+ canMoveDown : Boolean = true,
102+ ): ChargeRuleRow {
103+ val rule = ChargeRule (id = id, label = label, condition = condition, policyId = policy.stableId)
104+ return ChargeRuleRow (
105+ rule = rule,
106+ policy = rule.policy,
107+ active = active,
108+ unsupportedCondition = false ,
109+ unsupportedPolicy = false ,
110+ canMoveUp = canMoveUp,
111+ canMoveDown = canMoveDown,
61112 )
62113}
63114
@@ -245,48 +296,6 @@ private fun sessionState() = DashboardUiState(
245296 ),
246297)
247298
248- // Samsung One UI 8 multi-mode: four fixed limits plus pause-at-full, shown as chips.
249- private fun samsungState () = DashboardUiState (
250- onboardingComplete = true ,
251- batteryReadout = holdingAtLimit(),
252- stats = liveStats(),
253- charging = ChargingState (
254- device = DeviceInfo (
255- " samsung" ,
256- " SM-X210" ,
257- 36 ,
258- " preview" ,
259- oneUiVersion = 80000 ,
260- protectBatteryProbe = SettingProbe .PRESENT ,
261- ),
262- adapterName = " Samsung battery protection" .toCaString(),
263- adapterId = " samsung-oneui8-v1" ,
264- supportedPolicies = listOf (
265- ChargePolicy .FixedLimit (80 ),
266- ChargePolicy .FixedLimit (85 ),
267- ChargePolicy .FixedLimit (90 ),
268- ChargePolicy .FixedLimit (95 ),
269- ChargePolicy .PauseAtFull ,
270- ChargePolicy .Unrestricted ,
271- ),
272- reconnectSupported = false ,
273- controlEnabled = true ,
274- access = AccessSnapshot (
275- direct = BackendStatus (
276- available = true ,
277- granted = true ,
278- detail = " Charge-control access granted" .toCaString(),
279- ),
280- shizuku = BackendStatus (
281- available = false ,
282- granted = false ,
283- detail = " Shizuku not installed" .toCaString(),
284- ),
285- ),
286- observation = ChargeObservation .Verified (ChargePolicy .FixedLimit (80 ), BackendKind .DIRECT_WSS ),
287- ),
288- )
289-
290299// Pixel before access is granted: the dashboard leads with the setup guide.
291300private fun setupNeededState () = DashboardUiState (
292301 // Capture is off here: this shot is about the setup guide, and the charging card showing its
@@ -326,17 +335,17 @@ private fun PreviewDashboardReady() = DashboardReadyContent()
326335@Composable
327336private fun PreviewDashboardActive () = DashboardActiveContent ()
328337
329- @Preview(name = " 3 - Samsung multi-mode " , device = DS , showSystemUi = true )
338+ @Preview(name = " 3 - Charge conditions " , device = DS , showSystemUi = true )
330339@Composable
331- private fun PreviewSamsungMultiMode () = SamsungMultiModeContent ()
340+ private fun PreviewChargeConditions () = ChargeConditionsContent ()
332341
333342@Preview(name = " 4 - Setup guide" , device = DS , showSystemUi = true )
334343@Composable
335344private fun PreviewSetupGuide () = SetupGuideContent ()
336345
337- @Preview(name = " 5 - Settings " , device = DS , showSystemUi = true )
346+ @Preview(name = " 5 - Battery hub " , device = DS , showSystemUi = true )
338347@Composable
339- private fun PreviewSettings () = SettingsContent ()
348+ private fun PreviewBatteryHub () = HubTileGridContent ()
340349
341350@Preview(name = " 6 - Reconnect gesture" , device = DS , showSystemUi = true )
342351@Composable
0 commit comments