#include "set-scedule-info.h"
#include <system_settings.h>
#include <time.h>
-
-bool isNextDay = true;
+#include <notification_setting_internal.h>
enum TimeFormat
{
#define TIME_STRING_SIZE 200
#define BUTTON_TEXT_SIZE 512
#define WEEK_BUTTON_SIZE 80
+#define WEEK_MAX_STRING 560
+#define DAY_MAX_LENGTH 80
+
+#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>"
+
+#define GREEN_TEXT_MAIN "<color=#b3b3b3>%s</color>"
+#define GREY_TEXT_MAIN "<color=#97e57b>%s</color>"
typedef struct changecolor
{
+ dnd_schedule_week_flag_e week;
const char *text;
bool change_color;
Evas_Object *label;
} datetime_s;
datetime_s start_time_p, end_time_p;
+static int day = 0;
+
+static void set_set_schedule(bool state);
+static void enable_time_items(bool enable);
+static Evas_Object *create_week_repeat_layout(Evas_Object* parent);
+static void week_button_clicked_cb(void *data, Evas_Object *obj, void *event_info);
+static Evas_Object *create_week_button(Evas_Object *parent, const char *text, dnd_schedule_week_flag_e week);
+static Evas_Object *repeat_weekly_layout_cb(Evas_Object* parent, void *data);
+static void popup_cancel_btn_clicked_cb(void *data , Evas_Object *obj , void *event_info);
+static void popup_set_btn_clicked_cb(void *data , Evas_Object *obj , void *event_info);
+static void create_datetime_popup(datetime_s *dt);
+static void launch_popup_cb(void *data , Evas_Object *obj , void *event_info);
+static Evas_Object *create_time_button(Evas_Object *parent, const char *text, const char *format, datetime_s *dt);
+static Evas_Object *create_start_end_time_layout(Evas_Object* parent);
+static void close_set_schedule_cb(void *data, Evas_Object *obj, void *event_info);
+static const char *make_color_text(dnd_schedule_week_flag_e week_day, const char *text);
+
+const char *get_time_string()
+{
+ char buff_start[TIME_STRING_SIZE / 2] = {0};
+ char buff_end[TIME_STRING_SIZE / 2] = {0};
+ char buff[TIME_STRING_SIZE] = {0};
-void set_schedule_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+ time_t local_time = time(0);
+ struct tm *time_info = localtime(&local_time);
+
+ start_time_p.saved_time = *time_info;
+ start_time_p.saved_time.tm_sec = 0;
+ end_time_p.saved_time = *time_info;
+ end_time_p.saved_time.tm_sec = 0;
+
+ notification_system_setting_h system_setting = NULL;
+ int err = notification_system_setting_load_system_setting(&system_setting);
+ if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL)
+ {
+ NOTISET_ERR("notification_system_setting_load_system_setting failed [%d]\n", err);
+ return NULL;
+ }
+ notification_system_setting_dnd_schedule_get_start_time(system_setting, &start_time_p.saved_time.tm_hour, &start_time_p.saved_time.tm_min);
+ if(start_time_p.saved_time.tm_hour == 0 && start_time_p.saved_time.tm_min == 0)
+ {
+ start_time_p.saved_time.tm_hour = 22;
+ notification_system_setting_dnd_schedule_set_start_time(system_setting, start_time_p.saved_time.tm_hour, start_time_p.saved_time.tm_min);
+ }
+ notification_system_setting_dnd_schedule_get_end_time(system_setting, &end_time_p.saved_time.tm_hour, &end_time_p.saved_time.tm_min);
+ if(end_time_p.saved_time.tm_hour == 0 && end_time_p.saved_time.tm_min == 0)
+ {
+ end_time_p.saved_time.tm_hour = 8;
+ notification_system_setting_dnd_schedule_set_start_time(system_setting, end_time_p.saved_time.tm_hour, end_time_p.saved_time.tm_min);
+ }
+
+ notification_system_setting_update_system_setting(system_setting);
+ if (err != NOTIFICATION_ERROR_NONE)
+ NOTISET_ERR("notification_setting_update_setting [%d]\n", err);
+ if(system_setting)
+ notification_system_setting_free_system_setting(system_setting);
+
+
+ if(get_time_format() == time_format_12H)
+ {
+ strftime(buff_start, TIME_STRING_SIZE / 2, TIME_12_FORMAT, &start_time_p.saved_time);
+ strftime(buff_end, TIME_STRING_SIZE / 2, TIME_12_FORMAT, &end_time_p.saved_time);
+ }
+ else
+ {
+ strftime(buff_start, TIME_STRING_SIZE / 2, TIME_24_FORMAT, &start_time_p.saved_time);
+ strftime(buff_end, TIME_STRING_SIZE / 2, TIME_24_FORMAT, &end_time_p.saved_time);
+ }
+
+ snprintf(buff, TIME_STRING_SIZE, "%s ~ %s %s", buff_start, buff_end, is_next_day() ? APP_STRING("IDS_ST_SBODY_NEXT_DAY_M_LC_ABB") : "");
+ return strdup(buff);
+}
+
+static const char *make_color_text(dnd_schedule_week_flag_e week_day, const char *text)
+{
+ char variable[DAY_MAX_LENGTH] = { 0 };
+ if((day & week_day) == 0)
+ snprintf(variable, DAY_MAX_LENGTH, GREY_TEXT_MAIN, text);
+ else
+ snprintf(variable, DAY_MAX_LENGTH, GREEN_TEXT_MAIN, text);
+
+ return strdup(variable);
+}
+
+const char *get_day_string()
+{
+ char buff[WEEK_MAX_STRING] = { 0 };
+
+ notification_system_setting_h system_setting = NULL;
+ int err = notification_system_setting_load_system_setting(&system_setting);
+ if(err != NOTIFICATION_ERROR_NONE || system_setting == NULL)
+ {
+ NOTISET_ERR("notification_system_setting_load_system_setting failed [%d]\n", err);
+ return NULL;
+ }
+
+ notification_system_setting_dnd_schedule_get_day(system_setting, &day);
+ if(system_setting)
+ notification_system_setting_free_system_setting(system_setting);
+
+
+ strcat(buff, make_color_text(DND_SCHEDULE_WEEK_FLAG_MONDAY, "M "));
+ strcat(buff, make_color_text(DND_SCHEDULE_WEEK_FLAG_TUESDAY, "T "));
+ strcat(buff, make_color_text(DND_SCHEDULE_WEEK_FLAG_WEDNESDAY, "W "));
+ strcat(buff, make_color_text(DND_SCHEDULE_WEEK_FLAG_THURSDAY, "T "));
+ strcat(buff, make_color_text(DND_SCHEDULE_WEEK_FLAG_FRIDAY, "F "));
+ strcat(buff, make_color_text(DND_SCHEDULE_WEEK_FLAG_SATURDAY, "S "));
+ strcat(buff, make_color_text(DND_SCHEDULE_WEEK_FLAG_SUNDAY, "S"));
+
+ return strdup(buff);
+}
+
+bool is_next_day()
+{
+ double diff_time = difftime(mktime(&end_time_p.saved_time), mktime(&start_time_p.saved_time));
+ NOTISET_DBG("diff_time = %f", diff_time);
+ return diff_time <= 0 ? true : false;
+}
+
+static void set_set_schedule(bool state)
{
NOTISET_TRACE_BEGIN;
- //TODO: Will be done, after receiving API
+
+ notification_system_setting_h system_setting = NULL;
+ int err = notification_system_setting_load_system_setting(&system_setting);
+ if(err != NOTIFICATION_ERROR_NONE || system_setting == NULL)
+ {
+ NOTISET_ERR("notification_system_setting_load_system_setting failed [%d]\n", err);
+ return;
+ }
+ notification_system_setting_dnd_schedule_set_enabled(system_setting, state);
+ NOTISET_DBG("set set_schedule [%d]\n", state);
+
+ err = notification_system_setting_update_system_setting(system_setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ NOTISET_ERR("notification_setting_update_setting [%d]\n", err);
+
+ if(system_setting)
+ notification_system_setting_free_system_setting(system_setting);
+}
+
+static void enable_time_items(bool enable)
+{
ug_data *ug_main = get_app_ui_data();
ret_if(ug_main == NULL);
-
- unsigned int i = 0;
- Eina_Bool check = !elm_check_state_get(obj);
+ unsigned int i = 1;
unsigned int size = elm_genlist_items_count(ug_main->list_sub);
Elm_Object_Item *item = elm_genlist_first_item_get(ug_main->list_sub);
- for(i = 1; i < size; ++i)
+ for(; i < size; ++i)
{
Elm_Object_Item *next = elm_genlist_item_next_get(item);
- elm_object_item_disabled_set(next, check);
+ elm_object_item_disabled_set(next, !enable);
item = next;
}
+}
+void set_schedule_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ NOTISET_TRACE_BEGIN;
+ ug_data *ug_main = get_app_ui_data();
+ ret_if(ug_main == NULL);
+ bool check = elm_check_state_get(obj);
+ enable_time_items(check);
+ set_set_schedule(check);
+ elm_genlist_item_update(elm_genlist_item_prev_get(elm_genlist_last_item_get(ug_main->list_main)));
}
-static int get_time_format()
+int get_time_format()
{
bool timeFormat = false;
if(system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &timeFormat) < 0)
bool get_schedule()
{
NOTISET_TRACE_BEGIN;
- // TODO: will be implemented after receiving of API
- return true;
+
+ bool set_schedule = false;
+ notification_system_setting_h system_setting = NULL;
+ int err = notification_system_setting_load_system_setting(&system_setting);
+ if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL)
+ {
+ NOTISET_ERR("notification_system_setting_load_system_setting failed [%d]\n", err);
+ return set_schedule;
+ }
+ notification_system_setting_dnd_schedule_get_enabled(system_setting, &set_schedule);
+ NOTISET_DBG("set_schedule [%d]\n", set_schedule);
+
+ if(system_setting)
+ notification_system_setting_free_system_setting(system_setting);
+
+ return set_schedule;
}
static Evas_Object *create_week_repeat_layout(Evas_Object* parent)
return layout;
}
+
static void week_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
NOTISET_TRACE_BEGIN;
+ ug_data *ug_main = get_app_ui_data();
+ ret_if(ug_main == NULL);
changecolor_s *cc = data;
char buf[BUTTON_TEXT_SIZE] = {0, };
if(cc->change_color)
{
- snprintf(buf, sizeof(buf), "<font_size=80><color=#000000>%s</color></font_size>", cc->text);
+ day ^= cc->week;
+ snprintf(buf, sizeof(buf), GREY_TEXT_COLOR, cc->text);
elm_object_text_set(cc->label, buf);
}
else
{
- snprintf(buf, sizeof(buf), "<font_size=80><color=#66ff66>%s</color></font_size>", cc->text);
+ day |= cc->week;
+ snprintf(buf, sizeof(buf), GREEN_TEXT_COLOR, cc->text);
elm_object_text_set(cc->label, buf);
}
-
cc->change_color = !cc->change_color;
+
+ notification_system_setting_h system_setting = NULL;
+ int err = notification_system_setting_load_system_setting(&system_setting);
+ if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL)
+ {
+ NOTISET_ERR("notification_system_setting_load_system_setting failed [%d]\n", err);
+ return;
+ }
+ notification_system_setting_dnd_schedule_set_day(system_setting, day);
+ notification_system_setting_update_system_setting(system_setting);
+ if(system_setting)
+ notification_system_setting_free_system_setting(system_setting);
+
+ elm_genlist_item_update(elm_genlist_item_prev_get(elm_genlist_last_item_get(ug_main->list_main)));
}
-static Evas_Object *create_week_button(Evas_Object *parent, const char *text)
+static Evas_Object *create_week_button(Evas_Object *parent, const char *text, dnd_schedule_week_flag_e week)
{
//add buttons
+ char buf[BUTTON_TEXT_SIZE] = {0, };
Evas_Object *button = elm_button_add(parent);
evas_object_size_hint_max_set(button, WEEK_BUTTON_SIZE, WEEK_BUTTON_SIZE);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- char buf[BUTTON_TEXT_SIZE] = {0, };
- snprintf(buf, sizeof(buf), "<font_size=80><color=#000000>%s</color></font_size>", text);
- elm_object_text_set(label, buf);
- evas_object_show(label);
+ notification_system_setting_h system_setting = NULL;
+ int err = notification_system_setting_load_system_setting(&system_setting);
+ if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL)
+ {
+ NOTISET_ERR("notification_system_setting_load_system_setting failed [%d]\n", err);
+ return NULL;
+ }
+ notification_system_setting_dnd_schedule_get_day(system_setting, &day);
+ if(system_setting)
+ notification_system_setting_free_system_setting(system_setting);
changecolor_s *cc = calloc(1, sizeof(changecolor_s));
+ cc->week = week;
cc->label = label;
- cc->change_color = false;
cc->text = text;
+ if((day & week) == 0)
+ {
+ snprintf(buf, sizeof(buf), GREY_TEXT_COLOR, text);
+ cc->change_color = false;
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), GREEN_TEXT_COLOR, text);
+ cc->change_color = true;
+ }
+ elm_object_text_set(label, buf);
+ evas_object_show(label);
+
evas_object_smart_callback_add(button, "clicked", week_button_clicked_cb, cc);
elm_object_content_set(button, label);
evas_object_show(button);
elm_box_horizontal_set(box, EINA_TRUE);
elm_object_part_content_set(layout, "elm.box.content", box);
- create_week_button(box, "M");
- create_week_button(box, "T");
- create_week_button(box, "W");
- create_week_button(box, "T");
- create_week_button(box, "F");
- create_week_button(box, "S");
- create_week_button(box, "S");
+ create_week_button(box, "M", DND_SCHEDULE_WEEK_FLAG_MONDAY);
+ create_week_button(box, "T", DND_SCHEDULE_WEEK_FLAG_TUESDAY);
+ create_week_button(box, "W", DND_SCHEDULE_WEEK_FLAG_WEDNESDAY);
+ create_week_button(box, "T", DND_SCHEDULE_WEEK_FLAG_THURSDAY);
+ create_week_button(box, "F", DND_SCHEDULE_WEEK_FLAG_FRIDAY);
+ create_week_button(box, "S", DND_SCHEDULE_WEEK_FLAG_SATURDAY);
+ create_week_button(box, "S", DND_SCHEDULE_WEEK_FLAG_SUNDAY);
evas_object_show(box);
elm_box_recalculate(box);
static void popup_set_btn_clicked_cb(void *data , Evas_Object *obj , void *event_info)
{
NOTISET_TRACE_BEGIN;
- ug_data *main_data = get_app_ui_data();
- ret_if(main_data == NULL);
-
+ ug_data *ug_main = get_app_ui_data();
+ ret_if(ug_main == NULL);
char buff[TIME_STRING_SIZE] = { 0 };
const char *format;
datetime_s *dt = data;
elm_datetime_value_get(dt->datetime, &dt->saved_time);
format = elm_datetime_format_get(dt->datetime);
+ notification_system_setting_h system_setting = NULL;
+ int err = notification_system_setting_load_system_setting(&system_setting);
+ if(err != NOTIFICATION_ERROR_NONE || system_setting == NULL)
+ {
+ NOTISET_ERR("notification_system_setting_load_system_setting failed [%d]\n", err);
+ return;
+ }
+
+ 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(system_setting, dt->saved_time.tm_hour, dt->saved_time.tm_min);
+ else
+ notification_system_setting_dnd_schedule_set_end_time(system_setting, dt->saved_time.tm_hour, dt->saved_time.tm_min);
+
+ err = notification_system_setting_update_system_setting(system_setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ NOTISET_ERR("notification_setting_update_setting [%d]\n", err);
+
+ if(system_setting)
+ notification_system_setting_free_system_setting(system_setting);
+
if(!strcmp(format, POPUP_TIME_12_FORMAT))
strftime(buff, TIME_STRING_SIZE, TIME_12_FORMAT, &dt->saved_time);
else
strftime(buff, TIME_STRING_SIZE, TIME_24_FORMAT, &dt->saved_time);
- double diff_time = difftime(mktime(&end_time_p.saved_time), mktime(&start_time_p.saved_time));
- isNextDay = diff_time <= 0 ? true : false;
- NOTISET_DBG("diff_time = %f", diff_time);
-
- elm_genlist_item_update(elm_genlist_last_item_get(main_data->list_sub));
+ elm_genlist_item_update(elm_genlist_last_item_get(ug_main->list_sub));
+ elm_genlist_item_update(elm_genlist_item_prev_get(elm_genlist_last_item_get(ug_main->list_main)));
elm_object_text_set(dt->button, buff);
Evas_Object* start_end_time_item(Evas_Object* parent, bool is_start_time_item)
{
Evas_Object* layout = create_start_end_time_layout(parent);
- datetime_s dt;
char buff[TIME_STRING_SIZE] = {0};
+ datetime_s dt;
time_t local_time = time(0);
struct tm *time_info = localtime(&local_time);
dt.is_start_time = is_start_time_item;
dt.saved_time = *time_info;
- dt.saved_time.tm_min = 0;
dt.saved_time.tm_sec = 0;
+ notification_system_setting_h system_setting = NULL;
+ int err = notification_system_setting_load_system_setting(&system_setting);
+ if(err != NOTIFICATION_ERROR_NONE || system_setting == NULL)
+ {
+ NOTISET_ERR("notification_system_setting_load_system_setting failed [%d]\n", err);
+ return NULL;
+ }
+ if(is_start_time_item)
+ {
+ notification_system_setting_dnd_schedule_get_start_time(system_setting, &dt.saved_time.tm_hour, &dt.saved_time.tm_min);
+ if(dt.saved_time.tm_hour == 0 && dt.saved_time.tm_min == 0)
+ {
+ dt.saved_time.tm_hour = 22;
+ notification_system_setting_dnd_schedule_set_start_time(system_setting, dt.saved_time.tm_hour, dt.saved_time.tm_min);
+ }
+ }
+ else
+ {
+ notification_system_setting_dnd_schedule_get_end_time(system_setting, &dt.saved_time.tm_hour, &dt.saved_time.tm_min);
+ if(dt.saved_time.tm_hour == 0 && dt.saved_time.tm_min == 0)
+ {
+ dt.saved_time.tm_hour = 8;
+ notification_system_setting_dnd_schedule_set_end_time(system_setting, dt.saved_time.tm_hour, dt.saved_time.tm_min);
+ }
+ }
+
+ err = notification_system_setting_update_system_setting(system_setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ NOTISET_ERR("notification_setting_update_setting [%d]\n", err);
+
+ if(system_setting)
+ notification_system_setting_free_system_setting(system_setting);
+
long int curr_end_time = (long int)mktime(&end_time_p.saved_time);
long int curr_start_time = (long int)mktime(&start_time_p.saved_time);
if(dt.is_start_time && curr_start_time == -1)
- {
start_time_p = dt;
- start_time_p.saved_time.tm_hour = 22;
- }
else if(!dt.is_start_time && curr_end_time == -1)
- {
end_time_p = dt;
- end_time_p.saved_time.tm_hour = 8;
- }
char *timeFormat = get_time_format() == time_format_12H ? TIME_12_FORMAT : TIME_24_FORMAT;
if(is_start_time_item)
return layout;
}
+static void close_set_schedule_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ NOTISET_TRACE_BEGIN;
+ ret_if(!data);
+ elm_naviframe_item_pop(data);
+}
+
void gl_set_schedule_selected(ug_data *data)
{
NOTISET_TRACE_BEGIN;
/* back Button */
Evas_Object *back_btn = elm_button_add(ugd->naviframe);
elm_object_style_set(back_btn, "naviframe/back_btn/default");
- evas_object_smart_callback_add(back_btn, "clicked", back_button_cb, ugd->naviframe);
+ evas_object_smart_callback_add(back_btn, "clicked", close_set_schedule_cb, ugd->naviframe);
/* Push to naviframe */
ugd->list_sub = _create_set_schedule_disturb_gl(ugd);
append_gl_start_option(ugd->list_sub, "type1", "start-time");
append_gl_start_option(ugd->list_sub, "type1", "end-time");
ugd->navi_item = elm_naviframe_item_push(ugd->naviframe, APP_STRING("IDS_ST_MBODY_SET_SCHEDULE_M_TIME"), back_btn, NULL, ugd->list_sub, NULL);
+ enable_time_items(get_schedule());
}
-