Fixed wrong Choosert on Export option 70/85070/5
authorAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Tue, 23 Aug 2016 10:57:40 +0000 (13:57 +0300)
committerAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Tue, 23 Aug 2016 11:32:01 +0000 (14:32 +0300)
Change-Id: I45b35f32b13c275590fc1d1f4845e73fc640632e
Signed-off-by: Aleksandr Sapozhnik <a.sapozhnik@samsung.com>
lib-contacts/inc/Contacts/Settings/ExportItem.h
lib-contacts/src/Contacts/Settings/ExportItem.cpp

index 043e4f4..44f4019 100644 (file)
 #ifndef CONTACTS_SETTINGS_EXPORT_ITEM_H
 #define CONTACTS_SETTINGS_EXPORT_ITEM_H
 
-#include "App/AppControl.h"
+#include "Contacts/Settings/ExportController.h"
 #include "Ui/GenItem.h"
+#include "Ux/SelectTypes.h"
 #include <vector>
 
 namespace Contacts
 {
        namespace Settings
        {
-               class ExportController;
-
                /**
                 * @brief Export item
                 */
@@ -36,12 +35,9 @@ namespace Contacts
                private:
                        virtual char *getText(Evas_Object *parent, const char *part) override;
                        virtual void onSelected() override;
-                       void onPickResult(app_control_h request, app_control_h reply,
-                                       app_control_result_e result);
+                       void onStorageTypeSelected(void *data);
                        void onExportFinish(ExportController *exporter);
-                       void runExporter(void *data, std::vector<int> ids);
-
-                       App::AppControl m_AppControl;
+                       void runExporter(StorageType storageType, std::vector<int> ids);
                };
        }
 }
index 330fe33..af9eb66 100644 (file)
  */
 
 #include "Contacts/Settings/ExportItem.h"
-#include "Contacts/Settings/ExportController.h"
+
+#include "Contacts/List/ListView.h"
 #include "Contacts/Settings/Model/Storage.h"
 
-#include "App/AppControlRequest.h"
 #include "Ui/Genlist.h"
 #include "Ui/ListPopup.h"
-#include "Ui/Popup.h"
-#include "Utils/Callback.h"
-#include "Utils/Logger.h"
+#include "Ui/Navigator.h"
 
 #include <app_i18n.h>
 
 #define BUFFER_SIZE 1024
 
+using namespace Contacts::List;
 using namespace Contacts::Settings;
 using namespace Contacts::Settings::Model;
 using namespace std::placeholders;
@@ -45,30 +44,40 @@ char *ExportItem::getText(Evas_Object *parent, const char *part)
 
 void ExportItem::onSelected()
 {
-       m_AppControl = App::requestContactPick(APP_CONTROL_SELECT_MULTIPLE, APP_CONTROL_RESULT_ID);
-       m_AppControl.launch(makeCallbackWithLastParam(&ExportItem::onPickResult), this);
-}
-
-void ExportItem::onPickResult(app_control_h request, app_control_h reply,
-               app_control_result_e result)
-{
-       std::vector<int> ids = App::getIntExtraDataArray(reply, APP_CONTROL_DATA_SELECTED);
-       RETM_IF(ids.empty(), "Person id list is empty.");
-       StorageType storageType = StorageDevice;
+       Ui::ListPopup *popup = new Ui::ListPopup();
+       popup->create(getParent()->getEvasObject());
+       popup->setTitle("IDS_PB_HEADER_IMPORT");
 
        if (isAccessGranted(STORAGE_TYPE_EXTERNAL, StorageAccessWrite)) {
-               Ui::ListPopup *popup = new Ui::ListPopup();
-               popup->create(getParent()->getEvasObject());
-               popup->setTitle("IDS_PB_HEADER_IMPORT");
                popup->addItem("IDS_PB_OPT_SD_CARD", (void *) StorageSdCard);
-               popup->addItem("IDS_PB_OPT_DEVICE", (void *) StorageDevice);
-               popup->setSelectedCallback(std::bind(&ExportItem::runExporter, this, _1, std::move(ids)));
-               popup->show();
+       }
+       popup->addItem("IDS_PB_OPT_DEVICE", (void *) StorageDevice);
+       popup->setSelectedCallback(std::bind(&ExportItem::onStorageTypeSelected, this, _1));
+       popup->show();
+}
 
+void ExportItem::onStorageTypeSelected(void *data)
+{
+       Ui::Navigator *navigator = getParent()->findParent<Ui::Navigator>();
+       if (!navigator) {
                return;
        }
 
-       runExporter((void *) storageType, std::move(ids));
+       auto storageType = (StorageType) (long) data;
+       ListView *view = new ListView();
+       view->setSelectMode(Ux::SelectMulti);
+       view->setSelectCallback([this, storageType](Ux::SelectResults results) {
+               std::vector<int> ids;
+               ids.reserve(results.size());
+               for (auto &&result : results) {
+                       ids.push_back(result.value.id);
+               }
+
+               runExporter(storageType, std::move(ids));
+               return true;
+       });
+
+       navigator->navigateTo(view);
 }
 
 void ExportItem::onExportFinish(ExportController *exporter)
@@ -85,9 +94,8 @@ void ExportItem::onExportFinish(ExportController *exporter)
        finishPopup->show();
 }
 
-void ExportItem::runExporter(void *data, std::vector<int> ids)
+void ExportItem::runExporter(StorageType storageType, std::vector<int> ids)
 {
-       auto storageType = (StorageType) (long) data;
        ExportController *exporter = new ExportController(
                        getParent()->getEvasObject(), "IDS_PB_HEADER_EXPORT_CONTACTS_ABB",
                        std::move(ids), storageType);