TizenRefApp-5563 Create popup-menu that will appear on tap on conversation title 19/58019/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Tue, 26 Jan 2016 17:21:44 +0000 (19:21 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Tue, 26 Jan 2016 17:23:21 +0000 (19:23 +0200)
Change-Id: I65959ce98b7dfb67fb4d7ec972e76133211d5220
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/ContactManager/src/ContactManager.cpp
src/Common/View/src/NaviFrameItem.cpp
src/Conversation/Main/Controller/inc/Conversation.h
src/Conversation/Main/Controller/src/Conversation.cpp
src/Conversation/Main/View/inc/ConversationLayout.h
src/Conversation/Main/View/src/ConversationLayout.cpp
src/Conversation/Recipients/Controller/inc/RecipientsPanel.h
src/Conversation/Recipients/Controller/src/RecipientsPanel.cpp
src/Conversation/Recipients/View/inc/RecipientsPanelView.h
src/Conversation/Recipients/View/src/RecipientsPanelView.cpp

index 09a5e34..d10a95b 100644 (file)
             _contacts_person_number.image_thumbnail_path
         };
 
-        int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection)/sizeof(unsigned int));
-        if(ctRrr == CONTACTS_ERROR_NONE) {
+        int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int));
+        if(ctRrr == CONTACTS_ERROR_NONE)
             ctRrr = contacts_db_get_records_with_query(query, 0, 0, &list);
-        }
 
         contacts_filter_destroy(filter);
         contacts_query_destroy(query);
