package com.openclaw.alfred.alarm

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log

/**
 * BroadcastReceiver for handling alarm dismiss actions from notifications.
 */
class AlarmDismissReceiver : BroadcastReceiver() {
    
    private val TAG = "AlarmDismissReceiver"
    
    override fun onReceive(context: Context?, intent: Intent?) {
        if (context == null || intent == null) return
        
        when (intent.action) {
            "com.openclaw.alfred.DISMISS_ALARM" -> {
                val alarmId = intent.getStringExtra("alarm_id")
                if (alarmId != null) {
                    Log.d(TAG, "Dismissing alarm: $alarmId")
                    
                    // Get AlarmManager singleton and dismiss the alarm
                    val alarmManager = AlarmManager.getInstance(context)
                    alarmManager.dismissAlarm(alarmId)
                    
                    Log.d(TAG, "Alarm dismissed: $alarmId")
                }
            }
        }
    }
}
