package com.example.iot_controlhost.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.example.iot_controlhost.utils.MyUtil;
import com.example.iot_controlhost.utils.log.MyLog;

/**
 * 消毒计划-广播接受者
 */
public class ThemeReceiver extends BroadcastReceiver {
    /**
     * 切为亮色调
     */
    public static final String THEME_LIGHT = "THEME_LIGHT";
    /**
     * 切为暗色调
     */
    public static final String THEME_NIGHT = "THEME_NIGHT";

    public void onReceive(Context context, Intent intent) {
        //是否目标为暗色调
        boolean target = false;
        if (THEME_LIGHT.equals(intent.getAction())) {
            target = false;
        } else if (THEME_NIGHT.equals(intent.getAction())) {
            target = true;
        }
        MyUtil.switchDarkMode(target);
        MyLog.auto("定时任务：开启" + (target ? "暗" : "亮") + "色调");
    }
}