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
*
* @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);
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",
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;
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]);
}
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;
}
#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,
}
}
+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)
{