TizenRefApp-6909 Implement selection from Group Member list in Chooser 81/85081/4
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Fri, 26 Aug 2016 08:21:28 +0000 (11:21 +0300)
committerAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Fri, 26 Aug 2016 09:52:52 +0000 (02:52 -0700)
Change-Id: I92ed3d2cc4e7de5d3d755831a2c29eb65549cc5a
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-apps-common/src/Ui/NaviframePage.cpp
lib-contacts/inc/Contacts/Chooser/ChooserView.h
lib-contacts/src/Contacts/Chooser/ChooserView.cpp
lib-logs/inc/Logs/Details/DetailsView.h
lib-logs/src/Logs/Details/DetailsView.cpp

index bfd79e8..69b9e2a 100644 (file)
@@ -29,9 +29,7 @@ NaviframePage::NaviframePage(Elm_Object_Item *naviItem)
 
 void NaviframePage::setTitle(const char *title)
 {
-       bool isEnabled = title && *title;
        elm_object_item_translatable_part_text_set(m_NaviItem, "elm.text.title", title);
-       setTitleVisibility(isEnabled);
 }
 
 void NaviframePage::setSubtitle(const char *subtitle)
index 1cf36fc..cd278e4 100644 (file)
@@ -59,6 +59,11 @@ namespace Contacts
 
                        Ux::SelectView *createContactsView();
                        Ux::SelectView *createGroupsView();
+                       Ux::SelectView *createMembersView(int groupId);
+                       void checkMembers(Ux::SelectView *membersView);
+
+                       bool onMemberChecked(Ux::SelectItem *item, bool isChecked, bool isSelectAll);
+                       bool onMemberCheckedForData(Ux::SelectItem *item, bool isChecked, bool isSelectAll);
 
                        bool onPersonChecked(Ux::SelectItem *item, bool isChecked, bool isSelectAll);
                        bool onPersonCheckedForData(Ux::SelectItem *item, bool isChecked, bool isSelectAll);
index 467879e..afbfabf 100644 (file)
 #include "Contacts/Chooser/ChooserView.h"
 #include "Contacts/Chooser/ContactsGroupsNavigator.h"
 
-#include "Contacts/Details/DetailsView.h"
 #include "Contacts/Groups/GroupsView.h"
+#include "Contacts/Groups/Model/Group.h"
+#include "Contacts/Groups/Model/MembersProvider.h"
+
 #include "Contacts/List/ListView.h"
+#include "Contacts/List/PersonItem.h"
+#include "Contacts/List/Model/Person.h"
+
+#include "Contacts/Details/DetailsView.h"
 #include "Contacts/Settings/ExportController.h"
 
 #include "Common/Actions.h"
 #include "Ux/SelectItem.h"
 #include "Utils/Logger.h"
 
+#include <app_i18n.h>
+#include <notification.h>
+
+#define POPUP_BUFFER_SIZE 256
+
 using namespace Common;
 using namespace Common::Database;
 
@@ -37,6 +48,8 @@ using namespace Contacts;
 using namespace Contacts::Chooser;
 using namespace Contacts::List;
 using namespace Contacts::Details;
+using namespace Contacts::Groups;
+using namespace Contacts::Groups::Model;
 using namespace Ux;
 using namespace std::placeholders;
 