index 63ebe97..b3edeb7 100644 (file)
@@ -143,8 +143,7 @@ void NaviFrameItem::NaviBar::getButton(NaviButtonId id)
 {
     if(!m_ButtonList[id].button)
     {
-        Evas_Object *parent = getEo();
-        Evas_Object *btn = elm_button_add(parent);
+        Evas_Object *btn = elm_button_add(getEo());
         m_ButtonList[id].button = btn;
         elm_object_style_set(btn, m_ButtonList[id].style);
         setButtonText(id, msgt(m_ButtonList[id].default_text_id));
index 305efba..4441c9f 100644 (file)
@@ -84,6 +84,7 @@ namespace Msg
             virtual void onItemDeleted(RecipientsPanel &panel, RecipientItem &item);
             virtual void onKeyDown(RecipientsPanel &panel, Evas_Event_Key_Down &ev);
             virtual void onEntryFocusChanged(RecipientsPanel &panel);
+            virtual void onItemClicked(RecipientsPanel &panel, RecipientItem &item);
 
             // IBodyListener:
             virtual void onChanged(Body &body);
@@ -99,6 +100,10 @@ namespace Msg
             void onDeleteItemPressed(ContextPopupItem &item);
             void onAddRecipientsItemPressed(ContextPopupItem &item);
 
+            void onMakeVoiceItemPressed(ContextPopupItem &item);
+            void onCreateContactItemPressed(ContextPopupItem &item);
+            void onUpdateContactItemPressed(ContextPopupItem &item);
+
             // ConvList callbacks:
             virtual void onAllItemsDeleted(ConvList &list);
 
@@ -122,9 +127,12 @@ namespace Msg
             void createConvList(Evas_Object *parent);
             void destroyConvList();
             void markAsRead();
+            void recipientClickHandler(const std::string &address);
+            MsgAddressListRef getAddressList();
 
             void showMainCtxPopup();
             void showNoRecipPopup();
+            void showRecipPopup();
             void showSendResultPopup(MsgTransport::SendResult result);
 
             void notifyConvertMsgType();
index c7b4f87..a1de0d7 100644 (file)
@@ -97,6 +97,20 @@ void Conversation::markAsRead()
         getMsgEngine().getStorage().setReadStatus(m_ThreadId);
 }
 
+void Conversation::recipientClickHandler(const std::string &address)
+{
+    // TODO: impl for email
+    ContactPersonNumber contactPersonNumber = getApp().getContactManager().getContactPersonNumber(address);
+    if(contactPersonNumber.isValid())
+    {
+        // TODO: show Phone-Contacts
+    }
+    else
+    {
+        showRecipPopup();
+    }
+}
+
 void Conversation::navigateTo(MsgId msgId)
 {
     m_pConvList->navigateTo(msgId);
@@ -108,12 +122,20 @@ void Conversation::setThreadId(ThreadId id)
     setMode(m_ThreadId.isValid() ? ConversationMode : NewMessageMode);
     m_pBody->clear();
     if(m_pRecipPanel)
+    {
         m_pRecipPanel->clear();
+        m_pRecipPanel->update(m_ThreadId);
+    }
     if(m_pConvList)
         m_pConvList->setThreadId(m_ThreadId);
     markAsRead();
 }
 
+MsgAddressListRef Conversation::getAddressList()
+{
+    return getMsgEngine().getStorage().getAddressList(m_ThreadId);
+}
+
 void Conversation::setMode(Mode mode)
 {
     if(m_Mode == mode)
@@ -122,14 +144,7 @@ void Conversation::setMode(Mode mode)
     switch(mode)
     {
         case NewMessageMode:
-            if(m_Mode == InitMode)
-            {
-                setNewMessageMode();
-            }
-            else
-            {
-                MSG_LOG_ERROR("Wrong mode");
-            }
+            setNewMessageMode();
             break;
 
         case ConversationMode:
@@ -167,11 +182,9 @@ void Conversation::setConversationMode()
     m_Mode = ConversationMode;
     createConvList(*m_pLayout);
 
-    m_pLayout->showSelectAll(false);
-
     updateNavibar();
 
-    MsgAddressListRef addressList = getMsgEngine().getStorage().getAddressList(m_ThreadId);
+    MsgAddressListRef addressList = getAddressList();
     if(addressList && addressList->getLength() > 1)
     {
         createRecipPanel(*m_pLayout);
@@ -289,7 +302,7 @@ void Conversation::fillMsgAddress(Message &msg)
 {
     if(m_ThreadId.isValid() && m_Mode != NewMessageMode)
     {
-        MsgAddressListRef addressList = getMsgEngine().getStorage().getAddressList(m_ThreadId);
+        MsgAddressListRef addressList = getAddressList();
         if(addressList)
             msg.addAddresses(*addressList);
     }
@@ -380,14 +393,23 @@ void Conversation::checkAndSetMsgType()
 
 void Conversation::showNoRecipPopup()
 {
-    auto &popupMngr = getApp().getPopupManager();
-    Popup &popup = popupMngr.getPopup();
+    Popup &popup = getApp().getPopupManager().getPopup();
     popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onPopupDel), this);
     popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this);
     popup.setContent(msgt("IDS_MSG_POP_YOUR_MESSAGE_WILL_BE_DISCARDED_NO_RECIPIENTS_HAVE_BEEN_SELECTED"));
     popup.show();
 }
 
+void Conversation::showRecipPopup()
+{
+    ContextPopup &popup = getApp().getPopupManager().getCtxPopup();
+    popup.appendItem(msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), nullptr, CTXPOPUP_ITEM_PRESSED_CB(Conversation, onMakeVoiceItemPressed), this);
+    popup.appendItem(msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), nullptr, CTXPOPUP_ITEM_PRESSED_CB(Conversation, onCreateContactItemPressed), this);
+    popup.appendItem(msg("IDS_MSG_OPT_UPDATE_CONTACT"), nullptr, CTXPOPUP_ITEM_PRESSED_CB(Conversation, onUpdateContactItemPressed), this);
+    popup.align(getApp().getWindow());
+    popup.show();
+}
+
 void Conversation::showSendResultPopup(MsgTransport::SendResult result)
 {
     if(result == MsgTransport::SendSuccess)
@@ -453,6 +475,12 @@ void Conversation::onItemDeleted(RecipientsPanel &panel, RecipientItem &item)
     checkAndSetMsgType();
 }
 
