TizenRefApp-6914 Disable ability to rename built-in groups (Co-Workers, Friends,... 93/84393/5
authorNataliia Sydorchuk <n.sydorchuk@samsung.com>
Thu, 18 Aug 2016 11:21:34 +0000 (14:21 +0300)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 18 Aug 2016 14:32:51 +0000 (07:32 -0700)
Change-Id: I4e2d43117afd6d9efd4e17949699f5ef42e241ba
Signed-off-by: Nataliia Sydorchuk <n.sydorchuk@samsung.com>
lib-apps-common/inc/Ui/Editfield.h
lib-apps-common/src/Ui/Editfield.cpp
lib-contacts/src/Contacts/Groups/NameItem.cpp

index 59b4015..bd71b77 100644 (file)
@@ -57,13 +57,26 @@ namespace Ui
                 */
                Evas_Object *getClearButton();
 
+               /**
+                * @brief Set whether entry is enabled or not.
+                * @param[in]   isEnabled   Whether input will be inserted in the entry
+                */
+               void setEnabled(bool isEnabled);
+
+               /**
+                * @brief Set Clear button visibility.
+                * @param[in]   isVisible   Whether Clear button is visible
+                */
+               void setClearButtonVisible(bool isVisible);
+
        private:
                virtual Evas_Object *onCreate(Evas_Object *parent) override;
 
-               static void onChanged(Evas_Object *layout, Evas_Object *entry, void *eventInfo);
+               static void onChanged(Editfield *editfield, Evas_Object *entry, void *eventInfo);
                static void onFocused(Evas_Object *layout, Evas_Object *entry, void *eventInfo);
                static void onUnfocused(Evas_Object *layout, Evas_Object *entry, void *eventInfo);
                static void onClearPressed(Evas_Object *entry, Evas_Object *button, void *eventInfo);
+
        };
 }
 
index 94acfd6..2bc1c3a 100644 (file)
@@ -39,7 +39,7 @@ Evas_Object *Editfield::onCreate(Evas_Object *parent)
        elm_entry_scrollable_set(entry, EINA_TRUE);
        elm_object_part_content_set(layout, "elm.swallow.content", entry);
 
-       evas_object_smart_callback_add(entry, "changed", (Evas_Smart_Cb) onChanged, layout);
+       evas_object_smart_callback_add(entry, "changed", (Evas_Smart_Cb) onChanged, this);
        evas_object_smart_callback_add(entry, "focused", (Evas_Smart_Cb) onFocused, layout);
        evas_object_smart_callback_add(entry, "unfocused", (Evas_Smart_Cb) onUnfocused, layout);
 
@@ -67,12 +67,25 @@ Evas_Object *Editfield::getClearButton()
        return elm_object_part_content_get(getEvasObject(), "elm.swallow.button");
 }
 
-void Editfield::onChanged(Evas_Object *layout, Evas_Object *entry, void *eventInfo)
+void Editfield::setEnabled(bool isEnabled)
 {
-       if (elm_entry_is_empty(entry)) {
-               elm_object_signal_emit(layout, "elm,action,hide,button", "");
+       elm_object_disabled_set(getEntry(), !isEnabled);
+       setClearButtonVisible(isEnabled);
+}
+
+void Editfield::setClearButtonVisible(bool isVisible)
+{
+       if (isVisible) {
+               elm_object_signal_emit(getEvasObject(), "elm,action,show,button", "");
        } else {
-               elm_object_signal_emit(layout, "elm,action,show,button", "");
+               elm_object_signal_emit(getEvasObject(), "elm,action,hide,button", "");
+       }
+}
+
+void Editfield::onChanged(Editfield *editfield, Evas_Object *entry, void *eventInfo)
+{
+       if (!elm_object_disabled_get(entry)) {
+               editfield->setClearButtonVisible(!elm_entry_is_empty(entry));
        }
 }
 
index 6adb89a..44f6564 100644 (file)
@@ -27,6 +27,7 @@
 
 using namespace Common::Database;
 using namespace Contacts::Groups;
+using namespace Utils;
 
 NameItem::NameItem(contacts_record_h record)
        : m_Record(record)
@@ -58,6 +59,11 @@ Evas_Object *NameItem::getContent(Evas_Object *parent, const char *part)
                Ui::Editfield *edit = Ui::Editfield::create(parent, "IDS_PB_MBODY_GROUP_NAME_ABB");
                char *name = elm_entry_utf8_to_markup(getRecordStr(m_Record, _contacts_group.name));
                elm_entry_entry_set(edit->getEntry(), name);
+               if (safeCmp(name, "Co-workers")
+                               || safeCmp(name, "Family")
+                               || safeCmp(name, "Friends")) {
+                       edit->setEnabled(false);
+               }
                free(name);
                evas_object_smart_callback_add(edit->getEntry(), "changed",
                                makeCallback(&NameItem::onChanged), this);