TizenRefApp-5385 Implement contact image field popup in Input view. 04/56904/3
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Wed, 13 Jan 2016 13:50:02 +0000 (15:50 +0200)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 14 Jan 2016 07:46:25 +0000 (09:46 +0200)
Change-Id: I87c0e88562c1d20541be400f6431d59d360f6d49
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-common/inc/App/AppControlRequest.h
lib-common/src/App/AppControlRequest.cpp
lib-contact/inc/Contacts/Input/ContactImageFieldControl.h
lib-contact/res/input/edje/InputItemLayoutMetrics.h
lib-contact/res/input/edje/input-item-layout.edc
lib-contact/src/Contacts/Input/ContactImageFieldControl.cpp
lib-contact/src/Contacts/Input/InputView.cpp
main-app/tizen-manifest.xml
main-app/tizen-manifest.xml.in

index b8b8b7a63623a712ada39e785af912481c1c4542..ed5bce0b35247a7a1d69625465aac4a4acde8932 100644 (file)
@@ -87,6 +87,18 @@ namespace App
         */
        AppControl EXPORT_API requestMessageComposer(const char *scheme, const char *to,
                        const char *subject = nullptr, const char *text = nullptr);
+
+       /**
+        * @brief Request camera image capture
+        * @return AppControl wrapper
+        */
+       AppControl EXPORT_API requestCameraImage();
+
+       /**
+        * @brief Request pick image from gallery
+        * @return AppControl wrapper
+        */
+       AppControl EXPORT_API requestGalleryImage();
 }
 
 #endif /* APP_APP_CONTROL_REQUEST_H */
index 3a6ded3f209e954c8ad1ee1db6aae8f66dc5285a..18de98a92950a0a88581517d738d88bca184fe26 100644 (file)
@@ -73,3 +73,13 @@ AppControl App::requestMessageComposer(const char *scheme, const char *to,
        request.addExtra(APP_CONTROL_DATA_TEXT, text);
        return request;
 }
+
+AppControl App::requestCameraImage()
+{
+       return AppControl(APP_CONTROL_OPERATION_CREATE_CONTENT, "image/*");
+}
+
+AppControl App::requestGalleryImage()
+{
+       return AppControl(APP_CONTROL_OPERATION_PICK, "image/*");
+}
index bbae8d8a1a2ae74734551f3f5f5d165df28febfe..19be449e900441698f2829508843ae7c0ac9f9e2 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef CONTACTS_INPUT_CONTACT_IMAGE_FIELD_CONTROL_H
 #define CONTACTS_INPUT_CONTACT_IMAGE_FIELD_CONTROL_H
 
+#include "App/AppControl.h"
 #include "Ui/Thumbnail.h"
 
 namespace Contacts
@@ -43,9 +44,14 @@ namespace Contacts
 
                private:
                        virtual void onCreated() override;
+
+                       void updateImage();
+                       void onImageResult(app_control_h request, app_control_h reply,
+                                       app_control_result_e result);
                        void onImagePressed(Evas_Object *image, void *eventInfo);
 
                        Model::ContactTextField *m_Field;
+                       App::AppControl m_AppControl;
                };
        }
 }
index 4ae816a7a191e0fb2417c39b2df66b662104256d..47bdee1e49c22312688de94713ec611778d603b8 100644 (file)
@@ -31,9 +31,9 @@
 #define ITEM_RIGHT_X1 2
 #define ITEM_RIGHT_X2 10
 
-#define IMAGE_H 166
-#define IMAGE_ITEM_H 182
-#define IMAGE_ITEM_PADDING_Y (IMAGE_ITEM_H-IMAGE_H)/2
+#define IMAGE_SIZE 240
+#define IMAGE_ITEM_PADDING_Y 44
+#define IMAGE_ITEM_H (IMAGE_SIZE+IMAGE_ITEM_PADDING_Y*2)
 
 #define BUTTONS_ITEM_H 247
 #define BUTTONS_ITEM_PADDING_Y 22
index 8e5090c936a2b7c537216e79919ba54d01ad8d83..de0a53175b77c889f8ce95b19e6648599154b98e 100644 (file)
@@ -91,20 +91,17 @@ collections
                alias: "elm/genlist/tree/"INPUT_IMAGE_ITEM_STYLE"/default";
                alias: "elm/genlist/tree_compress/"INPUT_IMAGE_ITEM_STYLE"/default";
 
