TizenRefApp-5466 Implement Contact Relationship Item in Input View 43/57043/1
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 14 Jan 2016 15:42:31 +0000 (17:42 +0200)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 14 Jan 2016 15:42:49 +0000 (17:42 +0200)
Change-Id: I554ed583f709dffc4c754100aa26404523a07ce9
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-common/res/common/edje/common-colors.edc
lib-common/res/common/edje/common-utils.edc
lib-contact/inc/Contacts/Input/ContactRelationshipFieldItem.h [new file with mode: 0644]
lib-contact/res/input/edje/InputItemLayout.h
lib-contact/res/input/edje/InputItemLayoutMetrics.h
lib-contact/res/input/edje/InputPath.h
lib-contact/res/input/edje/input-item-layout.edc
lib-contact/res/input/images/contacts_btn_ic_multiple.png [new file with mode: 0644]
lib-contact/src/Contacts/Input/ContactRelationshipFieldItem.cpp [new file with mode: 0644]
lib-contact/src/Contacts/Input/InputView.cpp

index bd42582bdd77bf61fdd8e720e585efd49c5a076f..552246326d4cd3679d6bf667dbae042a83d06d22 100644 (file)
@@ -38,4 +38,12 @@ color_classes {
                name: "icon_expand";
                color: 61 185 204 255;
        }
+       color_class { //W0113 (Input Color 1)
+               name: "touch_icon_normal";
+               color: 61 185 204 255;
+       }
+       color_class { //W0113P
+               name: "touch_icon_pressed";
+               color: 34 104 115 255;
+       }
 }
index 08b3c1200f0b297117c8a78f7be0c48f5ae5d1dd..b04202b16de0459269d9a9a92faa95e3b2b6f001 100644 (file)
                        } \
                } \
        }
+
+#define IMAGE_WITH_PRESSED_COLOR(GROUP_NAME, IMAGE_PATH, COLOR_CLASS, PRESSED_COLOR_CLASS) \
+       group { \
+               name: GROUP_NAME; \
+               images.image: IMAGE_PATH COMP; \
+               parts { \
+                       part { name: "image"; \
+                               description { \
+                                       state: "default" 0.0; \
+                                       image.normal: IMAGE_PATH; \
+                                       color_class: COLOR_CLASS; \
+                                       aspect: 1 1; \
+                                       aspect_preference: SOURCE; \
+                               } \
+                               description { \
+                                       state: "pressed" 0.0; \
+                                       inherit:  "default" 0.0; \
+                                       color_class: PRESSED_COLOR_CLASS; \
+                               } \
+                       } \
+               } \
+               programs { \
+                       program { \
+                               name: "pressed"; \
+                               signal: "mouse,down,*"; \
+                               source: "*"; \
+                               action: STATE_SET "pressed" 0.0; \
+                               target: "image"; \
+                       } \
+                       program { \
+                               name: "unpressed"; \
+                               signal: "mouse,up,*"; \
+                               source: "*"; \
+                               action: STATE_SET "default" 0.0; \
+                               target: "image"; \
+                       } \
+               } \
+       }
diff --git a/lib-contact/inc/Contacts/Input/ContactRelationshipFieldItem.h b/lib-contact/inc/Contacts/Input/ContactRelationshipFieldItem.h
new file mode 100644 (file)
index 0000000..9a60ea7
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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_RELATIONSHIP_FIELD_ITEM_H
+#define CONTACTS_INPUT_CONTACT_RELATIONSHIP_FIELD_ITEM_H
+
+#include "App/AppControl.h"
+#include "Contacts/Input/ContactTypedFieldItem.h"
+
+namespace Contacts
+{
+       namespace Input
+       {
+               /**
+                * @brief Genlist item representing FieldRelationship field.
+                */
+               class ContactRelationshipFieldItem : public ContactTypedFieldItem
+               {
+               public:
+                       using ContactTypedFieldItem::ContactTypedFieldItem;
+
+               private:
+                       virtual Elm_Genlist_Item_Class *getItemClass() const override;
+                       virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
+
+                       void onPickPressed(Evas_Object *button, void *eventInfo);
+                       void onPickResult(app_control_h request, app_control_h reply,
+                                       app_control_result_e result);
+
+                       App::AppControl m_AppControl;
+               };
+       }
+}
+
+#endif /* CONTACTS_INPUT_CONTACT_RELATIONSHIP_FIELD_ITEM_H */
index 52961de490f13cbfff286559b54a1bd6eb6cefe0..49f4679311c27a92629da30d4e3ae000d5506419 100644 (file)
 
 #define INPUT_ITEM_STYLE         "input_item"
 #define INPUT_IMAGE_ITEM_STYLE   "input_image_item"
