2 * Copyright (c) 2009 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <Elementary.h>
22 #include <ui-gadget-module.h>
23 #include <package_manager.h>
24 #include "do-not-disturb-efl.h"
25 #include "pkgmgr-setting-info.h"
26 #include "excepted-apps-efl.h"
27 #include "common-efl.h"
32 ug_data *g_ug_data = NULL;
34 static Evas_Object* _create_do_not_disturb_gl(ug_data *ugd);
35 static void _append_item_in_list(Evas_Object* genlist);
37 ug_data* get_ug_data(_)
42 static void _do_not_disturb_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
45 char *appid = (char*)data;
47 Eina_Bool state = elm_check_state_get(obj);
48 set_do_not_disturb(state);
49 NOTISET_DBG("do_not_disturb check value = %s", state==false ? "FALSE":"TRUE");
53 static Eina_Bool _notifiacation_setting_main_pop_cb(void *data, Elm_Object_Item * it)
56 ug_data *ugd = (ug_data *) data;
57 retv_if(!ugd, EINA_FALSE);
59 ug_destroy_me(ugd->ug);
64 void do_not_disturb_append_item_in_list(Evas_Object* genlist)
66 append_gl_start_option(genlist, "multiline", "do-not-disturb");
68 append_gl_group_index(genlist, APP_STRING("IDS_ST_HEADER_EXCLUDED_APPS_ABB"));
70 append_gl_item_list(genlist, get_excepted_apps_list(), ITEM_STYLE_ONE_ICON);
73 static Evas_Object* _create_do_not_disturb_gl(ug_data *ugd)
75 Evas_Object *parent = ugd->naviframe;
78 genlist = elm_genlist_add(parent);
79 elm_genlist_mode_set(genlist, ELM_LIST_SCROLL);
80 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
81 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
82 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
83 elm_genlist_block_count_set(genlist, 8);
85 /* Add Smart Callback */
86 evas_object_smart_callback_add(genlist, "realized", gl_realized_cb, NULL);
87 evas_object_smart_callback_add(genlist, "loaded", gl_loaded_cb, NULL);
88 evas_object_smart_callback_add(genlist, "longpressed", gl_longpressed_cb, NULL);
89 evas_object_smart_callback_add(genlist, "contracted", gl_contracted_cb, NULL);
91 do_not_disturb_append_item_in_list(genlist);
96 static void _create_main_view(void *data)
99 ug_data *ugd = (ug_data *) data;
103 g_ug_data->list_main = _create_do_not_disturb_gl(ugd);
106 Evas_Object *back_btn = elm_button_add(ugd->naviframe);
107 elm_object_style_set(back_btn, "naviframe/back_btn/default");
108 evas_object_smart_callback_add(back_btn, "clicked", back_button_cb, ugd->naviframe);
110 /* Push to naviframe */
111 g_ug_data->navi_item = elm_naviframe_item_push(ugd->naviframe, APP_STRING("IDS_ST_HEADER_DO_NOT_DISTURB_ABB"), back_btn, NULL, g_ug_data->list_main, NULL);
112 elm_naviframe_item_pop_cb_set(g_ug_data->navi_item, _notifiacation_setting_main_pop_cb, ugd);
115 Evas_Object *bottom_box = elm_box_add(ugd->naviframe);
116 evas_object_size_hint_weight_set(bottom_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
117 evas_object_size_hint_align_set(bottom_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
118 elm_box_horizontal_set(bottom_box, EINA_TRUE);
119 evas_object_show(bottom_box);
121 Evas_Object *bottom_button = elm_button_add(bottom_box);
122 evas_object_show(bottom_button);
123 elm_object_style_set(bottom_button, "bottom");
124 evas_object_size_hint_weight_set(bottom_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
125 evas_object_size_hint_align_set(bottom_button, EVAS_HINT_FILL, 0.5);
126 elm_object_translatable_text_set(bottom_button, APP_STRING("IDS_ST_BUTTON_MANAGE_EXCLUDED_APPS_ABB"));
127 evas_object_smart_callback_add(bottom_button, "clicked", exception_application_clicked_cb, g_ug_data);
128 elm_object_item_part_content_set(g_ug_data->navi_item, "toolbar", bottom_box);
129 elm_box_pack_start(bottom_box, bottom_button);
133 static Evas_Object *_create_fullview(Evas_Object *parent, ug_data *ugd)
138 /* Create Full view */
139 ugd->layout = create_layout(parent);
140 elm_layout_theme_set(ugd->layout, "layout", "application", "default");
141 elm_win_indicator_mode_set(parent, ELM_WIN_INDICATOR_SHOW);
143 /* Create background */
144 create_background(ugd->layout);
146 /* Create navigation bar */
147 ugd->naviframe = create_naviframe(ugd->layout);
149 /* Create main view */
150 _create_main_view(ugd);
155 static void *on_create(ui_gadget_h ug, enum ug_mode mode, app_control_h service, void *priv)
166 parent = ug_get_parent_layout(ug);
173 create_do_not_disturb_application_list();
174 ugd->layout = _create_fullview(parent, ugd);
179 static void on_start(ui_gadget_h ug, app_control_h service, void *priv)
185 static void on_pause(ui_gadget_h ug, app_control_h service, void *priv)
191 static void on_resume(ui_gadget_h ug, app_control_h service, void *priv)
197 static void on_destroy(ui_gadget_h ug, app_control_h service, void *priv)
203 remove_excepted_apps_list();
205 EVAS_OBJECT_DELIF(ugd->cancel_button);
206 EVAS_OBJECT_DELIF(ugd->done_button);
207 EVAS_OBJECT_DELIF(ugd->list_sub);
208 EVAS_OBJECT_DELIF(ugd->list_main);
209 EVAS_OBJECT_DELIF(ugd->naviframe);
210 EVAS_OBJECT_DELIF(ugd->layout);
213 static void on_message(ui_gadget_h ug, app_control_h msg, app_control_h service, void *priv)
218 static void on_event(ui_gadget_h ug, enum ug_event event, app_control_h service, void *priv)
221 case UG_EVENT_LOW_MEMORY:
223 case UG_EVENT_LOW_BATTERY:
225 case UG_EVENT_LANG_CHANGE:
227 case UG_EVENT_REGION_CHANGE:
229 case UG_EVENT_ROTATE_PORTRAIT:
231 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
233 case UG_EVENT_ROTATE_LANDSCAPE:
235 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
242 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, app_control_h service, void *priv)
245 case UG_KEY_EVENT_NONE:
247 case UG_KEY_EVENT_END:
249 * @TODO: Terminate UG itself?
257 int UG_MODULE_INIT(struct ug_module_ops *ops)
265 ugd = calloc(1, sizeof(ug_data));
271 ops->create = on_create;
272 ops->start = on_start;
273 ops->pause = on_pause;
274 ops->resume = on_resume;
275 ops->destroy = on_destroy;
276 ops->message = on_message;
277 ops->event = on_event;
278 ops->key_event = on_key_event;
280 ops->opt = UG_OPT_INDICATOR_ENABLE;
282 if (bindtextdomain(PKGNAME, "/usr/apps/ug-setting-notification-efl/res/locale") == NULL) {
283 /* Failed to allocate memory for allocating heap for store the path of LOCALE directory */
289 void UG_MODULE_EXIT(struct ug_module_ops *ops)