+void Conversation::onItemClicked(RecipientsPanel &panel, RecipientItem &item)
+{
+    MSG_LOG("");
+    recipientClickHandler(item.getAddress());
+}
+
 void Conversation::onChanged(Body &body)
 {
     updateMsgInputPanel();
@@ -492,7 +520,7 @@ void Conversation::updateNavibar()
         }
         else
         {
-            MsgAddressListRef addressList = getMsgEngine().getStorage().getAddressList(m_ThreadId);
+            MsgAddressListRef addressList = getAddressList();
             if(addressList && !addressList->isEmpty())
             {
                 std::string conversationName;
@@ -587,6 +615,16 @@ void Conversation::onNaviOkButtonClicked()
 void Conversation::onNaviCenterButtonClicked()
 {
     MSG_LOG("");
+    if(m_pRecipPanel)
+    {
+        onNaviDownButtonClicked();
+    }
+    else
+    {
+        MsgAddressListRef addressList = getAddressList();
+        if(addressList && !addressList->isEmpty())
+            recipientClickHandler(addressList->at(0).getAddress());
+    }
 }
 
 void Conversation::onNaviDownButtonClicked()
@@ -594,7 +632,7 @@ void Conversation::onNaviDownButtonClicked()
     MSG_LOG("");
     if(m_pRecipPanel)
     {
-        bool isMbeInvisible= !m_pRecipPanel->isMbeVisible();
+        bool isMbeInvisible = !m_pRecipPanel->isMbeVisible();
         m_pRecipPanel->showMbe(isMbeInvisible);
         getNaviBar().setDownButtonState(isMbeInvisible);
     }
@@ -633,35 +671,58 @@ void Conversation::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId)
 
 void Conversation::onPopupDel(Evas_Object *popup, void *eventInfo)
 {
+    MSG_LOG("");
     m_pBody->setFocus(true);
 }
 
 void Conversation::onMsgSendErrorButtonClicked(Popup &popup, int buttonId)
 {
+    MSG_LOG("");
     m_pBody->setFocus(true);
     popup.destroy();
 }
 
 void Conversation::onDeleteItemPressed(ContextPopupItem &item)
 {
+    MSG_LOG("");
     item.getParent().destroy();
-
     m_pConvList->setMode(ConvList::SelectMode);
-    setConversationMode();
+    updateNavibar();
 }
 
 void Conversation::onAddRecipientsItemPressed(ContextPopupItem &item)
 {
+    MSG_LOG("");
+    item.getParent().destroy();
+    setMode(NewMessageMode);
+}
+
+void Conversation::onMakeVoiceItemPressed(ContextPopupItem &item)
+{
+    MSG_LOG("");
+    item.getParent().destroy();
+}
+
+void Conversation::onCreateContactItemPressed(ContextPopupItem &item)
+{
+    MSG_LOG("");
+    item.getParent().destroy();
+}
+
+void Conversation::onUpdateContactItemPressed(ContextPopupItem &item)
+{
+    MSG_LOG("");
     item.getParent().destroy();
-    setNewMessageMode();
 }
 
 void Conversation::onAllItemsDeleted(ConvList &list)
 {
+    MSG_LOG("");
     onHwBackButtonClicked();
 }
 
 void Conversation::onFileSelected(AttachPanel &panel, const AttachPanel::FileList &files)
 {
+    MSG_LOG("");
     m_pBody->addMedia(files);
 }
index 5204af4..73f5b22 100644 (file)
@@ -32,10 +32,7 @@ namespace Msg
             virtual ~ConversationLayout();
 
             void showContactList(bool value);
-            void showSelectAll(bool value);
-
             void setConvList(Evas_Object *layout);
-            void setSelectAll(Evas_Object *layout);
             void setContactList(Evas_Object *layout);
             void setMsgInputPanel(Evas_Object *layout);
             void setRecipientPanel(Evas_Object *layout);
index b80a7ab..1ec40c6 100644 (file)
@@ -37,12 +37,6 @@ void ConversationLayout::showContactList(bool value)
     elm_object_signal_emit(m_pLayout, sig, "*");
 }
 
