TizenRefApp-8339 Implement settings block list 90/123690/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Thu, 6 Apr 2017 11:59:08 +0000 (14:59 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Thu, 6 Apr 2017 11:59:08 +0000 (14:59 +0300)
Update/Refact: LangUtils, TitleListItem
Add onSelect callback to ListViewItem

Change-Id: I88866eaf36f06bd659ed4356b0f1b2b5d076fd82
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
22 files changed:
inc/Resource.h
res/edje/common_genlist_theme.edc [new file with mode: 0644]
res/edje/conv_genlist_theme.edc
src/Common/Controller/inc/App.h
src/Common/Controller/src/App.cpp
src/Common/Utils/inc/LangUtils.h
src/Common/Utils/inc/TextDecorator.h
src/Common/Utils/src/TextDecorator.cpp
src/Common/View/inc/ListItem.h
src/Common/View/inc/TitleListItem.h [new file with mode: 0644]
src/Common/View/src/ListItem.cpp
src/Common/View/src/ListView.cpp
src/Common/View/src/TitleListItem.cpp [new file with mode: 0644]
src/Conversation/Controller/inc/ConvList.h
src/Conversation/Controller/src/ConvList.cpp
src/Conversation/View/inc/ConvTitleListItem.h [deleted file]
src/Conversation/View/src/ConvTitleListItem.cpp [deleted file]
src/Settings/Controller/inc/SettingsBlockListFrame.h
src/Settings/Controller/src/SettingsBlockListFrame.cpp
src/Settings/View/inc/BlockedNumberListViewItem.h
src/Settings/View/inc/SettingsMenuListItem.h [new file with mode: 0644]
src/Settings/View/src/SettingsMenuListItem.cpp [new file with mode: 0644]

index 12859ad5eeab25da58a2a4ac256de8d5e1b24918..2aaa4ccc73c0350ad667bb5727722014daa2e2a4 100644 (file)
@@ -67,6 +67,7 @@
 #define COMPOSER_LAYOUT_EDJ_PATH         EDJ_PATH"/composer_layout.edj"
 #define MSG_BODY_EDJ_PATH                EDJ_PATH"/msg_body.edj"
 #define SEARCH_BAR_EDJ_PATH              EDJ_PATH"/search_bar.edj"
+#define COMMON_GENLIST_THEME_EDJ_PATH    EDJ_PATH"/common_genlist_theme.edj"
 #define CONV_GENLIST_THEME_EDJ_PATH      EDJ_PATH"/conv_genlist_theme.edj"
 #define INPUT_LAYOUT_EDJ_PATH            EDJ_PATH"/input_layout.edj"
 #define CONV_LIST_BUBBLE_EDJ_PATH        EDJ_PATH"/conv_list_bubble.edj"
diff --git a/res/edje/common_genlist_theme.edc b/res/edje/common_genlist_theme.edc
new file mode 100644 (file)
index 0000000..8a9b05b
--- /dev/null
@@ -0,0 +1,22 @@
+#include "macros.inl"
+
+collections {
+   BASE_SCALE;
+   group {
+      name: "elm/genlist/item/custom_title/default";
+      data.item: "contents" "swl.content";
+      parts{
+         PADDING_TOP("pad.top", 37);
+         PADDING_BOTTOM("pad.bottom", 7);
+         swallow { "swl.content"; scale; nomouse;
+            desc { "default";
+               align: 0.5 1.0;
+               min: 0 39;
+               max: 240 39;
+               rel1 { relative : 0.0 1.0; to_y: "pad.top"; }
+               rel2 { relative : 1.0 0.0; to_y: "pad.bottom"; }
+            }
+         }
+      }
+   }
+}
index 177be3ba7f8652b1ef4eb2b0cc59d89781620271..da97658547b80cbfa77a4e8cbd5974b8afecf739 100644 (file)
@@ -559,25 +559,6 @@ collections {
          }
       }
    }
