TizenRefApp-6699 Implement open contact image 30/81030/3
authorSergei Kobec <s.kobec@samsung.com>
Thu, 21 Jul 2016 13:32:19 +0000 (16:32 +0300)
committerSergei Kobec <s.kobec@samsung.com>
Thu, 21 Jul 2016 13:32:19 +0000 (16:32 +0300)
Change-Id: I4f34f528f0326efc3214f724487d4413b3a6cac3
Signed-off-by: Sergei Kobec <s.kobec@samsung.com>
contacts-app/src/OperationViewController.cpp
lib-apps-common/inc/App/AppControlRequest.h
lib-apps-common/src/App/AppControlRequest.cpp
lib-contacts/inc/Contacts/Details/BasicInfoItem.h
lib-contacts/src/Contacts/Details/BasicInfoItem.cpp

index aee6bbe..97588ba 100644 (file)
@@ -28,8 +28,6 @@
 #include <string.h>
 #include <sys/stat.h>
 
-#define APP_CONTROL_URI_PATH "file://"
-
 using namespace Common::Database;
 using namespace Contacts;
 using namespace Contacts::Details;
@@ -52,7 +50,7 @@ void OperationViewController::onRequest(Operation operation, app_control_h reque
                        view = new DetailsView(getDisplayContactId(personId));
                }
        } else {
-               std::string path = getUrn(APP_CONTROL_URI_PATH);
+               std::string path = getUrn(APP_CONTROL_URI_SCHEME_FILE);
                struct stat buffer;
                if (stat(path.c_str(), &buffer) == 0) {
                        view = new VcardView(path);
index df98222..afd1de2 100644 (file)
 
 #define APP_CONTROL_OPERATION_SETTING_CALL "http://tizen.org/appcontrol/operation/setting/call"
 
-#define APP_CONTROL_MIME_CONTACT "application/vnd.tizen.contact"
+#define APP_CONTROL_MIME_CONTACT    "application/vnd.tizen.contact"
+#define APP_CONTROL_MIME_IMAGE      "image/*"
+
+#define APP_CONTROL_URI_SCHEME_FILE "file://"
 
 #define APP_CONTROL_SELECT_SINGLE   "single"
 #define APP_CONTROL_SELECT_MULTIPLE "multiple"
@@ -106,6 +109,13 @@ namespace App
        AppControl EXPORT_API requestGalleryImage();
 
        /**
+        * @brief Request view image
+        * @param[in]   path    Path to image file
+        * @return AppControl wrapper
+        */
+       AppControl EXPORT_API requestViewImage(const char *path);
+
+       /**
         * @brief Request share contact via other application
         * @param[in]   personId    Contact's person ID
         * @return AppControl wrapper
index 3bc2fe7..8bed893 100644 (file)
@@ -76,16 +76,22 @@ AppControl App::requestMessageComposer(const char *scheme, const char *to,
 
 AppControl App::requestCameraImage()
 {
-       return AppControl(APP_CONTROL_OPERATION_CREATE_CONTENT, "image/*");
+       return AppControl(APP_CONTROL_OPERATION_CREATE_CONTENT, APP_CONTROL_MIME_IMAGE);
 }
 
 AppControl App::requestGalleryImage()
 {
-       AppControl request(APP_CONTROL_OPERATION_PICK, "image/*");
+       AppControl request(APP_CONTROL_OPERATION_PICK, APP_CONTROL_MIME_IMAGE);
        app_control_set_app_id(request.getHandle(), "org.tizen.ug-gallery-efl");
        return request;
 }
 
+AppControl App::requestViewImage(const char *path)
+{
+       return AppControl(APP_CONTROL_OPERATION_VIEW, APP_CONTROL_MIME_IMAGE,
+                       std::string(APP_CONTROL_URI_SCHEME_FILE).append(path).c_str());
+}
+
 AppControl App::requestShareContact(int personId)
 {
        AppControl request(APP_CONTROL_OPERATION_SHARE, APP_CONTROL_MIME_CONTACT);
index 7ba7a79..b7e73dd 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef CONTACTS_DETAILS_BASIC_INFO_ITEM_H
 #define CONTACTS_DETAILS_BASIC_INFO_ITEM_H
 
+#include "App/AppControl.h"
 #include "Ui/GenItem.h"
 #include "Ux/SelectTypes.h"
 
@@ -96,6 +97,7 @@ namespace Contacts
 
                        void onBackPressed(Evas_Object *button, void *eventInfo);
                        void onFavChanged(Evas_Object *check, void *eventInfo);
+                       void onImageClicked(Evas_Object *image, void *eventInfo);
                        void onFieldUpdated(Model::ContactField &field, contacts_changed_e change);
 
                        Model::Contact &m_Contact;
@@ -113,6 +115,8 @@ namespace Contacts
 
                        Ux::SelectMode m_SelectMode;
                        BackCallback m_OnBackPressed;
+
+                       App::AppControl m_Request;
                };
        }
 }
index b4c5d7c..b309e18 100644 (file)
@@ -21,6 +21,7 @@
 #include "Contacts/Model/ContactCompoundObject.h"
 #include "Contacts/Model/ContactTextField.h"
 
+#include "App/AppControlRequest.h"
 #include "Ui/Genlist.h"
 #include "Ui/Thumbnail.h"
 #include "Utils/Callback.h"
@@ -94,6 +95,9 @@ Evas_Object *BasicInfoItem::getContent(Evas_Object *parent, const char *part)
        if (strcmp(part, PART_THUMBNAIL) == 0) {
                auto control = Ui::Thumbnail::create(parent, Ui::Thumbnail::SizeLarge);
                control->setImagePath(m_ImagePath.getValue());
+               evas_object_smart_callback_add(control->getImage(), "clicked",
+                       makeCallback(&BasicInfoItem::onImageClicked), this);
+
                return control->getEvasObject();
        }
 
@@ -163,6 +167,15 @@ void BasicInfoItem::onFavChanged(Evas_Object *check, void *eventInfo)
        m_Contact.save();
 }
 
+void BasicInfoItem::onImageClicked(Evas_Object *image, void *eventInfo)
+{
+       const char *path = m_ImagePath.getValue();
+       if (path) {
+               m_Request = App::requestViewImage(path);
+               m_Request.launch();
+       }
+}
+
 void BasicInfoItem::onFieldUpdated(ContactField &field, contacts_changed_e change)
 {
        if (&field == &m_Contact && change == CONTACTS_CHANGE_DELETED) {