-void ConversationLayout::showSelectAll(bool value)
-{
-    const char *sig = value ? "show_select_all" : "hide_select_all";
-    elm_object_signal_emit(m_pLayout, sig, "*");
-}
-
 void ConversationLayout::setRecipientRect(Evas_Object *layout)
 {
     elm_object_part_content_set(m_pLayout, "swl.recipient.rect", layout);
@@ -53,11 +47,6 @@ void ConversationLayout::setConvList(Evas_Object *layout)
     elm_object_part_content_set(m_pLayout, "swl.bubble", layout);
 }
 
-void ConversationLayout::setSelectAll(Evas_Object *layout)
-{
-    elm_object_part_content_set(m_pLayout, "swl.sel_al", layout);
-}
-
 void ConversationLayout::setContactList(Evas_Object *layout)
 {
     elm_object_part_content_set(m_pLayout, "swl.predictsearch", layout);
index 67eb281..eb5b7c9 100644 (file)
@@ -94,6 +94,7 @@ namespace Msg
             virtual void onEntryFocusChanged(RecipientsPanel &panel) {};
             virtual void onItemAdded(RecipientsPanel &panel, RecipientItem &item) {};
             virtual void onItemDeleted(RecipientsPanel &panel, RecipientItem &item) {};
+            virtual void onItemClicked(RecipientsPanel &panel, RecipientItem &item) {};
     };
 }
 
index e1c926f..e95eb77 100644 (file)
@@ -216,7 +216,7 @@ void RecipientsPanel::onItemDeleted(RecipientViewItem &item)
 void RecipientsPanel::onContactButtonClicked()
 {
     const int maxRecipientCount = m_App.getMsgEngine().getSettings().getMaxRecipientCount();
-    int currentRecipientsCount = getMbeItemsCount();
+    int currentRecipientsCount = getItemsCount();
     if(currentRecipientsCount < maxRecipientCount)
         m_Picker.launch(maxRecipientCount - currentRecipientsCount);
     else
@@ -230,7 +230,8 @@ void RecipientsPanel::onItemSelected(RecipientViewItem &item)
 
 void RecipientsPanel::onItemClicked(RecipientViewItem &item)
 {
-    MSG_LOG("");
+    if(m_pListener)
+        m_pListener->onItemClicked(*this, static_cast<RecipientItem&>(item));
 }
 
 bool RecipientsPanel::isRecipientExists(const std::string& address) const
@@ -253,7 +254,10 @@ void RecipientsPanel::onContactsPicked(const std::list<int> &numberIdList)
     {
         ContactPersonNumber num = m_App.getContactManager().getContactPersonNumber(phoneNumId);
         if(num.isValid())
+        {
             duplicateFound |= appendItem(num.getNumber(), num.getDispName(), MsgAddress::Phone) == DuplicatedStatus;
+            num.release();
+        }
     }
 
     if(duplicateFound)
index e2bf9ff..ac796cb 100644 (file)
@@ -54,7 +54,7 @@ namespace Msg
             /**
              * Gets a count of mbe items
              */
-            unsigned int getMbeItemsCount() const;
+            unsigned int getItemsCount() const;
 
         private:
             // Out signals:
index 704ce16..44d649d 100644 (file)
@@ -353,7 +353,7 @@ void RecipientsPanelView::unselectMbeItem()
         elm_multibuttonentry_item_selected_set(selectedItem, EINA_FALSE);
 }
 
-unsigned int RecipientsPanelView::getMbeItemsCount() const
+unsigned int RecipientsPanelView::getItemsCount() const
 {
     unsigned int res = 0;
     const Eina_List* items = elm_multibuttonentry_items_get(m_pMbe);