RTL badge count 78/101378/1
authorYoungHun Cho <hoon.cho@samsung.com>
Thu, 1 Dec 2016 05:05:37 +0000 (14:05 +0900)
committerYoungHun Cho <hoon.cho@samsung.com>
Thu, 1 Dec 2016 05:06:35 +0000 (14:06 +0900)
Change-Id: Ib7b87a5ceebc2c6e4ab2a9d278e2d28261958cde
Signed-off-by: YoungHun Cho <hoon.cho@samsung.com>
.cproject
inc/conf.h
inc/util.h
project_def.prop
src/apps_view.c
src/util.c

index 738406a..a6da12c 100755 (executable)
--- a/.cproject
+++ b/.cproject
                                                                <option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.481743771" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.2102599528" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.compiler.option.1070320025" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="mobile-3.0-device.core_gcc49.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="mobile-3.0-device.core.public.20161129_1_gcc49.armel.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.312288874" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/attach-panel&quot;"/>
@@ -74,6 +68,7 @@
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/geofence&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/harfbuzz&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/iotcon&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/maps&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/nsd/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/service-adaptor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/shortcut&quot;"/>
                                                                <option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.247638963" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.982331969" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.c.compiler.option.1644890019" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="mobile-3.0-device.core_gcc49.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="mobile-3.0-device.core.public.20161129_1_gcc49.armel.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1483034184" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/attach-panel&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/geofence&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/harfbuzz&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/iotcon&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/maps&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/nsd/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/service-adaptor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/shortcut&quot;"/>
index b4cb5ed..08b14a4 100755 (executable)
@@ -21,7 +21,6 @@
 
 #define STR_ID_LEN 256
 #define STR_PATH_LEN 1024
-#define LOCALE_LEN 32
 #define STR_MAX 2048
 #define INIT_VALUE -987654321
 
index 70d6ba2..b54d36d 100755 (executable)
@@ -52,6 +52,7 @@ enum app_subdir {
 };
 
 const char *util_get_file_path(enum app_subdir dir, const char *relative);
+const char *util_to_string(int num);
 
 #define util_get_data_file_path(x) util_get_file_path(APP_DIR_DATA, (x))
 #define util_get_cache_file_path(x) util_get_file_path(APP_DIR_CACHE, (x))
index b64d38e..e3e696d 100755 (executable)
@@ -18,7 +18,7 @@ USER_EDCS =
 USER_POS = res/po/ca.po res/po/fr.po res/po/nl.po res/po/pt_BR.po res/po/sk.po res/po/sv.po res/po/uz.po res/po/ko_KR.po res/po/is.po res/po/ka.po res/po/ro.po res/po/it_IT.po res/po/en_PH.po res/po/lt.po res/po/mk.po res/po/nb.po res/po/ru_RU.po res/po/el_GR.po res/po/zh_TW.po res/po/az.po res/po/hr.po res/po/uk.po res/po/zh_CN.po res/po/de.po res/po/es_US.po res/po/eu.po res/po/kk.po res/po/sl.po res/po/et.po res/po/fr_CA.po res/po/ga.po res/po/gl.po res/po/hy.po res/po/lv.po res/po/ja_JP.po res/po/es_ES.po res/po/bg.po res/po/cs.po res/po/pl.po res/po/pt_PT.po res/po/sr.po res/po/hu.po res/po/ar.po res/po/en_US.po res/po/fi.po res/po/da.po res/po/en.po res/po/zh_HK.po res/po/tr_TR.po 
 
 # User Defines
-USER_DEFS = TIZEN_DEPRECATION 
+USER_DEFS = 
 USER_CPP_DEFS = 
 
 # User Undefines
index 92c47f6..ba9fbc6 100755 (executable)
@@ -18,8 +18,6 @@
 #include <package_manager.h>
 #include <badge.h>
 #include <feedback.h>
-#include <utils_i18n.h>
-#include <system_settings.h>
 
 #include "apps_view.h"
 #include "conf.h"
@@ -138,11 +136,11 @@ static Eina_Bool __apps_view_show_folder_anim(void *data, double pos);
 static Eina_Bool __apps_view_hide_folder_anim(void *data, double pos);
 static void __apps_view_hide_folder_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
 static void __apps_view_badge_update_cb(unsigned int action, const char *app_id, unsigned int count, void *user_data);
+static void __apps_view_badge_lang_changed(void);
 static void __apps_view_badge_update_icon(app_data_t *item);
 static void __apps_view_badge_update_folder(int parent_db_id);
 static void __apps_view_badge_update_count(app_data_t *item);
 static void __apps_view_plus_icon_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
-static char *__apps_view_get_locale_badge_count(int count);
 
 static void __apps_view_scroller_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
 static void __apps_view_scroller_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
@@ -583,7 +581,7 @@ void apps_view_lang_changed(homescreen_view_t view_type)
                apps_view_set_state(VIEW_STATE_NORMAL);
        }
        apps_data_update_item_label();
-       __apps_view_badge_update_cb(1, NULL, 0, NULL);
+       __apps_view_badge_lang_changed();
 }
 
 void apps_view_get_access_object_list(Eina_List **list)