-               data.item: "banded_bg_area" "swallow.bg";
                data.item: "contents" "swallow.content";
 
                parts {
-                       swallow { "swallow.bg"; }
                        spacer { "spacer.base"; scale;
                                desc { "default";
                                        min: 0 IMAGE_ITEM_H;
                                }
                        }
-                       swallow { "swallow.content";
+                       swallow { "swallow.content"; scale;
                                desc { "default";
-                                       rel1.relative: 0.0 IMAGE_ITEM_PADDING_Y/IMAGE_ITEM_H;
-                                       rel2.relative: 1.0 1.0-IMAGE_ITEM_PADDING_Y/IMAGE_ITEM_H;
+                                       max: IMAGE_SIZE IMAGE_SIZE;
                                }
                        }
                }
index 60ddd1c345874d679aee85b3fb0e33636d6064e0..338f031c9697607eed160a0e929e143964b65c2e 100644 (file)
 
 #include "Contacts/Input/ContactImageFieldControl.h"
 #include "Contacts/Model/ContactTextField.h"
+
+#include "App/AppControlRequest.h"
+#include "Ui/ListPopup.h"
 #include "Utils/Callback.h"
+#include "Utils/Logger.h"
 
 using namespace Contacts::Input;
 using namespace Contacts::Model;
 
 ContactImageFieldControl::ContactImageFieldControl(ContactTextField *field)
-       : Thumbnail(Thumbnail::SizeMedium), m_Field(field)
+       : Thumbnail(Thumbnail::SizeLarge), m_Field(field)
 {
 }
 
 void ContactImageFieldControl::onCreated()
 {
-       setImagePath(m_Field->getValue());
+       setSizeHint(true);
+       updateImage();
        evas_object_smart_callback_add(getImage(), "clicked",
                        makeCallback(&ContactImageFieldControl::onImagePressed), this);
 }
 
+void ContactImageFieldControl::updateImage()
+{
+       setImagePath(m_Field->getValue());
+}
+
+void ContactImageFieldControl::onImageResult(app_control_h request, app_control_h reply,
+               app_control_result_e result)
+{
+       char **imagePath = nullptr;
+       int count = 0;
+
+       int err = app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &imagePath, &count);
+       RETM_IF_ERR(err, "app_control_get_extra_data_array() failed.")
+
+       if (count > 0) {
+               m_Field->setValue(imagePath[0]);
+               updateImage();
+       }
+
+       for (int i = 0; i < count; ++i) {
+               free(imagePath[i]);
+       }
+       free(imagePath);
+}
+
 void ContactImageFieldControl::onImagePressed(Evas_Object *image, void *eventInfo)
 {
-       //TODO: Show popup
+       Ui::ListPopup *popup = new Ui::ListPopup();
+       popup->create(getEvasObject());
+       popup->setTitle("IDS_PB_HEADER_SET_CONTACT_PICTURE_ABB");
+       popup->addItem("IDS_PB_OPT_FROM_GALLERY_ABB2", [this] {
+               m_AppControl = App::requestGalleryImage();
+               m_AppControl.launch(makeCallbackWithLastParam(&ContactImageFieldControl::onImageResult), this);
+       });
+       popup->addItem("IDS_PB_OPT_TAKE_PICTURE_ABB", [this] {
+               m_AppControl = App::requestCameraImage();
+               m_AppControl.launch(makeCallbackWithLastParam(&ContactImageFieldControl::onImageResult), this);
+       });
+
+       if (!m_Field->isEmpty()) {
+               popup->addItem("IDS_PB_OPT_REMOVE", [this] {
+                       m_Field->reset();
+                       updateImage();
+               });
+       }
 }
index 97476082f0406b35f39953bc113b7262f4fb2c2e..680f6564c031dafc2c83b85ff09bd67a9b822770 100644 (file)
@@ -62,9 +62,10 @@ void InputView::onCreated()
        int err = m_Contact.initialize(m_RecordId);
        RETM_IF_ERR(err, "Contact::initialize() failed.");
 
+       addFieldItem(addField(FieldImage));
+       addFieldItem(addField(FieldName));
+
        if (m_Contact.isNew()) {
-               addFieldItem(addField(FieldImage));
-               addFieldItem(addField(FieldName));
                addFieldItem(addField(FieldNumber));
                return;
        }
@@ -77,7 +78,7 @@ void InputView::onCreated()
                                }
                                break;
                        case TypeObject:
-                               if (!field->isEmpty()) {
+                               if (!m_Items[field->getId()] && !field->isEmpty()) {
                                        m_AddFieldsItem->setAddFieldState(ContactFieldId(field->getId()), false);
                                        addFieldItem(std::move(field));
                                }
index 6d99c384801a1c5a3b6e4558d83849e563a28ea4..1b6695d10b9d2716c02c424adc85d43d1a611614 100644 (file)
         <privilege>http://tizen.org/privilege/callhistory.read</privilege>
         <privilege>http://tizen.org/privilege/contact.read</privilege>
         <privilege>http://tizen.org/privilege/contact.write</privilege>
+        <privilege>http://tizen.org/privilege/mediastorage</privilege>
         <privilege>http://tizen.org/privilege/notification</privilege>
     </privileges>
 </manifest>
index f6e6f733d15de2b76dd14c066207c53fea798a1c..fe49e54c9d6c130b5967a898bffbd9e31d871ecf 100644 (file)
                <privilege>http://tizen.org/privilege/callhistory.read</privilege>
                <privilege>http://tizen.org/privilege/contact.read</privilege>
                <privilege>http://tizen.org/privilege/contact.write</privilege>
+               <privilege>http://tizen.org/privilege/mediastorage</privilege>
                <privilege>http://tizen.org/privilege/notification</privilege>
        </privileges>
 </manifest>