TizenRefApp-5968 Predictive search looks very small with huge message-body 03/64303/6
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Thu, 31 Mar 2016 09:14:49 +0000 (12:14 +0300)
committerAndrey Klimenko <and.klimenko@samsung.com>
Tue, 5 Apr 2016 07:54:27 +0000 (00:54 -0700)
Change-Id: I4b6ea3899341ba4dfdaee7272f3b3d4f9cc426d4
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
12 files changed:
inc/Resource.h
res/edje/conv_contact_list_layout.edc [new file with mode: 0755]
res/edje/conv_layout.edc
src/Common/View/inc/ListView.h
src/Common/View/inc/View.h
src/Common/View/src/ListView.cpp
src/Conversation/ContactList/Controller/inc/ConvContactList.h
src/Conversation/ContactList/Controller/src/ConvContactList.cpp
src/Conversation/ContactList/View/inc/ConvContactListView.h [new file with mode: 0644]
src/Conversation/ContactList/View/src/ConvContactListView.cpp [new file with mode: 0644]
src/Conversation/Main/Controller/inc/Conversation.h
src/Conversation/Main/Controller/src/Conversation.cpp

index edf4c23..b504ceb 100644 (file)
 #define BUBBLE_THEME_EDJ_PATH            EDJ_PATH"/bubble_theme.edj"
 #define MSG_INPUT_PANEL_EDJ_PATH         EDJ_PATH"/msg_input_panel.edj"
 #define RECIPIENT_PANEL_EDJ_PATH         EDJ_PATH"/recipient_panel.edj"
-#define CONV_LAYOUT_EDJ_PATH             EDJ_PATH"/conv_layout.edj"
+
 #define MSG_THREAD_EDJ_PATH              EDJ_PATH"/msg_thread.edj"
 #define CONTACTS_SEARCH_EDJ_PATH         EDJ_PATH"/contact_search.edj"
 #define MSG_BODY_EDJ_PATH                EDJ_PATH"/msg_body.edj"
 #define THUMBNAIL_EDJ_PATH               EDJ_PATH"/msg_thumbnail.edj"
 #define MSG_TITLE_EDJ_PATH               EDJ_PATH"/msg_title.edj"
-#define CONV_LIST_EDJ_PATH               EDJ_PATH"/conv_list.edj"
 #define SELECT_ALL_EDJ_PATH              EDJ_PATH"/select_all.edj"
 #define VIEWER_LAYOUT_EDJ_PATH           EDJ_PATH"/viewer_layout.edj"
 #define VIEWER_PALYER_EDJ_PATH           EDJ_PATH"/viewer_player.edj"
 #define VIEWER_SUBJECT_LAYOUT_EDJ_PATH   EDJ_PATH"/viewer_subject_layout.edj"
 #define SMIL_ITEM_EDJ_PATH               EDJ_PATH"/smil_item.edj"
 
+#define CONV_LIST_EDJ_PATH               EDJ_PATH"/conv_list.edj"
+#define CONV_LAYOUT_EDJ_PATH             EDJ_PATH"/conv_layout.edj"
+#define CONV_CONTACT_LIST_LAYOUT         EDJ_PATH"/conv_contact_list_layout.edj"
+
 // Images(res):
 #define THUMB_CONTACT_IMG_PATH           IMAGE_PATH"/list_ic_contacts.png"
 #define THUMB_GROUP_IMG_PATH             IMAGE_PATH"/list_ic_group.png"
