Implemented genlist item and UI control for Name and Phonetic name fields. 15/55415/3
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 24 Dec 2015 07:36:29 +0000 (09:36 +0200)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 24 Dec 2015 11:43:55 +0000 (13:43 +0200)
Change-Id: I605678b26ac02f7d3ea07ce77b1e2b39af823d42
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
16 files changed:
lib-common/res/common/edje/common-colors.edc
lib-contact/.cproject
lib-contact/inc/Contacts/Input/ContactCompoundFieldItem.h [new file with mode: 0644]
lib-contact/inc/Contacts/Input/ContactCompoundObjectControl.h [new file with mode: 0644]
lib-contact/inc/Contacts/Input/ContactFieldItem.h
lib-contact/inc/Contacts/Input/ContactFieldSubItem.h
lib-contact/res/input/edje/InputItemLayout.h
lib-contact/res/input/edje/InputPath.h
lib-contact/res/input/edje/input-item-layout.edc
lib-contact/res/input/images/core_icon_expand_close.png [new file with mode: 0644]
lib-contact/res/input/images/core_icon_expand_open.png [new file with mode: 0644]
lib-contact/src/Contacts/Input/ContactCompoundFieldItem.cpp [new file with mode: 0644]
lib-contact/src/Contacts/Input/ContactCompoundObjectControl.cpp [new file with mode: 0644]
lib-contact/src/Contacts/Input/ContactFieldItem.cpp
lib-contact/src/Contacts/Input/ContactFieldSubItem.cpp
lib-contact/src/Contacts/Input/InputView.cpp

index 788d6ba414a9590958c253656e93b6f368b46369..bd42582bdd77bf61fdd8e720e585efd49c5a076f 100644 (file)
@@ -34,4 +34,8 @@ color_classes {
                name: BUTTON_COLOR_CLASS_PRESSED;
                color: 48 139 153 255;
        }
+       color_class { //W023 (Input Color 1)
+               name: "icon_expand";
+               color: 61 185 204 255;
+       }
 }
index 4acf9677d62d76e16768268d54a217a9313e83db..c3cfe51d52159244a86e3f8622b3ce37ba27a8eb 100644 (file)
                                                        <tool id="org.tizen.nativecore.tool.ast.cpp.1667914133" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.1732270539" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.po.compiler.144173857" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
-                                                       <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1336766367" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
+                                                       <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1336766367" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler">
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.id.1879286091" superClass="sbi.gnu.edc.compiler.option.misc.id" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/res}&quot;"/>
+                                                               </option>
+                                                       </tool>
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
diff --git a/lib-contact/inc/Contacts/Input/ContactCompoundFieldItem.h b/lib-contact/inc/Contacts/Input/ContactCompoundFieldItem.h
new file mode 100644 (file)
index 0000000..cee803a
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef CONTACTS_INPUT_CONTACT_COMPOUND_FIELD_ITEM_H
+#define CONTACTS_INPUT_CONTACT_COMPOUND_FIELD_ITEM_H
+
+#include "Contacts/Input/ContactFieldItem.h"
+
+namespace Contacts
+{
+       namespace Input
+       {
+               /**
+                * @brief Genlist item representing ContactCompoundObject.
+                */
+               class ContactCompoundFieldItem : public ContactFieldItem
+               {
+               public:
+                       using ContactFieldItem::ContactFieldItem;
+
+               private:
+                       /**
+                        * @see GenlistItem::getContent()
+                        */
+                       virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
+
+                       /**
+                        * @brief Disables auto-expansion.
+                        * @see ContactFieldItem::onInserted()
+                        */
+                       virtual void onInserted() override { }
+
+                       /**
+                        * @see GenlistItem::onExpanded()
+                        */
+                       virtual void onExpanded() override;
+
+                       /**
+                        * @see GenlistItem::onContracted()
+                        */
+                       virtual void onContracted() override;
+
+                       void onButtonPressed(Evas_Object *button, void *eventInfo);
+               };
+       }
+}
+
+#endif /* CONTACTS_INPUT_CONTACT_COMPOUND_FIELD_ITEM_H */
diff --git a/lib-contact/inc/Contacts/Input/ContactCompoundObjectControl.h b/lib-contact/inc/Contacts/Input/ContactCompoundObjectControl.h
new file mode 100644 (file)
index 0000000..0e28e8d
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef CONTACTS_INPUT_CONTACT_COMPOUND_OBJECT_CONTROL_H
+#define CONTACTS_INPUT_CONTACT_COMPOUND_OBJECT_CONTROL_H
+
+#include "Ui/Editfield.h"
+
+namespace Contacts
+{
+       namespace Model
+       {
+               class ContactCompoundObject;
+       }
+
+       namespace Input
+       {
+               /**
+                * @brief UI Control for editing ContactCompoundObject
+                */
+               class ContactCompoundObjectControl : public Ui::Editfield
+               {
+               public:
+                       /**
+                        * @brief Create control
+                        * @param[in]   object  Contact compound object
+                        */
+                       ContactCompoundObjectControl(Model::ContactCompoundObject *object);
+
+               private:
+                       virtual void onCreated() override;
+                       void onUnfocused(Evas_Object *entry, void *eventInfo);
+
+                       Model::ContactCompoundObject *m_Object;
+               };
+       }
+}
+
+#endif /* CONTACTS_INPUT_CONTACT_COMPOUND_OBJECT_CONTROL_H */
index 4a4d770fb19a108f441f03ecfab1d9ce0e765c4e..5ae81a38e8ea72da801e0633efaf0c3069729834 100644 (file)
@@ -62,7 +62,7 @@ namespace Contacts
                        /**
                         * @return ContactObject associated with the item.
                         */
