diff options
author | Igor Olshevskyi <i.olshevskyi@samsung.com> | 2017-10-18 13:04:41 +0300 |
---|---|---|
committer | Igor Nazarov <i.nazarov@samsung.com> | 2017-10-25 17:15:37 +0300 |
commit | c2ac6f69df4c62b04fb43dfc3fe27b84f683142c (patch) | |
tree | a49c6d523b41a870bcb96b914eb36f1d5f35d608 | |
parent | 4fa2eb57251d57581d95e241a8d6aed2ac60b119 (diff) | |
download | call-setting-c2ac6f69df4c62b04fb43dfc3fe27b84f683142c.tar.gz call-setting-c2ac6f69df4c62b04fb43dfc3fe27b84f683142c.tar.bz2 call-setting-c2ac6f69df4c62b04fb43dfc3fe27b84f683142c.zip |
TizenRefApp-9641 [Call Setting] Implement Screen Reader support for BlockNumbersPage
Change-Id: Icd7702091de3ddae4aa475e5619752aa9711b1f2
-rw-r--r-- | call-setting/model/impl/misc/BlockListManager.h | 2 | ||||
-rw-r--r-- | call-setting/presenters/items/SimpleListItem.cpp | 26 | ||||
-rw-r--r-- | call-setting/presenters/items/SimpleListItem.h | 9 | ||||
-rw-r--r-- | call-setting/presenters/pages/BlockedNumbersPage.cpp | 71 | ||||
-rw-r--r-- | call-setting/presenters/pages/BlockedNumbersPage.h | 12 | ||||
-rw-r--r-- | ucl/include/ucl/mvp/ListItemPresenter.h | 31 | ||||
-rw-r--r-- | ucl/source/mvp/ListItemPresenter.cpp | 27 |
7 files changed, 155 insertions, 23 deletions
diff --git a/call-setting/model/impl/misc/BlockListManager.h b/call-setting/model/impl/misc/BlockListManager.h index 2fc93f8..6e82a9b 100644 --- a/call-setting/model/impl/misc/BlockListManager.h +++ b/call-setting/model/impl/misc/BlockListManager.h @@ -126,7 +126,7 @@ namespace call_setting { ucl::Result getRules(Rules &rules) const; /** - * @brief Adds rule with exanct matching type + * @brief Adds rule with exact matching type * @param[in] number Number * @param[in] rule Rule * @return RES_OK on success, otherwise an error code on failure diff --git a/call-setting/presenters/items/SimpleListItem.cpp b/call-setting/presenters/items/SimpleListItem.cpp index dd63a39..a0d6f51 100644 --- a/call-setting/presenters/items/SimpleListItem.cpp +++ b/call-setting/presenters/items/SimpleListItem.cpp @@ -26,19 +26,22 @@ namespace call_setting { namespace { namespace impl { namespace call_setting { - using ucl::HashMap; using ucl::ListItemPresenter; using ucl::IPicker; - SimpleListItem::SimpleListItem(IRefCountObj &rc, - ElmStyle style, PartTextMap parts) : + SimpleListItem::SimpleListItem(IRefCountObj &rc, ElmStyle style, + PartTextMap parts, bool useAtspiRedundant) : ListItemPresenter::ListItemPresenter(rc), m_listItemStyle(style), - m_listItemParts(std::move(parts)) + m_listItemParts(std::move(parts)), + m_useAtspiRedundant(useAtspiRedundant) { } - SimpleListItem::~SimpleListItem() + SimpleListItem::SimpleListItem(IRefCountObj &rc, ElmStyle style) : + ListItemPresenter::ListItemPresenter(rc), + m_listItemStyle(style), + m_useAtspiRedundant(true) { } @@ -57,7 +60,8 @@ namespace call_setting { return *this; } - ListItemPresenter::ItemInsertionParams SimpleListItem::getItemInsertionParams() + ListItemPresenter::ItemInsertionParams + SimpleListItem::getItemInsertionParams() { return m_listItemStyle; } @@ -75,7 +79,8 @@ namespace call_setting { EdjePart part, ElmWidget &parent) { return tryCreatePickModeItemPartContent(part, parent, - {impl::PICK_MODE_CHECK_PART, impl::PICK_MODE_CHECK_STYLE}); + {impl::PICK_MODE_CHECK_PART, impl::PICK_MODE_CHECK_STYLE, + true}); } void SimpleListItem::onItemSelected() @@ -95,4 +100,11 @@ namespace call_setting { } } } + + void SimpleListItem::onItemAttached() + { + if (m_useAtspiRedundant) { + getItemAtspi()->setRole(ELM_ATSPI_ROLE_REDUNDANT_OBJECT); + } + } } diff --git a/call-setting/presenters/items/SimpleListItem.h b/call-setting/presenters/items/SimpleListItem.h index b4a214b..b953a0f 100644 --- a/call-setting/presenters/items/SimpleListItem.h +++ b/call-setting/presenters/items/SimpleListItem.h @@ -30,12 +30,15 @@ namespace call_setting { public ucl::IPickable { public: SimpleListItem(ucl::IRefCountObj &rc, ucl::ElmStyle style, - PartTextMap parts = {}); + PartTextMap parts, bool useAtspiRedundant = false); + + SimpleListItem(ucl::IRefCountObj &rc, ucl::ElmStyle style); void setItemSelectHandler(NotiHandler handler); void setItemLongpressHandler(NotiHandler handler); // IPickable // + virtual ucl::IPicker &getPicker() final override; protected: @@ -49,9 +52,10 @@ namespace call_setting { virtual void onItemSelected() override; virtual void onItemLongpressed() override; + virtual void onItemAttached() override; private: - ~SimpleListItem(); + ~SimpleListItem() = default; private: ucl::ElmStyle m_listItemStyle; @@ -59,6 +63,7 @@ namespace call_setting { NotiHandler m_onItemSelected; NotiHandler m_onItemLongpressed; + bool m_useAtspiRedundant; friend class ucl::ReffedObj<SimpleListItem>; }; diff --git a/call-setting/presenters/pages/BlockedNumbersPage.cpp b/call-setting/presenters/pages/BlockedNumbersPage.cpp index abf7141..c523686 100644 --- a/call-setting/presenters/pages/BlockedNumbersPage.cpp +++ b/call-setting/presenters/pages/BlockedNumbersPage.cpp @@ -16,6 +16,8 @@ #include "BlockedNumbersPage.h" +#include "call-setting/view/AoSequencer.h" + #include "call-setting/presenters/misc/ProcessingPresenter.h" #include "call-setting/resources.h" @@ -32,6 +34,7 @@ namespace call_setting { namespace { namespace impl { namespace call_setting { using ucl::ListPresenter; + using ucl::ListItemPresenter; using ucl::NaviItem; using ucl::NaviframeSRef; using ucl::IPickerHost; @@ -58,6 +61,11 @@ namespace call_setting { return *m_item; } + const SimpleListItem &getItem() const + { + return *m_item; + } + private: ~Item() = default; @@ -71,7 +79,7 @@ namespace call_setting { BlockedNumbers::Item m_model; SimpleListItemSRef m_item; - friend class ucl::ReffedObj<Item>; + friend class ReffedObj<Item>; }; // BlockedNumbersPage::Builder // @@ -150,9 +158,13 @@ namespace call_setting { FAIL_RETURN(makeList(), "makeList() failed!"); FAIL_RETURN(makeMoreOptions(), "makeMoreOptions() failed!"); FAIL_RETURN(makeSelectMode(), "makeSelectMode() failed!"); + FAIL_RETURN(makeAtspiHighlightHelper(), + "makeAtspiHighlightHelper() failed!"); makeListItems(); + registerAccessObjects(); + item = getNaviframe().push(getContent()); if (!item) { LOG_RETURN(RES_FAIL, "Naviframe::push() failed!"); @@ -189,6 +201,7 @@ namespace call_setting { STR_DELETE, nullptr, getImageTheme(ICON_MORE_OPT_DELETE)}). build(*this); + if (!m_more) { LOG_RETURN(RES_FAIL, "MoreOptionsPresenter::build() failed!"); } @@ -216,7 +229,8 @@ namespace call_setting { void BlockedNumbersPage::makeListItems() { - m_list->append(*makeTitleListItem(STR_BLOCKED_NUMBERS_PAGE_TITLE)); + m_titleItem = makeTitleListItem(STR_BLOCKED_NUMBERS_PAGE_TITLE); + m_list->append(*m_titleItem); m_model->forEachItem(DELEGATE_THIS(onEachItem)); @@ -232,6 +246,8 @@ namespace call_setting { void BlockedNumbersPage::remakeListItems() { + m_titleItem.reset(); + m_items.clear(); m_list->clear(); @@ -433,4 +449,55 @@ namespace call_setting { break; } } + + Result BlockedNumbersPage::makeAtspiHighlightHelper() + { + m_atspiHelper = AtspiHighlightHelper::newInstance(*this); + if (!m_atspiHelper) { + LOG_RETURN(RES_FAIL, + "AtspiHighlightHelper::newInstance() failed!"); + } + + m_atspiHelper->setEventHandler(WEAK_DELEGATE_THIS(onAtspiHighlight)); + + return RES_OK; + } + + const Elm_Interface_Atspi_Accessible *BlockedNumbersPage::onAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, + Elm_Atspi_Relation_Type flowRelation) + { + if (!m_isInSelectMode) { + return nullptr; + } + + return AoSequencer(ao, flowRelation) + .process(*m_titleItem) + .process(m_smp->getSelectButton()) + .process(*m_items.front()) + .processDefault() + .process(*m_items.back()) + .process(m_smp->getBottomButton()) + .getNext(); + } + + void BlockedNumbersPage::registerAccessObjects() + { + m_atspiHelper->registerObject(getWindow()); + + m_atspiHelper->registerObject(m_smp->getBottomButton()); + m_atspiHelper->registerObject(m_smp->getSelectButton()); + + m_atspiHelper->registerObject(*m_titleItem); + m_atspiHelper->registerObject(m_items.front()->getItem()); + m_atspiHelper->registerObject(m_items.back()->getItem()); + } + + // Non-member functions // + + const Elm_Interface_Atspi_Accessible *as_ao( + const BlockedNumbersPage::Item &item) + { + return as_ao(item.getItem()); + } } diff --git a/call-setting/presenters/pages/BlockedNumbersPage.h b/call-setting/presenters/pages/BlockedNumbersPage.h index bfccbef..5c8f166 100644 --- a/call-setting/presenters/pages/BlockedNumbersPage.h +++ b/call-setting/presenters/pages/BlockedNumbersPage.h @@ -23,6 +23,7 @@ #include "call-setting/model/BlockedNumbers.h" +#include "call-setting/presenters/misc/AtspiHighlightHelper.h" #include "call-setting/presenters/misc/MoreOptionsPresenter.h" #include "call-setting/presenters/misc/SelectModePresenter.h" @@ -64,6 +65,7 @@ namespace call_setting { ucl::Result makeList(); ucl::Result makeMoreOptions(); ucl::Result makeSelectMode(); + ucl::Result makeAtspiHighlightHelper(); void makeListItems(); bool onEachItem(BlockedNumbers::Item modelItem); @@ -83,6 +85,11 @@ namespace call_setting { void onModelItemsChanged(); void onInstanceResumed(ucl::Widget &sender, void *eventInfo); + void registerAccessObjects(); + const Elm_Interface_Atspi_Accessible *onAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, + Elm_Atspi_Relation_Type flowRelation); + // GuiPresenter // virtual void onActivateBy(const DeactivatorInfo &info) final override; @@ -116,12 +123,17 @@ namespace call_setting { MoreOptionsPresenterSRef m_more; SelectModePresenterSRef m_smp; + AtspiHighlightHelperSRef m_atspiHelper; + + ucl::ListItemPresenterSRef m_titleItem; std::vector<ItemSRef> m_items; int m_selectCount; bool m_isInSelectMode; friend class ucl::ReffedObj<BlockedNumbersPage>; + + friend const Elm_Interface_Atspi_Accessible *as_ao(const Item &item); }; } diff --git a/ucl/include/ucl/mvp/ListItemPresenter.h b/ucl/include/ucl/mvp/ListItemPresenter.h index 37175bd..bda4546 100644 --- a/ucl/include/ucl/mvp/ListItemPresenter.h +++ b/ucl/include/ucl/mvp/ListItemPresenter.h @@ -36,6 +36,15 @@ namespace ucl { protected IPicker { public: /** + * @brief Gets GUI item Access object of the item presenter + * @param[in] item List item presenter + * @return Pointer to Access object or NULL + */ + friend const Elm_Interface_Atspi_Accessible *as_ao( + const ListItemPresenter &item); + + public: + /** * @brief Updates GUI item of this item */ Result updateItem(); @@ -62,12 +71,6 @@ namespace ucl { */ void setItemAtspiGestureHandler(AtspiGestureHandler handler); - /** - * @brief Gets GUI item Access object of this item - * @return Pointer to Access object or NULL - */ - Elm_Interface_Atspi_Accessible *getItemAo(); - // IDisposable // virtual void dispose() final override; @@ -128,6 +131,22 @@ namespace ucl { ElmStyle checkStyle; /** + * @brief Enable/disable Atspi support state + */ + bool enableAtspi; + + /** + * @brief Constructor + * @param[in] checkPart Part in GUI item for check widget + * @param[in] checkStyle Style of the check widget + * @param[in] enableAtspi Enable/disable Atspi support state + */ + ItemPickModeParams(EdjePart checkPart, ElmStyle checkStyle, + bool enableAtspi = false) : + checkPart(checkPart), checkStyle(checkStyle), + enableAtspi(enableAtspi) {} + + /** * @brief Checks validity of data in this structure * @return true - if valid, false - if not valid */ diff --git a/ucl/source/mvp/ListItemPresenter.cpp b/ucl/source/mvp/ListItemPresenter.cpp index 3fff862..bb8d719 100644 --- a/ucl/source/mvp/ListItemPresenter.cpp +++ b/ucl/source/mvp/ListItemPresenter.cpp @@ -324,6 +324,20 @@ namespace ucl { check->addEventHandler( impl::CHECK_CHANGED, WEAK_DELEGATE_THIS(onPickCheckChanged)); + if (params.enableAtspi) { + auto itemAtspi = getItemAtspi(); + if (itemAtspi) { + auto &checkAtspi = check->getAtspi(); + + checkAtspi.addRelationship(ELM_ATSPI_RELATION_CONTROLLED_BY, + as_ao(*itemAtspi)); + itemAtspi->addRelationship(ELM_ATSPI_RELATION_CONTROLLER_FOR, + as_ao(checkAtspi)); + itemAtspi->addRelationship(ELM_ATSPI_RELATION_DESCRIBED_BY, + as_ao(checkAtspi)); + } + } + return check; } @@ -408,11 +422,6 @@ namespace ucl { m_itemAtspiGestureHandler = std::move(handler); } - Elm_Interface_Atspi_Accessible *ListItemPresenter::getItemAo() - { - return as_ao(getItemAtspi()); - } - Result ListItemPresenter::updateItemStyle(const ElmStyle newItemStyle) { if (!m_item) { @@ -500,4 +509,12 @@ namespace ucl { void ListItemPresenter::onItemLongpressed() { } + + // Non-member functions // + + const Elm_Interface_Atspi_Accessible *as_ao( + const ListItemPresenter &item) + { + return as_ao(item.getItemAtspi()); + } } |