Refactored localized group name retrieval to remove duplication. 72/86672/3
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Fri, 2 Sep 2016 09:42:58 +0000 (12:42 +0300)
committerAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Tue, 6 Sep 2016 08:32:09 +0000 (01:32 -0700)
Fixed group members list title while initialization is in progress.

Change-Id: I9aa6999020fc259a8abef2a0d2d028aee1b358d4
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-common/inc/Common/Strings.h
lib-common/src/Common/Strings.cpp
lib-contacts/src/Contacts/Details/GroupsFieldItem.cpp
lib-contacts/src/Contacts/Groups/GroupItem.cpp
lib-contacts/src/Contacts/Groups/MembersListView.cpp
lib-contacts/src/Contacts/Groups/NameItem.cpp
lib-contacts/src/Contacts/Input/ContactGroupsFieldItem.cpp

index a9f965c..fcdcb28 100644 (file)
@@ -57,11 +57,11 @@ namespace Common
        EXPORT_API const Ux::SelectView::Strings &getSelectViewStrings();
 
        /**
-        * @brief Get default group name.
-        * @param[in]   type    Group type
-        * @return Group translatable name.
+        * @brief Get translated group name.
+        * @param[in]   name    Original group name
+        * @return Translated group name.
         */
-       EXPORT_API const char *getDefaultGroupName(GroupType type);
+       EXPORT_API const char *getGroupName(const char *name);
 }
 
 #endif /* COMMON_STRINGS_H */
index f2478cb..ec4698d 100644 (file)
@@ -16,6 +16,8 @@
  */
 
 #include "Common/Strings.h"
+
+#include <app_i18n.h>
 #include <contacts.h>
 
 using namespace Common;
@@ -114,9 +116,9 @@ namespace
        };
 
        const char *defaultGroupName[] = {
-               /* [TypeCoWorkers]  = */ "IDS_PB_BODY_CO_WORKERS",
-               /* [TypeFamily]     = */ "IDS_PB_BODY_DEFAULT_GROUP_FAMILY",
-               /* [TypeFriends]    = */ "IDS_PB_BODY_DEFAULT_GROUP_FRIENDS"
+               /* [GroupCoWorkers]  = */ "IDS_PB_BODY_CO_WORKERS",
+               /* [GroupFamily]     = */ "IDS_PB_BODY_DEFAULT_GROUP_FAMILY",
+               /* [GroupFriends]    = */ "IDS_PB_BODY_DEFAULT_GROUP_FRIENDS"
        };
 }
 
@@ -146,7 +148,12 @@ const Ux::SelectView::Strings &Common::getSelectViewStrings()
        return selectViewStrings;
 }
 
-const char *Common::getDefaultGroupName(GroupType type)
+const char *Common::getGroupName(const char *name)
 {
-       return Utils::at(defaultGroupName, type);
+       GroupType type = getGroupType(name);
+       if (type != GroupCustom) {
+               return _(Utils::at(defaultGroupName, type));
+       }
+
+       return name;
 }
index 6c13965..3908819 100644 (file)
@@ -44,12 +44,10 @@ std::string GroupsFieldItem::formatGroups() const
        std::string groups;
        for (auto &&field : *getObject().getField<ContactArray>(0)) {
                const char *name = getRecordStr(field.getRecord(), _contacts_group_relation.name);
-               GroupType type = getGroupType(name);
-               const char *groupName = (type == GroupCustom) ? name : _(getDefaultGroupName(type));
                if (!groups.empty()) {
                        groups.append(", ");
                }
-               groups.append(groupName);
+               groups.append(getGroupName(name));
        }
 
        return groups;
index 0150467..60a60dc 100644 (file)
@@ -53,10 +53,9 @@ void GroupItem::update(int changes)
 char *GroupItem::getText(Evas_Object *parent, const char *part)
 {
        if (strcmp(part, PART_GROUP_NAME) == 0) {
-               char title[BUFFER_SIZE] = { 0, };
-               const char *name = (m_Group.getType() == GroupCustom) ? m_Group.getName()
-                               : _(getDefaultGroupName(m_Group.getType()));
-               snprintf(title, sizeof(title), "%s (%d)", name, m_Group.getMembersCount());
+               char title[BUFFER_SIZE];
+               snprintf(title, sizeof(title), "%s (%d)",
+                               getGroupName(m_Group.getName()), m_Group.getMembersCount());
                return strdup(title);
        }
        return nullptr;
index 3f5a8a0..e42923c 100644 (file)
@@ -81,8 +81,11 @@ MembersListView::MembersListView(MembersProvider *provider)
 
 void MembersListView::onPageAttached(NavigatorPage *page)
 {
-       SelectView::onPageAttached(page);
-       updateTitle();
+       if (getSelectMode() == SelectNone) {
+               page->setTitle(getGroupName(m_Group.getName()));
+       } else {
+               SelectView::onPageAttached(page);
+       }
 }
 
 void MembersListView::onMenuPressed()
@@ -131,9 +134,7 @@ void MembersListView::updateTitle()
                return;
        }
 
-       const char *name = (m_Group.getType() == GroupCustom) ?
-                       m_Group.getName() : _(getDefaultGroupName(m_Group.getType()));
-
+       const char *name = getGroupName(m_Group.getName());
        int count = getProvider()->getDataList().size();
        if (count == 0) {
                page->setTitle(name);
index ec4ad7f..6888066 100644 (file)
@@ -62,14 +62,11 @@ Evas_Object *NameItem::getContent(Evas_Object *parent, const char *part)
 {
        if (strcmp(part, PART_GROUP_NAME_VALUE) == 0) {
                Ui::Editfield *edit = Ui::Editfield::create(parent, "IDS_PB_MBODY_GROUP_NAME_ABB");
-
-               const char *name = m_Group.getName();
                if (m_Group.getType() != GroupCustom) {
                        edit->setEnabled(false);
-                       name = _(getDefaultGroupName(m_Group.getType()));
                }
 
-               char *markupName = elm_entry_utf8_to_markup(name);
+               char *markupName = elm_entry_utf8_to_markup(getGroupName(m_Group.getName()));
                elm_entry_entry_set(edit->getEntry(), markupName);
                free(markupName);
 
index 09f88d4..7a833d0 100644 (file)
@@ -106,12 +106,10 @@ std::string ContactGroupsFieldItem::formatGroups() const
        std::string groups;
        for (auto &&field : m_GroupRels) {
                const char *name = getRecordStr(field.getRecord(), _contacts_group_relation.name);
-               GroupType type = getGroupType(name);
-               const char *groupName = (type == GroupCustom) ? name : _(getDefaultGroupName(type));
                if (!groups.empty()) {
                        groups.append(", ");
                }
-               groups.append(groupName);
+               groups.append(getGroupName(name));
        }
 
        return groups;