-
-   group {
-      name: "elm/genlist/item/conv_title/default";
-      data.item: "contents" "swl.content";
-      parts{
-         PADDING_TOP("pad.top", 37);
-         PADDING_BOTTOM("pad.bottom", 7);
-         swallow { "swl.content"; scale; nomouse;
-            desc { "default";
-               align: 0.5 1.0;
-               min: 0 39;
-               max: 240 39;
-               rel1 { relative : 0.0 1.0; to_y: "pad.top"; }
-               rel2 { relative : 1.0 0.0; to_y: "pad.bottom"; }
-            }
-         }
-      }
-   }
-
    group {
       name: "elm/genlist/item/1lineitem/default";
       inherit: "elm/genlist/item/dateline/default";
index ecefc759dda177c9dc04afcd5d5a0369acf1e384..082120b3d208df9c402436e064baa39dedd42b65 100644 (file)
@@ -77,6 +77,9 @@ namespace Msg {
             void onLowBattery(app_event_info_h appEvent);
             void onRegionChanged(app_event_info_h appEvent);
 
+        private:
+            void addTheme(const std::string &themePath);
+
         private:
             Window *m_pWindow;
             MsgEngine *m_pEngine;
index 4f97212a55d98f1460d80a14ce08bf5ff4b05c55..6754b5557b4a2d31ae0520d29b244785abb954bb 100644 (file)
@@ -228,23 +228,23 @@ bool App::isPause() const
     return m_IsPause;
 }
 
+void App::addTheme(const std::string &themePath)
+{
+    std::string path = PathUtils::getResourcePath(themePath);
+    elm_theme_extension_add(nullptr, path.c_str());
+}
+
 bool App::onCreate()
 {
     TRACE;
     if (!appInstance)
         return false;
 
-    std::string convGenlistThemePath = PathUtils::getResourcePath(CONV_GENLIST_THEME_EDJ_PATH);
-    elm_theme_extension_add(nullptr, convGenlistThemePath.c_str());
-
-    std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH);
-    elm_theme_extension_add(nullptr, imagesPath.c_str());
-
-    std::string threadThemePath = PathUtils::getResourcePath(THREAD_THEME_EDJ_PATH);
-    elm_theme_extension_add(nullptr, threadThemePath.c_str());
-
-    std::string threadComposeThemePath = PathUtils::getResourcePath(THREAD_COMPOSE_LIST_VIEW_ITEM);
-    elm_theme_extension_add(nullptr, threadComposeThemePath.c_str());
+    addTheme(COMMON_GENLIST_THEME_EDJ_PATH);
+    addTheme(CONV_GENLIST_THEME_EDJ_PATH);
+    addTheme(IMAGES_EDJ_PATH);
+    addTheme(THREAD_THEME_EDJ_PATH);
+    addTheme(THREAD_COMPOSE_LIST_VIEW_ITEM);
 
     feedback_initialize();
     getWindow();
index bb2673f665b062507b962284f9b49d6af7949ad9..6b582e449fc2517f8ec8cfdfb4659c6af3bf6ab7 100644 (file)
@@ -34,58 +34,61 @@ namespace Msg
         // Constructor for nullptr;
         TText(std::nullptr_t)
             : m_pDomain(nullptr)
-            , m_pMsg(nullptr)
             , m_IsTranslatable(false)
         {
         }
 
-        // Constructor for translatable string;
-        TText(bool dummy, const char *stringId, const char *domainName)
-            : m_pDomain(domainName)
-            , m_pMsg(stringId)
-            , m_IsTranslatable(true)
+        // Move Constructor;
+        TText(TText &&text)
+            : m_pDomain(text.m_pDomain)
+            , m_Str(std::move(text.m_Str))
+            , m_IsTranslatable(text.m_IsTranslatable)
         {
         }
 
-        // Constructor for plain C string;
-        TText(const char *str)
-            : m_pDomain(nullptr)
-            , m_pMsg(str)
-            , m_IsTranslatable(false)
+        // Constructor for C string
+        TText(const char *str, bool translatable = false, const char *domainName = MSG_DOMAIN)
+            : m_pDomain(domainName)
+            , m_Str(str ? str : "")
+            , m_IsTranslatable(translatable)
         {
         }
 
-        // Constructor for plain std::string;
-        TText(std::string str)
-            : m_pDomain(nullptr)
+        // Constructor for C++ string
+        TText(std::string str, bool translatable = false, const char *domainName = MSG_DOMAIN)
+            : m_pDomain(domainName)
             , m_Str(std::move(str))
-            , m_pMsg(m_Str.c_str())
-            , m_IsTranslatable(false)
+            , m_IsTranslatable(translatable)
         {
         }
 
+        void clear()
+        {
+            m_Str.clear();
+            m_pDomain = nullptr;
+            m_IsTranslatable = false;
+        }
+
         const char *getMsg() const
         {
-            return m_pMsg;
+            return m_Str.c_str();
         }
 
         const char *getDomain() const
         {
+            if (m_pDomain && m_pDomain[0] == 0)
+                return nullptr;
             return m_pDomain;
         }
 
         bool isTranslatable() const
         {
-            return  m_IsTranslatable;
+            return m_IsTranslatable;
         }
 
     private:
-        TText(TText&) = delete;
-        TText operator =(TText&) = delete;
-
         const char *m_pDomain;
         std::string m_Str;
-        const char *m_pMsg;
         bool m_IsTranslatable;
     };
 
