From 4bf03f0ac8edf4f0137b4ae990279ca190332350 Mon Sep 17 00:00:00 2001 From: Agnieszka Janowicz Date: Wed, 10 Feb 2016 13:46:58 +0100 Subject: [PATCH] Wakeup Timer view implementation (no functionality yet) Change-Id: I9e6f612a99661dd25e51e44bfe38c50ec10faeb1 Signed-off-by: Agnieszka Janowicz > --- CMakeLists.txt | 2 + include/common/utils.h | 5 +- include/data/system/settings_wakeup_timer.h | 59 +++ include/define.h | 18 + include/view/system/view_wakeup_timer.h | 22 + res/settings.edc | 1 + res/view/system/wakeup_timer.edc | 452 +++++++++++++++++++++ src/common/utils.c | 6 +- src/data/system/settings_wakeup_timer.c | 64 +++ src/layout/layout_system.c | 8 +- src/main.c | 10 + src/view/system/view_clock.c | 4 +- src/view/system/view_wakeup_timer.c | 608 ++++++++++++++++++++++++++++ 13 files changed, 1251 insertions(+), 8 deletions(-) create mode 100644 include/data/system/settings_wakeup_timer.h create mode 100644 include/view/system/view_wakeup_timer.h create mode 100644 res/view/system/wakeup_timer.edc create mode 100644 src/data/system/settings_wakeup_timer.c create mode 100644 src/view/system/view_wakeup_timer.c diff --git a/CMakeLists.txt b/CMakeLists.txt index bcda956..f5ad111 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ SET(SRCS src/main.c src/view/view_base.c src/view/system/view_clock.c + src/view/system/view_wakeup_timer.c src/view/system/view_location.c src/view/view_new_network.c src/common/utils.c @@ -86,6 +87,7 @@ SET(SRCS src/data/system/data_wireless.c src/data/system/data_wired.c src/data/system/settings_clock.c + src/data/system/settings_wakeup_timer.c ) SET(TARGET_EDJ "${PROJECT_NAME}.edj") diff --git a/include/common/utils.h b/include/common/utils.h index 4e48cfa..6482ed9 100644 --- a/include/common/utils.h +++ b/include/common/utils.h @@ -42,10 +42,11 @@ Evas_Object *utils_add_slider(Evas_Object *parent, const char *part, int value, int min_value, int max_value, int step); Evas_Object *utils_add_hoversel(Evas_Object *parent, const char *part, int opt_count, int *opt_id, const char **opt_text, int selected_opt, - Evas_Smart_Cb, void *data); + Evas_Smart_Cb opt_handler, void *data); Evas_Object *utils_add_datetime(Evas_Object *parent, const char *part, Eina_Bool field_year, Eina_Bool field_month, Eina_Bool field_date, - Eina_Bool field_hour, Eina_Bool field_minute, Eina_Bool field_ampm); + Eina_Bool field_hour, Eina_Bool field_minute, Eina_Bool field_ampm, + struct tm *time_to_set); Evas_Object *utils_add_flipselector(Evas_Object *parent, const char *part, int opt_count, int *opt_id, const char **opt_text, int selected_opt, Evas_Smart_Cb opt_handler, void *data); diff --git a/include/data/system/settings_wakeup_timer.h b/include/data/system/settings_wakeup_timer.h new file mode 100644 index 0000000..422275c --- /dev/null +++ b/include/data/system/settings_wakeup_timer.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __AIR_SETTINGS_WAKEUP_TIMER_H__ +#define __AIR_SETTINGS_WAKEUP_TIMER_H__ + +#include +#include + +enum setup_type { + SETUP_TYPE_OFF = 0, + SETUP_TYPE_ONCE, + SETUP_TYPE_EVERYDAY, + SETUP_TYPE_MON_FRI, + SETUP_TYPE_MON_SAT, + SETUP_TYPE_SAT_SUN, + SETUP_TYPE_MAX +}; + +enum source_type { + SOURCE_TYPE_TV = 0, + SOURCE_TYPE_USB, + SOURCE_TYPE_APP_TV, + SOURCE_TYPE_HDMI2_DVI, + SOURCE_TYPE_HDMI3, + SOURCE_TYPE_HDMI4, + SOURCE_TYPE_MAX +}; + +enum tmp_channel { + TMP_CHANNEL1 = 0, + TMP_CHANNEL2, + TMP_CHANNEL3, + TMP_CHANNEL4, + TMP_CHANNEL_MAX +}; + +int settings_wakeup_timer_get_setup(void); +bool settings_wakeup_timer_get_time(struct tm *def_time); +int settings_wakeup_timer_get_volume(void); +int settings_wakeup_timer_get_source(void); +int settings_wakeup_timer_get_channel(void); +//@TODO settings_wakeup_timer_set_timer() + + +#endif /* __AIR_SETTINGS_WAKEUP_TIMER_H__ */ diff --git a/include/define.h b/include/define.h index 0ca04dd..a2182f1 100644 --- a/include/define.h +++ b/include/define.h @@ -29,6 +29,7 @@ #define VIEW_CLOCK "VIEW_CLOCK" #define VIEW_LOCATION "VIEW_LOCATION" #define VIEW_NEW_NETWORK "VIEW_NEW_NETWORK" +#define VIEW_WAKEUP_TIMER "WAKEUP_TIMER" /* Layout ID */ #define LAYOUT_ID_PICTURE "LAYOUT_ID_PICTURE" @@ -45,6 +46,7 @@ #define GRP_VIEW_CLOCK "grp.view.clock" #define GRP_VIEW_LOCATION "grp.view.location" #define GRP_VIEW_NEW_NETWORK "grp.view.new_network" +#define GRP_VIEW_WAKEUP_TIMER "grp.view.wakeup_timer" /* Part for EDC */ #define PART_TOP_TITLE "part.top.title" @@ -59,14 +61,22 @@ #define PART_MENU_VALUE "part.menu.value" #define PART_GUIDE "part.guide" +#define PART_GUIDE_2 "part.guide2" #define PART_MAIN_LABEL_SETUP "part.main.label.setup" #define PART_MAIN_LABEL_DATE "part.main.label.date" #define PART_MAIN_LABEL_24HOUR "part.main.label.24hour" #define PART_MAIN_LABEL_TIME "part.main.label.time" +#define PART_MAIN_LABEL_VOLUME "part.main.label.volume" +#define PART_MAIN_LABEL_SOURCE "part.main.label.source" +#define PART_MAIN_LABEL_CHANNEL "part.main.label.channel" #define PART_MAIN_ITEM_SETUP "part.main.item.setup" #define PART_MAIN_ITEM_DATE "part.main.item.date" #define PART_MAIN_ITEM_24HOUR "part.main.item.24hour" #define PART_MAIN_ITEM_TIME "part.main.item.time" +#define PART_MAIN_ITEM_VOLUME_SLIDER "part.main.item.volume.slider" +#define PART_MAIN_ITEM_VOLUME_LABEL "part.main.item.volume.label" +#define PART_MAIN_ITEM_SOURCE "part.main.item.source" +#define PART_MAIN_ITEM_CHANNEL "part.main.item.channel" #define PART_POPUP_BUTTON1 "part.popup.btn1" #define PART_POPUP_BUTTON2 "part.popup.btn2" @@ -138,6 +148,9 @@ #define STR_CLOCK "Clock" #define STR_CLOCK_DES "If you set Clock Manual, You can set date and time." +#define STR_WAKEUP_TIMER "Wake up timer" +#define STR_WAKEUP_TIMER_DES1 "You can set wake up timer." +#define STR_WAKEUP_TIMER_DES2 "If you set wake up timer, TV will be turned on on your timer." #define STR_SETUP "Setup" #define STR_AUTO "Auto" @@ -145,6 +158,8 @@ #define STR_DATE "Date" #define STR_24HOUR "24 hour" #define STR_TIME "Time" +#define STR_VOLUME "Volume" +#define STR_SOURCE "Source" #define STR_LANGUAGE "Language" #define STR_LOCATION "Location" @@ -172,4 +187,7 @@ #define BASE_RESOLUTION_X 1920.0 #define BASE_RESOLUTION_Y 1080.0 +/* Settings */ +#define VOLUME_MAX 100 + #endif /* __AIR_SETTINGS_DEFINE_H__ */ diff --git a/include/view/system/view_wakeup_timer.h b/include/view/system/view_wakeup_timer.h new file mode 100644 index 0000000..d19a710 --- /dev/null +++ b/include/view/system/view_wakeup_timer.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __AIR_SETTINGS_VIEW_WAKEUP_TIMER_H__ +#define __AIR_SETTINGS_VIEW_WAKEUP_TIMER_H__ + +view_class *view_wakeup_timer_get_vclass(void); + +#endif /* __AIR_SETTINGS_VIEW_WAKEUP_TIMER_H__ */ diff --git a/res/settings.edc b/res/settings.edc index abcde16..366fca4 100644 --- a/res/settings.edc +++ b/res/settings.edc @@ -20,6 +20,7 @@ collections { base_scale: APP_BASE_SCALE; #include "view/base.edc" #include "view/system/clock.edc" + #include "view/system/wakeup_timer.edc" #include "view/system/location.edc" #include "layout/picture.edc" #include "layout/channel.edc" diff --git a/res/view/system/wakeup_timer.edc b/res/view/system/wakeup_timer.edc new file mode 100644 index 0000000..677e361 --- /dev/null +++ b/res/view/system/wakeup_timer.edc @@ -0,0 +1,452 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +group { + name, GRP_VIEW_WAKEUP_TIMER; + + parts { + part { + name, "bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 244 244 244 255; + } + } + + part { + name, "title.bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + min, 0 104; + rel2.relative, 1.0 0.0; + align, 0.5 0.0; + fixed, 0 1; + } + } + + part { + name, PART_TOP_TITLE; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 51 51 51 255; + rel1.to, "title.bg"; + rel2.to, "title.bg"; + text { + font, FONT_REGULAR; + size, 46; + align, 0.5 0.5; + } + } + } + + part { + name, "padding.guide"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 0 68; + align, 0.5 0.0; + rel1 { to, "title.bg"; relative, 0.0 1.0; } + rel2.to, "title.bg"; + } + } + + part { + name, "part.guide.bg"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 0 32; + rel1 { to, "padding.guide"; relative, 0.0 1.0; } + rel2.to, "padding.guide"; + align, 0.5 0.0; + } + } + + part { + name, PART_GUIDE; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 116 116 116 255; + rel1.to, "part.guide.bg"; + rel2.to, "part.guide.bg"; + text { + font, FONT_LIGHT; + size, 32; + align, 0.5 0.5; + } + } + } + + part { + name, "part.guide2.bg"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 0 32; + rel1 { to, "part.guide.bg"; relative, 0.0 1.5; } + rel2 { to, "part.guide.bg"; relative, 1.0 2.5; } + align, 0.5 0.0; + } + } + + part { + name, PART_GUIDE_2; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 116 116 116 255; + rel1.to, "part.guide2.bg"; + rel2.to, "part.guide2.bg"; + text { + font, FONT_LIGHT; + size, 32; + align, 0.5 0.5; + } + } + } + + part { + name, "padding.main"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 0 74; + align, 0.5 0.0; + rel1 { to, "part.guide2.bg"; relative, 0.0 1.0; } + rel2.to, "part.guide2.bg"; + } + } + + part { + name, "part.main.bg"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 0 578; + rel1 { to, "padding.main"; relative, 0.0 1.0; } + rel2.to, "padding.main"; + align, 0.5 0.0; + } + } + + part { + name, "part.main"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + max, 760 578; + fixed, 1 1; + align, 0.5 0.0; + rel1.to, "part.main.bg"; + rel2.to, "part.main.bg"; + } + } + + part { + name, "part.main.options.texts.bg"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + max, 150 578; + fixed, 1 1; + align, 0.0 0.0; + rel1.to, "part.main"; + rel2.to, "part.main"; + } + } + + part { + name, PART_MAIN_LABEL_SETUP; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 116 116 116 255; + rel1.to, "part.main.options.texts.bg"; + rel2 { to, "part.main.options.texts.bg"; relative, 1.0 0.2; } + text { + font, FONT_REGULAR; + size, 32; + align, 1.0 0.5; + } + } + } + + part { + name, PART_MAIN_LABEL_TIME; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 116 116 116 255; + rel1 { to, "part.main.options.texts.bg"; relative, 0.0 0.2; } + rel2 { to, "part.main.options.texts.bg"; relative, 1.0 0.4; } + text { + font, FONT_REGULAR; + size, 32; + align, 1.0 0.5; + } + } + } + + part { + name, PART_MAIN_LABEL_VOLUME; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 116 116 116 255; + rel1 { to, "part.main.options.texts.bg"; relative, 0.0 0.4; } + rel2 { to, "part.main.options.texts.bg"; relative, 1.0 0.6; } + text { + font, FONT_REGULAR; + size, 32; + align, 1.0 0.5; + } + } + } + + part { + name, PART_MAIN_LABEL_SOURCE; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 116 116 116 255; + rel1 { to, "part.main.options.texts.bg"; relative, 0.0 0.6; } + rel2 { to, "part.main.options.texts.bg"; relative, 1.0 0.8; } + text { + font, FONT_REGULAR; + size, 32; + align, 1.0 0.5; + } + } + } + + part { + name, PART_MAIN_LABEL_CHANNEL; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 116 116 116 255; + rel1 { to, "part.main.options.texts.bg"; relative, 0.0 0.8; } + rel2.to, "part.main.options.texts.bg"; + text { + font, FONT_REGULAR; + size, 32; + align, 1.0 0.5; + } + } + } + + part { + name, "part.main.options.controllers.padding"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 20 0; + fixed, 1 1; + align, 0.0 0.0; + rel1 { to, "part.main.options.texts.bg"; relative, 1.0 0.0; } + rel2 { to, "part.main.options.texts.bg"; relative, 1.0 1.0; } + } + } + + part { + name, "part.main.options.controllers.bg"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + fixed, 1 1; + align, 0.0 0.0; + rel1 { to, "part.main.options.controllers.padding"; relative, 1.0 0.0; } + rel2 { to, "part.main"; relative, 1.0 1.0; } + } + } + + part { + name, PART_MAIN_ITEM_SETUP; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { to, "part.main.options.controllers.bg"; relative, 0.0 0.05; } + rel2 { to, "part.main.options.controllers.bg"; relative, 0.5 0.15; } + } + } + + part { + name, PART_MAIN_ITEM_TIME; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { to, "part.main.options.controllers.bg"; relative, 0.0 0.2; } + rel2 { to, "part.main.options.controllers.bg"; relative, 0.4 0.4; } + } + } + + part { + name, "part.main.options.controllers.volume.bg"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { to, "part.main.options.controllers.bg"; relative, 0.0 0.4; } + rel2 { to, "part.main.options.controllers.bg"; relative, 1.0 0.6; } + } + } + + part { + name, PART_MAIN_ITEM_VOLUME_SLIDER; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1.to, "part.main.options.controllers.volume.bg"; + rel2 { to, "part.main.options.controllers.volume.bg"; relative, 0.9 1.0; } + } + } + + part { + name, PART_MAIN_ITEM_VOLUME_LABEL; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 116 116 116 255; + rel1 { to, "part.main.options.controllers.volume.bg"; relative, 0.9 0.0; } + rel2.to, "part.main.options.controllers.volume.bg"; + text { + font, FONT_REGULAR; + size, 26; + align, 0.5 0.5; + } + } + } + + part { + name, PART_MAIN_ITEM_SOURCE; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { to, "part.main.options.controllers.bg"; relative, 0.0 0.65; } + rel2 { to, "part.main.options.controllers.bg"; relative, 0.5 0.75; } + } + } + + part { + name, PART_MAIN_ITEM_CHANNEL; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { to, "part.main.options.controllers.bg"; relative, 0.0 0.85; } + rel2 { to, "part.main.options.controllers.bg"; relative, 0.4 0.95; } + } + } + + part { + name, "padding.bottom"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 0 76; + align, 0.5 1.0; + fixed, 0 1; + rel1 { to, "part.bottom.bg"; relative, 0.0 1.0; } + rel2 { to, "part.bottom.bg"; relative, 1.0 0.0; } + } + } + + part { + name, "part.bottom.bg"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 0 148; + fixed, 0 1; + align, 0.5 1.0; + rel1.relative, 0.0 1.0; + rel2.relative, 1.0 1.0; + } + } + + part { + name, "part.bottom.pad"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 24 64; + fixed, 1 1; + rel1 { to, "part.bottom.bg"; relative, 0.5 0.5; } + rel2 { to, "part.bottom.bg"; relative, 0.5 0.5; } + } + } + + part { + name, PART_VIEW_BOTTOM_BTN1; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + min, 308 64; + fixed, 1 1; + align, 1.0 0.5; + rel1.to, "part.bottom.pad"; + rel2 { to, "part.bottom.pad"; relative, 0.0 1.0; } + } + } + + part { + name, PART_VIEW_BOTTOM_BTN2; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + min, 308 64; + fixed, 1 1; + align, 0.0 0.5; + rel1 { to, "part.bottom.pad"; relative, 1.0 0.0; } + rel2.to, "part.bottom.pad"; + } + } + } +} diff --git a/src/common/utils.c b/src/common/utils.c index a5a4437..353391d 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -412,7 +412,8 @@ Evas_Object *utils_add_hoversel(Evas_Object *parent, const char *part, Evas_Object *utils_add_datetime(Evas_Object *parent, const char *part, Eina_Bool field_year, Eina_Bool field_month, Eina_Bool field_date, - Eina_Bool field_hour, Eina_Bool field_minute, Eina_Bool field_ampm) + Eina_Bool field_hour, Eina_Bool field_minute, Eina_Bool field_ampm, + struct tm *time_to_set) { Evas_Object *dtime = NULL; @@ -437,6 +438,9 @@ Evas_Object *utils_add_datetime(Evas_Object *parent, const char *part, /*@TODO: Temporary */ elm_object_scale_set(dtime, 1.0 / APP_BASE_SCALE); + if (time_to_set) + elm_datetime_value_set(dtime, (Elm_Datetime_Time *)time_to_set); + if (part) elm_object_part_content_set(parent, part, dtime); diff --git a/src/data/system/settings_wakeup_timer.c b/src/data/system/settings_wakeup_timer.c new file mode 100644 index 0000000..239ee05 --- /dev/null +++ b/src/data/system/settings_wakeup_timer.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "app_debug.h" +#include "data/system/settings_clock.h" +#include "data/system/settings_wakeup_timer.h" + +int settings_wakeup_timer_get_setup(void) +{ + //@TODO: get from stored settings + + return SETUP_TYPE_OFF; +} + +bool settings_wakeup_timer_get_time(struct tm *def_time) +{ + if (!def_time) { + _ERR("Invalid parameter."); + return false; + } + + //@TODO: where wakeup_timer time is? + //@TODO: what should the default time be if wake up timer has not been set? + + settings_clock_get_current_time(def_time); + + return true; +} + +int settings_wakeup_timer_get_volume(void) +{ + //@TODO: get wakeup_timer volume + //@TODO: if wakeup timer not set - system volume + + return 50; +} + +int settings_wakeup_timer_get_source(void) +{ + //@TODO: get wakeup timer source + + return SOURCE_TYPE_TV; +} + +int settings_wakeup_timer_get_channel(void) +{ + //@TODO: get wakeup timer channel + //@TODO: if not set, get last viewed channel + + return TMP_CHANNEL1; +} diff --git a/src/layout/layout_system.c b/src/layout/layout_system.c index 23fe551..b48e0e8 100644 --- a/src/layout/layout_system.c +++ b/src/layout/layout_system.c @@ -252,18 +252,20 @@ static char *_get_location(void *data, int id) static void _selected(void *data, int id) { switch (id) { - case 0: + case MENU_CLOCK: if (!viewmgr_push_view(VIEW_CLOCK)) _ERR("Push Clock view failed."); break; - + case MENU_WAKEUP_TIMER: + if (!viewmgr_push_view(VIEW_WAKEUP_TIMER)) + _ERR("Push Wake up timer view failed."); + break; default: _ERR("Invalid menu."); } } static input_handler _popup_input_handler = { - //.mouse_move = _mouse_move_cb, .mouse_move = NULL, .clicked = _popup_clicked_cb, .key_down = _popup_key_down_cb diff --git a/src/main.c b/src/main.c index 4d4f692..7aa5db6 100644 --- a/src/main.c +++ b/src/main.c @@ -23,6 +23,7 @@ #include "view/view_base.h" #include "view/system/view_clock.h" #include "view/system/view_location.h" +#include "view/system/view_wakeup_timer.h" #include @@ -83,6 +84,12 @@ static bool _create(void *data) return false; } + if (!viewmgr_add_view(view_wakeup_timer_get_vclass(), NULL)) { + _ERR("Add view failed."); + evas_object_del(win); + return false; + } + ad->win = win; return true; @@ -107,6 +114,9 @@ static void _terminate(void *data) if (!viewmgr_remove_view(VIEW_LOCATION)) _ERR("Remove view failed."); + if (!viewmgr_remove_view(VIEW_WAKEUP_TIMER)) + _ERR("Remove view failed."); + if (!viewmgr_destroy()) _ERR("Destroy viewmgr failed."); diff --git a/src/view/system/view_clock.c b/src/view/system/view_clock.c index 982262d..5b786bd 100644 --- a/src/view/system/view_clock.c +++ b/src/view/system/view_clock.c @@ -213,7 +213,7 @@ static bool _add_clock_setting(clock_view_priv_data *priv) priv->auto_manual_setup_btn = utils_add_button(priv->base, PART_MAIN_ITEM_SETUP, STYLE_OPTION_BTN, _(STR_MANUAL)); priv->date_part = utils_add_datetime(priv->base, PART_MAIN_ITEM_DATE, - EINA_TRUE, EINA_TRUE, EINA_TRUE, EINA_FALSE, EINA_FALSE, EINA_FALSE); + EINA_TRUE, EINA_TRUE, EINA_TRUE, EINA_FALSE, EINA_FALSE, EINA_FALSE, NULL); /* 24/12h check: */ priv->check_24 = elm_check_add(priv->base); @@ -221,7 +221,7 @@ static bool _add_clock_setting(clock_view_priv_data *priv) elm_object_scale_set(priv->check_24, 1.0 / APP_BASE_SCALE); priv->time_part = utils_add_datetime(priv->base, PART_MAIN_ITEM_TIME, - EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_TRUE, EINA_TRUE, EINA_TRUE); + EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_TRUE, EINA_TRUE, EINA_TRUE, NULL); inputmgr_add_callback(done, INPUT_HANDLER_TYPE_BTN_DONE, &done_btn_handler, priv); inputmgr_add_callback(cancel, INPUT_HANDLER_TYPE_BTN_CANCEL, &cancel_btn_handler, priv); diff --git a/src/view/system/view_wakeup_timer.c b/src/view/system/view_wakeup_timer.c new file mode 100644 index 0000000..9de7737 --- /dev/null +++ b/src/view/system/view_wakeup_timer.c @@ -0,0 +1,608 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "app_debug.h" +#include "define.h" +#include "common/viewmgr.h" +#include "common/inputmgr.h" +#include "common/utils.h" +#include "data/system/settings_wakeup_timer.h" +#include "view/system/view_wakeup_timer.h" + +#define VOLUME_STR_LEN 5 + +static int id_setup_type_opt[] = { + SETUP_TYPE_OFF, + SETUP_TYPE_ONCE, + SETUP_TYPE_EVERYDAY, + SETUP_TYPE_MON_FRI, + SETUP_TYPE_MON_SAT, + SETUP_TYPE_SAT_SUN +}; + +static const char *str_setup_type_opt[] = { + "OFF", + "Once", + "Everyday", + "Mon - Fri", + "Mon - Sat", + "Sat - Sun" +}; + +static int id_source_type_opt[] = { + SOURCE_TYPE_TV, + SOURCE_TYPE_USB, + SOURCE_TYPE_APP_TV, + SOURCE_TYPE_HDMI2_DVI, + SOURCE_TYPE_HDMI3, + SOURCE_TYPE_HDMI4 +}; + +static const char *str_source_type_opt[] = { + "TV", + "USB", + "App TV", + "HDMI2/DVI", + "HDMI3", + "HDMI4" +}; + +static int id_tmp_channel[] = { + TMP_CHANNEL1, + TMP_CHANNEL2, + TMP_CHANNEL3, + TMP_CHANNEL4 +}; + +static const char *str_tmp_channel[] = { + "CHANNEL1", + "CHANNEL2", + "CHANNEL3", + "CHANNEL4" +}; + +struct _priv { + Evas_Object *win; + Evas_Object *base; + Evas_Object *setup_hs; + Evas_Object *datetime; + Evas_Object *volume_slider; + Evas_Object *source_hs; + Evas_Object *channel_fs; + + Eina_Bool opt_disabled; + + int wut_setup; + int wut_volume; + int wut_source; + int wut_channel; + Elm_Datetime_Time *wut_time; +}; + +enum wakeup_timer_eo_type { + EO_TYPE_BTN_DONE, + EO_TYPE_BTN_CANCEL, + EO_TYPE_SETUP_HOVERSEL, + EO_TYPE_DATETIME, + EO_TYPE_VOLUME_SLIDER, + EO_TYPE_SOURCE_HOVERSEL, + EO_TYPE_CHANNEL_FLIPSELECTOR +}; + +/* Set disabled/enabled state on wakeup timer controllers */ +static void _disable_opts_controllers(struct _priv *priv, Eina_Bool disable); +/* Callback for key down events */ +static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev); +/* Callback for clicked events */ +static void _clicked_cb(int id, void *data, Evas_Object *obj); +/* Callback for widget changed events (datetime,volume) */ +static void _changed_cb(int id, void *data, Evas_Object *obj); +/* Callback for setup hoversel item selected changed event */ +static void _setup_opt_changed_cb(void *data, Evas_Object *obj, void *event_info); +/* Callback for source hoversel item selected changed event */ +static void _source_opt_changed_cb(void *data, Evas_Object *obj, void *event_info); +/* Callback for channel flipselector item selected changed event */ +static void _channel_opt_changed_cb(void *data, Evas_Object *obj, void *event_info); +/* Add wakeup timer widget controllers to base layout */ +static Eina_Bool _fill_layout(struct _priv *priv); +/* Set wakeup timer options to system wakeup timer data */ +static void _set_wakeup_timer_opts(struct _priv *priv); +/* Update wakeup timer options controllers to reflect wakeup timer data */ +static void _update_time_opt_wgt(struct _priv *priv); +static void _update_volume_opt_wgt(struct _priv *priv); +static void _update_setup_opt_wgt(struct _priv *priv); +static void _update_source_opt_wgt(struct _priv *priv); +static void _update_channel_opt_wgt(struct _priv *priv); + +static input_handler handler = { + .key_down = _key_down_cb, + .clicked = _clicked_cb, + .changed = _changed_cb +}; + +static Evas_Object *_create(Evas_Object *win, void *data) +{ + struct _priv *priv = NULL; + Evas_Object *base = NULL; + Evas_Object *btn1 = NULL; + Evas_Object *btn2 = NULL; + + if (!win) { + _ERR("Get window object failed."); + return NULL; + } + + priv = calloc(1, sizeof(*priv)); + if (!priv) { + _ERR("Calloc failed."); + return NULL; + } + + /* Base layout */ + base = utils_add_layout(win, GRP_VIEW_WAKEUP_TIMER, EINA_TRUE); + if (!base) { + _ERR("Add layout failed."); + free(priv); + priv = NULL; + return NULL; + } + + elm_object_part_text_set(base, PART_TOP_TITLE, STR_WAKEUP_TIMER); + elm_object_part_text_set(base, PART_GUIDE, STR_WAKEUP_TIMER_DES1); + elm_object_part_text_set(base, PART_GUIDE_2, STR_WAKEUP_TIMER_DES2); + elm_object_part_text_set(base, PART_MAIN_LABEL_SETUP, STR_SETUP); + elm_object_part_text_set(base, PART_MAIN_LABEL_TIME, STR_TIME); + elm_object_part_text_set(base, PART_MAIN_LABEL_VOLUME, STR_VOLUME); + elm_object_part_text_set(base, PART_MAIN_LABEL_SOURCE, STR_SOURCE); + elm_object_part_text_set(base, PART_MAIN_LABEL_CHANNEL, STR_CHANNEL); + + /* Cancel/Done buttons */ + btn1 = utils_add_button(base, PART_VIEW_BOTTOM_BTN1, "elm/button/base/style.normal.button", STR_CANCEL); + if (!btn1) { + _ERR("Add cancel btn failed."); + evas_object_del(base); + free(priv); + priv = NULL; + return NULL; + } + + btn2 = utils_add_button(base, PART_VIEW_BOTTOM_BTN2, "elm/button/base/style.normal.button", STR_DONE); + if (!btn2) { + _ERR("Add done btn failed."); + evas_object_del(base); + free(priv); + priv = NULL; + return NULL; + } + + priv->win = win; + priv->base = base; + + /* Wakeup timer options layout */ + if (!_fill_layout(priv)) { + _ERR("Fill layout failed."); + evas_object_del(base); + free(priv); + priv = NULL; + return NULL; + } + + inputmgr_add_callback(btn1, EO_TYPE_BTN_CANCEL, &handler, priv); + inputmgr_add_callback(btn2, EO_TYPE_BTN_CANCEL, &handler, priv); + + if (!viewmgr_set_view_data(VIEW_WAKEUP_TIMER, priv)) { + _ERR("Set view data failed."); + evas_object_del(base); + free(priv); + priv = NULL; + return NULL; + } + + return base; +} + +static void _show(void *data) +{ + struct _priv *priv = (struct _priv *)data; + + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + if (priv->base) + evas_object_show(priv->base); + + /* Set wakeup timer data */ + _set_wakeup_timer_opts(priv); + + //@TODO: get channels list + + _update_time_opt_wgt(priv); + _update_volume_opt_wgt(priv); + _update_setup_opt_wgt(priv); + _update_source_opt_wgt(priv); + _update_channel_opt_wgt(priv); + + /* If wakeup timer is off, disable options controllers */ + if (priv->wut_setup == SETUP_TYPE_OFF) + _disable_opts_controllers(priv, EINA_TRUE); + +} + +static void _hide(void *data) +{ + struct _priv *priv = (struct _priv *)data; + + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + if (priv->base) + evas_object_hide(priv->base); +} + +static void _destroy(void *data) +{ + struct _priv *priv = (struct _priv *)data; + + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + if (priv->base) + evas_object_del(priv->base); + + free(priv); + priv = NULL; +} + +static view_class _vclass = { + .view_id = VIEW_WAKEUP_TIMER, + .create = _create, + .show = _show, + .hide = _hide, + .destroy = _destroy +}; + +view_class *view_wakeup_timer_get_vclass(void) +{ + return &_vclass; +} + +static void _disable_opts_controllers(struct _priv *priv, Eina_Bool disable) +{ + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + elm_object_disabled_set(priv->datetime, disable); + elm_object_disabled_set(priv->volume_slider, disable); + elm_object_disabled_set(priv->source_hs, disable); + elm_object_disabled_set(priv->channel_fs, disable); +} + +static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev) +{ + struct _priv *priv = (struct _priv *)data; + + if (!obj || !ev || !priv) { + _ERR("Invalid argument."); + return; + } + + if (!strcmp(ev->keyname, KEY_BACK)) { + switch (id) { + case EO_TYPE_SETUP_HOVERSEL: + elm_hoversel_hover_end(priv->setup_hs); + break; + case EO_TYPE_SOURCE_HOVERSEL: + elm_hoversel_hover_end(priv->source_hs); + break; + } + } else if (!strcmp(ev->keyname, KEY_ENTER)) { + switch (id) { + case EO_TYPE_SETUP_HOVERSEL: + elm_hoversel_hover_begin(priv->setup_hs); + break; + case EO_TYPE_SOURCE_HOVERSEL: + elm_hoversel_hover_begin(priv->source_hs); + break; + } + } +} + +static void _clicked_cb(int id, void *data, Evas_Object *obj) +{ + if (!obj) { + _ERR("Invalid argument."); + return; + } + + switch (id) { + case EO_TYPE_BTN_CANCEL: + viewmgr_pop_view(); + break; + + case EO_TYPE_BTN_DONE: + //@TODO: settings_wakeup_timer_set_timer() + viewmgr_pop_view(); + break; + + default: + return; + } +} + +static void _changed_cb(int id, void *data, Evas_Object *obj) +{ + struct _priv *priv = (struct _priv *)data; + + if (!obj || !priv) { + _ERR("Invalid argument."); + return; + } + + switch (id) { + case EO_TYPE_DATETIME: + elm_datetime_value_get(priv->datetime, priv->wut_time); + break; + case EO_TYPE_VOLUME_SLIDER: + { + char val_str[VOLUME_STR_LEN] = {0, }; + + priv->wut_volume = (int)elm_slider_value_get(obj); + + snprintf(val_str, VOLUME_STR_LEN, "%d", priv->wut_volume); + elm_object_part_text_set(priv->base, PART_MAIN_ITEM_VOLUME_LABEL, val_str); + break; + } + default: + return; + } +} + +static void _setup_opt_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + struct _priv *priv = NULL; + + if (!obj) { + _ERR("Invalid parameter."); + return; + } + + priv = (struct _priv *)evas_object_data_get(obj, DATA_KEY_PRIV); + if (!priv) { + _ERR("Get priv data failed."); + return; + } + + priv->wut_setup = (int)data; + if (priv->wut_setup < 0 || priv->wut_setup >= SETUP_TYPE_MAX) { + _ERR("Invalid data"); + return; + } + + elm_object_text_set(obj, str_setup_type_opt[priv->wut_setup]); + _disable_opts_controllers(priv, priv->wut_setup == SETUP_TYPE_OFF); +} + +static void _source_opt_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + struct _priv *priv = NULL; + + if (!obj) { + _ERR("Invalid parameter."); + return; + } + + priv = (struct _priv *)evas_object_data_get(obj, DATA_KEY_PRIV); + if (!priv) { + _ERR("Get priv data failed."); + return; + } + + priv->wut_source = (int)data; + if (priv->wut_source < 0 || priv->wut_source >= SOURCE_TYPE_MAX) { + _ERR("Invalid data"); + return; + } + + elm_object_text_set(obj, str_source_type_opt[priv->wut_source]); +} + +static void _channel_opt_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + struct _priv *priv = NULL; + + if (!obj) { + _ERR("Invalid parameter."); + return; + } + + priv = (struct _priv *)evas_object_data_get(obj, DATA_KEY_PRIV); + if (!priv) { + _ERR("Get priv data failed."); + return; + } + + priv->wut_channel = (int)data; +} + +static Eina_Bool _fill_layout(struct _priv *priv) +{ + Evas_Object *slider = NULL; + Evas_Object *dtime = NULL; + Evas_Object *setup = NULL; + Evas_Object *source = NULL; + Evas_Object *channel = NULL; + char wut_volume_str[VOLUME_STR_LEN] = {0,}; + + if (!priv) { + _ERR("Invalid parameter."); + return EINA_FALSE; + } + + /* Setup */ + setup = utils_add_hoversel(priv->base, PART_MAIN_ITEM_SETUP, + SETUP_TYPE_MAX, id_setup_type_opt, str_setup_type_opt, priv->wut_setup, + _setup_opt_changed_cb, priv); + if (!setup) { + _ERR("Add setup hoversel failed."); + return EINA_FALSE; + } + + /* Volume */ + slider = utils_add_slider(priv->base, PART_MAIN_ITEM_VOLUME_SLIDER, + priv->wut_volume, 0, VOLUME_MAX, 1); + if (!slider) { + _ERR("Add slider failed."); + return EINA_FALSE; + } + + snprintf(wut_volume_str, VOLUME_STR_LEN, "%d", priv->wut_volume); + elm_object_part_text_set(priv->base, PART_MAIN_ITEM_VOLUME_LABEL, wut_volume_str); + + /* Time */ + dtime = utils_add_datetime(priv->base, PART_MAIN_ITEM_TIME, EINA_FALSE, + EINA_FALSE, EINA_FALSE, EINA_TRUE, EINA_TRUE, EINA_TRUE, priv->wut_time); + if (!dtime) { + _ERR("Add datetime failed."); + return EINA_FALSE; + } + + /* Source */ + source = utils_add_hoversel(priv->base, PART_MAIN_ITEM_SOURCE, + SOURCE_TYPE_MAX, id_source_type_opt, str_source_type_opt, + priv->wut_source, _source_opt_changed_cb, priv); + if (!source) { + _ERR("Add source hoversel failed."); + return EINA_FALSE; + } + + /* Channel */ + channel = utils_add_flipselector(priv->base, PART_MAIN_ITEM_CHANNEL, + TMP_CHANNEL_MAX, id_tmp_channel, str_tmp_channel, priv->wut_channel, + _channel_opt_changed_cb, priv); + if (!channel) { + _ERR("Add channel flipselector failed."); + return EINA_FALSE; + } + + inputmgr_add_callback(setup, EO_TYPE_SETUP_HOVERSEL, &handler, priv); + inputmgr_add_callback(slider, EO_TYPE_VOLUME_SLIDER, &handler, priv); + inputmgr_add_callback(dtime, EO_TYPE_DATETIME, &handler, priv); + inputmgr_add_callback(source, EO_TYPE_SOURCE_HOVERSEL, &handler, priv); + + priv->setup_hs = setup; + priv->datetime = dtime; + priv->volume_slider = slider; + priv->source_hs = source; + priv->channel_fs = channel; + + return EINA_TRUE; +} + +static void _set_wakeup_timer_opts(struct _priv *priv) +{ + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + priv->wut_setup = settings_wakeup_timer_get_setup(); + priv->wut_source = settings_wakeup_timer_get_source(); + priv->wut_channel = settings_wakeup_timer_get_channel(); + priv->wut_volume = settings_wakeup_timer_get_volume(); + settings_wakeup_timer_get_time(priv->wut_time); +} + +static void _update_time_opt_wgt(struct _priv *priv) +{ + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + if (priv->datetime) + elm_datetime_value_set(priv->datetime, priv->wut_time); +} + +static void _update_volume_opt_wgt(struct _priv *priv) +{ + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + if (priv->volume_slider) { + char val_str[VOLUME_STR_LEN] = {0, }; + elm_slider_value_set(priv->volume_slider, priv->wut_volume); + + snprintf(val_str, VOLUME_STR_LEN, "%d", priv->wut_volume); + elm_object_part_text_set(priv->base, PART_MAIN_ITEM_VOLUME_LABEL, val_str); + } +} + +static void _update_setup_opt_wgt(struct _priv *priv) +{ + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + if (priv->setup_hs) { + elm_object_text_set(priv->setup_hs, str_setup_type_opt[priv->wut_setup]); + _disable_opts_controllers(priv, priv->wut_setup == SETUP_TYPE_OFF); + } +} + +static void _update_source_opt_wgt(struct _priv *priv) +{ + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + if (priv->source_hs) + elm_object_text_set(priv->source_hs, str_source_type_opt[priv->wut_source]); +} + +static void _update_channel_opt_wgt(struct _priv *priv) +{ + if (!priv) { + _ERR("Invalid parameter."); + return; + } + + if (priv->channel_fs) { + const Eina_List *items = elm_flipselector_items_get(priv->channel_fs); + if (!items) { + _ERR("Get channel fs items list failed."); + return; + } + + elm_flipselector_item_selected_set((Elm_Flipselector_Item *)eina_list_nth(items, priv->wut_channel), EINA_TRUE); + } +} -- 2.7.4