[SM][Mob]Info genlist element texts fixed 30/157630/6
authorPawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
Wed, 25 Oct 2017 11:11:05 +0000 (13:11 +0200)
committerPawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
Mon, 30 Oct 2017 12:42:02 +0000 (13:42 +0100)
Change-Id: I5131b191429491d17080d85a8f1e8501e4bf5068
Signed-off-by: Pawel Aksiutowicz <p.aksiutowic@partner.samsung.com>
setting-smartmanager/smartmanager-data/include/smartmanager-utils.h
setting-smartmanager/smartmanager-data/src/smartmanager-data-usage-mobile-settings.c
setting-smartmanager/smartmanager-data/src/smartmanager-utils.c

index 842ae2953709a5682e51a9c62a2ad7068aeb0b8b..28fa68b9f35c0f247a19e00ad3e7ff85d07c1321 100644 (file)
@@ -38,6 +38,18 @@ typedef enum {
 void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out,
                                                int len_max);
 
+/**
+ * @brief Formats string composed of number and ordinal number postfix
+ *
+ * @param[in] number           Number to format with postfix
+ * @param[in] output           Formatted string composed of number and postfix
+ * @param[in] max_len          Max len of formatted string
+ *
+ * @return
+ */
+
+void create_number_with_postfix(int number, char *output, int max_len);
+
 /**
  * @brief Gets total statistics for SIM type interface
  *
@@ -51,6 +63,7 @@ void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out,
  * @return true on success, otherwise false
  *
  */
+
 bool get_sim_total_stats(stc_h stc, stc_stats_info_cb stats_cb,
                                                const char *subscriber_id, time_t t_from, time_t t_to);
 
index 1e68b5793a607cbb0e6f56f8e2b83cf4c44285ec..673bef0b29b68e414188fd25086c5a7fbf22ada2 100755 (executable)
@@ -68,13 +68,6 @@ typedef struct {
        Data_Unit_Type_E unit;
 } Popup_Info;
 
-static char *elements_info_initial_values[] = {
-               "The data usage info will be reset on the 1st day of every month.",
-               "The data usage info will be reset every %s.",
-               "The data usage info will be reset at midnight every day.",
-               "The data usage info will be reset on the 1st day of every month.",
-};
-
 static char *elements_cycle_initial_values[] = {
                "Monthly",
                "Weekly",
@@ -99,7 +92,7 @@ static Evas_Smart_Cb create_start_popup_functions[] = {
                create_custom_start_date_popup
 };
 
-static Popup_Info popup_info = {0,};
+static Popup_Info popup_info = {0};
 
 static Evas_Object *mobile_genlist = NULL;
 static Evas_Object *cycle_mode_radio_group = NULL;
@@ -1038,7 +1031,9 @@ static char *_cycle_item_label_get(void *data, Evas_Object *obj, const char *par
 
        if (!strcmp(part, "elm.text")) {
                if (smd->selected_sim_limits->custom_mode_interval && smd->selected_sim_limits->cycle_mode == CYCLE_MODE_CUSTOM) {
-                       snprintf(buf, sizeof(buf), "%d Days", smd->selected_sim_limits->custom_mode_interval);
+                       snprintf(buf, sizeof(buf), "%d %s",
+                                       smd->selected_sim_limits->custom_mode_interval,
+                                       smd->selected_sim_limits->custom_mode_interval == 1 ? _("Day") : _("Days"));
                } else {
                        snprintf(buf, sizeof(buf), "%s", elements_cycle_initial_values[smd->selected_sim_limits->cycle_mode]);
                }
@@ -1092,10 +1087,41 @@ static char *_start_date_item_label_get(void *data, Evas_Object *obj, const char
 static char *_description_item_label_get(void *data, Evas_Object *obj,
                const char *part)
 {
+       char buf[256] = {0};
+       char number_with_postfix[256] = {0};
        SmartMgrData *smd = (SmartMgrData *)data;
        retv_if(!smd, NULL);
 
-       if (!strcmp(part, "elm.text.multiline"))
-               return strdup(elements_info_initial_values[smd->selected_sim_limits->cycle_mode]);
+       if (!strcmp(part, "elm.text.multiline")) {
+               switch (smd->selected_sim_limits->cycle_mode) {
+               case CYCLE_MODE_MONTHLY:
+                       create_number_with_postfix(smd->selected_sim_limits->cycle_start,
+                                       number_with_postfix, sizeof(number_with_postfix));
+                       snprintf(buf, sizeof(buf),  "%s %s %s",
+                               _("The data usage info will be reset on the"),
+                               number_with_postfix,
+                               _("day of every month."));
+                       break;
+               case CYCLE_MODE_WEEKLY:
+                       snprintf(buf, sizeof(buf), "%s %s.",
+                               _("The data usage info will be reset every"),
+                               elements_cycle_day_of_week[smd->selected_sim_limits->cycle_start-1]);
+                       break;
+               case CYCLE_MODE_DAILY:
+                       snprintf(buf, sizeof(buf), "%s",
+                               _("The data usage info will be reset at midnight every day."));
+                       break;
+               case CYCLE_MODE_CUSTOM:
+                       snprintf(buf, sizeof(buf), "%s %d %s %s",
+                               _("The data usage info will be reset every"),
+                               smd->selected_sim_limits->custom_mode_interval,
+                               smd->selected_sim_limits->custom_mode_interval == 1 ? _("day") : _("days"),
+                               _("from the start date."));
+                       break;
+               }
+
+               return strdup(buf);
+       }
+
        return NULL;
 }
index 6465ffa78c736e35570c6d3ee86a3c73cf25b671..94bc1eafc22778818eacb1b211b85ff4c891b68d 100755 (executable)
@@ -6,6 +6,12 @@
 
 #include <app_preference.h>
 
+#define TH_POSTFIX_IDX 0
+
+const char *number_postfixes[] = {
+       "th", "st", "nd", "rd"
+};
+
 static bool _create_stats_list(stc_h stc, stc_iface_type_e iface,
                                                                stc_stats_info_cb stats_cb,
                                                                void *cb_data, time_t t_from,
@@ -42,6 +48,20 @@ void get_data_amount_str(const char *prefix, int64_t num_bytes, char *txt_out, i
        }
 }
 
+void create_number_with_postfix(int number, char *output, int max_len)
+{
+       int temp = number % 100;
+
+       if (temp >= 20)
+               temp = temp % 10;
+
+       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]);
+       }
+}
+
 bool get_sim_total_stats(stc_h stc, stc_stats_info_cb stats_cb,
                                                const char *subscriber_id, time_t t_from, time_t t_to)
 {