@@ -135,11 +138,11 @@ namespace Msg
         const char *m_pMsg;
     };
 
-    #define msgt(strId) TText(true, strId, MSG_DOMAIN)
+    #define msgt(strId) TText(strId, true, MSG_DOMAIN)
     #define msg(strId) DText(strId, MSG_DOMAIN)
     #define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__)
     #define sys(strId) DText(strId, SYS_DOMAIN)
-    #define syst(strId) TText(true, strId, SYS_DOMAIN)
+    #define syst(strId) TText(strId, true, SYS_DOMAIN)
     #define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__)
 }
 
index 7d60cebe6c621b3ec7590b9dcfd7c744653e8f6f..f7a5c7adf82ceece3082d6bfab267b0a6c463779 100644 (file)
@@ -40,6 +40,8 @@ namespace Msg {
 
         public:
             TextStyle();
+            TextStyle(const TextStyle&) = default;
+            TextStyle(TextStyle &&style);
             TextStyle(int size, const std::string &color, Align align = Align::None);
             ~TextStyle();
 
@@ -47,6 +49,7 @@ namespace Msg {
             TextStyle &setSize(int size);
             TextStyle &setAlign(Align align);
             TextStyle &setWeight(Weight weight);
+            bool isEmpty() const;
 
             const std::string &getColor() const;
             int getSize() const;
index 83ef0e770d0a8981c7429bc9b52aa73b9d065b34..c7345dae311a0ff759cfa21f7bae06501b58f6ab 100644 (file)
@@ -75,6 +75,14 @@ TextStyle::TextStyle()
 {
 }
 
+TextStyle::TextStyle(TextStyle &&style)
+    : m_Weight(style.m_Weight)
+    , m_Color(std::move(style.m_Color))
+    , m_Align(style.m_Align)
+    , m_Size(style.m_Size)
+{
+}
+
 TextStyle::TextStyle(int size, const std::string &color, Align align)
     : m_Weight(Weight::None)
     , m_Color(color)
@@ -111,6 +119,14 @@ TextStyle &TextStyle::setWeight(Weight weight)
     return *this;
 }
 
+bool TextStyle::isEmpty() const
+{
+    return m_Weight == Weight::None &&
+           m_Align == Align::None &&
+           m_Color.empty() &&
+           m_Size == 0;
+}
+
 const std::string &TextStyle::getColor() const
 {
     return m_Color;
@@ -136,6 +152,8 @@ namespace TextDecorator {
 
 std::string make(const std::string &text, const TextStyle &style)
 {
+    if (style.isEmpty())
+        return text;
     return make(text, style.getSize(), style.getColor(), style.getAlign(), style.getWeight());
 }
 
index a7d2632d2e3e3ae542c3088b6f2216ca29553af4..625224125cbc6f362c43bc50aee012058c877717 100644 (file)
@@ -23,6 +23,7 @@
 #include <memory>
 #include <vector>
 #include <Elementary.h>
+#include <functional>
 
 namespace Msg
 {
@@ -65,6 +66,8 @@ namespace Msg
         friend class ListView;
 
         public:
+            using OnSelectedCb = std::function<void(ListItem &item)>;
+
             /**
              * @brief Creates instance of ListItem of specified genlist-item type.
              * @param[in] type genlist item-type.
@@ -179,6 +182,12 @@ namespace Msg
              */
             bool isSame(const ListItem &item) const;
 
+            /**
+             * @brief Sets custom selected callback to item
+             * @param[in] cb OnSelectedCb callback
+             */
+            void setOnSelectedCb(OnSelectedCb cb);
+
         protected:
             virtual std::string getText(ListItem &item, const char *part);
             virtual Evas_Object *getContent(ListItem &item, const char *part);
@@ -206,6 +215,7 @@ namespace Msg
         ListItemStyleRef m_ItemStyle;
         Elm_Genlist_Item_Type m_Type;
         bool m_Checked;
+        OnSelectedCb m_OnSelectedCb;
     };
 }
 
diff --git a/src/Common/View/inc/TitleListItem.h b/src/Common/View/inc/TitleListItem.h
new file mode 100644 (file)
index 0000000..3bc9c53
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 TitleListItem_h_
+#define TitleListItem_h_
+
+#include "ListItem.h"
+#include "TextDecorator.h"
+
+namespace Msg {
+    class TitleListItem
+        : public ListItem {
+        public:
+            TitleListItem();
+
+            void setTitle(std::string title, bool translate);
+
+        private:
+            Evas_Object *getContent(ListItem &item, const char *part) override;
+            Evas_Object *createLabel();
+
+        private:
+            std::string m_Title;
+            bool m_Translate;
+    };
+}
+
+#endif /* TitleListItem_h_ */
index 20b31c5e4542d1bfcf505b64b0df74e3ff1b1a1b..355f89e429c696808ef50335559dfeb8ad00be0f 100644 (file)
@@ -89,6 +89,7 @@ ListItem::ListItem(const ListItemStyleRef &itemStyle, Elm_Genlist_Item_Type type
     , m_ItemStyle(itemStyle)
     , m_Type(type)
     , m_Checked(false)
+    , m_OnSelectedCb()
 {
 }
 
@@ -198,6 +199,11 @@ bool ListItem::isSame(const ListItem &item) const
     return item.getElmObjItem() == getElmObjItem();
 }
 
+void ListItem::setOnSelectedCb(OnSelectedCb cb)
+{
+    m_OnSelectedCb = cb;
+}
+
 void ListItem::onCheckChanged(Evas_Object *obj, void *eventInfo)
 {
     m_Checked = elm_check_state_get(obj);
index 7d2e85d0b10f5ba91380617db5c6f400e759a180..88cacb1bcf980687d2ad1ca449650ce8fcc03c86 100644 (file)
@@ -352,6 +352,8 @@ void ListView::on_item_selected_cb(void *data, Evas_Object *obj, void *event_inf
         item->changeCheckedState(true);
         notifyListener(data, obj, event_info, &IListViewListener::onListItemChecked);
     } else {
+        if (item->m_OnSelectedCb)
+            item->m_OnSelectedCb(*item);
         notifyListener(data, obj, event_info, &IListViewListener::onListItemSelected);
     }
 }
diff --git a/src/Common/View/src/TitleListItem.cpp b/src/Common/View/src/TitleListItem.cpp
new file mode 100644 (file)
index 0000000..5c24f42
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "TitleListItem.h"
+#include "ListView.h"
+#include "TextDecorator.h"
+#include "LangUtils.h"
+
+using namespace Msg;
+
+const auto titleTextStyle = TextStyle().
+                            setSize(30).
+                            setAlign(TextStyle::Align::Center).
+                            setWeight(TextStyle::Weight::Bold).
+                            setColor("#ffae0d");
+
+TitleListItem::TitleListItem()
+    : ListItem(ListItemStyle::create("custom_title"))
+    , m_Translate(false)
+{
+}
+
+void TitleListItem::setTitle(std::string title, bool translate)
+{
+    m_Title = std::move(title);
+    m_Translate = translate;
+}
+
+Evas_Object *TitleListItem::createLabel()
+{
+    static const double slideDuration = 3.0;
+
+    Evas_Object *label = elm_label_add(*getOwner());
+    elm_object_focus_allow_set(label, false);
+    elm_object_style_set(label, "slide_roll");
+    elm_label_ellipsis_set(label, true);
+    elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO);
+    elm_label_slide_duration_set(label, slideDuration);
+
+    std::string text = m_Translate ? msg(m_Title) : m_Title;
+    std::string resultText = TextDecorator::make(text, titleTextStyle);
+
+    View::setText(label, resultText);
+    elm_label_slide_go(label);
+    return label;
+}
+
+Evas_Object *TitleListItem::getContent(ListItem &item, const char *part)
+{
+    return createLabel();
+}
index b1697adb4a5a4fb0ab23e68c34cda97259921404..7af3db9bd625ae5ab41029c7d32d7595f43ffd29 100644 (file)
@@ -31,7 +31,7 @@ namespace Msg {
     class PaddingListViewItem;
     class ConvReplyListItem;
     class IConvListListener;
-    class ConvTitleListItem;
+    class TitleListItem;
 
     class ConvList
         : public ListView
@@ -84,7 +84,7 @@ namespace Msg {
             PaddingListViewItem *m_pBottomPadItem;
             ConvReplyListItem *m_pReplyItem;
             ListItem *m_pItemAfterConv; // Reply or Bottom padding.
-            ConvTitleListItem *m_pConvTitleItem;
+            TitleListItem *m_pTitleItem;
             WorkingDirRef m_WorkingDir;
             BubbleEntityFactory m_BubbleEntityFactory;
             ConvListItemMap m_ConvListItemMap;
index 5e5f20b51d1239a1c15fa126674b9be8ccb21696..821b2d984560ec23a213908848f6bae4ede1d5ae 100644 (file)
@@ -21,7 +21,7 @@
 #include "Window.h"
 #include "ConvReplyListItem.h"
 #include "PaddingListViewItem.h"
-#include "ConvTitleListItem.h"
+#include "TitleListItem.h"
 #include "ConvDateLineListItem.h"
 #include "TimeUtils.h"
 #include "BubbleEntityFactory.h"
@@ -35,7 +35,7 @@ ConvList::ConvList(Evas_Object *parent, WorkingDirRef &workingDir)
     , m_pBottomPadItem(nullptr)
     , m_pReplyItem(nullptr)
     , m_pItemAfterConv(nullptr)
-    , m_pConvTitleItem(nullptr)
+    , m_pTitleItem(nullptr)
     , m_WorkingDir(workingDir)
     , m_BubbleEntityFactory(m_WorkingDir)
 {
@@ -105,8 +105,8 @@ bool ConvList::isEmpty() const
 void ConvList::updateTitle()
 {
     MsgAddressListRef list = getMsgStorage().getAddressList(m_ThreadId);
-    if (list && !list->isEmpty() && m_pConvTitleItem) {
-        m_pConvTitleItem->setTitle(list->at(0).getAddress());
+    if (list && !list->isEmpty() && m_pTitleItem) {
+        m_pTitleItem->setTitle(list->at(0).getAddress(), false);
         // TODO: Find address in contacts
     }
 }
@@ -123,8 +123,8 @@ void ConvList::fillList()
     clear();
 
     // Recipient name:
-    m_pConvTitleItem = new ConvTitleListItem;
-    ListView::appendItem(*m_pConvTitleItem);
+    m_pTitleItem = new TitleListItem;
+    ListView::appendItem(*m_pTitleItem);
 
     MsgConversationListRef convList = getMsgStorage().getConversationList(m_ThreadId);
     int convListLen = convList->getLength();
diff --git a/src/Conversation/View/inc/ConvTitleListItem.h b/src/Conversation/View/inc/ConvTitleListItem.h
deleted file mode 100644 (file)
index adbba7e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 ConvTitleListItem_h_
-#define ConvTitleListItem_h_
-
-#include "ListItem.h"
-
-namespace Msg {
-    class ConvTitleListItem
-        : public ListItem {
-        public:
-            ConvTitleListItem();
-
-            void setTitle(const std::string &title);
-
-        private:
-            Evas_Object *getContent(ListItem &item, const char *part) override;
-            Evas_Object *createLabel() const;
-
-        private:
-            std::string m_Title;
-    };
-}
-
-#endif /* ConvTitleListItem_h_ */
diff --git a/src/Conversation/View/src/ConvTitleListItem.cpp b/src/Conversation/View/src/ConvTitleListItem.cpp
deleted file mode 100644 (file)
index 708a7f5..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "ConvTitleListItem.h"
-#include "ListView.h"
-#include "TextDecorator.h"
-
-using namespace Msg;
-
-const TextStyle titleTextStyle = TextStyle().
-                                 setSize(30).
-                                 setAlign(TextStyle::Align::Center).
-                                 setWeight(TextStyle::Weight::Bold).
-                                 setColor("#ffae0d");
-
-ConvTitleListItem::ConvTitleListItem()
-    : ListItem(ListItemStyle::create("conv_title"))
-{
-}
-
-void ConvTitleListItem::setTitle(const std::string &title)
-{
-    m_Title = TextDecorator::make(title, titleTextStyle);
-}
-
-Evas_Object *ConvTitleListItem::createLabel() const
-{
-    static const double slideDuration = 3.0;
-
-    Evas_Object *label = elm_label_add(*getOwner());
-    elm_object_focus_allow_set(label, false);
-    elm_object_style_set(label, "slide_roll");
-    elm_label_ellipsis_set(label, true);
-    elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO);
-    elm_label_slide_duration_set(label, slideDuration);
-    elm_label_slide_go(label);
-    View::setText(label, m_Title);
-    return label;
-}
-
-Evas_Object *ConvTitleListItem::getContent(ListItem &item, const char *part)
-{
-    return createLabel();
-}
index 911c8a4dfdc41ef95d12d663fd6538075bf9f839..2550a91c2a3193b4cba942b75d562a46577cca10 100644 (file)
 #define SettingsBlockListFrame_h_
 
 #include "FrameController.h"
-#include "ListView.h"
 
 namespace Msg
 {
+    class ListView;
+
     class SettingsBlockListFrame
         : public FrameController
-        , private IListViewListener
     {
         public:
             SettingsBlockListFrame(NaviFrameController &parent);
@@ -35,10 +35,11 @@ namespace Msg
             void onAttached(ViewItem &item) override;
 
         private:
-            // IListViewListener:
-            void onListItemSelected(ListItem &listItem) override;
+            void onBlockedNumberSelected(ListItem &listItem);
+            void onBlockedMsgSelected(ListItem &listItem);
 
             void preapareList();
+            void fillList();
 
         private:
             ListView *m_pList;
index 9c9b426a46d484bb7e9a9c8aacd286d4f20b511b..6c72f058796b897bdf40574acc47e42347e60ada 100644 (file)
  */
 
 #include "SettingsBlockListFrame.h"
+#include "SettingsMenuListItem.h"
+#include "PaddingListViewItem.h"
 #include "App.h"
 #include "Window.h"
 #include "Logger.h"
+#include "ListView.h"
+#include "TitleListItem.h"
+#include "ListView.h"
 
 using namespace Msg;
 
@@ -43,13 +48,45 @@ void SettingsBlockListFrame::preapareList()
 {
     if (!m_pList) {
         m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface());
-        m_pList->setListener(this);
         m_pList->setHomogeneous(false);
         m_pList->setMultiSelection(false);
+        fillList();
     }
 }
 
-void SettingsBlockListFrame::onListItemSelected(ListItem &listItem)
+void SettingsBlockListFrame::fillList()
 {
+    using namespace std::placeholders;
 
+    // Title:
+    auto *titleItem = new TitleListItem;
+    titleItem->setTitle("WDS_MSG_MBODY_BLOCK_LIST", true);
+    m_pList->appendItem(*titleItem);
+
+    // Blocked number:
+    auto *blockedNum = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle);
+    blockedNum->setText("WDS_MSG_MBODY_BLOCKED_NUMBERS");
+    std::bind(&SettingsBlockListFrame::onBlockedNumberSelected, this);
+    blockedNum->setOnSelectedCb(std::bind(&SettingsBlockListFrame::onBlockedNumberSelected, this, _1));
+    m_pList->appendItem(*blockedNum);
+
+    // Blocked messages:
+    auto *blockedMsg = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle);
+    blockedMsg->setText("WDS_MSG_MBODY_BLOCKED_NUMBERS");
+    blockedMsg->setOnSelectedCb(std::bind(&SettingsBlockListFrame::onBlockedMsgSelected, this, _1));
+    m_pList->appendItem(*blockedMsg);
+
+    // Bottom padding:
+    m_pList->appendItem(*new PaddingListViewItem);
+}
+
+void SettingsBlockListFrame::onBlockedNumberSelected(ListItem &listItem)
+{
+    MSG_LOG("");
 }
+
+void SettingsBlockListFrame::onBlockedMsgSelected(ListItem &listItem)
+{
+    MSG_LOG("");
+}
+
index ae599cad7825abc35b7598be56c770c7ce0cd1a5..8984fc95bc22cf9eff8bdf7926cbbaf082d89a4a 100644 (file)
@@ -25,7 +25,7 @@ namespace Msg {
         : public ListItem {
         public:
             BlockedNumberListViewItem();
-            ~BlockedNumberListViewItem();
+            virtual ~BlockedNumberListViewItem();
 
         public:
             static ListItemStyleRef numberStyle;
diff --git a/src/Settings/View/inc/SettingsMenuListItem.h b/src/Settings/View/inc/SettingsMenuListItem.h
new file mode 100644 (file)
index 0000000..5e75bf1
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 SettingsMenuListItem_h_
+#define SettingsMenuListItem_h_
+
+#include "ListItem.h"
+
+namespace Msg {
+    class SettingsMenuListItem
+        : public ListItem {
+
+         public:
+            static ListItemStyleRef oneTextStyle;
+            static ListItemStyleRef twoTextStyle;
+
+        public:
+            SettingsMenuListItem(const ListItemStyleRef &itemStyle);
+            virtual ~SettingsMenuListItem();
+
+            void setText(std::string text);
+            void setSubText(std::string text);
+
+        private:
+            std::string getText(ListItem &item, const char *part) override;
+
+        private:
+            std::string m_Text;
+            std::string m_SubText;
+    };
+}
+
+#endif // SettingsMenuListItem_h_
diff --git a/src/Settings/View/src/SettingsMenuListItem.cpp b/src/Settings/View/src/SettingsMenuListItem.cpp
new file mode 100644 (file)
index 0000000..edf6d81
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "SettingsMenuListItem.h"
+#include "LangUtils.h"
+
+using namespace Msg;
+
+namespace {
+    const char *mainTextPart = "elm.text";
+    const char *subTextPart = "elm.text.1";
+}
+
+ListItemStyleRef SettingsMenuListItem::oneTextStyle = ListItemStyle::create("1text");
+ListItemStyleRef SettingsMenuListItem::twoTextStyle = ListItemStyle::create("2text");
+
+SettingsMenuListItem::SettingsMenuListItem(const ListItemStyleRef &itemStyle)
+    : ListItem(itemStyle)
+{
+}
+
+SettingsMenuListItem::~SettingsMenuListItem()
+{
+}
+
+void SettingsMenuListItem::setText(std::string text)
+{
+    m_Text = std::move(text);
+}
+
+void SettingsMenuListItem::setSubText(std::string text)
+{
+    m_SubText = std::move(text);
+}
+
+std::string SettingsMenuListItem::getText(ListItem &item, const char *part)
+{
+    if (strcmp(part, mainTextPart) == 0)
+        return msg(m_Text.c_str());
+
+    if (strcmp(part, subTextPart) == 0)
+        return msg(m_SubText.c_str());
+
+    return "";
+}
+