Integrated SelectView into LogsView. 65/61165/3
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 3 Mar 2016 09:19:55 +0000 (11:19 +0200)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Wed, 9 Mar 2016 10:58:19 +0000 (12:58 +0200)
Change-Id: I3d1b8c9077d92fc84fbfcbb7c15335be57229cc2
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-logs/inc/Logs/List/LogItem.h
lib-logs/inc/Logs/List/LogsView.h
lib-logs/src/Logs/List/LogItem.cpp
lib-logs/src/Logs/List/LogsView.cpp
main-app/tizen-manifest.xml
main-app/tizen-manifest.xml.in

index 7d404ff..bf081af 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef LOGS_LIST_LOG_ITEM_H
 #define LOGS_LIST_LOG_ITEM_H
 
-#include "Ui/GenlistCheckItem.h"
+#include "Contacts/SelectItem.h"
 
 #define PART_LOG_TIME           "elm.text.sub.end"
 
@@ -28,18 +28,10 @@ namespace Logs
        {
                class LogGroup;
        }
+
        namespace List
        {
-               /**
-                * @brief Represents item mode
-                */
-               enum class ItemMode
-               {
-                       Default,    /*< Usual mode */
-                       Pick        /*< Mode with ability to select item */
-               };
-
-               class LogItem : public Ui::GenlistCheckItem
+               class LogItem : public Contacts::SelectItem
                {
                public:
                        /**
@@ -55,15 +47,8 @@ namespace Logs
                        /**
                         * @brief Create log item
                         * @param[in]   group       Log group
-                        * @param[in]   mode        Item mode
-                        */
-                       LogItem(Model::LogGroup *group, ItemMode mode = ItemMode::Default);
-
-                       /**
-                        * @brief Set item mode
-                        * @param[in]   mode    Item mode
                         */
-                       void setMode(ItemMode mode);
+                       LogItem(Model::LogGroup *group);
 
                        /**
                         * @brief Set delete item callback
@@ -85,6 +70,7 @@ namespace Logs
                private:
                        virtual char *getText(Evas_Object *parent, const char *part) override;
                        virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
+                       virtual Contacts::SelectResult getSelectResult() const override;
 
                        Evas_Object *createThumbnail(Evas_Object *parent);
                        Evas_Object *createLayout(Evas_Object *parent, const char *layoutName);
@@ -98,7 +84,6 @@ namespace Logs
                        DeleteCallback m_OnDelete;
                        DetailsCallback m_OnDetails;
                        Model::LogGroup *m_Group;
-                       ItemMode m_Mode;
                };
        }
 }
index e8ddb15..d4937f2 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef LOGS_LIST_LOGS_VIEW_H
 #define LOGS_LIST_LOGS_VIEW_H
 
-#include "Ui/View.h"
+#include "Contacts/SelectView.h"
 #include "Logs/Model/LogProvider.h"
 #include <system_settings.h>
 
@@ -33,12 +33,11 @@ namespace Logs
        {
                class LogGroupItem;
                class LogItem;
-               enum class ItemMode;
 
                /**
                 * @brief Logs list view
                 */
-               class EXPORT_API LogsView : public Ui::View
+               class EXPORT_API LogsView : public Contacts::SelectView
                {
                public:
 
@@ -61,9 +60,12 @@ namespace Logs
                private:
                        virtual Evas_Object *onCreate(Evas_Object *parent) override;
                        virtual void onCreated() override;
-                       virtual void onPageAttached() override;
                        virtual void onMenuPressed() override;
 
+                       virtual const char *getPageTitle() const override;
+                       virtual void onSelectAllInsert(Ui::GenlistItem *item) override;
+                       virtual void onItemPressed(Contacts::SelectItem *item) override;
+
                        void fillLayout();
                        void updateLayout(bool isEmpty);
                        Evas_Object *createNoContentsLayout(Evas_Object *parent);
@@ -78,15 +80,12 @@ namespace Logs
                        void setLastGroupItem(LogGroupItem *groupItem);
 
 
-                       void setMode(ItemMode mode);
-
                        void onSettingsChanged(system_settings_key_e key);
                        void onSelectViewBy();
                        void onLogInserted(Model::LogGroup *group);
                        void onLogItemDelete(LogItem *item);
 
                        Model::LogProvider m_LogProvider;
-                       ItemMode m_Mode;
                        FilterType m_FilterType;
 
                        Ui::Genlist *m_Genlist;
index 98051bd..c9ee5d1 100644 (file)
@@ -45,6 +45,7 @@
 #define PART_END                "elm.swallow.end"
 
 using namespace Ui;
+using namespace Contacts;
 using namespace Logs::List;
 using namespace Logs::Model;
 using namespace Logs::Details;
@@ -54,18 +55,12 @@ namespace
        const std::string layoutPath = App::getResourcePath(LOG_ITEM_LAYOUT_EDJ);
 }
 
-LogItem::LogItem(LogGroup *group, ItemMode mode)
-       : m_Group(group), m_Mode(mode)
+LogItem::LogItem(LogGroup *group)
+       : m_Group(group)
 {
        setUpdateCallback();
 }
 
-void LogItem::setMode(ItemMode mode)
-{
-       m_Mode = mode;
-       elm_genlist_item_fields_update(getObjectItem(), PART_END, ELM_GENLIST_ITEM_FIELD_CONTENT);
-}
-
 void LogItem::setDeleteCallback(DeleteCallback callback)
 {
        m_OnDelete = std::move(callback);
@@ -93,10 +88,12 @@ char *LogItem::getText(Evas_Object *parent, const char *part)
        const Log *log = m_Group->getLogList().back();
        const char *name = log->getName();
        const char *number = log->getNumber();
+
        if (name == nullptr) {
                name = number;
                number = _("IDS_LOGS_SBODY_UNSAVED_M_STATUS");
        }
+
        if (strcmp(part, PART_LOG_NAME) == 0) {
                return strdup(name);
        } else if (strcmp(part, PART_LOG_NUMBER) == 0) {
@@ -122,20 +119,25 @@ Evas_Object *LogItem::getContent(Evas_Object *parent, const char *part)
        if (strcmp(part, PART_PERSON_THUMBNAIL) == 0) {
                return createThumbnail(parent);
        } else if (strcmp(part, PART_END) == 0) {
-               if (m_Mode == ItemMode::Pick) {
-                       return GenlistCheckItem::getContent(parent, part);
-               } else {
+               if (getSelectMode() == SelectNone) {
                        Evas_Object *icon = createIcon(parent, ICON_INFO);
                        evas_object_propagate_events_set(icon, EINA_FALSE);
                        evas_object_smart_callback_add(icon, "clicked",
                                        (Evas_Smart_Cb) makeCallback(&LogItem::onInfoIconPressed), this);
                        return icon;
+               } else {
+                       return SelectItem::getContent(parent, part);
                }
        }
 
        return nullptr;
 }
 
+SelectResult LogItem::getSelectResult() const
+{
+       return { 0, m_Group };
+}
+
 Evas_Object *LogItem::createThumbnail(Evas_Object *parent)
 {
        using Ui::Thumbnail;
index 3565dc0..7351e27 100644 (file)
 #include "Utils/Logger.h"
 #include "Utils/Callback.h"
 
+using namespace Contacts;
 using namespace Logs::Model;
 using namespace Logs::List;
 using namespace Logs::Details;
 using namespace std::placeholders;
 
 LogsView::LogsView(FilterType filterType)
-       : m_Mode(ItemMode::Default), m_FilterType(filterType),
+       : m_FilterType(filterType),
          m_Genlist(nullptr), m_LastGroupItem(nullptr)
 {
        system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, makeCallbackWithLastParam(&LogsView::onSettingsChanged), this);
@@ -65,14 +66,9 @@ void LogsView::onCreated()
        fillLayout();
 }
 
-void LogsView::onPageAttached()
-{
-       getPage()->setTitle("IDS_LOGS_ITAB3_LOGS");
-}
-
 void LogsView::onMenuPressed()
 {
-       if (m_Mode == ItemMode::Pick) {
+       if (getSelectMode() != SelectNone) {
                return;
        }
 
@@ -84,13 +80,49 @@ void LogsView::onMenuPressed()
        });
 
        menu->addItem("IDS_LOGS_OPT_DELETE", [this] {
-               LogsView *deleteView = new LogsView(m_FilterType);
-               deleteView->setMode(ItemMode::Pick);
-               getNavigator()->navigateTo(deleteView);
+               LogsView *view = new LogsView(m_FilterType);
+               view->setSelectMode(SelectMulti);
+               view->setSelectCallback([](SelectResults results) {
+                       for (auto &&result : results) {
+                               LogGroup *group = (LogGroup *) result.value.data;
+                               group->remove();
+                       }
+
+                       return true;
+               });
+               getNavigator()->navigateTo(view);
        });
+
        menu->show();
 }
 
+const char *LogsView::getPageTitle() const
+{
+       if (getSelectMode() == SelectNone) {
+               return "IDS_LOGS_ITAB3_LOGS";
+       }
+
+       return SelectView::getPageTitle();
+}
+
+void LogsView::onSelectAllInsert(Ui::GenlistItem *item)
+{
+       m_Genlist->insert(item, nullptr, nullptr, Ui::Genlist::After);
+}
+
+void LogsView::onItemPressed(Contacts::SelectItem *item)
+{
+       LogItem *logItem = (LogItem *) item;
+       LogGroup *group = logItem->getGroup();
+
+       const char *number = group->getLogList().back()->getNumber();
+       if (number) {
+               App::AppControl appControl = App::requestTelephonyCall(number);
+               appControl.launch(nullptr, nullptr, false);
+               appControl.detach();
+       }
+}
+
 void LogsView::fillLayout()
 {
        if (m_Genlist) {
@@ -164,18 +196,8 @@ bool LogsView::shouldDisplayLogs(const LogGroup *group) const
 
 LogItem *LogsView::createLogItem(LogGroup *group)
 {
-       LogItem *item = new LogItem(group, m_Mode);
-
+       LogItem *item = new LogItem(group);
        item->setDeleteCallback(std::bind(&LogsView::onLogItemDelete, this, _1));
-       item->setSelectCallback([this, group]() {
-               const char *number = group->getLogList().back()->getNumber();
-               if (number) {
-                       App::AppControl appControl = App::requestTelephonyCall(number);
-                       appControl.launch(nullptr, nullptr, false);
-                       appControl.detach();
-               }
-       });
-
        item->setDetailsCallback([this](LogItem *item) {
                getNavigator()->navigateTo(new DetailsView(item->getGroup()));
        });
@@ -193,6 +215,7 @@ LogItem *LogsView::insertLogItem(LogGroup *group)
 
        LogItem *item = createLogItem(group);
        m_Genlist->insert(item, groupItem, *groupItem->begin());
+       onItemInserted(item);
        return item;
 }
 
@@ -232,11 +255,6 @@ void LogsView::setLastGroupItem(LogGroupItem *groupItem)
        });
 }
 
-void LogsView::setMode(ItemMode mode)
-{
-       m_Mode = mode;
-}
-
 void LogsView::onSettingsChanged(system_settings_key_e key)
 {
        if (key == SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY ||
@@ -281,6 +299,7 @@ void LogsView::onLogInserted(LogGroup *group)
 void LogsView::onLogItemDelete(LogItem *item)
 {
        Ui::GenlistGroupItem *groupItem = item->getParentItem();
+       onItemRemove(item);
        delete item;
 
        if (groupItem->empty()) {
index 6a8688d..6cf38a6 100644 (file)
         <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
         <privilege>http://tizen.org/privilege/call</privilege>
         <privilege>http://tizen.org/privilege/callhistory.read</privilege>
+        <privilege>http://tizen.org/privilege/callhistory.write</privilege>
         <privilege>http://tizen.org/privilege/contact.read</privilege>
         <privilege>http://tizen.org/privilege/contact.write</privilege>
         <privilege>http://tizen.org/privilege/externalstorage</privilege>
index e2816e3..0a83634 100644 (file)
                <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
                <privilege>http://tizen.org/privilege/call</privilege>
                <privilege>http://tizen.org/privilege/callhistory.read</privilege>
+               <privilege>http://tizen.org/privilege/callhistory.write</privilege>
                <privilege>http://tizen.org/privilege/contact.read</privilege>
                <privilege>http://tizen.org/privilege/contact.write</privilege>
                <privilege>http://tizen.org/privilege/mediastorage</privilege>