TizenRefApp-8333 Implement blocked numbers/messages frame 14/123914/2
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Fri, 7 Apr 2017 11:19:56 +0000 (14:19 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Fri, 7 Apr 2017 12:41:30 +0000 (05:41 -0700)
Change-Id: I7339bfd1e8b799d28de28bb08460cb2dc6ebb789
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
13 files changed:
src/MsgThread/Controller/src/ThreadList.cpp
src/MsgThread/View/inc/NoContentListViewItem.h
src/Settings/Controller/inc/BlockedMsgListItem.h [new file with mode: 0644]
src/Settings/Controller/inc/BlockedNumberListItem.h [new file with mode: 0644]
src/Settings/Controller/inc/SettingsBlockListFrame.h
src/Settings/Controller/inc/SettingsFrame.h
src/Settings/Controller/inc/SettingsMenuBlockListFrame.h [new file with mode: 0644]
src/Settings/Controller/src/BlockedMsgListItem.cpp [new file with mode: 0644]
src/Settings/Controller/src/BlockedNumberListItem.cpp [new file with mode: 0644]
src/Settings/Controller/src/SettingsBlockListFrame.cpp
src/Settings/Controller/src/SettingsFrame.cpp
src/Settings/Controller/src/SettingsMenuBlockListFrame.cpp [new file with mode: 0644]
src/Settings/View/inc/BlockedNumberListViewItem.h

index 1bf79fea6baf987103895fd00fc6382f5c81af64..28ec73bf9b1bbd32416e8069a496b3dc449c0cd0 100644 (file)
@@ -254,6 +254,7 @@ void ThreadList::showNoContent(bool value)
     if (value) {
         if (!m_pNoContentItem) {
             m_pNoContentItem = new NoContentListViewItem;
+            m_pNoContentItem->setText("WDS_MSG_NPBODY_NO_MESSAGES_ABB");
             insertBeforeItem(*m_pNoContentItem, *m_pBottomPadItem);
         }
     } else if (m_pNoContentItem){
index 5cc2be68159717ba53eb06806f660e3bb03508f1..554181585ffd2b338c6b3ecf909660be619ccd55 100644 (file)
@@ -26,11 +26,16 @@ namespace Msg {
         public:
             NoContentListViewItem();
 
+            void setText(std::string text);
+
         protected:
             void onAttached(ViewItem &item) override;
 
         private:
             std::string getText(ListItem &item, const char *part) override;
+
+        private:
+            std::string m_Text;
     };
 
     inline NoContentListViewItem::NoContentListViewItem()
@@ -38,10 +43,15 @@ namespace Msg {
     {
     }
 
+    inline void NoContentListViewItem::setText(std::string text)
+    {
+        m_Text = std::move(text);
+    }
+
     inline std::string NoContentListViewItem::getText(ListItem &item, const char *part)
     {
         if (!strcmp(part, "elm.text"))
-            return (std::string)msg("WDS_MSG_NPBODY_NO_MESSAGES_ABB");
+            return (std::string)msg(m_Text.c_str());
 
         return "";
     }
diff --git a/src/Settings/Controller/inc/BlockedMsgListItem.h b/src/Settings/Controller/inc/BlockedMsgListItem.h
new file mode 100644 (file)
index 0000000..488723c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 BlockedMsgListItem_h_
+#define BlockedMsgListItem_h_
+
+#include "ThreadListViewItem.h"
+
+namespace Msg {
+    class BlockedMsgListItem
+        : public ThreadListViewItem {
+
+        public:
+            BlockedMsgListItem();
+            virtual ~BlockedMsgListItem();
+
+        private:
+            std::string getName() override;
+            std::string getMessage() override;
+            std::string getTime() override;
+            std::string getUnreadCount() override;
+    };
+}
+
+#endif // BlockedMsgListItem_h_
diff --git a/src/Settings/Controller/inc/BlockedNumberListItem.h b/src/Settings/Controller/inc/BlockedNumberListItem.h
new file mode 100644 (file)
index 0000000..5a31e16
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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 BlockedNumberListItem_h_
+#define BlockedNumberListItem_h_
+
+#include "BlockedNumberListViewItem.h"
+
+namespace Msg {
+    class BlockedNumberListItem
+        : public BlockedNumberListViewItem {
+
+        public:
+            BlockedNumberListItem();
+            virtual ~BlockedNumberListItem();
+
+        private:
+            std::string getAddress() override;
+            std::string getContactName() override;
+    };
+}
+
+#endif // BlockedNumberListItem_h_
index fa3b1da7b3471b460f3cc35fc57e4b4c0410fc3c..003fb36b00e8d54ee104ac56d4e03007e05b77c7 100644 (file)
 #define SettingsBlockListFrame_h_
 
 #include "FrameController.h"
+#include "ListView.h"
+
+namespace Msg {
 
-namespace Msg
-{
     class ListView;
     class ListItem;
+    class DefaultLayout;
+    class MoreOption;
+    class BottomButton;
+    class CtxPopupItem;
+    class SelectButton;
+    class PaddingListViewItem;
+    class NoContentListViewItem;
 
     class SettingsBlockListFrame
-        : public FrameController
-    {
+        : public FrameController {
+
         public:
-            SettingsBlockListFrame(NaviFrameController &parent);
+            enum BlockListType {
+                BlockedNumType,
+                BlockedMsgType
+            };
+
+            SettingsBlockListFrame(NaviFrameController &parent, BlockListType type);
             virtual ~SettingsBlockListFrame();
 
         protected:
@@ -36,14 +49,37 @@ namespace Msg
             void onAttached(ViewItem &item) override;
 
         private:
-            void onBlockedNumberSelected(ListItem &listItem);
-            void onBlockedMsgSelected(ListItem &listItem);
+            // Select mode cb:
+            void onDoneButtonClicked(Evas_Object *obj, void *event);
+            void onSelectButtonClicked(Evas_Object *obj, void *event);
+            void onSelectAllButtonClicked(CtxPopupItem &item);
+            void onDeselectAllButtonClicked(CtxPopupItem &item);
+
+            // More option:
+            void onRestoreClicked(MoreOption &obj);
+            void onDeleteClicked(MoreOption &obj);
 
+            void prepareMainLayout();
+            void prepareMoreOption();
+            void prepareSelectViews();
             void preapareList();
+            void updateCheckViews();
             void fillList();
+            void setSelectMode(bool value);
+            void showSelectPopup();
+            void updateNoContent();
+            void insertItem(ListItem *item);
 
         private:
+            const BlockListType m_BlockListType;
+            bool m_IsSelectMode;
+            DefaultLayout *m_pLayout;
+            MoreOption *m_pMoreOption;
+            BottomButton *m_pDoneButton;
+            SelectButton *m_pSelectButton;
             ListView *m_pList;
+            PaddingListViewItem *m_pBottomItem;
+            NoContentListViewItem *m_pNoContentItem;
     };
 }
 
index a2620ab0d00fe16b3b39b0b49a9a411b0dbc855d..48b37500bf894b618c57413f6f1eb2475f7966c4 100644 (file)
 #define SettingsFrame_h_
 
 #include "FrameController.h"
-#include "SettingsBlockListFrame.h"
+#include "SettingsMenuBlockListFrame.h"
 
-namespace Msg
-{
+namespace Msg {
     /**
      * @brief A core-class responsible for a whole lifecycle of settings-module and for managing
      *        sub-components of message settings.
      */
     class SettingsFrame
-        : public SettingsBlockListFrame
-    {
+        : public SettingsMenuBlockListFrame {
         public:
             /**
              * @brief A constructor of Settings object based on outside parent object.
diff --git a/src/Settings/Controller/inc/SettingsMenuBlockListFrame.h b/src/Settings/Controller/inc/SettingsMenuBlockListFrame.h
new file mode 100644 (file)
index 0000000..f9c5bfe
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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 SettingsMenuBlockListFrame_h_
+#define SettingsMenuBlockListFrame_h_
+
+#include "FrameController.h"
+
+namespace Msg {
+    class ListView;
+    class ListItem;
+
+    class SettingsMenuBlockListFrame
+        : public FrameController {
+        public:
+            SettingsMenuBlockListFrame(NaviFrameController &parent);
+            virtual ~SettingsMenuBlockListFrame();
+
+        protected:
+            // NaviFrameItem:
+            void onAttached(ViewItem &item) override;
+
+        private:
+            void onBlockedNumberSelected(ListItem &listItem);
+            void onBlockedMsgSelected(ListItem &listItem);
+
+            void preapareList();
+            void fillList();
+
+        private:
+            ListView *m_pList;
+    };
+}
+
+#endif /* SettingsMenuBlockListFrame_h_ */
diff --git a/src/Settings/Controller/src/BlockedMsgListItem.cpp b/src/Settings/Controller/src/BlockedMsgListItem.cpp
new file mode 100644 (file)
index 0000000..0e675f1
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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 "BlockedMsgListItem.h"
+
+using namespace Msg;
+
+BlockedMsgListItem::BlockedMsgListItem()
+{
+
+}
+
+BlockedMsgListItem::~BlockedMsgListItem()
+{
+
+}
+
+std::string BlockedMsgListItem::getName()
+{
+    // TODO: impl.
+    return "Name";
+}
+
+std::string BlockedMsgListItem::getMessage()
+{
+    // TODO: impl.
+    return "Message";
+}
+
+std::string BlockedMsgListItem::getTime()
+{
+    // TODO: impl.
+    return "";
+}
+
+std::string BlockedMsgListItem::getUnreadCount()
+{
+    // TODO: impl.
+    return "";
+}
+
diff --git a/src/Settings/Controller/src/BlockedNumberListItem.cpp b/src/Settings/Controller/src/BlockedNumberListItem.cpp
new file mode 100644 (file)
index 0000000..ff551ad
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 "BlockedNumberListItem.h"
+
+using namespace Msg;
+
+BlockedNumberListItem::BlockedNumberListItem()
+{
+    // TODO: impl.
+}
+
+BlockedNumberListItem::~BlockedNumberListItem()
+{
+}
+
+std::string BlockedNumberListItem::getAddress()
+{
+    // TODO: impl.
+    return "Address";
+}
+
+std::string BlockedNumberListItem::getContactName()
+{
+    // TODO: impl.
+    return "Name";
+}
index 6c72f058796b897bdf40574acc47e42347e60ada..d7f528dc5bc8dde8bc32753d04102aca15aa0eb7 100644 (file)
  * limitations under the License.
  */
 
+
 #include "SettingsBlockListFrame.h"
-#include "SettingsMenuListItem.h"
+#include "MoreOption.h"
+#include "BottomButton.h"
+#include "DefaultLayout.h"
+#include "TitleListItem.h"
 #include "PaddingListViewItem.h"
-#include "App.h"
-#include "Window.h"
+#include "SelectButton.h"
+#include "SelectCtxPopup.h"
 #include "Logger.h"
-#include "ListView.h"
-#include "TitleListItem.h"
-#include "ListView.h"
+#include "BlockedNumberListItem.h"
+#include "BlockedMsgListItem.h"
+#include "NoContentListViewItem.h"
 
 using namespace Msg;
 
-SettingsBlockListFrame::SettingsBlockListFrame(NaviFrameController &parent)
+SettingsBlockListFrame::SettingsBlockListFrame(NaviFrameController &parent, BlockListType type)
     : FrameController(parent)
+    , m_BlockListType(type)
+    , m_IsSelectMode(false)
+    , m_pLayout(nullptr)
+    , m_pMoreOption(nullptr)
+    , m_pDoneButton(nullptr)
+    , m_pSelectButton(nullptr)
     , m_pList(nullptr)
+    , m_pBottomItem(nullptr)
+    , m_pNoContentItem(nullptr)
 {
+    MSG_LOG("");
+    prepareMainLayout();
+    prepareMoreOption();
     preapareList();
+    updateNoContent();
 }
 
 SettingsBlockListFrame::~SettingsBlockListFrame()
 {
+}
+
+void SettingsBlockListFrame::setSelectMode(bool value)
+{
+    if (value == m_IsSelectMode)
+        return;
+
+    m_IsSelectMode = value;
+    m_pLayout->showBottomButton(value);
+    m_pLayout->showMoreOption(!value);
 
+    if (value) {
+        prepareSelectViews();
+        m_pSelectButton->setText("0");
+        m_pSelectButton->showButton(true);
+        m_pDoneButton->disabled(true);
+    } else {
+        if (m_pSelectButton)
+            m_pSelectButton->showButton(false);
+    }
 }
 
-void SettingsBlockListFrame::onAttached(ViewItem &item)
+void SettingsBlockListFrame::prepareMainLayout()
 {
-    FrameController::onAttached(item);
-    setContent(*m_pList);
+    if (!m_pLayout) {
+        m_pLayout = new DefaultLayout(getParent());
+        m_pLayout->showSelectButton(true);
+        m_pLayout->showMoreOption(true);
+    }
 }
 
 void SettingsBlockListFrame::preapareList()
@@ -50,43 +88,142 @@ void SettingsBlockListFrame::preapareList()
         m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface());
         m_pList->setHomogeneous(false);
         m_pList->setMultiSelection(false);
+        m_pLayout->setContent(*m_pList);
         fillList();
     }
 }
 
 void SettingsBlockListFrame::fillList()
 {
-    using namespace std::placeholders;
-
     // Title:
     auto *titleItem = new TitleListItem;
-    titleItem->setTitle("WDS_MSG_MBODY_BLOCK_LIST", true);
+    const char *titleStr = m_BlockListType == BlockedMsgType ? "WDS_MSG_MBODY_BLOCKED_MESSAGES"
+                                                             : "WDS_MSG_MBODY_BLOCKED_NUMBERS";
+    titleItem->setTitle(titleStr, 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);
+    // Bottom padding:
+    m_pBottomItem = new PaddingListViewItem;
+    insertItem(m_pBottomItem);
+}
+
+void SettingsBlockListFrame::prepareMoreOption()
+{
+    if (!m_pMoreOption) {
+        m_pMoreOption = new MoreOption(*m_pLayout);
+        m_pMoreOption->setDirection(EEXT_MORE_OPTION_DIRECTION_RIGHT);
+        m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_NEW_MESSAGE_ABB"), NEW_MSG_MORE_ICON, makeCbLast(&SettingsBlockListFrame::onRestoreClicked), this);
+        m_pMoreOption->appendItem(msgt("WDS_MSG_OPT_DELETE_ABB"), DELETEG_MORE_ICON, makeCbLast(&SettingsBlockListFrame::onDeleteClicked), this);
+        m_pLayout->setMoreOption(*m_pMoreOption);
+    }
+}
 
-    // 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);
+void SettingsBlockListFrame::prepareSelectViews()
+{
+    if (!m_pDoneButton) {
+        m_pDoneButton = new BottomButton(*m_pLayout);
+        m_pDoneButton->setText(msgt("IDS_MSG_ACBUTTON_DELETE_ABB"));
+        View::addSmartCb(m_pDoneButton->getInnerButton(), "clicked", makeCbFirst(&SettingsBlockListFrame::onDoneButtonClicked), this);
+        m_pLayout->setBottomButton(*m_pDoneButton);
+    }
 
-    // Bottom padding:
-    m_pList->appendItem(*new PaddingListViewItem);
+    if (!m_pSelectButton) {
+        m_pSelectButton = new SelectButton(*m_pLayout);
+        View::addSmartCb(m_pSelectButton->getInnerButton(), "clicked", makeCbFirst(&SettingsBlockListFrame::onSelectButtonClicked), this);
+        m_pLayout->setSelectButton(*m_pSelectButton);
+    }
+}
+
+void SettingsBlockListFrame::updateCheckViews()
+{
+    if (m_IsSelectMode) {
+        int count = m_pList->getCheckedItemsCount();
+        m_pSelectButton->setText(std::to_string(count));
+        m_pDoneButton->disabled(count <= 0);
+    }
+}
+
+void SettingsBlockListFrame::showSelectPopup()
+{
+    auto *ctx = new SelectCtxPopup;
+    int checkedCount = m_pList->getCheckedItemsCount();
+    int checkableCount = m_pList->getCheckableItemsCount();
+
+    if (checkedCount < checkableCount)
+        ctx->appendTopItem(msg("WDS_MSG_OPT_SELECT_ALL_ABB"), makeCbLast(&SettingsBlockListFrame::onSelectAllButtonClicked), this);
+    if (checkedCount > 0)
+        ctx->appendBottomItem(msg("WDS_MSG_OPT_DESELECT_ALL_ABB"), makeCbLast(&SettingsBlockListFrame::onDeselectAllButtonClicked), this);
+
+    if (m_pSelectButton)
+        ctx->align(m_pSelectButton->getInnerButton());
+
+    ctx->go();
+}
+
+void SettingsBlockListFrame::updateNoContent()
+{
+    int count = m_BlockListType == BlockedNumType ? m_pList->getItemsCount<BlockedNumberListItem>()
+                                                  : m_pList->getItemsCount<BlockedMsgListItem>();
+
+    if (count <= 0) {
+        if (!m_pNoContentItem) {
+            const char *noContentText = m_BlockListType == BlockedNumType ? "WDS_MSG_NPBODY_NO_BLOCKED_NUMBERS_ABB"
+                                                                          : "WDS_MSG_NPBODY_NO_BLOCKED_MESSAGES_ABB";
+            m_pNoContentItem = new NoContentListViewItem;
+            m_pNoContentItem->setText(noContentText);
+            insertItem(m_pNoContentItem);
+        }
+    } else if (m_pNoContentItem) {
+        m_pNoContentItem->destroy();
+        m_pNoContentItem = nullptr;
+    }
+}
+
+void SettingsBlockListFrame::insertItem(ListItem *item)
+{
+    if(m_pBottomItem && m_pBottomItem != item)
+        m_pList->insertBeforeItem(*item, *m_pBottomItem);
+    else
+        m_pList->appendItem(*item);
+}
+
+void SettingsBlockListFrame::onAttached(ViewItem &item)
+{
+    FrameController::onAttached(item);
+    setContent(*m_pLayout);
+}
+
+void SettingsBlockListFrame::onSelectAllButtonClicked(CtxPopupItem &item)
+{
+    MSG_LOG("");
+}
+
+void SettingsBlockListFrame::onDeselectAllButtonClicked(CtxPopupItem &item)
+{
+    MSG_LOG("");
+}
+
+void SettingsBlockListFrame::onRestoreClicked(MoreOption &obj)
+{
+    MSG_LOG("");
+}
+
+void SettingsBlockListFrame::onDeleteClicked(MoreOption &obj)
+{
+    MSG_LOG("");
+    setSelectMode(true);
 }
 
-void SettingsBlockListFrame::onBlockedNumberSelected(ListItem &listItem)
+void SettingsBlockListFrame::onDoneButtonClicked(Evas_Object *obj, void *event)
 {
     MSG_LOG("");
+    setSelectMode(false);
 }
 
-void SettingsBlockListFrame::onBlockedMsgSelected(ListItem &listItem)
+void SettingsBlockListFrame::onSelectButtonClicked(Evas_Object *obj, void *event)
 {
     MSG_LOG("");
 }
 
+
+
index 65b4e148f95aba1e5e970dd3895df26c1addb236..85eb4627183131ded7ded2af9883e48483e11ae2 100644 (file)
@@ -20,7 +20,7 @@
 using namespace Msg;
 
 SettingsFrame::SettingsFrame(NaviFrameController &parent)
-    : SettingsBlockListFrame(parent)
+    : SettingsMenuBlockListFrame(parent)
 {
 }
 
@@ -31,5 +31,5 @@ SettingsFrame::~SettingsFrame()
 void SettingsFrame::onAttached(ViewItem &item)
 {
     MSG_LOG("");
-    SettingsBlockListFrame::onAttached(item);
+    SettingsMenuBlockListFrame::onAttached(item);
 }
diff --git a/src/Settings/Controller/src/SettingsMenuBlockListFrame.cpp b/src/Settings/Controller/src/SettingsMenuBlockListFrame.cpp
new file mode 100644 (file)
index 0000000..09a84d5
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * 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 "SettingsMenuBlockListFrame.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"
+#include "SettingsBlockListFrame.h"
+
+using namespace Msg;
+
+SettingsMenuBlockListFrame::SettingsMenuBlockListFrame(NaviFrameController &parent)
+    : FrameController(parent)
+    , m_pList(nullptr)
+{
+    preapareList();
+}
+
+SettingsMenuBlockListFrame::~SettingsMenuBlockListFrame()
+{
+
+}
+
+void SettingsMenuBlockListFrame::onAttached(ViewItem &item)
+{
+    FrameController::onAttached(item);
+    setContent(*m_pList);
+}
+
+void SettingsMenuBlockListFrame::preapareList()
+{
+    if (!m_pList) {
+        m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface());
+        m_pList->setHomogeneous(false);
+        m_pList->setMultiSelection(false);
+        fillList();
+    }
+}
+
+void SettingsMenuBlockListFrame::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");
+    blockedNum->setOnSelectedCb(std::bind(&SettingsMenuBlockListFrame::onBlockedNumberSelected, this, _1));
+    m_pList->appendItem(*blockedNum);
+
+    // Blocked messages:
+    auto *blockedMsg = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle);
+    blockedMsg->setText("WDS_MSG_MBODY_BLOCKED_MESSAGES");
+    blockedMsg->setOnSelectedCb(std::bind(&SettingsMenuBlockListFrame::onBlockedMsgSelected, this, _1));
+    m_pList->appendItem(*blockedMsg);
+
+    // Bottom padding:
+    m_pList->appendItem(*new PaddingListViewItem);
+}
+
+void SettingsMenuBlockListFrame::onBlockedNumberSelected(ListItem &listItem)
+{
+    MSG_LOG("");
+    auto *frame = new SettingsBlockListFrame(getParent(), SettingsBlockListFrame::BlockedNumType);
+    getParent().push(*frame);
+}
+
+void SettingsMenuBlockListFrame::onBlockedMsgSelected(ListItem &listItem)
+{
+    MSG_LOG("");
+    auto *frame = new SettingsBlockListFrame(getParent(), SettingsBlockListFrame::BlockedMsgType);
+    getParent().push(*frame);
+}
+
index 8984fc95bc22cf9eff8bdf7926cbbaf082d89a4a..a221c9b1843601181c4dbb08b3fc67db6027daaf 100644 (file)
 namespace Msg {
     class BlockedNumberListViewItem
         : public ListItem {
-        public:
-            BlockedNumberListViewItem();
-            virtual ~BlockedNumberListViewItem();
 
         public:
             static ListItemStyleRef numberStyle;
             static ListItemStyleRef contactNameStyle;
 
+        public:
+            BlockedNumberListViewItem();
+            virtual ~BlockedNumberListViewItem();
+
+
         protected:
             virtual std::string getAddress() = 0;
             virtual std::string getContactName() = 0;