@@ -19,6 +19,7 @@ import eu.darken.amply.main.ui.MainActivity
1919object SessionNotifications {
2020 const val SESSION_ID = 4101
2121 private const val RECOVERY_ID = 4102
22+ private const val ACTION_REQUEST_CODE_BASE = 8
2223 // Channel ids are invisible to the user and permanent — changing one resets that channel's
2324 // settings — so this keeps its original id while its display name has moved on.
2425 private const val SESSION_CHANNEL = " temporary_full_charge"
@@ -164,14 +165,15 @@ object SessionNotifications {
164165 }
165166
166167 /* *
167- * [protectPolicy] is the adapter's declared protective default and has no default value on
168- * purpose: the action writes it persistently, so the capability has to be handed in by the
169- * caller that resolved the adapter rather than guessed here.
168+ * [actionPolicies] are the persistent-policy buttons to offer, already resolved and validated
169+ * against the adapter by the caller (see [resolveQuickActionPolicies]) — no default value on
170+ * purpose: these actions write persistently, so the capability has to be handed in rather than
171+ * guessed here.
170172 */
171173 fun gesture (
172174 context : Context ,
173175 decision : QuickFullChargeDecision ,
174- protectPolicy : ChargePolicy ,
176+ actionPolicies : List < ChargePolicy > ,
175177 anyLevel : Boolean = false,
176178 limitPercent : Int? = null,
177179 ): Notification {
@@ -235,35 +237,34 @@ object SessionNotifications {
235237 // WAITING_FOR_RECONNECT": TRIGGER also reaches this builder, and neither the 10s countdown
236238 // nor the tick that starts a full charge should offer a competing persistent write.
237239 if (decision == QuickFullChargeDecision .IDLE || decision == QuickFullChargeDecision .ARMED ) {
238- builder
239- .addAction(
240+ actionPolicies.forEachIndexed { index, policy ->
241+ builder .addAction(
240242 R .drawable.ic_launcher_monochrome,
241- protectActionLabel(context, protectPolicy),
242- persistentPolicyIntent(context, 8 , protectPolicy),
243- )
244- .addAction(
245- R .drawable.ic_launcher_monochrome,
246- context.getString(R .string.gesture_notification_action_always_full),
247- persistentPolicyIntent(context, 9 , ChargePolicy .Unrestricted ),
243+ policyActionLabel(context, policy),
244+ persistentPolicyIntent(context, ACTION_REQUEST_CODE_BASE + index, policy),
248245 )
246+ }
249247 }
250248 return builder.build()
251249 }
252250
253- /* * Mirrors the widget's protect- button naming; other policies are not protective defaults today . */
254- private fun protectActionLabel (context : Context , policy : ChargePolicy ): String = when (policy) {
251+ /* * Mirrors the widget's button naming. */
252+ private fun policyActionLabel (context : Context , policy : ChargePolicy ): String = when (policy) {
255253 is ChargePolicy .FixedLimit -> context.getString(
256254 R .string.gesture_notification_action_protect_fixed,
257255 policy.percent,
258256 )
259257 ChargePolicy .Adaptive -> context.getString(R .string.gesture_notification_action_protect_adaptive)
258+ ChargePolicy .Unrestricted -> context.getString(R .string.gesture_notification_action_always_full)
259+ ChargePolicy .PauseAtFull -> context.getString(R .string.gesture_notification_action_pause_at_full)
260260 else -> context.getString(R .string.gesture_notification_action_protect)
261261 }
262262
263263 /* *
264- * Both actions share [ChargeSessionService.ACTION_SET_PERSISTENT_POLICY] and differ only in an
264+ * All actions share [ChargeSessionService.ACTION_SET_PERSISTENT_POLICY] and differ only in an
265265 * extra, which does NOT factor into PendingIntent equality — hence the distinct [requestCode]
266- * per action, or the second would overwrite the first's target.
266+ * per slot, or a later action would overwrite an earlier one's target. The base leaves the
267+ * request codes this file already uses (1–5, 7) alone.
267268 */
268269 private fun persistentPolicyIntent (
269270 context : Context ,
0 commit comments