[SM][Mob]Few minor fixes 2 91/159691/5
authorPawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
Fri, 10 Nov 2017 14:45:31 +0000 (15:45 +0100)
committerPawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
Mon, 13 Nov 2017 16:14:16 +0000 (17:14 +0100)
*When you click Cancel in popup with cycle interval cycle information isn't stored
*Initial value of cycle interval is 1
*Every entry is singleline, has numeric keyboard and can take 9 chars
*Click editfield clear button doesn't take away focus from entry
*Sunday is first day of week now

Change-Id: I42b982e264d4fefd18680b96fcda79b1cc5a3a05
Signed-off-by: Pawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
setting-smartmanager/smartmanager-data/src/smartmanager-data-usage-mobile-settings.c
setting-smartmanager/smartmanager-data/src/smartmanager-data.c
setting-smartmanager/smartmanager-data/src/smartmanager-utils.c

index 950c4387db5aac3ef4867f482c47dca9d8f927f3..ccd419f4c95642cfb3ba3133f1ea73121e22c663 100755 (executable)
@@ -80,13 +80,13 @@ static char *elements_cycle_initial_values[] = {
 };
 
 static char *elements_cycle_day_of_week[] = {
+               "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday",
                "Thursday",
                "Friday",
-               "Saturday",
-               "Sunday"
+               "Saturday"
 };
 
 static Evas_Smart_Cb create_start_popup_functions[] = {
@@ -141,11 +141,6 @@ static Elm_Genlist_Item_Class itc_start_weekday_list = {
                .func.del = _genlist_radio_del
 };
 
-static Elm_Entry_Filter_Accept_Set accept_set = {
-               .accepted = "0123456789.",
-               .rejected = NULL
-};
-
 static Elm_Entry_Filter_Limit_Size limit_size = {
                .max_char_count = 9
 };
@@ -204,8 +199,8 @@ static Evas_Object *_create_generic_popup_button(Evas_Object *parent,
        return btn;
 }
 
-static Evas_Object *create_editfield_clear_popup_button(Evas_Object *parent, char *part,
-       char *title, float weight_x, float weight_y, Evas_Smart_Cb cb,
+static Evas_Object *create_editfield_clear_popup_button(Evas_Object *parent,
+       char *part, char *title, float weight_x, float weight_y, Evas_Smart_Cb cb,
        void *callback_data)
 {
        return _create_generic_popup_button(parent, part, title,
@@ -360,21 +355,19 @@ static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
 static void _clean_entry_cb(void *data, Evas_Object *obj, void *event_info)
 {
        Evas_Object *entry = (Evas_Object *)data;
-       ret_if(!entry);
        elm_object_text_set(entry, "");
+       elm_object_focus_set(entry, EINA_TRUE);
 }
 
 static Evas_Object *_create_entry(Evas_Object *parent)
 {
        Evas_Object *entry = elm_entry_add(parent);
-       retv_if(!entry, NULL);
+       elm_entry_single_line_set(entry, EINA_TRUE);
 
-       elm_entry_markup_filter_append(entry, elm_entry_filter_accept_set,
-               &accept_set);
        elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size,
                &limit_size);
-
-       elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NUMBER);
+       elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY);
+       elm_entry_input_panel_show(entry);
 
        evas_object_size_hint_weight_set(entry, 0.73, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -476,8 +469,13 @@ static void _custom_cycle_popup_ok_cb(void *data, Evas_Object *obj,
                        elm_object_text_set(popup_info.content, "90");
                }
                if (value >= 1 && value <= 90) {
+                       smd->selected_sim_limits->cycle_mode = CYCLE_MODE_CUSTOM;
+                       smd->selected_sim_limits->cycle_start = 1;
                        smd->selected_sim_limits->custom_mode_interval = value;
+                       elm_radio_value_set(cycle_mode_radio_group,
+                               smd->selected_sim_limits->cycle_mode);
                        write_cycle_info(smd);
+                       generate_list(mobile_genlist, smd);
                        evas_object_del(popup_info.popup);
                        elm_genlist_realized_items_update(mobile_genlist);
                }
@@ -609,7 +607,8 @@ static void _warning_popup_done_cb(void *data, Evas_Object *obj,
                                evas_object_del(popup_info.popup);
                        } else {
                                create_toast_popup(popup_info.popup,
-                                       _("Maximum value allowed is 100GB. Value changed to 100GB"));
+                                       _("Maximum value allowed is 100GB.\
+                                               Value changed to 100GB"));
                                smd->selected_sim_limits->warning = MAX_LIMIT_IN_BYTES;
                                _entry_set_displayed_value(popup_info.content,
                                        popup_info.unit_btn, smd->selected_sim_limits->warning);
@@ -762,30 +761,35 @@ static void _genlist_radio_del(void *data, Evas_Object *obj)
        free(item_data);
 }
 
-static void _radio_cycle_list_item_selected_cb(void *data, Evas_Object *obj,
-       void *event_info)
+static void _handle_radio_cycle_item(Radio_List_Item_T *item_data)
 {
-       Radio_List_Item_T *item_data = (Radio_List_Item_T *)data;
-
-       if (item_data->smd->selected_sim_limits->cycle_mode !=
-                       item_data->radio_value) {
-               item_data->smd->selected_sim_limits->cycle_mode =
-                       item_data->radio_value;
-               item_data->smd->selected_sim_limits->cycle_start = 1;
-               elm_radio_value_set(cycle_mode_radio_group,
-                       item_data->smd->selected_sim_limits->cycle_mode);
-               generate_list(mobile_genlist, item_data->smd);
-       }
-
-       if (item_data->smd->selected_sim_limits->cycle_mode == CYCLE_MODE_CUSTOM)
+       if (item_data->radio_value != CYCLE_MODE_CUSTOM) {
+               if (item_data->smd->selected_sim_limits->cycle_mode !=
+                               item_data->radio_value) {
+                       item_data->smd->selected_sim_limits->cycle_mode =
+                                       item_data->radio_value;
+                       item_data->smd->selected_sim_limits->cycle_start = 1;
+                       item_data->smd->selected_sim_limits->custom_mode_interval = 1;
+                       elm_radio_value_set(cycle_mode_radio_group,
+                                       item_data->smd->selected_sim_limits->cycle_mode);
+                       generate_list(mobile_genlist, item_data->smd);
+                       write_cycle_info(item_data->smd);
+               }
+       } else {
                _create_custom_cycle_popup(item_data->smd, _("Set data usage cycle"),
-                       item_data->smd->selected_sim_limits->custom_mode_interval);
+                               item_data->smd->selected_sim_limits->custom_mode_interval);
+       }
 
-       write_cycle_info(item_data->smd);
        evas_object_del(item_data->popup);
        elm_genlist_realized_items_update(mobile_genlist);
 }
 
+static void _radio_cycle_list_item_selected_cb(void *data, Evas_Object *obj,
+       void *event_info)
+{
+       _handle_radio_cycle_item((Radio_List_Item_T *)data);
+}
+
 static Elm_Widget_Item *_append_item_to_radio_list(SmartMgrData *smd,
                Evas_Object *popup, Evas_Object *genlist, Elm_Gen_Item_Class *itc,
                const char *text, int radio_value, bool is_first,
@@ -814,27 +818,7 @@ static Elm_Widget_Item *_append_item_to_radio_list(SmartMgrData *smd,
 static void _radio_cycle_selected_cb(void *data, Evas_Object *obj,
        void *event_info)
 {
-       Radio_List_Item_T *item_data = (Radio_List_Item_T *)data;
-
-       if (item_data->smd->selected_sim_limits->cycle_mode !=
-                       item_data->radio_value) {
-               item_data->smd->selected_sim_limits->cycle_mode =
-                               item_data->radio_value;
-               item_data->smd->selected_sim_limits->cycle_start = 1;
-               elm_radio_value_set(cycle_mode_radio_group,
-                               item_data->smd->selected_sim_limits->cycle_mode);
-               generate_list(mobile_genlist, item_data->smd);
-       }
-
-       if (item_data->smd->selected_sim_limits->cycle_mode == CYCLE_MODE_CUSTOM)
-               _create_custom_cycle_popup(item_data->smd, _("Set data usage cycle"),
-                               item_data->smd->selected_sim_limits->custom_mode_interval);
-
-
-
-       write_cycle_info(item_data->smd);
-       evas_object_del(item_data->popup);
-       elm_genlist_realized_items_update(mobile_genlist);
+       _handle_radio_cycle_item((Radio_List_Item_T *)data);
 }
 
 static Evas_Object *_genlist_cycle_radio_content_get(void *data,
@@ -1042,8 +1026,8 @@ static int _create(void *data)
        mobile_genlist = elm_genlist_add(smd->md.naviframe);
        generate_list(mobile_genlist, smd);
 
-       nf_it = elm_naviframe_item_push(smd->md.naviframe, _("Data usage settings"),
-               back_btn, NULL, mobile_genlist, NULL);
+       nf_it = elm_naviframe_item_push(smd->md.naviframe,
+               _("Data usage settings"), back_btn, NULL, mobile_genlist, NULL);
        elm_naviframe_item_style_set(nf_it, "tabbar");
        elm_naviframe_item_pop_cb_set(nf_it, _pop_view_cb, smd);
 
index 27e2cc2b4b5d9f71947a4948d5f7afe4b2c3935d..3a3c2904d08ca5de7fdc5424d784e89652c0545d 100755 (executable)
@@ -719,7 +719,7 @@ static stc_callback_ret_e _get_restrictions_cb(stc_error_e result,
 
 static void _initialize_cycle(Data_Limits_T *limits)
 {
-       limits->custom_mode_interval = 0;
+       limits->custom_mode_interval = 1;
        limits->cycle_mode = CYCLE_MODE_MONTHLY;
        limits->cycle_start = 1;
 }
index 768040f6156efb506c89064a7a368f61d9c361c0..18895c3f7ac9ef6ad543e6277a39575ddf6ab89a 100755 (executable)
@@ -36,7 +36,8 @@ int get_days_in_current_month()
        return now_tm.tm_mday;
 }
 
-void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out, int len_max)
+void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out,
+       int len_max)
 {
        float amount = 0.0;
 
@@ -137,7 +138,8 @@ void create_number_with_postfix(int number, char *output, int max_len)
        if (temp < 4) {
                snprintf(output, max_len, "%d%s", number, number_postfixes[temp]);
        } else {
-               snprintf(output, max_len, "%d%s", number, number_postfixes[TH_POSTFIX_IDX]);
+               snprintf(output, max_len, "%d%s", number,
+                       number_postfixes[TH_POSTFIX_IDX]);
        }
 }
 
@@ -206,7 +208,8 @@ static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
                return true;
        }
 
-       SETTING_TRACE_DEBUG("\033[1;33mObtaining per app data usage for ifce: %d", iface);
+       SETTING_TRACE_DEBUG("\033[1;33mObtaining per app data usage for ifce: %d",
+               iface);
        ret = stc_foreach_stats(stc, rule, stats_cb, cb_data);
        if (ret != STC_ERROR_NONE) {
                SETTING_TRACE_ERROR("stc_get_stats() error: %s",
@@ -251,7 +254,8 @@ static bool _get_total_stats(stc_h stc, stc_iface_type_e iface_type,
                return true;
        }
 
-       SETTING_TRACE_DEBUG("\033[1;34mObtaining total stats for ifce: %d", iface_type);
+       SETTING_TRACE_DEBUG("\033[1;34mObtaining total stats for ifce: %d",
+               iface_type);
        ret = stc_get_total_stats(stc, rule, stats_cb, cb_data);
        if (ret != STC_ERROR_NONE) {
                SETTING_TRACE_ERROR("stc_get_total_stats() error: %s",
@@ -301,7 +305,8 @@ static bool _get_restrictions(stc_h stc, stc_iface_type_e iface_type,
                return true;
        }
 
-       SETTING_TRACE_DEBUG("\033[1;35mObtaining restrictions for ifce: %d", iface_type);
+       SETTING_TRACE_DEBUG("\033[1;35mObtaining restrictions for ifce: %d",
+               iface_type);
        ret = stc_foreach_restriction(stc, rule, restrictions_cb,
                                                                        restriction_info_cb_data);
        if (STC_ERROR_NONE != ret) {
@@ -382,8 +387,9 @@ restrictions_result set_mobile_restriction_rule_parameters(
        ret = stc_restriction_rule_set_warning_limit(rule, warning_limit);
        if (STC_ERROR_NONE != ret) {
                (void)stc_restriction_rule_destroy(rule);
-               SETTING_TRACE_ERROR("stc_restriction_rule_set_warning_limit() error: %s",
-                                                                                       get_error_message(ret));
+               SETTING_TRACE_ERROR(
+                       "stc_restriction_rule_set_warning_limit() error: %s",
+                       get_error_message(ret));
                return RESTRICTIONS_ERROR;
        }
 
@@ -427,10 +433,12 @@ restrictions_result set_mobile_limit_restrictions(stc_h stc_handle,
        return RESTRICTIONS_OK;
 }
 
-bool unset_mobile_limit_restrictions(stc_h stc_handle, stc_restriction_info_cb _get_and_unset_limit_restrictions_cb, void *data)
+bool unset_mobile_limit_restrictions(stc_h stc_handle,
+       stc_restriction_info_cb _get_and_unset_limit_restrictions_cb, void *data)
 {
        SETTING_TRACE_BEGIN;
-       return _get_restrictions(stc_handle, STC_IFACE_DATACALL, _get_and_unset_limit_restrictions_cb, data);
+       return _get_restrictions(stc_handle, STC_IFACE_DATACALL,
+               _get_and_unset_limit_restrictions_cb, data);
        SETTING_TRACE_END;
 }