+#define INPUT_REL_ITEM_STYLE     "input_rel_item"
 #define INPUT_BUTTONS_ITEM_STYLE "input_buttons_item"
 
 #define PART_LEFT                "swallow.left"
 #define PART_MIDDLE              "swallow.middle"
 #define PART_RIGHT               "swallow.right"
+#define PART_REL_ICON            "swallow.rel_icon"
 
 #define GROUP_ICON_EXPAND        "icon_expand"
 #define GROUP_ICON_CONTRACT      "icon_contract"
+#define GROUP_ICON_RELATIONSHIP  "icon_relationship"
 
 #endif /* INPUT_ITEM_LAYOUT_H */
index 47bdee1e49c22312688de94713ec611778d603b8..343d73d490289e7a661bdd1486ad815932334959 100644 (file)
@@ -35,6 +35,8 @@
 #define IMAGE_ITEM_PADDING_Y 44
 #define IMAGE_ITEM_H (IMAGE_SIZE+IMAGE_ITEM_PADDING_Y*2)
 
+#define RELATIONSHIP_ICON_SIZE 80 80
+
 #define BUTTONS_ITEM_H 247
 #define BUTTONS_ITEM_PADDING_Y 22
 
index 211eb9691da8b4d4fac9ebedab1ee176d61028a3..c2ba8a4eb1d7c4fe3a5cc9cf76c8a5f7ce9b832c 100644 (file)
@@ -28,6 +28,8 @@
 #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_RELATIONSHIP INPUT_IMG_DIR"contacts_btn_ic_multiple.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"
 
index de0a53175b77c889f8ce95b19e6648599154b98e..671e254db3a058f5e109632c96d559e5f214b599 100644 (file)
@@ -27,6 +27,8 @@ collections
 
        IMAGE_WITH_COLOR(GROUP_ICON_EXPAND, INPUT_ICON_EXPAND, "icon_expand")
        IMAGE_WITH_COLOR(GROUP_ICON_CONTRACT, INPUT_ICON_CONTRACT, "icon_expand")
+       IMAGE_WITH_PRESSED_COLOR(GROUP_ICON_RELATIONSHIP, INPUT_ICON_RELATIONSHIP,
+                       "touch_icon_normal", "touch_icon_pressed");
 
        group {
                name: "elm/genlist/item/"INPUT_ITEM_STYLE"/default";
@@ -85,6 +87,38 @@ collections
                }
        }
 