diff --git a/res/edje/conv_contact_list_layout.edc b/res/edje/conv_contact_list_layout.edc
new file mode 100755 (executable)
index 0000000..eb4cda9
--- /dev/null
@@ -0,0 +1,50 @@
+collections {
+
+       base_scale: 1.8;
+
+       group
+       {
+               name: "conv_contact_list_layout";
+               parts {
+                       part {
+                               name: "swl.rect";
+                               type: SWALLOW;
+                               scale: 1;
+                               repeat_events: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       rel1 {relative: 0.0 0.0;}
+                                       rel2 {relative: 1.0 1.0;}
+                                       align: 0 0.0;
+                                       visible: 1;
+                                       fixed: 1 1;
+                               }
+                       }
+                       part {
+                               name: "bg_rect";
+                               type: RECT;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       color: 255 255 255 255;
+                                       rel1 {to: "swl.contact_list"; relative: 0.0 0.0;}
+                                       rel2 {to: "swl.contact_list"; relative: 1.0 1.0;}
+                                       visible: 1;
+                                       align: 0 0.0;
+                                       fixed: 1 1;
+                               }
+                       }
+                       part {
+                               name: "swl.contact_list";
+                               type: SWALLOW;
+                               scale: 1;
+                               description {
+                                       state: "default" 0.0;
+                                       visible: 1;
+                                       align: 0 0;
+                                       fixed: 1 1;
+                               }
+                       }
+               }
+       }
+}
index 178c375..475026f 100755 (executable)
@@ -124,14 +124,14 @@ collections {
                                        state: "default" 0.0;
                                        fixed: 1 1;
                                        rel1 {to: "swl.recipient.rect"; relative: 0.0 1.0;}
-                                       rel2 {to: "swl.bubble"; relative: 1.0 1.0;}
+                                       rel2 {to_x: "swl.recipient.rect"; to_y: "swl.msg_input_panel"; relative: 1.0 1.0;}
                                        align: 0.5 0.0;
-                                       visible: 1;
+                                       visible: 0;
                                }
                                description {
-                                       state: "hide" 0.0;
+                                       state: "show" 0.0;
                                        inherit: "default" 0.0;
-                                       visible: 0;
+                                       visible: 1;
                                }
                        }
                        programs {
@@ -139,16 +139,15 @@ collections {
                                        name: "hide.predictsearch";
                                        signal: "hide.predictsearch";
                                        source: "*";
-                                       action: STATE_SET "hide" 0.0;
+                                       action: STATE_SET "default" 0.0;
                                        target: "swl.predictsearch";
                                }
                                program {
                                        name: "show.predictsearch";
                                        signal: "show.predictsearch";
                                        source: "*";
-                                       action: STATE_SET "default" 0.0;
+                                       action: STATE_SET "show" 0.0;
                                        target: "swl.predictsearch";
-                                       target: "swl.recipient.rect";
                                }
                                program {
                                        name: "bubble_layout_clicked";
index 36139c8..e483543 100644 (file)
@@ -49,6 +49,7 @@ namespace Msg
             void setMode(Elm_List_Mode mode);
             void setHomogeneous(bool isHomogeneous);
             ListItem *getSelectedItem() const;
+            unsigned getItemsCount() const;
 
             void setCheckMode(bool check);
             bool getCheckMode() const;
index 9c066c5..e158fe6 100644 (file)
@@ -48,6 +48,8 @@ namespace Msg
             static void expand(Evas_Object *obj);
             void setSizeHintMin(Evas_Coord w, Evas_Coord h);
             void setSizeHintMax(Evas_Coord w, Evas_Coord h);
+            void getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const;
+            void getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const;
             Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false);
             Evas_Object *unsetContent(const char *part = nullptr);
             Evas_Object* getContent(const char *part = nullptr) const;
@@ -172,6 +174,16 @@ namespace Msg
         evas_object_size_hint_max_set(m_pEo, w, h);
     }
 
+    inline void View::getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const
+    {
+        evas_object_size_hint_min_get(m_pEo, w, h);
+    };
+
+    inline void View::getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const
+    {
+        evas_object_size_hint_max_get(m_pEo, w, h);
+    }
+
     inline void View::move(Evas_Coord x, Evas_Coord y)
     {
         evas_object_move(m_pEo, x, y);
index cc4ab70..428b4c7 100644 (file)
@@ -144,6 +144,11 @@ ListItem *ListView::getSelectedItem() const
     return ListItem::staticCast<ListItem*>(elmItem);
 }
 
