#define DAYS_IN_WEEK 7
#define NUMBER_OF_SPACES 6
#define WEEK_MAX_STRING DAY_MAX_LENGTH * DAYS_IN_WEEK + NUMBER_OF_SPACES + 1
+#define MINUTES_IN_HOUR 60
+#define HOURS_IN_DAY 24
+
#define GREEN_TEXT_COLOR "<font_size=80><color=#b3b3b3>%s</color></font_size>"
#define GREY_TEXT_COLOR "<font_size=80><color=#97e57b>%s</color></font_size>"
static char *get_formatted_date(const char *locale, const char *best_pattern, time_t time);
static char *make_time_string(time_t curr_time);
static void calc_label_size(Evas_Object *label);
+static void show_user_change_schedule_popup();
+
+static bool is_current_time_in_scheduled_time_range()
+{
+ time_t rawtime = time(NULL);
+ struct tm curtime = {};
+ localtime_r(&rawtime, &curtime);
+ int start_hour = 0;
+ int start_min = 0;
+ int end_hour = 0;
+ int end_min = 0;
+ int wday_map = DND_SCHEDULE_WEEK_FLAG_SUNDAY;
+ bool res = false;
+
+ notification_system_setting_dnd_schedule_get_day(get_system_setting(), &wday_map);
+ notification_system_setting_dnd_schedule_get_start_time(get_system_setting(), &start_hour, &start_min);
+ notification_system_setting_dnd_schedule_get_end_time(get_system_setting(), &end_hour, &end_min);
+
+ int start = MINUTES_IN_HOUR * start_hour + start_min;
+ int end = MINUTES_IN_HOUR * end_hour + end_min;
+ int cur = MINUTES_IN_HOUR * curtime.tm_hour + curtime.tm_min;
+ bool curr_day = wday_map & (1 << curtime.tm_wday);
+
+ if (is_next_day())
+ {
+ end += HOURS_IN_DAY * MINUTES_IN_HOUR;
+
+ int tm_prevwday = (curtime.tm_wday) ? curtime.tm_wday -1 : 6;
+ if (wday_map & (1 << tm_prevwday)) {
+ cur += HOURS_IN_DAY * MINUTES_IN_HOUR;
+ res = cur >= start && cur < end;
+ }
+ } else {
+ if (curr_day)
+ res = cur >= start && cur < end;
+ }
+
+ return res;
+}
static bool is_empty_str(const char *str)
{
ret_if(ug_main == NULL);
bool check = elm_check_state_get(obj);
enable_time_items(check);
+ elm_genlist_item_update(elm_genlist_item_next_get(elm_genlist_first_item_get(ug_main->list_main)));
+
set_set_schedule(check);
+
+ if(check) {
+ if(get_do_not_disturb()) {
+ notification_status_message_post("Do not disturb will automatically turn off at end time."); // TODO: IDS
+ } else {
+ if(is_current_time_in_scheduled_time_range()) {
+ set_do_not_disturb(true);
+ notification_status_message_post("Do not disturb enabled. Current time is between start and end times."); // TODO: IDS
+ }
+ }
+ } else {
+ if(is_current_time_in_scheduled_time_range()) {
+ set_do_not_disturb(false);
+ notification_status_message_post("Do not disturb disabled."); // TODO: IDS
+ }
+ }
+
update_system_settings();
- elm_genlist_item_update(elm_genlist_item_next_get(elm_genlist_first_item_get(ug_main->list_main)));
}
int get_time_format()
bool set_schedule = false;
notification_system_setting_dnd_schedule_get_enabled(get_system_setting(), &set_schedule);
- free_system_setting();
NOTISET_DBG("get_schedule [%d]\n", set_schedule);
return set_schedule;
return difftime(t1, t2) == 0.0;
}
-static void save_date_time(datetime_s *dt)
-{
- if (dt->saved_time.tm_hour == start_time_p.saved_time.tm_hour && dt->saved_time.tm_min == start_time_p.saved_time.tm_min)
- notification_system_setting_dnd_schedule_set_start_time(get_system_setting(), dt->saved_time.tm_hour, dt->saved_time.tm_min);
- else
- notification_system_setting_dnd_schedule_set_end_time(get_system_setting(), dt->saved_time.tm_hour, dt->saved_time.tm_min);
-}
-
static void week_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
NOTISET_TRACE_BEGIN;
calc_label_size(cc->label);
cc->change_color = !cc->change_color;
save_dnd_weekday(new_dnd_schedule_weekday);
- ecore_main_loop_iterate(); /* update_system_settings work slow, so we use ui at first */
+
+ show_user_change_schedule_popup();
+
update_system_settings();
}
evas_object_del(data);
}
+static void show_user_change_schedule_popup()
+{
+ bool res = is_current_time_in_scheduled_time_range();
+ if(res)
+ notification_status_message_post("Do not Disturb enabled. Current time is between start and end times."); //TODO: IDS
+ else
+ notification_status_message_post("Do not Disturb disabled. Current time is not between start and end times."); //TODO: IDS
+
+ set_do_not_disturb(res);
+}
+
static void popup_set_btn_clicked_cb(void *data , Evas_Object *obj , void *event_info)
{
NOTISET_TRACE_BEGIN;
evas_object_del(dt->popup);
+ show_user_change_schedule_popup();
update_system_settings();
}