--- /dev/null
+/*
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef CONTACTS_CHOOSER_CHOOSER_POPUP_H
+#define CONTACTS_CHOOSER_CHOOSER_POPUP_H
+
+#include "Ui/ListPopup.h"
+#include "Ux/SelectTypes.h"
+#include "Contacts/Model/ContactObject.h"
+
+namespace Contacts
+{
+ namespace Chooser
+ {
+ /**
+ * @brief Provides ability to choose data from contact.
+ */
+ class ChooserPopup : public Ui::ListPopup
+ {
+ public:
+ /**
+ * @brief Create popup.
+ * @param[in] contactId _contacts_contact record ID
+ * @param[in] filterType Bitmask filter for contact fields
+ * @see FilterType
+ */
+ explicit ChooserPopup(int contactId, int filterType);
+ virtual ~ChooserPopup() override;
+
+ /**
+ * @brief Set selection callback.
+ * @param[in] callback Item selection callback
+ */
+ void setSelectCallback(Ux::SelectCallback callback);
+
+ protected:
+ virtual void onCreated() override;
+ virtual char *getItemText(void *data, const char *part) override;
+ virtual void onItemSelected(void *data) override;
+
+ private:
+ Model::ContactObject m_Contact;
+ contacts_record_h m_Record;
+ int m_FilterType;
+ Ux::SelectCallback m_OnSelected;
+ };
+ }
+}
+
+#endif /* CONTACTS_CHOOSER_CHOOSER_POPUP_H */
--- /dev/null
+/*
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Contacts/Chooser/ChooserPopup.h"
+#include "Contacts/Model/ContactArray.h"
+#include "Contacts/Model/ContactFieldMetadata.h"
+#include "Contacts/Model/ContactObject.h"
+#include "Contacts/Model/ContactTextField.h"
+#include "Contacts/Model/ContactTypedObject.h"
+#include "Contacts/Common/Strings.h"
+#include "Common/Strings.h"
+
+#include <app_i18n.h>
+
+using namespace Common;
+using namespace Contacts::Model;
+using namespace Contacts::Chooser;
+
+ChooserPopup::ChooserPopup(int contactId, int filterType)
+ : ListPopup("type2"),
+ m_Contact(nullptr, *getContactMetadata(ObjectTypeContact)),
+ m_FilterType(filterType)
+{
+ contacts_db_get_record(_contacts_contact._uri, contactId, &m_Record);
+ m_Contact.initialize(m_Record);
+}
+
+ChooserPopup::~ChooserPopup()
+{
+ contacts_record_destroy(m_Record, true);
+}
+
+void ChooserPopup::setSelectCallback(Ux::SelectCallback callback)
+{
+ m_OnSelected = std::move(callback);
+}
+
+void ChooserPopup::onCreated()
+{
+ setTitle(m_Contact.getFieldById<ContactTextField>(FieldDisplayName)->getValue());
+
+ for (auto &&field : m_Contact) {
+ if (!(m_FilterType & (1 << field.getSubType()))) {
+ continue;
+ }
+
+ switch (field.getType()) {
+ case TypeArray:
+ for (auto &&element : field.cast<ContactArray>()) {
+ addItem(&element.cast<ContactObject>());
+ }
+ break;
+ case TypeObject:
+ if (!field.isEmpty()) {
+ addItem(&field.cast<ContactObject>());
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+char *ChooserPopup::getItemText(void *data, const char *part)
+{
+ ContactObject &object = *(ContactObject *) data;
+ ContactField &field = *object.getField(0);
+ if (strcmp(part, "elm.text") == 0) {
+ if (field.getType() == TypeText) {
+ return Utils::safeDup(field.cast<ContactTextField>().getValue());
+ }
+ } else if (strcmp(part, "elm.text.sub") == 0) {
+ const char *name = nullptr;
+ if (object.getInterfaces() & InterfaceTypedObject) {
+ auto &typedObject = object.cast<ContactTypedObject>();
+ auto &typeField = typedObject.getTypeField();
+ auto &labelField = typedObject.getLabelField();
+
+ if (typeField.hasCustomValue()) {
+ name = labelField.getValue();
+ } else {
+ EnumType type = EnumType(typeField.getSubType());
+ name = _(getEnumValueName(type, typeField.getValue()));
+ }
+ } else {
+ name = _(Common::getContactFieldName(ContactFieldId(object.getId())));
+ }
+
+ return Utils::safeDup(name);
+ }
+
+ return nullptr;
+}
+
+void ChooserPopup::onItemSelected(void *data)
+{
+ ContactObject &object = *(ContactObject *) data;
+ Ux::SelectResult result = { object.getSubType(), object.getRecordId() };
+ if (m_OnSelected) {
+ m_OnSelected({ result });
+ }
+}
*/
#include "Contacts/Chooser/ChooserView.h"
+#include "Contacts/Chooser/ChooserPopup.h"
#include "Contacts/Chooser/ContactsGroupsNavigator.h"
#include "Contacts/Groups/GroupsView.h"
#include "Contacts/List/ListView.h"
#include "Contacts/List/PersonItem.h"
#include "Contacts/List/Model/Person.h"
-
-#include "Contacts/Details/DetailsView.h"
#include "Contacts/Settings/ExportController.h"
#include "Common/Actions.h"
using namespace Contacts;
using namespace Contacts::Chooser;
using namespace Contacts::List;
-using namespace Contacts::Details;
using namespace Contacts::Groups;
using namespace Contacts::Groups::Model;
using namespace Ux;
return callback({ result });
}
- DetailsView *view = new DetailsView(getDisplayContactId(person.value.id),
- DetailsView::Type(person.type), m_FilterType);
- view->setSelectMode(SelectSingle);
- view->setSelectCallback(callback);
- getNavigator()->navigateTo(view);
+ auto popup = new ChooserPopup(getDisplayContactId(person.value.id), m_FilterType);
+ popup->create(getEvasObject());
+ popup->setSelectCallback(callback);
+ popup->show();
return false;
}