From: Dmytro Dragan Date: Fri, 8 Jan 2016 13:15:07 +0000 (+0200) Subject: TizenRefApp-5399 Implement more menu popup in conversation X-Git-Tag: accepted/tizen/mobile/20160111.230500^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7043dcc4f1735938c39258aedc0ba85eb5561df4;p=profile%2Fmobile%2Fapps%2Fnative%2Fmessage.git TizenRefApp-5399 Implement more menu popup in conversation Change-Id: I6beee544954af0dfbb93d3f543090dcff4197fe6 Signed-off-by: Dmytro Dragan --- diff --git a/src/Common/View/inc/NaviFrameItem.h b/src/Common/View/inc/NaviFrameItem.h index f82e023..ad25411 100644 --- a/src/Common/View/inc/NaviFrameItem.h +++ b/src/Common/View/inc/NaviFrameItem.h @@ -95,7 +95,7 @@ namespace Msg void disabledButton(NaviButtonId id, bool value); void setButtonText(NaviButtonId id, const std::string &text); void setButtonText(NaviButtonId id, const TText &text); - void clearBar(); + void clear(); void setSearch(Evas_Object *searchPanel); Evas_Object *getSearch(); const Evas_Object *getSearch() const; @@ -123,7 +123,7 @@ namespace Msg private: struct ButtonStruct { - ButtonStruct(Evas_Object *b = nullptr, const char *p = nullptr, const char *s = nullptr, const char *d = "IDS_MSG_OPT_DEFAULT") + ButtonStruct(Evas_Object *b = nullptr, const char *p = nullptr, const char *s = nullptr, const char *d = nullptr) : button(b) , part(p) , style(s) diff --git a/src/Common/View/src/NaviFrameItem.cpp b/src/Common/View/src/NaviFrameItem.cpp index b59c5ac..89e9d9c 100644 --- a/src/Common/View/src/NaviFrameItem.cpp +++ b/src/Common/View/src/NaviFrameItem.cpp @@ -168,8 +168,8 @@ void NaviFrameItem::NaviBar::showButton(NaviButtonId id, bool value) { if(getContent(m_ButtonList[id].part) == m_ButtonList[id].button) { - elm_object_part_content_unset(getEo(),m_ButtonList[id].part); - evas_object_hide(m_ButtonList[id].button); + evas_object_del(m_ButtonList[id].button); + m_ButtonList[id].button = nullptr; } } @@ -365,13 +365,14 @@ void NaviFrameItem::NaviBar::setButtonColor(NaviButtonId id, NaviColorId titleCo } } -void NaviFrameItem::NaviBar::clearBar() +void NaviFrameItem::NaviBar::clear() { emitSignal("sides,clear", "*"); for (int iter = NaviCancelButtonId; iter < NaviButtonMax; iter++) { evas_object_hide(elm_object_part_content_unset(getEo(), m_ButtonList[iter].part)); } + showCenterButtonPart(false); } void NaviFrameItem::NaviBar::setSearch(Evas_Object *searchPanel) diff --git a/src/Conversation/Main/Controller/inc/Conversation.h b/src/Conversation/Main/Controller/inc/Conversation.h index a1c6831..7e4f967 100644 --- a/src/Conversation/Main/Controller/inc/Conversation.h +++ b/src/Conversation/Main/Controller/inc/Conversation.h @@ -87,9 +87,13 @@ namespace Msg void onPopupDel(Evas_Object *popup, void *eventInfo); void onMsgSendErrorButtonClicked(Popup &popup, int buttonId); + // ContextPopup callbacks: + void onDeleteItemPressed(ContextPopupItem &item); + void onAddRecipientsItemPressed(ContextPopupItem &item); + private: // Empty initializer constructor: - Conversation(NaviFrameController &parent, bool dummy); + Conversation(NaviFrameController &parent, const AppControlComposeRef &cmd, bool dummy); void create(); void setMode(Mode mode); void setNewMessageMode(); @@ -104,11 +108,14 @@ namespace Msg void updateNavibar(); void createMainLayout(Evas_Object *parent); void createConvList(Evas_Object *parent); - void hideKeyboard(); + void destroyConvList(); + void showMainCtxPopup(); void showNoRecipPopup(); void showSendResultPopup(MsgTransport::SendResult result); + void hideKeyboard(); + void notifyConvertMsgType(); void convertMsgTypeHandler(); void checkAndSetMsgType(); @@ -128,7 +135,7 @@ namespace Msg ThreadId m_ThreadId; bool m_IsMms; // Compose message type ConvList *m_pConvList; - AppControlComposeRef m_ComposeCmd; + const AppControlComposeRef m_ComposeCmd; }; } diff --git a/src/Conversation/Main/Controller/src/Conversation.cpp b/src/Conversation/Main/Controller/src/Conversation.cpp index 033cd29..a3510ec 100644 --- a/src/Conversation/Main/Controller/src/Conversation.cpp +++ b/src/Conversation/Main/Controller/src/Conversation.cpp @@ -32,7 +32,7 @@ using namespace Msg; -Conversation::Conversation(NaviFrameController &parent, bool dummy) +Conversation::Conversation(NaviFrameController &parent, const AppControlComposeRef &cmd, bool dummy) : FrameController(parent) , m_Mode(InitMode) , m_pLayout(nullptr) @@ -43,23 +43,21 @@ Conversation::Conversation(NaviFrameController &parent, bool dummy) , m_ThreadId() , m_IsMms(false) , m_pConvList(nullptr) - , m_ComposeCmd() + , m_ComposeCmd(cmd) { } Conversation::Conversation(NaviFrameController &parent, const AppControlComposeRef &cmd) - : Conversation(parent, false) + : Conversation(parent, cmd, false) { if(cmd) - { - m_ComposeCmd = cmd; m_ThreadId = getMsgEngine().getStorage().getThreadId(m_ComposeCmd->getRecipientList()); - } + create(); } Conversation::Conversation(NaviFrameController &parent,ThreadId threadId) - : Conversation(parent, false) + : Conversation(parent, nullptr, false) { m_ThreadId = threadId; create(); @@ -82,7 +80,6 @@ Conversation::~Conversation() void Conversation::create() { createMainLayout(getParent()); - createConvList(*m_pLayout); createMsgInputPanel(*m_pLayout); createBody(*m_pMsgInputPanel); @@ -137,7 +134,10 @@ void Conversation::setNewMessageMode() m_pLayout->showPredictSearch(true); m_pLayout->setRecipientPanel(*m_pRecipPanel); m_pLayout->setPredictSearch(*m_pContactsList); + destroyConvList(); updateNavibar(); + m_pRecipPanel->update(m_ThreadId); + m_pRecipPanel->showMbe(!m_pRecipPanel->isMbeEmpty()); } void Conversation::setConversationMode() @@ -145,6 +145,8 @@ void Conversation::setConversationMode() MSG_LOG(""); m_Mode = ConversationMode; + createConvList(*m_pLayout); + m_pLayout->showPredictSearch(false); m_pLayout->showSelectAll(false); m_pLayout->setBubble(*m_pConvList); @@ -164,8 +166,20 @@ void Conversation::createMainLayout(Evas_Object *parent) void Conversation::createConvList(Evas_Object *parent) { - m_pConvList = new ConvList(*m_pLayout, getMsgEngine(), m_ThreadId); - m_pConvList->hide(); + if(!m_pConvList) + { + m_pConvList = new ConvList(*m_pLayout, getMsgEngine(), m_ThreadId); + m_pConvList->show(); + } +} + +void Conversation::destroyConvList() +{ + if(m_pConvList) + { + m_pConvList->destroy(); + m_pConvList = nullptr; + } } void Conversation::createRecipPanel(Evas_Object *parent) @@ -235,7 +249,7 @@ void Conversation::fillMessage(Message &msg) void Conversation::fillMsgAddress(Message &msg) { - if(m_ThreadId.isValid()) + if(m_ThreadId.isValid() && m_Mode != NewMessageMode) { MsgAddressListRef addressList = getMsgEngine().getStorage().getAddressList(m_ThreadId); msg.addAddresses(*addressList); @@ -362,6 +376,16 @@ void Conversation::showSendResultPopup(MsgTransport::SendResult result) popup.show(); } +void Conversation::showMainCtxPopup() +{ + auto &ctxPopup = getApp().getPopupManager().getCtxPopup(); + + ctxPopup.appendItem(msg("IDS_MSG_OPT_DELETE"), nullptr, CTXPOPUP_ITEM_PRESSED_CB(Conversation, onDeleteItemPressed), this); + ctxPopup.appendItem(msg("IDS_MSG_OPT_ADD_RECIPIENTS_ABB"), nullptr, CTXPOPUP_ITEM_PRESSED_CB(Conversation, onAddRecipientsItemPressed), this); + ctxPopup.align(getApp().getWindow()); + ctxPopup.show(); +} + void Conversation::onKeyDown(RecipientsPanel &panel, Evas_Event_Key_Down &ev) { if(ev.keyname) @@ -415,19 +439,31 @@ void Conversation::updateMsgInputPanel() void Conversation::updateNavibar() { + getNaviBar().clear(); getNaviBar().setColor(NaviBar::NaviWhiteColorId); - std::string conversationName = getMsgEngine().getStorage().getThread(m_ThreadId)->getName(); - if(conversationName.empty()) + + if(m_Mode == NewMessageMode) { getNaviBar().setTitle(msgt("IDS_MSGF_POP_NEW_MESSAGE")); + getNaviBar().showButton(NaviPrevButtonId, true); } else { - //TODO: enable down button when needed - getNaviBar().showButton(NaviCenterButtonId, true); - getNaviBar().setButtonText(NaviCenterButtonId, conversationName); + if(m_pConvList->getMode() == ConvList::NormalMode) + { + std::string conversationName = getMsgEngine().getStorage().getThread(m_ThreadId)->getName(); + //TODO: enable down button when needed + getNaviBar().showButton(NaviCenterButtonId, true); + getNaviBar().setButtonText(NaviCenterButtonId, conversationName); + getNaviBar().showButton(NaviPrevButtonId, true); + } + else + { + getNaviBar().setTitle(msgt("IDS_MSG_OPT_DELETE")); + getNaviBar().showButton(NaviCancelButtonId, true); + getNaviBar().showButton(NaviOkButtonId, true); + } } - getNaviBar().showButton(NaviPrevButtonId, true); } void Conversation::onButtonClicked(MessageInputPanel &obj, MessageInputPanel::ButtonId id) @@ -468,6 +504,7 @@ void Conversation::onHwBackButtonClicked() if(m_pConvList && m_pConvList->getMode() == ConvList::SelectMode) { m_pConvList->setMode(ConvList::NormalMode); + updateNavibar(); return; } @@ -477,9 +514,8 @@ void Conversation::onHwBackButtonClicked() void Conversation::onHwMoreButtonClicked() { - MSG_LOG(""); - //TODO: make more menu popup. - m_pConvList->setMode(m_pConvList->getMode() == ConvList::NormalMode ? ConvList::SelectMode : ConvList::NormalMode); + if(m_Mode == ConversationMode && m_pConvList->getMode() == ConvList::NormalMode) + showMainCtxPopup(); } void Conversation::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) @@ -498,6 +534,7 @@ void Conversation::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) break; case NaviCancelButtonId: + onHwBackButtonClicked(); break; case NaviOkButtonId: @@ -520,3 +557,17 @@ void Conversation::onMsgSendErrorButtonClicked(Popup &popup, int buttonId) popup.destroy(); } +void Conversation::onDeleteItemPressed(ContextPopupItem &item) +{ + item.getParent().destroy(); + + m_pConvList->setMode(ConvList::SelectMode); + setConversationMode(); +} + +void Conversation::onAddRecipientsItemPressed(ContextPopupItem &item) +{ + item.getParent().destroy(); + + setNewMessageMode(); +} diff --git a/src/Conversation/Recipients/Controller/inc/RecipientsPanel.h b/src/Conversation/Recipients/Controller/inc/RecipientsPanel.h index 89f667d..3b6e656 100644 --- a/src/Conversation/Recipients/Controller/inc/RecipientsPanel.h +++ b/src/Conversation/Recipients/Controller/inc/RecipientsPanel.h @@ -40,6 +40,7 @@ namespace Msg void read(Message &msg); bool isMms() const; void setListener(IRecipientsPanelListener *l); + void update(const ThreadId &threadId); bool appendItem(const std::string &address, const std::string &dispName, MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); diff --git a/src/Conversation/Recipients/Controller/src/RecipientsPanel.cpp b/src/Conversation/Recipients/Controller/src/RecipientsPanel.cpp index 2c0522f..bb6044a 100644 --- a/src/Conversation/Recipients/Controller/src/RecipientsPanel.cpp +++ b/src/Conversation/Recipients/Controller/src/RecipientsPanel.cpp @@ -85,6 +85,21 @@ void RecipientsPanel::addRecipients() setEntryText(result.invalidResult); } +void RecipientsPanel::update(const ThreadId &threadId) +{ + clearMbe(); + if(threadId.isValid()) + { + MsgAddressListRef addrList = m_App.getMsgEngine().getStorage().getAddressList(threadId); + int addrListLen = addrList->getLength(); + for(int i = 0; i < addrListLen; i++) + { + auto &addr = addrList->at(i); + appendItem(addr.getAddress(), addr.getAddress(), addr.getAddressType()); + } + } +} + bool RecipientsPanel::appendItem(const std::string &address, const std::string &dispName, MsgAddress::AddressType addressType) { bool result = false; diff --git a/src/Conversation/Recipients/View/inc/RecipientsPanelView.h b/src/Conversation/Recipients/View/inc/RecipientsPanelView.h index 4b9a7ab..e763588 100644 --- a/src/Conversation/Recipients/View/inc/RecipientsPanelView.h +++ b/src/Conversation/Recipients/View/inc/RecipientsPanelView.h @@ -45,6 +45,7 @@ namespace Msg bool getEntryFocus() const; void setEntryFocus(bool val); void clearEntry(); + void clearMbe(); void setRecipientRect(Evas_Object *rect); private: diff --git a/src/Conversation/Recipients/View/src/RecipientsPanelView.cpp b/src/Conversation/Recipients/View/src/RecipientsPanelView.cpp index dfa8bfb..5b16d86 100644 --- a/src/Conversation/Recipients/View/src/RecipientsPanelView.cpp +++ b/src/Conversation/Recipients/View/src/RecipientsPanelView.cpp @@ -68,6 +68,11 @@ void RecipientsPanelView::clearEntry() elm_object_text_set(m_pEntry, ""); } +void RecipientsPanelView::clearMbe() +{ + elm_multibuttonentry_clear(m_pMbe); +} + RecipientViewItemList RecipientsPanelView::getItems() const { RecipientViewItemList res; diff --git a/src/MsgThread/Controller/src/MsgThread.cpp b/src/MsgThread/Controller/src/MsgThread.cpp index b04efad..a7aa61d 100644 --- a/src/MsgThread/Controller/src/MsgThread.cpp +++ b/src/MsgThread/Controller/src/MsgThread.cpp @@ -140,7 +140,7 @@ void MsgThread::setMode(Mode mode) void MsgThread::setNormalMode() { MSG_LOG(""); - + getNaviBar().clear(); // Reset previus mode: switch(m_Mode) { diff --git a/src/Settings/Controller/src/MsgOnSimCard.cpp b/src/Settings/Controller/src/MsgOnSimCard.cpp index 2045dac..b640750 100644 --- a/src/Settings/Controller/src/MsgOnSimCard.cpp +++ b/src/Settings/Controller/src/MsgOnSimCard.cpp @@ -226,7 +226,7 @@ void MsgOnSimCard::setTitleWithButtons(bool value) { setTitleTranslatable(); - getNaviBar().clearBar(); + getNaviBar().clear(); getNaviBar().showButton(NaviOkButtonId, value); getNaviBar().showButton(NaviCancelButtonId, value); getNaviBar().showButton(NaviPrevButtonId, !value);