Added functionality to set entry focus when naviframe transition finished. 44/79944/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 13 Jul 2016 13:47:18 +0000 (16:47 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 13 Jul 2016 13:47:18 +0000 (16:47 +0300)
Change-Id: Ic7f287015263700a514cf6a8f054aaddbe7de70e
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/View/inc/NaviFrameItem.h
src/Common/View/inc/NaviFrameView.h
src/Common/View/src/NaviFrameView.cpp
src/Conversation/Main/Controller/inc/Conversation.h
src/Conversation/Main/Controller/src/Conversation.cpp
src/MsgThread/Controller/src/MsgThread.cpp

index db00845..31b0e80 100644 (file)
@@ -65,6 +65,7 @@ namespace Msg
 
             //ViewItem
             virtual void onAttached(ViewItem &item);
+            virtual void onTransitionFinished(NaviFrameItem &item) {};
 
         private:
             void setTitleVisibility(bool visible);
index c21358e..849ca67 100644 (file)
@@ -58,9 +58,15 @@ namespace Msg
             void pop();
             void insertToBottom(NaviFrameItem &item);
             void promote(NaviFrameItem &item);
+            NaviFrameItem *getTopFrame() const;
+            bool getTransitionStatus() const;
 
         private:
             void create(Evas_Object *parent);
+            void onTransitionFinished(Evas_Object *obj, void *eventInfo);
+
+        private:
+            bool m_TransitionStatus;
     };
 }
 
index d09571a..615d584 100644 (file)
@@ -26,12 +26,14 @@ const char *naviTitleStyleEmpty = "empty";
 
 NaviFrameView::NaviFrameView(Evas_Object *parent)
     : View()
+    , m_TransitionStatus(false)
 {
     create(parent);
 }
 
 NaviFrameView::NaviFrameView(View &parent)
     : View()
+    , m_TransitionStatus(false)
 {
     create(parent.getEo());
 }
@@ -44,6 +46,7 @@ NaviFrameView::~NaviFrameView()
 void NaviFrameView::create(Evas_Object *parent)
 {
     setEo(elm_naviframe_add(parent));
+    addSmartCb("transition,finished", SMART_CALLBACK(NaviFrameView, onTransitionFinished), this);
     show();
 }
 
@@ -52,6 +55,11 @@ bool NaviFrameView::isLastFrame() const
     return elm_naviframe_bottom_item_get(getEo()) == elm_naviframe_top_item_get(getEo());
 }
 
+NaviFrameItem *NaviFrameView::getTopFrame() const
+{
+    return ViewItem::staticCast<NaviFrameItem*>(elm_naviframe_top_item_get(getEo()));
+}
+
 int NaviFrameView::getItemsCount() const
 {
     int res = 0;
@@ -92,17 +100,20 @@ bool NaviFrameView::isEmpty() const
 
 void NaviFrameView::push(NaviFrameItem &item, Evas_Object *content)
 {
+    m_TransitionStatus = !isEmpty();
     Elm_Object_Item *it = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, content, naviTitleStyleEmpty);
     item.setElmObjItem(it);
 }
 
 void NaviFrameView::push(NaviFrameItem &item, View &content)
 {
+    m_TransitionStatus = !isEmpty();
     push(item, content);
 }
 
 void NaviFrameView::pop()
 {
+    m_TransitionStatus = getItemsCount() > 1;
     elm_naviframe_item_pop(getEo());
 }
 
@@ -121,5 +132,21 @@ void NaviFrameView::insertToBottom(NaviFrameItem &item)
 
 void NaviFrameView::promote(NaviFrameItem &item)
 {
+    m_TransitionStatus = &item != getTopFrame();
     elm_naviframe_item_promote(item);
 }
+
+void NaviFrameView::onTransitionFinished(Evas_Object *obj, void *eventInfo)
+{
+    MSG_LOG("");
+    m_TransitionStatus = false;
+    auto *item = ViewItem::staticCast<NaviFrameItem*>(eventInfo);
+    if(item)
+        item->onTransitionFinished(*item);
+}
+
+bool NaviFrameView::getTransitionStatus() const
+{
+    // TODO: Move functionality for gets TransitionStatus to EFL (elm_naviframe) side.
+    return m_TransitionStatus;
+}
index 4c86eb8..b16fe96 100644 (file)
@@ -37,6 +37,8 @@
 #include "SystemSettingsManager.h"
 #include "WorkingDir.h"
 
