#include "app-details.h"
#include <badge.h>
#include <badge_internal.h>
+#include <notification_setting_internal.h>
+
+#define AMOUNT_OF_CONTENT_ITEMS 3
typedef enum
{
item_info_s *g_app_info = NULL;
Evas_Object *g_app_notification_genlist = NULL;
+static char *items[AMOUNT_OF_CONTENT_ITEMS] = {
+ "IDS_QP_OPT_SHOW_ALL_CONTENT_ABB",
+ "IDS_QP_OPT_HIDE_SENSITIVE_CONTENT_ABB",
+ "IDS_QP_OPT_DONT_SHOW_NOTIFICATIONS_ABB"
+};
+
static void close_app_details_cb(void *data, Evas_Object *obj, void *event_info)
{
NOTISET_TRACE_BEGIN;
static Eina_Bool popup_noti_status_get()
{
- /*TODO: implement when API appears */
- return EINA_TRUE;
+ NOTISET_TRACE_BEGIN;
+
+ bool state = false;
+ notification_setting_h setting = NULL;
+
+ int err = notification_setting_get_setting_by_package_name(g_app_info->appid, &setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ {
+ NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
+ }
+ else if(setting == NULL)
+ {
+ NOTISET_ERR("Notification setting is NULL\n");
+ }
+ else
+ {
+ notification_setting_get_pop_up_notification(setting, &state);
+ NOTISET_DBG("notification_setting_get_pop_up_notification [%d]\n", state);
+ }
+
+ if(setting)
+ notification_setting_free_notification(setting);
+
+ return state;
}
static void popup_noti_status_set(Eina_Bool value)
{
- /*TODO: implement when API appears */
+ NOTISET_TRACE_BEGIN;
+ notification_setting_h setting = NULL;
+
+ int err = notification_setting_get_setting_by_package_name(g_app_info->appid, &setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ {
+ NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
+ }
+ else if(setting == NULL)
+ {
+ NOTISET_ERR("Notification setting is NULL\n");
+ }
+ else
+ {
+ notification_setting_set_pop_up_notification(setting, value);
+ NOTISET_DBG("notification_setting_set_pop_up_notification [%d]\n", value);
+
+ err = notification_setting_update_setting(setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ NOTISET_ERR("notification_setting_update_setting err[%d]\n", err);
+ }
+
+ if(setting)
+ notification_setting_free_notification(setting);
}
static void popup_noti_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
popup_noti_status_set(state);
}
+static Eina_Bool app_pop_up_notification_exists_get()
+{
+ /* implement when API will be available */
+ return EINA_TRUE;
+}
+
static Eina_Bool app_badge_exists_get()
{
bool value = EINA_FALSE;
app_badge_status_set(state);
}
-static const char *noti_on_lock_screen_status_get()
+static int noti_on_lock_screen_status_get()
{
- /*TODO: implement when API appears */
- return "IDS_QP_OPT_SHOW_ALL_CONTENT_ABB";
+ NOTISET_TRACE_BEGIN;
+
+ lock_screen_content_level_e level = SHOW_ALL_CONTENT;
+ notification_setting_h setting = NULL;
+
+ int err = notification_setting_get_setting_by_package_name(g_app_info->appid, &setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ {
+ NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
+ }
+ else if(setting == NULL)
+ {
+ NOTISET_ERR("Notification setting is NULL\n");
+ }
+ else
+ {
+ notification_setting_get_lock_screen_content(setting, &level);
+ NOTISET_DBG("notification_setting_get_lock_screen_content [%d]\n", level);
+ }
+
+ if(setting)
+ notification_setting_free_notification(setting);
+
+ return level;
}
static char *app_details_gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
}
else if(!strcmp(part, "elm.text.sub"))
{
- return strdup(APP_STRING(noti_on_lock_screen_status_get()));
+ int level = noti_on_lock_screen_status_get();
+ if(level == SHOW_ALL_CONTENT)
+ return strdup(APP_STRING("IDS_QP_OPT_SHOW_ALL_CONTENT_ABB"));
+ else if(level == HIDE_SENSITIVE_CONTENT)
+ return strdup(APP_STRING("IDS_QP_OPT_HIDE_SENSITIVE_CONTENT_ABB"));
+ else if(level == DO_NOT_SHOW_NOTIFICATIONS)
+ return strdup(APP_STRING("IDS_QP_OPT_DONT_SHOW_NOTIFICATIONS_ABB"));
}
break;
default:
{
}
+static void popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ evas_object_del(obj);
+}
+
+static char *gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ if(!strcmp(part, "elm.text"))
+ {
+ int index = (int)data;
+ return strdup(APP_STRING(items[index]));
+ }
+ return NULL;
+}
+
+static Evas_Object *gl_content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ if(!strcmp(part, "elm.swallow.end"))
+ {
+ int index = (int)data;
+ Evas_Object *radio = NULL;
+ Evas_Object *radio_main = evas_object_data_get(obj, "radio");
+ radio = elm_radio_add(obj);
+ elm_radio_group_add(radio, radio_main);
+ elm_radio_state_value_set(radio, index);
+ evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ return radio;
+ }
+
+ return NULL;
+}
+
+static void gl_radio_sel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ NOTISET_TRACE_BEGIN;
+
+ notification_setting_h setting = NULL;
+ lock_screen_content_level_e level = SHOW_ALL_CONTENT;
+ Elm_Object_Item *it = event_info;
+
+ Evas_Object *radio = NULL;
+
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+ radio = elm_object_item_part_content_get(it, "elm.swallow.end");
+ int index = (int)elm_object_item_data_get(it);
+ elm_radio_value_set(radio, index);
+
+ int err = notification_setting_get_setting_by_package_name(g_app_info->appid, &setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ {
+ NOTISET_ERR("notification_setting_get_setting_by_package_name [%d]\n", err);
+ }
+ else if(setting == NULL)
+ {
+ NOTISET_ERR("Notification setting is NULL\n");
+ }
+ else
+ {
+ switch (index)
+ {
+ case 0:
+ level = SHOW_ALL_CONTENT;
+ break;
+ case 1:
+ level = HIDE_SENSITIVE_CONTENT;
+ break;
+ case 2:
+ level = DO_NOT_SHOW_NOTIFICATIONS;
+ break;
+ default:
+ NOTISET_ERR("Incorrect index");
+ break;
+ }
+
+ notification_setting_set_lock_screen_content(setting, level);
+ NOTISET_DBG("notification_setting_set_lock_screen_content [%d]\n", level);
+
+ err = notification_setting_update_setting(setting);
+ if(err != NOTIFICATION_ERROR_NONE)
+ NOTISET_ERR("notification_setting_update_setting err[%d]\n", err);
+ }
+
+ if(setting)
+ notification_setting_free_notification(setting);
+
+ elm_genlist_item_update(elm_genlist_last_item_get(get_app_ui_data()->list_sub));
+ evas_object_del(data);
+}
+
+static void show_noti_on_lock_popup()
+{
+ NOTISET_TRACE_BEGIN;
+ static Elm_Genlist_Item_Class itc;
+ Evas_Object *popup = NULL;
+ Evas_Object *genlist = NULL;
+ ug_data *ug_main = get_app_ui_data();
+ ret_if(ug_main == NULL);
+
+ popup = elm_popup_add(ug_main->win);
+ elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
+ elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+ elm_object_part_text_set(popup, "title,text", APP_STRING("IDS_QP_TMBODY_NOTIFICATIONS_ON_LOCK_SCREEN"));
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, popup_hide_cb, NULL);
+ evas_object_smart_callback_add(popup, "dismissed", popup_hide_cb, NULL);
+ evas_object_smart_callback_add(popup, "block,clicked", popup_hide_cb, NULL);
+
+ /* genlist */
+ genlist = elm_genlist_add(popup);
+ elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
+ elm_object_content_set(popup, genlist);
+
+ Evas_Object *radio = elm_radio_add(genlist);
+ evas_object_data_set(genlist, "radio", radio);
+
+ itc.item_style = "type1";
+ itc.func.text_get = gl_text_get_cb;
+ itc.func.content_get = gl_content_get_cb;
+ itc.func.state_get = NULL;
+ itc.func.del = NULL;
+
+ for (int i = 0; i < AMOUNT_OF_CONTENT_ITEMS; i++)
+ {
+ elm_genlist_item_append(genlist, &itc, (void *)i, NULL, ELM_GENLIST_ITEM_NONE, gl_radio_sel_cb, popup);
+ }
+
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_genlist_mode_set(genlist, ELM_LIST_EXPAND);
+ evas_object_show(genlist);
+
+ int index = noti_on_lock_screen_status_get();
+ elm_radio_value_set(radio, index);
+
+ evas_object_show(popup);
+}
+
static void app_details_gl_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
+ App_Details_Items detail = (App_Details_Items)data;
+
Elm_Object_Item *it = (Elm_Object_Item*)event_info;
elm_genlist_item_selected_set(it, EINA_FALSE);
+ if(detail == APP_DETAILS_NOTI_ON_LOCK)
+ {
+ show_noti_on_lock_popup();
+ return;
+ }
+
Evas_Object *check = elm_object_item_part_content_get(it, "elm.swallow.end");
- if (check) {
+ if(check)
+ {
elm_check_state_set(check, !elm_check_state_get(check));
evas_object_smart_callback_call(check, "changed", NULL);
}
itc->func.del = app_details_gl_del_cb;
gen_item = elm_genlist_item_append(genlist, /* genlist object */
- itc, /* item class */
+ itc, /* item class */
(void *)item_name, /* item class user data */
- NULL, /* parent item */
- ELM_GENLIST_ITEM_NONE, /* item type */
- app_details_gl_selected_cb, /* select smart callback */
+ NULL, /* parent item */
+ ELM_GENLIST_ITEM_NONE, /* item type */
+ app_details_gl_selected_cb, /* select smart callback */
(void *)item_name); /* smart callback user data */
if(style && !strcmp(style, "group_index"))
elm_genlist_item_select_mode_set(gen_item, ELM_OBJECT_SELECT_MODE_NONE);
app_details_gl_append(genlist, "type1", APP_DETAILS_ALLOW_NOTI);
app_details_gl_append(genlist, "group_index", APP_DETAILS_GROUP_INDEX);
- /* TODO: Show this items only if API allows [ */
- app_details_gl_append(genlist, "multiline", APP_DETAILS_POPUP_NOTI);
- if (app_badge_exists_get())
+ if(app_pop_up_notification_exists_get())
+ app_details_gl_append(genlist, "multiline", APP_DETAILS_POPUP_NOTI);
+ if(app_badge_exists_get())
app_details_gl_append(genlist, "type1", APP_DETAILS_APP_BADGE);
- /* ] */
app_details_gl_append(genlist, "type1", APP_DETAILS_NOTI_ON_LOCK);
Elm_Object_Item *navi_item = elm_naviframe_item_push(data->naviframe, g_app_info->name, back_btn, NULL, genlist, NULL);
elm_naviframe_item_pop_cb_set(navi_item, app_details_pop_cb, NULL);
+
+ data->list_sub = genlist;
}
Evas_Object *create_app_notification_gl(ug_data *ugd)