TizenRefApp-5670 Add reusable title layout 08/59108/2
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 10 Feb 2016 15:27:19 +0000 (17:27 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Thu, 11 Feb 2016 10:29:06 +0000 (12:29 +0200)
Change-Id: I985eb124259cb8b5be57d011c830fda473e7b58c
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/Controller/inc/FrameController.h
src/Common/Controller/src/FrameController.cpp
src/Conversation/Main/Controller/src/Conversation.cpp
src/Viewer/Controller/inc/Viewer.h
src/Viewer/Controller/src/Viewer.cpp

index 0aead42..a8da4fc 100644 (file)
@@ -21,6 +21,7 @@
 #include "ViewItemController.h"
 #include "NaviFrameItem.h"
 #include "NaviFrameController.h"
+#include "MsgAddress.h"
 
 namespace Msg
 {
@@ -37,6 +38,8 @@ namespace Msg
             virtual NaviFrameController &getParent();
 
         protected:
+            void setNaviBarTitle(const MsgAddressList &addressList);
+
             // NaviFrameItem
             virtual void onAttached(ViewItem &item);
     };
index d549b58..53b8177 100644 (file)
@@ -20,6 +20,7 @@
 #include "NaviFrameController.h"
 #include "Logger.h"
 #include "App.h"
+#include "ContactManager.h"
 
 using namespace Msg;
 
@@ -45,3 +46,30 @@ void FrameController::onAttached(ViewItem &item)
     NaviFrameItem::onAttached(item);
 }
 