+       group {
+               name: "elm/genlist/item/"INPUT_REL_ITEM_STYLE"/default";
+               alias: "elm/genlist/item_compress/"INPUT_REL_ITEM_STYLE"/default";
+               alias: "elm/genlist/tree/"INPUT_REL_ITEM_STYLE"/default";
+               alias: "elm/genlist/tree_compress/"INPUT_REL_ITEM_STYLE"/default";
+               inherit: "elm/genlist/item/"INPUT_ITEM_STYLE"/default";
+
+               data.item: "contents" PART_LEFT" "PART_MIDDLE" "PART_RIGHT" "PART_REL_ICON;
+
+               parts {
+                       swallow { PART_MIDDLE;
+                               desc { "default";
+                                       rel2 {
+                                               relative: 0.0 1.0;
+                                               to_x: PART_REL_ICON;
+                                       }
+                               }
+                       }
+                       swallow { PART_REL_ICON; scale;
+                               desc { "default";
+                                       min: RELATIONSHIP_ICON_SIZE;
+                                       max: RELATIONSHIP_ICON_SIZE;
+                                       align: 1.0 0.5;
+                                       rel2 {
+                                               relative: 0.0 1.0;
+                                               to_x: PART_RIGHT;
+                                       }
+                               }
+                       }
+               }
+       }
+
        group {
                name: "elm/genlist/item/"INPUT_IMAGE_ITEM_STYLE"/default";
                alias: "elm/genlist/item_compress/"INPUT_IMAGE_ITEM_STYLE"/default";
diff --git a/lib-contact/res/input/images/contacts_btn_ic_multiple.png b/lib-contact/res/input/images/contacts_btn_ic_multiple.png
new file mode 100644 (file)
index 0000000..cee85f8
Binary files /dev/null and b/lib-contact/res/input/images/contacts_btn_ic_multiple.png differ
diff --git a/lib-contact/src/Contacts/Input/ContactRelationshipFieldItem.cpp b/lib-contact/src/Contacts/Input/ContactRelationshipFieldItem.cpp
new file mode 100644 (file)
index 0000000..d509db3
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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/ContactRelationshipFieldItem.h"
+#include "Contacts/Model/ContactTextField.h"
+
+#include "App/Path.h"
+#include "App/AppControlRequest.h"
+#include "Utils/Callback.h"
+#include "Utils/Logger.h"
+
+#include "InputItemLayout.h"
+
+using namespace Contacts::Input;
+using namespace Contacts::Model;
+
+namespace
+{
+       const std::string layoutPath = App::getResourcePath(INPUT_ITEM_LAYOUT_EDJ);
+}
+
+Elm_Genlist_Item_Class *ContactRelationshipFieldItem::getItemClass() const
+{
+       static Elm_Genlist_Item_Class itc = createItemClass(INPUT_REL_ITEM_STYLE);
+       return &itc;
+}
+
+Evas_Object *ContactRelationshipFieldItem::getContent(Evas_Object *parent, const char *part)
+{
+       if (strcmp(part, PART_REL_ICON) == 0) {
+               Evas_Object *button = elm_image_add(parent);
+               elm_image_file_set(button, layoutPath.c_str(), GROUP_ICON_RELATIONSHIP);
+               evas_object_smart_callback_add(button, "clicked",
+                               makeCallback(&ContactRelationshipFieldItem::onPickPressed), this);
+               return button;
+       }
+
+       return ContactTypedFieldItem::getContent(parent, part);
+}
+
+void ContactRelationshipFieldItem::onPickPressed(Evas_Object *button, void *eventInfo)
+{
+       m_AppControl = App::requestContactPick(APP_CONTROL_SELECT_SINGLE, APP_CONTROL_RESULT_ID);
+       m_AppControl.launch(makeCallbackWithLastParam(&ContactRelationshipFieldItem::onPickResult), this);
+}
+
+void ContactRelationshipFieldItem::onPickResult(app_control_h request, app_control_h reply,
+               app_control_result_e result)
+{
+       int personId = atoi(App::getSingleExtraData(reply, APP_CONTROL_DATA_SELECTED).c_str());
+       RETM_IF(personId < 1, "Invalid person ID.");
+
+       char *name = nullptr;
+       contacts_record_h record = nullptr;
+       contacts_db_get_record(_contacts_person._uri, personId, &record);
+       contacts_record_get_str_p(record, _contacts_person.display_name, &name);
+
+       getField().cast<ContactTextField>().setValue(name);
+       elm_genlist_item_fields_update(getObjectItem(), PART_MIDDLE, ELM_GENLIST_ITEM_FIELD_CONTENT);
+
+       contacts_record_destroy(record, true);
+}
index 680f6564c031dafc2c83b85ff09bd67a9b822770..dd6bb3a7f185d1870ad21bd7164b32ca17f37a22 100644 (file)
@@ -19,6 +19,7 @@
 #include "Contacts/Input/AddFieldsItem.h"
 #include "Contacts/Input/ContactCompoundFieldItem.h"
 #include "Contacts/Input/ContactImageFieldItem.h"
+#include "Contacts/Input/ContactRelationshipFieldItem.h"
 #include "Contacts/Input/ContactTypedFieldItem.h"
 #include "Contacts/Model/ContactArray.h"
 
@@ -114,6 +115,8 @@ ContactFieldItem *InputView::createFieldItem(ContactFieldPtr field)
        ContactFieldItem *item = nullptr;
        if (field->getId() == FieldImage) {
                item = new ContactImageFieldItem(std::move(field));
+       } else if (field->getId() == FieldRelationship) {
+               item = new ContactRelationshipFieldItem(std::move(field));
        } else if (field->getSubType() & ObjectTyped) {
                item = new ContactTypedFieldItem(std::move(field));
        } else if (field->getSubType() & ObjectCompound) {