From: Abhishek Sansanwal Date: Wed, 10 May 2017 06:17:13 +0000 (+0530) Subject: Added fix to allow return to menu from scan list using return button X-Git-Tag: accepted/tizen/unified/20170512.023837~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3012278c1b4a971c1cae6801ec0a438eb2d0399;p=profile%2Ftv%2Fapps%2Fnative%2Fair_settings.git Added fix to allow return to menu from scan list using return button Description: On return button press when the wifi ap list is displayed, the user is returned to the network submenu. Signed-off-by: Abhishek Sansanwal Change-Id: I5dbdd9bd471930d50aef07ba63570a6a24cb893c --- diff --git a/src/layout/layout_network.c b/src/layout/layout_network.c index fb1d606..4089ca7 100644 --- a/src/layout/layout_network.c +++ b/src/layout/layout_network.c @@ -69,9 +69,12 @@ static void _remove_wifi_passcode_popup(struct _priv *priv); static void _retry_wired_network(struct _priv *priv); static bool _draw_wifi_passcode_popup(struct _priv *priv, char *wifi_name, bool isReconnect); -static void _focused1(void *data, int id); +static void _focused_menu(void *data, int id); static void _selected(void *data, int id); static char *_get_connected_ap(void *data, int id); +static void _selected_menu(void *data, int id); +void network_wireless_set_update_callbacks(void *data); +void network_wired_set_update_callbacks(void *data); struct _priv * current_priv = NULL; @@ -91,11 +94,9 @@ static struct menumgr_info menu_info[] = { .progress_value = NULL, .progress_evas = NULL, .selected = _selected, - .focused = _focused1, - //.selected_menu = _selected_menu, - .selected_menu = NULL, -// .update_cb = settings_picture_set_contrast_update_callbacks - .update_cb = NULL + .focused = _focused_menu, + .selected_menu = _selected_menu, + .update_cb = network_wireless_set_update_callbacks }, { .id = TYPE_WIRED, @@ -107,11 +108,9 @@ static struct menumgr_info menu_info[] = { .progress_value = NULL, .progress_evas = NULL, .selected = _selected, - .focused = _focused1, - //.selected_menu = _selected_menu, - .selected_menu = NULL, -// .update_cb = settings_picture_set_contrast_update_callbacks - .update_cb = NULL + .focused = _focused_menu, + .selected_menu = _selected_menu, + .update_cb = network_wired_set_update_callbacks } }; @@ -794,7 +793,7 @@ void _retry_wireless_network(struct _priv *priv) } // viewmgr_pop_all_views(); - if(!viewmgr_add_view(view_wireless_scanning_get_vclass(), NULL)) + if(!viewmgr_add_view(view_wireless_scanning_get_vclass(), priv)) _ERR("Add wireless view failed."); if (!viewmgr_show_view(VIEW_WIRELESS_SCANNING)) _ERR("Push wireless view failed."); @@ -999,7 +998,28 @@ static void _grid_selected_cb(int id, void *data, Evas_Object *obj, _wireless_selected_cb(priv->selected_wireless_item, data); } -static void _focused1(void *data, int id) +void network_wired_set_update_callbacks(void *data) +{ + /* + if (data) + //@TODO: set needed callbacks + else + //@TODO: unset previously set callbacks + */ +} +void network_wireless_set_update_callbacks(void *data) +{ + /* + if (data) + //@TODO: set needed callbacks + else + //@TODO: unset previously set callbacks + */ +} +static void _selected_menu(void *data, int id) +{ +} +static void _focused_menu(void *data, int id) { viewmgr_update_view(VIEW_BASE, UPDATE_SUB_ITEM_SELECTED, (void *)LAYOUT_NETWORK); } @@ -1141,7 +1161,7 @@ static void _data_event_cb(enum event_type type, void *data) priv->wireless_update_requested = false; /* Failed to initialize wireless */ //viewmgr_pop_all_views(); - viewmgr_add_view(view_wireless_get_vclass(), priv->wirelessmgr); + viewmgr_add_view(view_wireless_get_vclass(), priv); _DBG("Wireless is not activated"); if (!viewmgr_show_view(VIEW_WIRELESS)) _ERR("Push wireless view failed."); @@ -1158,10 +1178,20 @@ static void _data_event_cb(enum event_type type, void *data) priv->wireless_update_requested = false; /* Do not update if network menu is not wireless */ - if (priv->cur_type != TYPE_WIRELESS) + if (priv->cur_type != TYPE_WIRELESS) { return; - //viewmgr_pop_all_views(); - viewmgr_add_view(view_wireless_list_get_vclass(), priv); + } + + viewmgr_pop_view(); + if (!viewmgr_remove_view(VIEW_WIRELESS_SCANNING)) { + _ERR("Remove view failed"); + } + + if (!viewmgr_add_view(view_wireless_list_get_vclass(), priv)) { + _ERR("Add view failed"); + } + + /* Do not update if network menu is not wireless */ _DBG("Wireless is not activated"); if (!viewmgr_show_view(VIEW_WIRELESS_LIST)) _ERR("Push wireless view failed."); diff --git a/src/view/network/view_wireless.c b/src/view/network/view_wireless.c index 63b0fa8..188dd8e 100644 --- a/src/view/network/view_wireless.c +++ b/src/view/network/view_wireless.c @@ -24,17 +24,11 @@ #include "common/inputmgr.h" #include "common/utils.h" #include "layout/network.h" +#include "layout/layout_network.h" //#include "data/system/settings_language.h" #include "view/network/view_wireless.h" #define STR_WIRELESS "Wireless" -struct _priv { - Evas_Object *base; - struct datamgr *wirelessmgr; - //Evas_Object *btn1; - //Evas_Object *btn2; -}; - enum input_type { EO_NO = 0, EO_YES @@ -85,7 +79,6 @@ static input_handler handler = { return; } evas_object_del(priv->base); - free(priv); }*/ static Evas_Object *_create(Evas_Object *win, void *data) @@ -99,16 +92,11 @@ static Evas_Object *_create(Evas_Object *win, void *data) return NULL; } - priv = calloc(1, sizeof(struct _priv)); - if (!priv) { - _ERR("Calloc failed."); - return NULL; - } - priv->wirelessmgr = data; + priv = data; + priv->base = utils_add_popup(win, STYLE_POPUP, STR_WIRELESS, NULL); if (!priv->base) { _ERR("Add popup failed"); - free(priv); return NULL; } @@ -116,7 +104,6 @@ static Evas_Object *_create(Evas_Object *win, void *data) if (!ly) { _ERR("Add layout failed."); evas_object_del(priv->base); - free(priv); return NULL; } //elm_object_part_text_set(ly, PART_POPUP_TITLE, "NO network ?"); @@ -124,7 +111,6 @@ static Evas_Object *_create(Evas_Object *win, void *data) if (!_fill_popup_btns(priv, ly, LANG_TYPE_MAX, PART_POPUP_BUTTON_X, language_option, EO_BTN_LANG_ENG)) { evas_object_del(priv->base); - free(priv); return NULL; } */ @@ -164,7 +150,6 @@ static Evas_Object *_create(Evas_Object *win, void *data) if (!viewmgr_set_view_data(VIEW_WIRELESS, priv)) { _ERR("Set view data failed."); evas_object_del(priv->base); - free(priv); return NULL; } @@ -208,7 +193,6 @@ static void _destroy(void *data) evas_object_del(priv->base); - free(priv); } static view_class _vclass = { diff --git a/src/view/network/view_wireless_list.c b/src/view/network/view_wireless_list.c index a02bde2..dc40701 100644 --- a/src/view/network/view_wireless_list.c +++ b/src/view/network/view_wireless_list.c @@ -62,6 +62,33 @@ static void widget_min_set(Evas_Object *table, Evas_Object *obj, Evas_Coord w, E // return table; } +static void _destroy_list_type_popup(struct _priv *priv) +{ + evas_object_hide(priv->base); + evas_object_del(priv->base); + viewmgr_remove_view(VIEW_WIRELESS_LIST); + viewmgr_remove_view(VIEW_WIRELESS_SCANNING); + priv->base = NULL; + +} + +static void _popup_list_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + struct _priv *priv = (struct _priv *)data; + Evas_Event_Key_Down *ev = (Evas_Event_Key_Down*)event_info; + + if (!priv || !ev) { + _ERR("Invalid callback data !"); + return; + } + + if (!strcmp(ev->keyname, KEY_BACK) + || !strcmp(ev->keyname, KEY_ESC) || !strcmp(ev->keyname, KEY_ESC_WAY) + ) { + _destroy_list_type_popup(priv); + } +} + /*void _destroy_wireless_status_popup() { evas_object_hide(connected_wireless_popup); @@ -217,13 +244,14 @@ static Evas_Object *_create(Evas_Object *win, void *data) free(priv); return NULL; } + evas_object_event_callback_add(priv->base, EVAS_CALLBACK_KEY_DOWN, + _popup_list_key_down_cb, priv); list = datamgr_get_data(priv->wirelessmgr); if (!list) { //_draw_no_contents_message(priv); return NULL; } - _wireless_data_found_done(ly, list); table = elm_table_add(priv->base); @@ -273,7 +301,6 @@ static Evas_Object *_create(Evas_Object *win, void *data) if (!listmgr_update_grid(priv->listmgr, LIST_WIRELESS)) _ERR("Listmgr update list failed."); - _wireless_data_found_done(ly, list); // Elm_Object_Item *gg = elm_gengrid_last_item_get(grid); // if (!gg) return NULL; @@ -363,7 +390,6 @@ static void _destroy(void *data) evas_object_del(priv->base); - free(priv); } static view_class _vclass = { diff --git a/src/view/network/view_wireless_scanning.c b/src/view/network/view_wireless_scanning.c index 6f4acdd..7cf6526 100644 --- a/src/view/network/view_wireless_scanning.c +++ b/src/view/network/view_wireless_scanning.c @@ -29,6 +29,7 @@ #include "common/listmgr.h" #include "common/utils.h" #include "layout/network.h" +#include "layout/layout_network.h" #include "layout.h" //#include "data/system/settings_language.h" #include "view/network/view_wireless.h" @@ -38,20 +39,6 @@ #define MAX_WIRELESS_LEN 64 #define MIN_WIRELESS_LEN 8 -struct _priv { - Evas_Object *base; - struct listmgr *listmgr; - Evas_Object *passcode_popup; - Evas_Object *passcode_entry; - Evas_Object *popup_btn1; - Evas_Object *popup_btn2; - Elm_Object_Item *selected_wireless_item; - Elm_Object_Item *focused_wireless_item; - Elm_Object_Item *connecting_wireless_item; - - //Evas_Object *btn1; - //Evas_Object *btn2; -}; enum object_type { EO_BTN_OK = 0, @@ -86,7 +73,7 @@ enum input_type { -static void _wireless_data_found_done(struct _priv *priv, Eina_List *list) +static void _wireless_scanning_data_found_done(struct _priv *priv, Eina_List *list) { if (!listmgr_fill_grid(priv->listmgr, LIST_WIRELESS, list, NULL, NULL) || !listmgr_show_grid(priv->listmgr, LIST_WIRELESS, PART_WIRELESS_LIST, NULL)) { @@ -169,11 +156,8 @@ static Evas_Object *_create(Evas_Object *win, void *data) return NULL; } - priv = calloc(1, sizeof(struct _priv)); - if (!priv) { - _ERR("Calloc failed."); - return NULL; - } + priv = data; + struct wifi_manager_ap_info *ap_info; ap_info = malloc(sizeof(struct wifi_manager_ap_info)); memset(ap_info, '\0', sizeof(struct wifi_manager_ap_info)); @@ -186,7 +170,6 @@ static Evas_Object *_create(Evas_Object *win, void *data) priv->base = utils_add_popup(win, STYLE_POPUP, STR_WIRELESS, NULL); if (!priv->base) { _ERR("Add popup failed"); - free(priv); return NULL; } @@ -194,7 +177,6 @@ static Evas_Object *_create(Evas_Object *win, void *data) if (!ly) { _ERR("Add layout failed."); evas_object_del(priv->base); - free(priv); return NULL; } table = elm_table_add(priv->base); @@ -212,7 +194,6 @@ static Evas_Object *_create(Evas_Object *win, void *data) if (!table) { _ERR("Add layout failed."); evas_object_del(priv->base); - free(priv); return NULL; } priv->listmgr = listmgr_create(table); @@ -244,7 +225,7 @@ static Evas_Object *_create(Evas_Object *win, void *data) if (!listmgr_update_grid(priv->listmgr, LIST_WIRELESS)) _ERR("Listmgr update list failed."); - _wireless_data_found_done(priv, list); + _wireless_scanning_data_found_done(priv, list); // Elm_Object_Item *gg = elm_gengrid_last_item_get(grid); // if (!gg) return NULL; @@ -259,7 +240,6 @@ static Evas_Object *_create(Evas_Object *win, void *data) if (!viewmgr_set_view_data(VIEW_WIRELESS_SCANNING, priv)) { _ERR("Set view data failed."); evas_object_del(priv->base); - free(priv); return NULL; } @@ -302,7 +282,6 @@ static void _destroy(void *data) evas_object_del(priv->base); - free(priv); } static view_class _vclass = {