+void FrameController::setNaviBarTitle(const MsgAddressList &addressList)
+{
+    std::string title;
+    if(!addressList.isEmpty())
+    {
+        std::string firstAddress = addressList[0].getAddress();
+        ContactPersonAddressRef contactPersonAddress = getApp().getContactManager().getContactPersonAddress(firstAddress);
+        if(contactPersonAddress)
+            title = contactPersonAddress->getDispName();
+
+        if(title.empty())
+        {
+            title = firstAddress;
+        }
+        else
+        {
+            int hidenAddresses = addressList.getLength() - 1;
+            if(hidenAddresses > 0)
+            {
+                title += " + " + std::to_string(hidenAddresses);
+                getNaviBar().showButton(NaviDownButtonId, true);
+            }
+        }
+    }
+    getNaviBar().showButton(NaviCenterButtonId, true);
+    getNaviBar().setButtonText(NaviCenterButtonId, title);
+}
index 9c32476..2ef9ed6 100644 (file)
@@ -602,48 +602,30 @@ void Conversation::updateMsgInputPanel()
 
 void Conversation::updateNavibar()
 {
-    getNaviBar().clear();
-    getNaviBar().setColor(NaviBar::NaviWhiteColorId);
-
-    // TODO: Update Navibar title(center) button in separated method ?
+    NaviBar &naviBar = getNaviBar();
+    naviBar.clear();
+    naviBar.setColor(NaviBar::NaviWhiteColorId);
+    naviBar.showButton(NaviPrevButtonId, true);
 
     if(m_Mode == NewMessageMode)
     {
-        getNaviBar().setTitle(msgt("IDS_MSGF_POP_NEW_MESSAGE"));
-        getNaviBar().showButton(NaviPrevButtonId, true);
+        naviBar.setTitle(msgt("IDS_MSGF_POP_NEW_MESSAGE"));
     }
     else if(m_Mode == ConversationMode)
     {
         if(m_pConvList->getMode() == ConvList::SelectMode)
         {
-            getNaviBar().setTitle(msgt("IDS_MSG_OPT_DELETE"));
-            getNaviBar().showButton(NaviCancelButtonId, true);
-            getNaviBar().showButton(NaviOkButtonId, true);
+            naviBar.setTitle(msgt("IDS_MSG_OPT_DELETE"));
+            naviBar.showButton(NaviCancelButtonId, true);
+            naviBar.showButton(NaviOkButtonId, true);
         }
         else
         {
             MsgAddressListRef addressList = getAddressList();
-            if(addressList && !addressList->isEmpty())
+            if(addressList)
             {
-                std::string conversationName;
-                std::string firstAddress = addressList->at(0).getAddress();
-                ContactPersonAddressRef contactPersonNumber = getApp().getContactManager().getContactPersonAddress(firstAddress);
-                if(contactPersonNumber)
-                    conversationName = contactPersonNumber->getDispName();
-
-                if(conversationName.empty())
-                    conversationName = firstAddress;
-
-                int hidenAddresses= addressList->getLength() - 1;
-                if(hidenAddresses > 0)
-                {
-                    conversationName += " + " + std::to_string(hidenAddresses);
-                    getNaviBar().showButton(NaviDownButtonId, true);
-                }
-
-                getNaviBar().showButton(NaviCenterButtonId, true);
-                getNaviBar().showButton(NaviPrevButtonId, true);
-                getNaviBar().setButtonText(NaviCenterButtonId, conversationName);
+                naviBar.showButton(NaviCenterButtonId, true);
+                FrameController::setNaviBarTitle(*addressList);
             }
         }
     }
index a707da9..05c6337 100644 (file)
@@ -23,6 +23,7 @@
 #include "ViewerLayout.h"
 #include "PlayerControl.h"
 #include "MsgTypes.h"
+#include "ContactManager.h"
 
 namespace Msg
 {
@@ -32,6 +33,7 @@ namespace Msg
         : public FrameController
         , private IHwButtonListener
         , private IPlayerControlListener
+        , private IContactManagerListener
     {
         public:
             Viewer(NaviFrameController &parent, MsgId id);
@@ -47,12 +49,15 @@ namespace Msg
             virtual void onHwBackButtonClicked();
             virtual void onHwMoreButtonClicked();
 
-            /// IPlayerControlListener:
+            // IPlayerControlListener:
             virtual void onPlayClicked();
             virtual void onPauseClicked();
             virtual void onNextClicked();
             virtual void onPrevClicked();
 
+            // IContactManagerListener:
+            virtual void onContactChanged();
+
         private:
             void updateNavibar();
             void create();
index 81344c2..32b5515 100644 (file)
@@ -19,6 +19,8 @@
 #include "Logger.h"
 #include "PathUtils.h"
 #include "Logger.h"
+#include "MsgEngine.h"
+#include "App.h"
 
 #include <Elementary.h>
 #include <sstream>
@@ -36,6 +38,7 @@ Viewer::Viewer(NaviFrameController &parent, MsgId id)
 
 Viewer::~Viewer()
 {
+    getApp().getContactManager().removeListener(*this);
 }
 
 void Viewer::onAttached(ViewItem &item)
@@ -47,13 +50,17 @@ void Viewer::onAttached(ViewItem &item)
 
 void Viewer::updateNavibar()
 {
-    getNaviBar().setTitle("Viewer");
+    getNaviBar().clear();
     getNaviBar().setColor(NaviBar::NaviBlueColorId);
     getNaviBar().showButton(NaviPrevButtonId, true);
+    MessageRef msg = getMsgEngine().getStorage().getMessage(m_MsgId);
+    if(msg)
+        FrameController::setNaviBarTitle(msg->getAddressList());
 }
 
 void Viewer::create()
 {
+    getApp().getContactManager().addListener(*this);
     createLayout();
     createPlayerControl();
     setHwButtonListener(*m_pLayout, this);
@@ -87,8 +94,22 @@ void Viewer::onHwMoreButtonClicked()
 
 void Viewer::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId)
 {
-    if(buttonId == NaviPrevButtonId)
-        getParent().pop();
+    MSG_LOG("");
+    switch(buttonId)
+    {
+        case NaviCenterButtonId:
+            break;
+
+        case NaviPrevButtonId:
+            getParent().pop();
+            break;
+
+        case NaviDownButtonId:
+            break;
+
+        default:
+            break;
+    };
 }
 
 void Viewer::onPlayClicked()
@@ -112,3 +133,9 @@ void Viewer::onPrevClicked()
 {
     MSG_LOG("");
 }
+
+void Viewer::onContactChanged()
+{
+    MSG_LOG("");
+    updateNavibar();
+}