-                       const Model::ContactObject &getObject() const;
+                       Model::ContactObject &getObject() const;
 
                protected:
                        friend class ContactFieldSubItem;
index cd3a5e8fd99e6cf1e93f5ab09da06457ecd2090b..a258c5e9334d15e75a12a9c3e1b5520a4490122d 100644 (file)
@@ -40,7 +40,7 @@ namespace Contacts
                        /**
                         * @return ContactField associated with the item.
                         */
-                       const Model::ContactField &getField() const;
+                       Model::ContactField &getField() const;
 
                private:
                        friend class ContactFieldItem;
index 22a6855c9b93ad9534d04721266a0cb73bed10aa..a7874ca20c9a47e45b7cab9e1552d576f488f387 100644 (file)
@@ -32,4 +32,7 @@
 #define PART_BUTTON_3            "swallow.button.3"
 #define PART_BUTTON_4            "swallow.button.4"
 
+#define GROUP_ICON_EXPAND        "icon_expand"
+#define GROUP_ICON_CONTRACT      "icon_contract"
+
 #endif /* INPUT_ITEM_LAYOUT_H */
index 1338ddf1d787d42b53fe6d43f92452039f49c8f3..211eb9691da8b4d4fac9ebedab1ee176d61028a3 100644 (file)
@@ -28,4 +28,7 @@
 #define INPUT_ICON_ADD_NOTE     INPUT_IMG_DIR"contacts_circle_btn_ic_note.png"
 #define INPUT_ICON_ADD_MORE     INPUT_IMG_DIR"contacts_circle_btn_ic_more.png"
 
+#define INPUT_ICON_EXPAND       INPUT_IMG_DIR"core_icon_expand_close.png"
+#define INPUT_ICON_CONTRACT     INPUT_IMG_DIR"core_icon_expand_open.png"
+
 #endif /* INPUT_PATH_H */
index e8227244e4c15a78bdf66db78c296b680ae698eb..66e31b5e960564e12f67ea18bf885325f03e816c 100644 (file)
 #include "InputItemLayout.h"
 #include "InputItemLayoutMetrics.h"
 
