From 0dd3b873481af4b0e78eeac742260b6dffdb01fd Mon Sep 17 00:00:00 2001 From: Jing Yigang Date: Thu, 20 Sep 2012 09:17:52 +0800 Subject: [PATCH] [Feature] Add number example in Setting > Langauage and region . Change-Id: I3775067bc7e0fb5afd4ea72246bf6e2a40e068be --- setting-phone/include/setting-phone.h | 2 ++ setting-phone/src/setting-phone.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/setting-phone/include/setting-phone.h b/setting-phone/include/setting-phone.h index 1e2ddee..b10e0b6 100755 --- a/setting-phone/include/setting-phone.h +++ b/setting-phone/include/setting-phone.h @@ -59,6 +59,8 @@ #define REGION_ITEM_MAX 300 +#define SETTING_PHONE_EXAMPLE_NUMBER "Number" + #define ASK_DEREG_PHONE "Your phone is
already registered.
Are you sure you
wish to deregister?" #define REGISTRATION_GET_FAILED "Failed to get registration code" #define REGISTRATION_INDICATOT "



Your device
registration code:

" diff --git a/setting-phone/src/setting-phone.c b/setting-phone/src/setting-phone.c index f0e0430..1595259 100755 --- a/setting-phone/src/setting-phone.c +++ b/setting-phone/src/setting-phone.c @@ -32,6 +32,7 @@ #include #include #include +#include "unicode/unum.h" #ifndef UG_MODULE_API #define UG_MODULE_API __attribute__ ((visibility("default"))) @@ -301,6 +302,24 @@ char *setting_phone_lang_get_by_pattern(const char *locale, return ret_str; } +static char *__setting_phone_number_format_get(const char *region) +{ + setting_retvm_if(region == NULL, NULL, "region parameter is NULL"); + UNumberFormat *fmt = NULL; + UErrorCode status = U_ZERO_ERROR; + UChar number_uchar[MAX_DISPLAY_NAME_LEN_ON_UI] = {0,}; + char number_char[MAX_DISPLAY_NAME_LEN_ON_UI] = {0,}; + double example_number = 1234567.89; + + fmt = unum_open(UNUM_DEFAULT, NULL, -1, region, NULL, &status); + unum_formatDouble(fmt, example_number, number_uchar, MAX_DISPLAY_NAME_LEN_ON_UI, NULL, &status); + u_austrcpy(number_char, number_uchar); + SETTING_TRACE("number_char = %s", number_char); + unum_close(fmt); + + return g_strdup(number_char); /* should be freed by caller */ +} + char *setting_phone_lang_get_example_desc(const char *region, void *data) { setting_retvm_if(region == NULL, NULL, "region parameter is NULL"); @@ -323,18 +342,22 @@ char *setting_phone_lang_get_example_desc(const char *region, void *data) char *time = setting_phone_lang_get_by_pattern(region, time_skeleton, data); + char *number = __setting_phone_number_format_get(region); + Eina_Strbuf *temp_str = eina_strbuf_new(); char *r_str_text = NULL; eina_strbuf_append_printf(temp_str, "%s", _("IDS_ST_BODY_REGIONAL_EXAMPLE")); eina_strbuf_append_printf(temp_str, "
%s : %s", _("IDS_ST_BODY_DATE"), date); eina_strbuf_append_printf(temp_str, "
%s : %s", _("IDS_COM_BODY_DETAILS_TIME"), time); + eina_strbuf_append_printf(temp_str, "
%s : %s", _(SETTING_PHONE_EXAMPLE_NUMBER), number); r_str_text = eina_strbuf_string_steal(temp_str); /* eina_strbuf_string_free(temp_str); */ eina_strbuf_free(temp_str); G_FREE(date); G_FREE(time); + G_FREE(number); return r_str_text; /* will be freed in calling place */ } -- 2.7.4