TizenRefApp-5912 Implement Share in the Contacts List 73/63873/1
authorNataliia Sydorchuk <n.sydorchuk@samsung.com>
Mon, 28 Mar 2016 08:00:21 +0000 (11:00 +0300)
committerNataliia Sydorchuk <n.sydorchuk@samsung.com>
Mon, 28 Mar 2016 08:00:47 +0000 (11:00 +0300)
Change-Id: I0cdedc8211d04d6b8e6eb020d3ff473d6e6b260f
Signed-off-by: Nataliia Sydorchuk <n.sydorchuk@samsung.com>
lib-apps-common/inc/App/AppControlRequest.h
lib-apps-common/src/App/AppControlRequest.cpp
lib-contact/inc/Contacts/List/ListView.h
lib-contact/src/Contacts/List/ListView.cpp

index 6dc07d596164712a4af665243e4326fc2da026d0..a7d1081d3d04152c96625e7340ef40d882e56fab 100644 (file)
@@ -119,6 +119,14 @@ namespace App
         */
        AppControl EXPORT_API requestShareMyProfile(int recordId);
 
+       /**
+        * @brief Request share of multiple contacts via other application
+        * @param[in]   personIds   Contact's person IDs
+        * @param[in]   count       Person IDs count
+        * @return AppControl wrapper
+        */
+       AppControl EXPORT_API requestMultiShareContacts(const char **personIds, int count);
+
        /**
         * @brief Request pick vcard(s) from filesystem
         * @param[in]   path    Path of storage from where files should be picked
index ff15cfbaed7c8e83da74381c7516d52c2dfc1294..4832d3c01572e059e597439a34cd59499a3ead54 100644 (file)
@@ -98,6 +98,13 @@ AppControl App::requestShareMyProfile(int recordId)
        return request;
 }
 
+AppControl App::requestMultiShareContacts(const char **personIds, int count)
+{
+       AppControl request(APP_CONTROL_OPERATION_MULTI_SHARE, APP_CONTROL_MIME_CONTACT);
+       request.addExtra(APP_CONTROL_DATA_ID, personIds, count);
+       return request;
+}
+
 AppControl App::requestPickVcard(const char *path)
 {
        //TODO: Replace it with AppControl which will not use application id.
index 1a66e61570371d1aaa7d9734013c094eb1806143..5549222b77cfc1f3cc22b8a846fa25a666507045 100644 (file)
@@ -60,13 +60,13 @@ namespace Contacts
                public:
                        /**
                         * @brief Create new person list view
-                        * @param]in]   filterType  Defines how to filter person list
+                        * @param[in]   filterType  Defines how to filter person list
                         */
                        ListView(int filterType = FilterNone);
 
                        /**
                         * @brief Create new vcard contact list view
-                        * @param]in]   vcardPath   Path of the vcard file
+                        * @param[in]   vcardPath   Path of the vcard file
                         */
                        explicit ListView(const char *vcardPath);
 
@@ -88,6 +88,8 @@ namespace Contacts
                        virtual void onCreated() override;
                        virtual void onMenuPressed() override;
 
+                       void onSharePressed();
+
                        virtual const char *getPageTitle() const override;
                        virtual void onSelectAllInsert(Ui::GenlistItem *item) override;
                        virtual void onSelectModeChanged(SelectMode selectMode) override;
index 19ce967363b1c5f1e4e55907e92bfadb6c9f6f6d..dd5ef2f8dbb106c2abf4095e532f9e42c86cb9e1 100644 (file)
@@ -29,6 +29,7 @@
 #include "Contacts/Input/InputView.h"
 #include "Contacts/Settings/MainView.h"
 
+#include "App/AppControlRequest.h"
 #include "Ui/Genlist.h"
 #include "Ui/Menu.h"
 #include "Ui/Navigator.h"
@@ -119,6 +120,8 @@ void ListView::onMenuPressed()
                getNavigator()->navigateTo(view);
        });
 
+       menu->addItem("IDS_PB_OPT_SHARE", std::bind(&ListView::onSharePressed, this));
+
        menu->addItem("IDS_PB_OPT_MANAGE_FAVOURITES_ABB", [this] {
                auto manageFavPopup = new ManageFavoritesPopup(getNavigator());
                manageFavPopup->create(getEvasObject());
@@ -131,6 +134,31 @@ void ListView::onMenuPressed()
        menu->show();
 }
 
+void ListView::onSharePressed()
+{
+       ListView *view = new ListView();
+       view->setSelectMode(SelectMulti);
+       view->setSelectCallback([](SelectResults results) {
+               size_t count = results.count();
+
+               std::vector<std::string> idString(count);
+               idString.reserve(count);
+               std::vector<const char *> ids(count);
+               ids.reserve(count);
+
+               for (size_t i = 0; i < count; ++i) {
+                       idString[i] = std::to_string(results[i].value.id);
+                       ids[i] = idString[i].c_str();
+               }
+               App::AppControl control = App::requestMultiShareContacts(ids.data(), count);
+               control.launch();
+               control.detach();
+
+               return true;
+       });
+       getNavigator()->navigateTo(view);
+}
+
 const char *ListView::getPageTitle() const
 {
        switch (getSelectMode()) {