InputLayout &getLayout();
protected:
+ virtual void onInputPanelHide() {};
+
// NaviFrameItem
void onAttached(ViewItem &item) override;
*/
#include "InputFrame.h"
-#include "PopupManager.h"
using namespace Msg;
{
switch (value) {
case ECORE_IMF_INPUT_PANEL_STATE_HIDE: {
- BasePopup *popup = App::getInst().getPopupManager().getTop();
- if (!isPause() && !(popup && popup->isVisible()))
- pop();
+ onInputPanelHide();
break;
}
}
#include "MsgTypes.h"
#include <string>
+#include <list>
namespace Msg {
class Recipient {
public:
+ Recipient(std::string address, std::string dispName);
Recipient();
~Recipient();
*/
static Recipient searchFirstRecip(const std::string &searchWord);
+
+ /**
+ * @brief Search all recipient in ContactPersonNumber and ContactPersonPhoneLog based on a given search word.
+ * @param searchWord - search keyword
+ * @return list of recipients
+ */
+ static std::list<Recipient> searchRecips(const std::string &searchWord);
+
/**
* @brief Get recipient by ThreadId
* @param id valid thread id
namespace {
template<typename ContactRec>
- std::shared_ptr<ContactRec> searchContact(const std::string &searchWord)
+ bool isValid(const ContactRec &rec)
+ {
+ return rec.isValid() && MsgUtils::isValidAddress(rec.getAddress());
+ }
+
+ template<typename ContactRec>
+ std::shared_ptr<ContactRec> searchFirstContact(const std::string &searchWord)
{
if (!searchWord.empty()) {
auto list = App::getInst().getContactManager().search<ContactRec>(searchWord);
if (list) {
do {
auto &rec = list->get();
- if (rec.isValid() && MsgUtils::isValidAddress(rec.getAddress())) {
+ if (isValid(rec)) {
return std::static_pointer_cast<ContactRec>(rec.clone());
} else {
MSG_LOG("Skip invalid contact: ", rec.getAddress());
}
return {};
}
+
+ template<typename ContactRec>
+ std::list<Recipient> searchContacts(const std::string &searchWord)
+ {
+ std::list<Recipient> results;
+ if (!searchWord.empty()) {
+ auto list = App::getInst().getContactManager().search<ContactRec>(searchWord);
+ if (list) {
+ do {
+ auto &rec = list->get();
+ if (isValid(rec)) {
+ results.emplace_back(Recipient(rec.getAddress(), rec.getDispName()));
+ } else {
+ MSG_LOG("Skip invalid contact: ", rec.getAddress());
+ }
+ } while (list->next());
+ }
+ }
+ return results;
+ }
}
Recipient::Recipient()
{
}
+Recipient::Recipient(std::string address, std::string dispName)
+ : m_Address(address)
+ , m_DispName(dispName)
+{
+}
+
Recipient::~Recipient()
{
}
{
Recipient res;
- auto numberRef = searchContact<ContactPersonNumber>(searchWord);
+ auto numberRef = searchFirstContact<ContactPersonNumber>(searchWord);
if (numberRef) {
res.m_Address = numberRef->getAddress();
res.m_DispName = numberRef->getDispName();
} else {
- auto phoneLogRef = searchContact<ContactPersonPhoneLog>(searchWord);
+ auto phoneLogRef = searchFirstContact<ContactPersonPhoneLog>(searchWord);
if (phoneLogRef)
res.m_Address = phoneLogRef->getAddress();
}
return res;
}
+std::list<Recipient> Recipient::searchRecips(const std::string &searchWord)
+{
+ std::list<Recipient> result;
+ result = searchContacts<ContactPersonNumber>(searchWord);
+ result.splice(result.end(), searchContacts<ContactPersonPhoneLog>(searchWord));
+ return result;
+}
+
Recipient Recipient::getByThreadId(ThreadId id)
{
Recipient res;
LineListViewItem(std::string titleText = std::string());
virtual ~LineListViewItem();
+ void setText(std::string text);
+
protected:
void onAttached(ViewItem &item) override;
setSelectable(false);
}
+void LineListViewItem::setText(std::string text)
+{
+ m_TitleText = std::move(text);
+}
+
std::string LineListViewItem::getText(ListItem &item, const char *part)
{
if (!strcmp(part, "elm.text"))
{
setEo(elm_genlist_add(parent));
setMode(ELM_LIST_COMPRESS);
+ setMultiSelection(false);
addSmartCb("realized", ListView::on_realized_cb, this);
addSmartCb("unrealized", ListView::on_unrealized_cb, this);
addSmartCb("longpressed", ListView::on_longpressed_cb, this);
Evas_Object *button = addIconButton(getEo(), "prediction_icon", makeCbFirst(&SearchBar::onButtonClicked), this);
setContent(button, "swl.button");
addSignalCb("mouse,clicked,*", "elm.text", makeCbFirst(&SearchBar::onTextClicked), this);
+ elm_object_tree_focus_allow_set(getEo(), false);
}
void SearchBar::setListener(ISearchBarListener *l)
#include "FrameController.h"
#include "ListView.h"
-#include "ContactAddress.h"
+#include "LineListViewItem.h"
+#include "Recipient.h"
namespace Msg {
class IContactFrameListener;
+ class PaddingListViewItem;
class ContactFrame
: public FrameController
, private IListViewListener {
public:
- ContactFrame(NaviFrameController &parent);
+ ContactFrame(NaviFrameController &parent, std::list<Recipient> recips, std::string searchWord);
virtual ~ContactFrame();
void setListener(IContactFrameListener *l);
private:
void prepareList();
+ void updateList();
+ void updateCounterItem();
+ void fillList(std::list<Recipient> recips);
private:
ListView *m_pList;
IContactFrameListener *m_pListener;
+ std::string m_SearchWord;
+ LineListViewItem *m_pInfoItem;
+ int m_ItemsCount;
};
class IContactFrameListener {
public:
virtual ~IContactFrameListener() {}
- virtual void onContactSelected(ContactAddressRef &contact) {};
+ virtual void onContactSelected(ContactFrame &sender, const Recipient &recip) {};
};
}
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 ContactListItem_h_
+#define ContactListItem_h_
+
+#include "ContactListViewItem.h"
+#include "Recipient.h"
+
+namespace Msg {
+ class ContactListItem
+ : public ContactListViewItem {
+
+ public:
+ ContactListItem(Recipient recip, const std::string &searchWord);
+ virtual ~ContactListItem();
+
+ const Recipient &getRecip() const;
+
+ private:
+ std::string getSubText() override;
+ std::string getMainText() override;
+
+ private:
+ Recipient m_Recip;
+ std::string m_DispName;
+ std::string m_Address;
+ };
+}
+
+#endif // ContactListItem_h_
#include "InputFrame.h"
#include "SearchBar.h"
#include "Recipient.h"
+#include "ContactFrame.h"
namespace Msg {
class RecipInputFrame
: public InputFrame
- , private ISearchBarListener {
+ , private ISearchBarListener
+ , private IContactFrameListener{
public:
RecipInputFrame(NaviFrameController &parent, const Recipient &recip);
const Recipient &getRecip() const;
private:
- // NaviFrameItem:
+ // NaviFrame:
void onAttached(ViewItem &item) override;
- bool onRequestPop() override;
+ void onInputPanelHide() override;
+
// Entry:
void onEntryChanged(Evas_Object *obj, void *event_info);
void onButtonClicked(SearchBar &obj) override;
void onTextClicked(SearchBar &obj) override;
+ // ISearchBarListener:
+ void onContactSelected(ContactFrame &sender, const Recipient &recip) override;
+
// Timer:
Eina_Bool onSearchTimerTick();
void reqestSearch();
void cancelSearch();
void searchButtonHandler();
+ void navigateToContactFrame(std::list<Recipient> recips, std::string searchWord);
private:
SearchBar *m_pSearchBar;
Ecore_Timer *m_pTimer;
Recipient m_Recip;
+ bool m_IsClosed;
};
}
*/
#include "ContactFrame.h"
+#include "PaddingListViewItem.h"
+#include "LineListViewItem.h"
+#include "ContactListItem.h"
+#include "App.h"
+#include "Window.h"
using namespace Msg;
-ContactFrame::ContactFrame(NaviFrameController &parent)
+ContactFrame::ContactFrame(NaviFrameController &parent, std::list<Recipient> recips, std::string searchWord)
: FrameController(parent)
, m_pList(nullptr)
, m_pListener(nullptr)
+ , m_SearchWord(std::move(searchWord))
+ , m_pInfoItem(nullptr)
+ , m_ItemsCount(0)
{
MSG_LOG("");
prepareList();
+ fillList(std::move(recips));
}
ContactFrame::~ContactFrame()
void ContactFrame::prepareList()
{
if (!m_pList) {
- m_pList = new ListView(getParent());
+ m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface());
m_pList->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&ContactFrame::onHwBackButtonPreessed), this);
m_pList->setHomogeneous(false);
- m_pList->setMultiSelection(false);
m_pList->setListener(this);
}
}
+void ContactFrame::updateList()
+{
+
+}
+
+void ContactFrame::updateCounterItem()
+{
+ if (m_pInfoItem)
+ m_pInfoItem->setText(msgArgs("WDS_PB_HEADER_PD_RESULTS_FOUND_ABB", m_ItemsCount));
+}
+
+void ContactFrame::fillList(std::list<Recipient> recips)
+{
+ m_ItemsCount = recips.size();
+
+ m_pList->clear();
+
+ // Top padding:
+ m_pList->appendItem(*new PaddingListViewItem);
+
+ m_pInfoItem = new LineListViewItem;
+ updateCounterItem();
+ m_pList->appendItem(*m_pInfoItem);
+
+ for (Recipient recip : recips) {
+ auto *item = new ContactListItem(std::move(recip), m_SearchWord);
+ m_pList->appendItem(*item);
+ }
+
+ // Bottom padding:
+ m_pList->appendItem(*new PaddingListViewItem);
+}
+
void ContactFrame::onAttached(ViewItem &item)
{
MSG_LOG("");
void ContactFrame::onListItemSelected(ListItem &listItem)
{
MSG_LOG("");
- if (m_pListener) {
- // TODO: impl.
+
+ auto *item = dynamic_cast<ContactListItem*>(&listItem);
+ if (item) {
+ if (m_pListener)
+ m_pListener->onContactSelected(*this, item->getRecip());
+ pop();
}
}
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "ContactListItem.h"
+#include "TextDecorator.h"
+
+using namespace Msg;
+
+ContactListItem::ContactListItem(Recipient recip, const std::string &searchWord)
+ : m_Recip(std::move(recip))
+{
+ ListItemStyleRef style = recip.getDispName().empty() ? text1 : text2;
+ setStyle(style);
+
+ m_DispName = TextDecorator::highlightKeyword(recip.getDispName(), searchWord);
+ m_Address = TextDecorator::highlightKeyword(recip.getAddress(), searchWord);
+}
+
+ContactListItem::~ContactListItem()
+{
+}
+
+const Recipient &ContactListItem::getRecip() const
+{
+ return m_Recip;
+}
+
+std::string ContactListItem::getSubText()
+{
+ return m_Address;
+}
+
+std::string ContactListItem::getMainText()
+{
+ return m_DispName;
+}
#include "TextDecorator.h"
#include "MsgUtils.h"
#include "ToastPopup.h"
+#include "PopupManager.h"
+#include "ContactFrame.h"
#include <Eina.h>
, m_pSearchBar(nullptr)
, m_pTimer(nullptr)
, m_Recip(recip)
+ , m_IsClosed(false)
{
prepareEntry(m_Recip.getAddress());
}
{
if (show && !m_pSearchBar) {
m_pSearchBar = new SearchBar(getLayout());
+ m_pSearchBar->setListener(this);
setPredictBar(*m_pSearchBar);
}
showPredictBar(show);
void RecipInputFrame::close(std::string address, std::string dispName)
{
- setRecip(std::move(address), std::move(dispName));
- cancelSearch();
- pop();
+ if (!m_IsClosed) {
+ m_IsClosed = true;
+ setRecip(std::move(address), std::move(dispName));
+ cancelSearch();
+ pop();
+ }
}
Eina_Bool RecipInputFrame::onSearchTimerTick()
return;
}
- Recipient recip = Recipient::searchFirstRecip(input);
- if (recip.isValid()) {
- // TODO: impl.
+ auto recips = Recipient::searchRecips(input);
+ if (!recips.empty()) {
+ navigateToContactFrame(std::move(recips), std::move(input));
} else {
if (MsgUtils::isValidNumber(input)) {
close();
}
}
-void RecipInputFrame::onAttached(ViewItem &item)
+void RecipInputFrame::navigateToContactFrame(std::list<Recipient> recips, std::string searchWord)
{
- MSG_LOG("");
- InputFrame::onAttached(item);
+ auto *frame = new ContactFrame(getParent(), std::move(recips), std::move(searchWord));
+ frame->setListener(this);
+ addToGroup(*frame);
+ getParent().push(*frame);
}
-bool RecipInputFrame::onRequestPop()
+void RecipInputFrame::onAttached(ViewItem &item)
{
- cancelSearch();
- setRecip();
- return true;
+ MSG_LOG("");
+ InputFrame::onAttached(item);
}
void RecipInputFrame::onEntryFilter(Evas_Object *obj, char **text)
if (isSeparatorChar(*text)) {
free(*text);
*text = nullptr;
- close();
+ std::string text = getEntry().getText();
+ close(text, text);
}
}
}
searchButtonHandler();
}
+void RecipInputFrame::onInputPanelHide()
+{
+ MSG_LOG("");
+ BasePopup *popup = App::getInst().getPopupManager().getTop();
+ if (!isPause() && !(popup && popup->isVisible())) {
+ std::string text = getEntry().getText();
+ close(text, text);
+ }
+}
+
+void RecipInputFrame::onContactSelected(ContactFrame &sender, const Recipient &recip)
+{
+ MSG_LOG("");
+ close(recip.getAddress(), recip.getDispName());
+}
+
virtual ~ContactListViewItem();
protected:
- static ListItemStyleRef logStyle;
- static ListItemStyleRef nameOrEmailStyle;
+ static ListItemStyleRef text1;
+ static ListItemStyleRef text2;
virtual std::string getSubText() = 0;
virtual std::string getMainText() = 0;
using namespace Msg;
-ListItemStyleRef ContactListViewItem::logStyle = ListItemStyle::create("1text");
-ListItemStyleRef ContactListViewItem::nameOrEmailStyle = ListItemStyle::create("2text");
+ListItemStyleRef ContactListViewItem::text1 = ListItemStyle::create("1text");
+ListItemStyleRef ContactListViewItem::text2 = ListItemStyle::create("2text");
namespace {
const char *mainTextPart = "elm.text";
if (strcmp(part, mainTextPart) == 0)
return getMainText();
- if (getStyle() == nameOrEmailStyle && strcmp(part, subTextPart) == 0)
+ if (getStyle() == text2 && strcmp(part, subTextPart) == 0)
return getSubText();
return "";
int imageHeight = 0;
Evas_Object *image = elm_image_add(parent);
- elm_image_preload_disabled_set(image, true);
elm_image_prescale_set(image, maxWidth);
elm_image_aspect_fixed_set(image, true);
elm_image_file_set(image, path.c_str(), nullptr);