+unsigned ListView::getItemsCount() const
+{
+    return elm_genlist_items_count(getEo());
+}
+
 void ListView::notifyListener(void *data, Evas_Object *obj, void *event_info, ListenerMethod method)
 {
     ListItem *item = ListItem::staticCast<ListItem*>(event_info);
index d4fb278..bc9d048 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef ConvContactList_h_
 #define ConvContactList_h_
 
-#include "ListView.h"
+#include "ConvContactListView.h"
 #include "App.h"
 #include "ContactListItem.h"
 
@@ -29,7 +29,7 @@ namespace Msg
     class IConvContactListListener;
 
     class ConvContactList
-        : public ListView
+        : public ConvContactListView
         , private IListViewListener
     {
         public:
@@ -39,6 +39,8 @@ namespace Msg
             void setListener(IConvContactListListener *l);
             void setSearchWorld(const std::string &searchWord);
             void requestSearch();
+            void clear();
+            bool isEmpty() const;
 
         private:
             // IListViewListener:
@@ -63,6 +65,7 @@ namespace Msg
             virtual ~IConvContactListListener() {}
 
             virtual void onContactSelected(ContactListItem &item) {};
+            virtual void onContactListChanged() {};
     };
 }
 
index 0d0afef..426fb29 100644 (file)
@@ -37,15 +37,12 @@ namespace
 }
 
 ConvContactList::ConvContactList(Evas_Object *parent, App &app)
-    : ListView(parent)
+    : ConvContactListView(parent)
     , m_pListener(nullptr)
     , m_pPredictSearchIdler(nullptr)
     , m_App(app)
 {
-    ListView::setListener(this);
-    ListView::setMultiSelection(true);
-    ListView::setMode(ELM_LIST_COMPRESS);
-    ListView::setFocusAllow(false);
+    getList().setListener(this);
 }
 
 ConvContactList::~ConvContactList()
@@ -62,6 +59,19 @@ void ConvContactList::setListener(IConvContactListListener *l)
     m_pListener = l;
 }
 