@@ -1491,65 +1489,41 @@ static void __apps_view_badge_update_count(app_data_t *item)
        if (result != BADGE_ERROR_NONE) {
                LOGE("badge_get_count error %d", result);
                item->badge_count = 0;
-               return;
        }
        __apps_view_badge_update_icon(item);
 }
 
-static char *__apps_view_get_locale_badge_count(int count)
+static void __apps_view_badge_lang_changed(void)
 {
-       char *locale = NULL;
-       char *ret_str = NULL;
-       char a_buffer[32];
-       i18n_uchar u_buffer[32];
-       i18n_unumber_format_h num_format;
-       i18n_error_code_e status;
-       int32_t ret = -1;
-       int32_t buf_len = (int32_t) (sizeof(u_buffer) / sizeof(u_buffer[0]));
-       int32_t number = count;
+       LOGD("%s language changed");
 
-       ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &locale);
-       if (ret < 0) {
-               LOGE("Failed to get the locale(%d)", ret);
-               return strdup("en_US");
-       }
+       Eina_List *data_list = apps_data_get_list();
+       Eina_List *find_list = NULL;
+       app_data_t *item = NULL;
 
-       if (I18N_ERROR_NONE != i18n_unumber_create(I18N_UNUMBER_DEFAULT, NULL, -1, locale, NULL, &num_format)) {
-               LOGE("Failed to create unumber format");                
+       EINA_LIST_FOREACH(data_list, find_list, item) {
+               __apps_view_badge_update_icon(item);
        }
-
-       i18n_unumber_format(num_format, number, u_buffer, buf_len, NULL, &status);
-
-       i18n_ustring_copy_au(a_buffer, u_buffer);
-
-       i18n_unumber_destroy(num_format);
-
-       ret_str = strdup(a_buffer);
-
-       return ret_str;
 }
 
 static void __apps_view_badge_update_icon(app_data_t *item)
 {
-       char result_number_str[STR_MAX];
-       char *number_str;
+       char number_str[STR_MAX];
        if (item->badge_count > MAX_BADGE_DISPLAY_COUNT) {
-               number_str = __apps_view_get_locale_badge_count(MAX_BADGE_DISPLAY_COUNT);
-               snprintf(result_number_str, sizeof(result_number_str), "%s+", number_str);
+               snprintf(number_str, sizeof(number_str), "%s+", util_to_string(MAX_BADGE_DISPLAY_COUNT));
        } else {
-               number_str = __apps_view_get_locale_badge_count(item->badge_count);
-               snprintf(result_number_str, sizeof(result_number_str), "%s", number_str);
+               snprintf(number_str, sizeof(number_str), "%s", util_to_string(item->badge_count));
        }
-       free(number_str);
 
        if (item->app_layout) {
                if (item->badge_count <= 0) {
                        elm_object_signal_emit(item->app_layout, SIGNAL_BADGE_HIDE, SIGNAL_SOURCE);
                } else {
-                       elm_layout_text_set(item->app_layout, APPS_ICON_BADGE_TEXT, result_number_str);
+                       elm_layout_text_set(item->app_layout, APPS_ICON_BADGE_TEXT, number_str);
                        elm_object_signal_emit(item->app_layout, SIGNAL_BADGE_SHOW, SIGNAL_SOURCE);
                }
        }
+
        if (item->parent_db_id != APPS_ROOT )
                __apps_view_badge_update_folder(item->parent_db_id);
 }
index 22a7de9..5e911e7 100755 (executable)
@@ -16,6 +16,8 @@
 
 #include <Elementary.h>
 #include <app_common.h>
+#include <utils_i18n.h>
+#include <system_settings.h>
 
 #include "util.h"
 
@@ -65,3 +67,36 @@ const char *util_get_file_path(enum app_subdir dir, const char *relative)
 
        return &buf[0];
 }
+
+const char *util_to_string(int num)
+{
+       static char buf[64];
+
+       char *locale = NULL;
+
+       int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &locale);
+       if (ret != SYSTEM_SETTINGS_ERROR_NONE) {
+               LOGE("Failed to get the locale(%d)", ret);
+               goto __fail;
+       }
+
+       i18n_unumber_format_h num_format;
+       ret = i18n_unumber_create(I18N_UNUMBER_DEFAULT, NULL, -1, locale, NULL, &num_format);
+       if (ret != I18N_ERROR_NONE) {
+               LOGE("Failed to create unumber format(%d)", ret);
+               goto __fail;
+       }
+
+       i18n_uchar u_buffer[64];
+       int32_t len = (int32_t) (sizeof(u_buffer) / sizeof(u_buffer[0]));
+       i18n_error_code_e status;
+       i18n_unumber_format(num_format, num, u_buffer, len, NULL, &status);
+       i18n_ustring_copy_au(buf, u_buffer);
+       i18n_unumber_destroy(num_format);
+
+       return &buf[0];
+
+__fail:
+       snprintf(buf, sizeof(buf), "%d", num);
+       return &buf[0];
+}