@@ -116,10 +129,101 @@ SelectView *ChooserView::createContactsView()
 
 SelectView *ChooserView::createGroupsView()
 {
-       return new Groups::GroupsView();
+       auto view = new GroupsView();
+       view->setSelectMode(SelectSingle);
+       view->setSelectCallback([this](SelectResults results) {
+               auto group = static_cast<Group *>(results.front().value.data);
+               auto view = createMembersView(group->getId());
+
+               navigateTo(view);
+               view->getPage()->setTitleVisibility(false);
+               return false;
+       });
+       return view;
+}
+
+SelectView *ChooserView::createMembersView(int groupId)
+{
+       auto view = new ListView(new MembersProvider(groupId, MembersProvider::ModeDefault, m_FilterType));
+       view->setSelectMode(SelectMulti);
+       view->setSectionVisibility(ListView::SectionFavorites, false);
+       view->setFillFinishCallback([this, view] {
+               checkMembers(view);
+               if (m_SelectLimit) {
+                       size_t selectCount = m_ContactsView->getSelectCount() - view->getSelectCount();
+                       view->setSelectLimit(m_SelectLimit - selectCount);
+                       view->setLimitCallback([this] {
+                               char buffer[POPUP_BUFFER_SIZE];
+                               snprintf(buffer, sizeof(buffer), _("IDS_PB_POP_THE_MAXIMUM_NUMBER_OF_ITEMS_THAT_CAN_BE_SELECTED_HPD_HAS_BEEN_EXCEEDED"), m_SelectLimit);
+                               notification_status_message_post(buffer);
+                               return false;
+                       });
+               }
+       });
+
+       if (m_ResultType == ResultPerson || m_ResultType == ResultVcard) {
+               view->setCheckCallback(std::bind(&ChooserView::onMemberChecked, this, _1, _2, _3));
+       } else {
+               view->setCheckCallback(std::bind(&ChooserView::onMemberCheckedForData, this, _1, _2, _3));
+       }
+
+       return view;
+}
+
+void ChooserView::checkMembers(SelectView *membersView)
+{
+       auto &members = membersView->getSelectItems();
+       auto &persons = m_ContactsView->getSelectItems();
+
+       auto memberIt = members.begin();
+       auto personIt = persons.begin();
+       auto getPersonId = [](SelectItem *item) {
+               return static_cast<PersonItem *>(item)->getPerson().getId();
+       };
+
+       while (memberIt != members.end() && personIt != persons.end()) {
+               if (getPersonId(*memberIt) == getPersonId(*personIt)) {
+                       (*memberIt)->setChecked((*personIt)->isChecked());
+                       (*memberIt)->setCustomResult({ 0, *personIt });
+                       ++memberIt;
+               }
+               ++personIt;
+       }
+}
+
+bool ChooserView::onMemberChecked(SelectItem *item, bool isChecked, bool isSelectAll)
+{
+       if (!item->hasCustomResult()) {
+               return true;
+       }
+
+       auto personItem = (PersonItem *) item->getSelectResult().value.data;
+       return personItem->setChecked(isChecked);
+}
+
+bool ChooserView::onMemberCheckedForData(SelectItem *item, bool isChecked, bool isSelectAll)
+{
+       if (!item->hasCustomResult()) {
+               return true;
+       }
+
+       auto personItem = (PersonItem *) item->getSelectResult().value.data;
+       if (!isChecked) {
+               return personItem->setChecked(false);
+       }
+       if (personItem->hasCustomResult()) {
+               return true;
+       }
+
+       return selectSingleResult(personItem->getSelectResult(), isSelectAll,
+               [this, item, personItem](SelectResults results) {
+                       onSingleResultSelected(std::move(results), personItem);
+                       item->setChecked(true);
+                       return true;
+               });
 }
 
-bool ChooserView::onPersonChecked(Ux::SelectItem *item, bool isChecked, bool isSelectAll)
+bool ChooserView::onPersonChecked(SelectItem *item, bool isChecked, bool isSelectAll)
 {
        if (isChecked) {
                m_ContactsGroups->addSelectedItem(item);
index b48a082..24968b6 100644 (file)
@@ -63,6 +63,7 @@ namespace Logs
                private:
                        virtual Evas_Object *onCreate(Evas_Object *parent) override;
                        virtual void onCreated() override;
+                       virtual void onPageAttached(Ui::NavigatorPage *page) override;
                        virtual void onMenuPressed() override;
 
                        virtual void onSelectModeChanged(Ux::SelectMode selectMode) override;
index 0149cb2..836ccc5 100644 (file)
@@ -87,6 +87,12 @@ void DetailsView::onCreated()
        });
 }
 
+void DetailsView::onPageAttached(Ui::NavigatorPage *page)
+{
+       SelectView::onPageAttached(page);
+       page->setTitleVisibility(getSelectMode() != SelectNone);
+}
+
 void DetailsView::onMenuPressed()
 {
        if (getSelectMode() != SelectNone) {
@@ -103,6 +109,10 @@ void DetailsView::onMenuPressed()
 
 void DetailsView::onSelectModeChanged(SelectMode selectMode)
 {
+       if (auto page = getPage()) {
+               page->setTitleVisibility(getSelectMode() != SelectNone);
+       }
+
        if (getSelectMode() == SelectNone) {
                insertBasicInfoItem();
                insertActionItem();