+#include "../../../../lib-common/res/common/edje/common-colors.edc"
+#include "../../../../lib-common/res/common/edje/common-utils.edc"
+
 collections
 {
        base_scale: 2.6;
 
+       IMAGE_WITH_COLOR(GROUP_ICON_EXPAND, INPUT_ICON_EXPAND, "icon_expand")
+       IMAGE_WITH_COLOR(GROUP_ICON_CONTRACT, INPUT_ICON_CONTRACT, "icon_expand")
+
        group {
                name: "elm/genlist/item/"INPUT_ITEM_STYLE"/default";
                alias: "elm/genlist/item_compress/"INPUT_ITEM_STYLE"/default";
diff --git a/lib-contact/res/input/images/core_icon_expand_close.png b/lib-contact/res/input/images/core_icon_expand_close.png
new file mode 100644 (file)
index 0000000..125f436
Binary files /dev/null and b/lib-contact/res/input/images/core_icon_expand_close.png differ
diff --git a/lib-contact/res/input/images/core_icon_expand_open.png b/lib-contact/res/input/images/core_icon_expand_open.png
new file mode 100644 (file)
index 0000000..6742e6f
Binary files /dev/null and b/lib-contact/res/input/images/core_icon_expand_open.png differ
diff --git a/lib-contact/src/Contacts/Input/ContactCompoundFieldItem.cpp b/lib-contact/src/Contacts/Input/ContactCompoundFieldItem.cpp
new file mode 100644 (file)
index 0000000..2ad02a6
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Contacts/Input/ContactCompoundFieldItem.h"
+#include "Contacts/Input/ContactCompoundObjectControl.h"
+#include "Contacts/Model/ContactObject.h"
+
+#include "App/Path.h"
+#include "Utils/Callback.h"
+
+#include "InputItemLayout.h"
+
+using namespace Contacts::Input;
+using namespace Contacts::Model;
+
+namespace
+{
+       const std::string layoutPath = App::getResourcePath(INPUT_ITEM_LAYOUT_EDJ);
+}
+
+Evas_Object *ContactCompoundFieldItem::getContent(Evas_Object *parent, const char *part)
+{
+       if (strcmp(part, PART_RIGHT) == 0) {
+               Evas_Object *button = elm_button_add(parent);
+               /* FIXME: Request standard style for expand open/close buttons */
+               elm_object_style_set(button, "floatingbutton/default");
+               evas_object_smart_callback_add(button, "clicked",
+                               makeCallback(&ContactCompoundFieldItem::onButtonPressed), this);
+
+               Evas_Object *image = elm_image_add(button);
+               elm_image_file_set(image, layoutPath.c_str(), isExpanded() ? GROUP_ICON_CONTRACT : GROUP_ICON_EXPAND);
+               elm_object_part_content_set(button, "elm.swallow.content", image);
+
+               return button;
+       } else if (!isExpanded() && strcmp(part, PART_MIDDLE) == 0) {
+               Ui::Control *control = new ContactCompoundObjectControl(&getObject().cast<ContactCompoundObject>());
+               return control->create(parent);
+       } else {
+               return ContactFieldItem::getContent(parent, part);
+       }
+}
+
+void ContactCompoundFieldItem::onExpanded()
+{
+       ContactFieldItem::onExpanded();
+       elm_genlist_item_update(getObjectItem());
+}
+
+void ContactCompoundFieldItem::onContracted()
+{
+       ContactFieldItem::onContracted();
+       elm_genlist_item_update(getObjectItem());
+}
+
+void ContactCompoundFieldItem::onButtonPressed(Evas_Object *button, void *eventInfo)
+{
+       elm_genlist_item_expanded_set(getObjectItem(), !isExpanded());
+}
diff --git a/lib-contact/src/Contacts/Input/ContactCompoundObjectControl.cpp b/lib-contact/src/Contacts/Input/ContactCompoundObjectControl.cpp
new file mode 100644 (file)
index 0000000..7a086a7
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Contacts/Input/ContactCompoundObjectControl.h"
+#include "Contacts/Model/ContactCompoundObject.h"
+#include "Contacts/Common/Strings.h"
+#include "Utils/Callback.h"
+
+using namespace Contacts::Input;
+using namespace Contacts::Model;
+
+ContactCompoundObjectControl::ContactCompoundObjectControl(ContactCompoundObject *object)
+       : m_Object(object)
+{
+}
+
+void ContactCompoundObjectControl::onCreated()
+{
+       setGuideText(Common::getContactFieldName(ContactFieldId(m_Object->getId())));
+
+       Evas_Object *entry = getEntry();
+       elm_entry_autocapital_type_set(entry, ELM_AUTOCAPITAL_TYPE_WORD);
+       evas_object_smart_callback_add(entry, "unfocused",
+                       makeCallback(&ContactCompoundObjectControl::onUnfocused), this);
+
+       char *text = elm_entry_utf8_to_markup(m_Object->getValue().c_str());
+       elm_entry_entry_set(entry, text);
+       free(text);
+}
+
+void ContactCompoundObjectControl::onUnfocused(Evas_Object *entry, void *eventInfo)
+{
+       char *text = elm_entry_markup_to_utf8(elm_entry_entry_get(getEntry()));
+       m_Object->setValue(text);
+       free(text);
+}
index cb85aa3ff2e7f051278f94582eb6b8481299f7da..63e6eeca9b6c0e6b76bd0c43bd6b9d5ad88a705b 100644 (file)
@@ -19,6 +19,7 @@
 #include "Contacts/Input/ContactFieldSubItem.h"
 #include "Contacts/Model/ContactObject.h"
 #include "Utils/Callback.h"
+#include "Utils/Logger.h"
 
 #include "InputItemLayout.h"
 
@@ -54,7 +55,7 @@ void ContactFieldItem::setRemoveCallback(RemoveCallback callback)
        m_OnRemove = std::move(callback);
 }
 
-const ContactObject &ContactFieldItem::getObject() const
+ContactObject &ContactFieldItem::getObject() const
 {
        return m_Object->cast<ContactObject>();
 }
index b52da4faadd9713a99f0f53d23b26e81ad951894..05b3fd4700cdd8ace8d9a1c984f340f1712e59b8 100644 (file)
@@ -35,7 +35,7 @@ ContactFieldSubItem::ContactFieldSubItem(ContactFieldPtr field)
 {
 }
 
-const ContactField &ContactFieldSubItem::getField() const
+ContactField &ContactFieldSubItem::getField() const
 {
        return *m_Field;
 }
index 71713cfdc4680a1ed81de1734fe597c58f2e4583..7c7629dc6d710e092b485c95f24ad21483128b34 100644 (file)
@@ -18,6 +18,7 @@
 #include "Contacts/Input/InputView.h"
 #include "Contacts/Input/AddFieldsItem.h"
 #include "Contacts/Input/ContactTypedFieldItem.h"
+#include "Contacts/Input/ContactCompoundFieldItem.h"
 #include "Contacts/Model/ContactArray.h"
 
 #include "App/Path.h"
@@ -111,6 +112,8 @@ ContactFieldItem *InputView::createFieldItem(Model::ContactFieldPtr field)
        ContactFieldItem *item = nullptr;
        if (field->getSubType() & ObjectTyped) {
                item = new ContactTypedFieldItem(std::move(field));
+       } else if (field->getSubType() & ObjectCompound) {
+               item = new ContactCompoundFieldItem(std::move(field));
        } else {
                item = new ContactFieldItem(std::move(field));
        }