+#include <functional>
+
 namespace Msg
 {
     class NaviFrameController;
@@ -85,6 +87,7 @@ namespace Msg
         private:
             // NaviFrameItem:
             virtual void onAttached(ViewItem &item);
+            virtual void onTransitionFinished(NaviFrameItem &item);
             virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId);
 
             // IHwButtonListener:
@@ -167,6 +170,8 @@ namespace Msg
             void convertMsgTypeHandler();
             void checkAndSetMsgType();
             void navigateToSlideShow(MsgId id);
+            void setBodyFocus();
+            void setRecipEntryFocus();
 
             void showMainPopup();
             void showNoRecipPopup();
@@ -201,6 +206,7 @@ namespace Msg
             DefferedCmd m_DefferedCmd;
             ContactEditor m_ContactEditor;
             IConversationListener *m_pListener;
+            std::function<void()> m_TransFinishedFunc;
     };
 
     class IConversationListener
index f43f822..789f32b 100644 (file)
@@ -112,9 +112,7 @@ void Conversation::execCmd(const AppControlComposeRef &cmd)
     }
 
     if(isRecipExists() && m_pBody)
-    {
         m_pBody->setFocus(true);
-    }
     else if(m_pRecipPanel)
         m_pRecipPanel->setEntryFocus(true);
 }
@@ -318,7 +316,7 @@ void Conversation::setNewMessageMode()
     m_pRecipPanel->update(m_ThreadId);
     m_pRecipPanel->showMbe(!m_pRecipPanel->isMbeEmpty());
     m_pRecipPanel->showEntry(true);
-    m_pRecipPanel->setEntryFocus(true);
+    m_pRecipPanel->setFocus(true);
 }
 
 void Conversation::setConversationMode()
@@ -618,6 +616,40 @@ void Conversation::navigateToSlideShow(MsgId id)
     getParent().push(*viewer);
 }
 
+void Conversation::setBodyFocus()
+{
+    if(getOwner().getTransitionStatus())
+    {
+        m_TransFinishedFunc = [this]()
+        {
+            if(m_pBody)
+                m_pBody->setFocus(true);
+        };
+    }
+    else
+    {
+        if(m_pBody)
+            m_pBody->setFocus(true);
+    }
+}
+
+void Conversation::setRecipEntryFocus()
+{
+    if(getOwner().getTransitionStatus())
+    {
+        m_TransFinishedFunc = [this]()
+        {
+            if(m_pRecipPanel)
+                m_pRecipPanel->setEntryFocus(true);
+        };
+    }
+    else
+    {
+        if(m_pRecipPanel)
+            m_pRecipPanel->setEntryFocus(true);
+    }
+}
+
 PopupList &Conversation::createPopupList(const std::string &title)
 {
     PopupList &popup = getApp().getPopupManager().getPopupList();
@@ -843,11 +875,22 @@ void Conversation::onContactListChanged()
 
 void Conversation::onAttached(ViewItem &item)
 {
+    MSG_LOG("");
     FrameController::onAttached(item);
     updateNavibar();
     setContent(*m_pLayout);
 }
 
+void Conversation::onTransitionFinished(NaviFrameItem &item)
+{
+    MSG_LOG("");
+    if(m_TransFinishedFunc)
+    {
+        m_TransFinishedFunc();
+        m_TransFinishedFunc = nullptr;
+    }
+}
+
 void Conversation::onHwBackButtonClicked()
 {
     MSG_LOG("");
index 08971cb..4bb109e 100644 (file)
@@ -98,8 +98,8 @@ void MsgThread::showMainPopup()
 void MsgThread::composeNewMessage()
 {
     Conversation *frame = new Conversation(getParent());
-    frame->setThreadId(ThreadId());
     getParent().push(*frame);
+    frame->setThreadId(ThreadId());
 }
 
 void MsgThread::navigateToSettings()