+void ConvContactList::clear()
+{
+    getList().clear();
+
+    if(m_pListener)
+        m_pListener->onContactListChanged();
+}
+
+bool ConvContactList::isEmpty() const
+{
+    return getList().isEmpty();
+}
+
 void ConvContactList::setSearchWorld(const std::string &searchWord)
 {
     m_SearchWord = searchWord;
@@ -75,13 +85,15 @@ void ConvContactList::requestSearch()
 
 void ConvContactList::search()
 {
-    ListView::clear();
+    getList().clear();
     if(!m_SearchWord.empty())
     {
         search<ContactPersonNumber>();
         search<ContactPersonEmail>();
         search<ContactPersonPhoneLog>();
     }
+    if(m_pListener)
+        m_pListener->onContactListChanged();
 }
 
 template<typename ContactRecord>
@@ -96,7 +108,7 @@ void ConvContactList::search()
             if(isValid(rec))
             {
                 ContactListItem *item = new ContactListItem(rec, m_App, m_SearchWord);
-                ListView::appendItem(*item);
+                getList().appendItem(*item);
             }
             else
             {
diff --git a/src/Conversation/ContactList/View/inc/ConvContactListView.h b/src/Conversation/ContactList/View/inc/ConvContactListView.h
new file mode 100644 (file)
index 0000000..2d7d9d7
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 ConvContactListView_h_
+#define ConvContactListView_h_
+
+#include "ListView.h"
+
+namespace Msg
+{
+    class ConvContactListView
+        : public View
+    {
+        public:
+            ConvContactListView(Evas_Object *parent);
+            virtual ~ConvContactListView();
+
+            ListView &getList();
+            const ListView &getList() const;
+
+        private:
+            int getItemHeight() const;
+            void recalcGeometry();
+            Evas_Object *createRect(Evas_Object *parent);
+            void onGometryChanged(Evas_Object *obj, void *eventInfo);
+
+        private:
+            Evas_Object *m_pRect;
+            Evas_Object *m_pBox;
+            ListView *m_pList;
+    };
+}
+
+#endif /* ConvContactListView_h_ */
diff --git a/src/Conversation/ContactList/View/src/ConvContactListView.cpp b/src/Conversation/ContactList/View/src/ConvContactListView.cpp
new file mode 100644 (file)
index 0000000..514f851
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "ConvContactListView.h"
+#include "Resource.h"
+
+using namespace Msg;
+
+ConvContactListView::ConvContactListView(Evas_Object *parent)
+    : m_pRect(nullptr)
+    , m_pBox(nullptr)
+    , m_pList(nullptr)
+{
+    setEo(addLayout(parent, CONV_CONTACT_LIST_LAYOUT, "conv_contact_list_layout"));
+    setFocusAllow(false);
+
+    m_pList = new ListView(getEo());
+    m_pList->setMultiSelection(true);
+    m_pList->setMode(ELM_LIST_COMPRESS);
+    m_pList->setHomogeneous(true);
+    m_pList->setFocusAllow(false);
+    m_pList->addSmartCb("realized", SMART_CALLBACK(ConvContactListView, onGometryChanged), this);
+    m_pList->addSmartCb("unrealized", SMART_CALLBACK(ConvContactListView, onGometryChanged), this);
+    m_pList->expand();
+    m_pList->show();
+
+    m_pBox = elm_box_add(getEo());
+    evas_object_show(m_pBox);
+    elm_box_pack_end(m_pBox, *m_pList);
+
+    setContent(m_pBox, "swl.contact_list");
+    setContent(createRect(getEo()), "swl.rect");
+}
+
+ConvContactListView::~ConvContactListView()
+{
+
+}
+
+ListView &ConvContactListView::getList()
+{
+    return *m_pList;
+}
+
+const ListView &ConvContactListView::getList() const
+{
+    return *m_pList;
+}
+
+void ConvContactListView::recalcGeometry()
+{
+    int itemHeight = getItemHeight();
+
+    int h = itemHeight * m_pList->getItemsCount();
+
+    int maxListHeight = 0;
+    evas_object_geometry_get(m_pRect, nullptr, nullptr, nullptr, &maxListHeight);
+
+    if(h > maxListHeight)
+        h = maxListHeight;
+
+    evas_object_size_hint_min_set(m_pBox, 0, h);
+    evas_object_size_hint_max_set(m_pBox, -1, h);
+}
+
+int ConvContactListView::getItemHeight() const
+{
+    int res = 0;
+    Evas_Object *track = nullptr;
+    Elm_Object_Item *item = elm_genlist_first_item_get(*m_pList);
+
+    for(; item ;)
+    {
+        track = elm_object_item_track(item);
+        if(track)
+            break;
+        item = elm_genlist_item_next_get(item);
+    }
+
+    if(track)
+    {
+        evas_object_geometry_get(track, nullptr, nullptr, nullptr, &res);
+        elm_object_item_untrack(track);
+    }
+
+    return res;
+}
+
+Evas_Object *ConvContactListView::createRect(Evas_Object *parent)
+{
+    m_pRect = evas_object_rectangle_add(evas_object_evas_get(parent));
+    evas_object_show(m_pRect);
+    evas_object_color_set(m_pRect, 0, 0, 0, 0);
+    evas_object_event_callback_add(m_pRect, EVAS_CALLBACK_MOVE, EVAS_EVENT_CALLBACK(ConvContactListView, onGometryChanged), this);
+    evas_object_event_callback_add(m_pRect, EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvContactListView, onGometryChanged), this);
+    evas_object_event_callback_add(m_pRect, EVAS_CALLBACK_CHANGED_SIZE_HINTS, EVAS_EVENT_CALLBACK(ConvContactListView, onGometryChanged), this);
+    return m_pRect;
+}
+
+void ConvContactListView::onGometryChanged(Evas_Object *obj, void *eventInfo)
+{
+    recalcGeometry();
+}
+
index a1f1168..3c542b2 100644 (file)
@@ -103,6 +103,7 @@ namespace Msg
 
             // IConvContactListListener:
             virtual void onContactSelected(ContactListItem &item);
+            virtual void onContactListChanged();
 
              // Popup callbacks:
             void onPopupDel(Evas_Object *popup, void *eventInfo);
index 51aa335..75f9364 100644 (file)
@@ -380,7 +380,6 @@ void Conversation::createContactList(Evas_Object *parent)
         m_pContactsList->setListener(this);
         m_pContactsList->show();
         m_pLayout->setContactList(*m_pContactsList);
-        m_pLayout->showContactList(true);
     }
 }
 
@@ -751,6 +750,12 @@ void Conversation::onContactSelected(ContactListItem &item)
     m_pContactsList->clear();
 }
 
+void Conversation::onContactListChanged()
+{
+    if(m_pContactsList)
+        m_pLayout->showContactList(!m_pContactsList->isEmpty());
+}
+
 void Conversation::onAttached(ViewItem &item)
 {
     FrameController::onAttached(item);