#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
*/
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);
};
}
}
*/
#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;
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)
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);