TizenRefApp-7958 Implement screen reader for Task Manager (part II) 70/112570/2
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 1 Feb 2017 12:42:48 +0000 (14:42 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 1 Feb 2017 12:45:13 +0000 (14:45 +0200)
Change-Id: I57b71fd39ad03dfec74d7d735c7d8afee9a3c640
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/App/inc/MainController.h
src/App/inc/TaskListView.h
src/App/inc/TaskListViewItem.h
src/App/src/MainController.cpp
src/App/src/TaskListView.cpp
src/App/src/TaskListViewItem.cpp
src/Common/inc/AtspiAccessibleInterface.h
src/Common/inc/BaseView.h

index 3af841d..544bd21 100644 (file)
@@ -47,10 +47,12 @@ namespace TaskMngr {
             void update();
             void updateIndex(int itemsCount);
             void updateNoContents(int itemsCount);
+            TaskListViewItem *createItem(const AppInfo &appInfo);
 
         private:
             TaskListView *m_pTaskListView;
             IndexView *m_pIndexView;
+            bool m_SkipHighlightCurrentPage;
     };
 }
 
index a63f38a..7b99186 100644 (file)
@@ -50,6 +50,7 @@ namespace TaskMngr
             Evas_Object *createPadding();
             void freezeScrollPush();
             void freezeScrollPop();
+            void updateHighlights();
 
             void onDelRequest(TaskListViewItem &item);
             void onAppClicked(TaskListViewItem &item);
index eaf5b5c..4f156a6 100644 (file)
@@ -37,6 +37,7 @@ namespace TaskMngr
             void playKillUpAnim();
             void playKillDownAnim();
             const AppInfo &getAppInfo() const;
+            void highlightIcon();
 
         private:
             void onMove(Evas *e, Evas_Object *obj, void *event_info);
@@ -73,6 +74,8 @@ namespace TaskMngr
             double m_MoveDistance; // 0..1;
             bool m_IsKillAnimPlaying;
             bool m_IgnoreAppClick;
+            Atspi m_AoIcon;
+            Atspi m_AoDelButton;
     };
 }
 
index efe6c58..c0be439 100644 (file)
@@ -24,6 +24,7 @@ MainController::MainController(Evas_Object *parent)
     : MainLayout(parent)
     , m_pTaskListView(nullptr)
     , m_pIndexView(nullptr)
+    , m_SkipHighlightCurrentPage(true)
 {
     m_pTaskListView = new TaskListView(getEo());
     m_pTaskListView->setListener(this);
@@ -38,12 +39,21 @@ MainController::~MainController()
 {
 }
 
+TaskListViewItem *MainController::createItem(const AppInfo &appInfo)
+{
+    auto item = new TaskListViewItem(*m_pTaskListView, appInfo);
+    return item;
+}
+
 void MainController::update()
 {
     m_pTaskListView->clear();
     auto list = App::getInst().getTaskMngr().getAppInfo();
     for (const AppInfo &appInfo : list) {
-        m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
+        auto item = createItem(appInfo);
+        if (item) {
+            m_pTaskListView->appendItem(*item);
+        }
     }
 
     //TODO: only for test will be removed.
@@ -93,15 +103,25 @@ void MainController::onCloseAllButtonClicked()
 void MainController::onListChanged(TaskListView &obj, int itemsCount)
 {
     LOG("", itemsCount);
-    if (itemsCount <= 0)
+    if (itemsCount <= 0) {
         App::getInst().exit();
-    updateIndex(itemsCount);
-    updateNoContents(itemsCount);
+    } else {
+        updateIndex(itemsCount);
+        updateNoContents(itemsCount);
+        TaskListViewItem *item = obj.getCurrentPage();
+        if (!m_SkipHighlightCurrentPage && item)
+            item->highlightIcon();
+    }
+    m_SkipHighlightCurrentPage = false;
 }
 
 void MainController::onCurrentPageChanged(TaskListView &obj)
 {
     LOG("");
+    TaskListViewItem *item = obj.getCurrentPage();
+    if (item) {
+        item->highlightIcon();
+    }
     updateIndex(m_pTaskListView->getItemsCount());
 }
 
index b07b81f..494ee5b 100644 (file)
@@ -106,10 +106,10 @@ TaskListViewItem *TaskListView::getCurrentPage() const
     Eina_List *list = elm_box_children_get(m_pBox);
 
     if (list) {
-        int currentIndex = getCurrentPageIndex();
-        int count = eina_list_count(list);
-        if (currentIndex >=0 && currentIndex < count)
-            res = staticCast<TaskListViewItem*>(eina_list_nth(list, currentIndex));
+        int i = getCurrentPageIndex() + 1; // left padding
+        int count = eina_list_count(list) - 1; // right padding
+        if (i >=0 && i < count)
+            res = staticCast<TaskListViewItem*>(eina_list_nth(list, i));
     }
 
     return res;
@@ -195,6 +195,15 @@ void TaskListView::freezeScrollPop()
     elm_object_scroll_freeze_pop(m_pScroller);
 }
 
+void TaskListView::updateHighlights()
+{
+    auto items = getItems();
+    TaskListViewItem *current = getCurrentPage();
+    for (TaskListViewItem *item : items) {
+        item->getAtspi().canHighlight(current == item);
+    }
+}
+
 void TaskListView::onDelRequest(TaskListViewItem &item)
 {
     LOG("");
@@ -213,6 +222,7 @@ void TaskListView::onAppClicked(TaskListViewItem &item)
 void TaskListView::onPageChanged(Evas_Object *obj, void *event_info)
 {
     LOG("");
+    updateHighlights();
     if (m_pListener)
         m_pListener->onCurrentPageChanged(*this);
 }
@@ -224,6 +234,7 @@ Eina_Bool TaskListView::onBoxSizeChangedIlder()
     int lastItemsCount = getItemsCount();
     if (lastItemsCount != m_LastItemsCount) {
         m_LastItemsCount = lastItemsCount;
+        updateHighlights();
         if (m_pListener)
             m_pListener->onListChanged(*this, m_LastItemsCount);
     }
index 019cb21..38fc11b 100644 (file)
@@ -62,6 +62,7 @@ TaskListViewItem::TaskListViewItem(TaskListView &parent, const AppInfo &appInfo)
     m_pDelButton = new DelButton(m_pTaskLayout);
     m_pDelButton->addSmartCb("clicked", makeCbFirst(&TaskListViewItem::onDelButtonClicked), this);
     elm_object_part_content_set(m_pTaskLayout, "swl.delete_button", *m_pDelButton);
+
 }
 
 TaskListViewItem::~TaskListViewItem()
@@ -74,6 +75,11 @@ const AppInfo &TaskListViewItem::getAppInfo() const
     return m_AppInfo;
 }
 
+void TaskListViewItem::highlightIcon()
+{
+    elm_atspi_component_highlight_grab(m_AoIcon);
+}
+
 void TaskListViewItem::setIcon(const std::string &path)
 {
     if (path.empty())
@@ -90,10 +96,10 @@ void TaskListViewItem::setIcon(const std::string &path)
     evas_object_image_filled_set(icon, true);
     elm_object_part_content_set(m_pTaskLayout, "img.app_image", icon);
 
-    Atspi aoAppIcon(elm_access_object_register(icon, m_pTaskLayout));
-    aoAppIcon.setName(m_AppInfo.name);
-    aoAppIcon.setDescriptionCb(makeCbFirst(&TaskListViewItem::onChangeDescription), this);
-    aoAppIcon.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
+    m_AoIcon = elm_access_object_register(icon, m_pTaskLayout);
+    m_AoIcon.setName(m_AppInfo.name);
+    m_AoIcon.setDescriptionCb(makeCbFirst(&TaskListViewItem::onChangeDescription), this);
+    m_AoIcon.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
 }
 
 void TaskListViewItem::setText(const std::string &text)
index 60f6d6e..894c9f1 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef AtspiAccessibleInterface_h_
-#define AtspiAccessibleInterface_h_
+#ifndef Atspi_h_
+#define Atspi_h_
 
 #include "LangUtils.h"
 #include "Config.h"
@@ -25,10 +25,10 @@ namespace TaskMngr {
     /**
      * @brief Wrapper for Elm_Interface_Atspi_Accessible interface (Screen reader)
      */
-    class AtspiAccessibleInterface {
+    class Atspi {
         public:
-            AtspiAccessibleInterface();
-            AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj);
+            Atspi();
+            Atspi(Elm_Interface_Atspi_Accessible *obj);
             void wrap(Elm_Interface_Atspi_Accessible *obj);
             Elm_Interface_Atspi_Accessible *getEo() const;
             operator Elm_Interface_Atspi_Accessible *() const;
@@ -50,83 +50,81 @@ namespace TaskMngr {
             Elm_Interface_Atspi_Accessible *m_pEo;
     };
 
-    typedef AtspiAccessibleInterface Atspi;
-
-    inline AtspiAccessibleInterface::AtspiAccessibleInterface()
+    inline Atspi::Atspi()
         : m_pEo(nullptr)
     {
     }
 
-    inline AtspiAccessibleInterface::AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj)
+    inline Atspi::Atspi(Elm_Interface_Atspi_Accessible *obj)
         : m_pEo(obj)
     {
     }
 
-    inline void AtspiAccessibleInterface::wrap(Elm_Interface_Atspi_Accessible *obj)
+    inline void Atspi::wrap(Elm_Interface_Atspi_Accessible *obj)
     {
         m_pEo = obj;
     }
 
-    inline Elm_Interface_Atspi_Accessible *AtspiAccessibleInterface::getEo() const
+    inline Elm_Interface_Atspi_Accessible *Atspi::getEo() const
     {
         return m_pEo;
     }
 
-    inline AtspiAccessibleInterface::operator Elm_Interface_Atspi_Accessible *() const
+    inline Atspi::operator Elm_Interface_Atspi_Accessible *() const
     {
         return getEo();
     }
 
-    inline void AtspiAccessibleInterface::setDescription(const char *text)
+    inline void Atspi::setDescription(const char *text)
     {
         elm_atspi_accessible_description_set(m_pEo, text);
         elm_atspi_accessible_translation_domain_set(m_pEo, PACKAGE_NAME);
     }
 
-    inline void AtspiAccessibleInterface::setDescription(const std::string &text)
+    inline void Atspi::setDescription(const std::string &text)
     {
         setDescription(text.c_str());
     }
 
-    inline void AtspiAccessibleInterface::setName(const char *text)
+    inline void Atspi::setName(const char *text)
     {
         elm_atspi_accessible_name_set(m_pEo, (char*)text);
     }
 
-    inline void AtspiAccessibleInterface::setName(const std::string &text)
+    inline void Atspi::setName(const std::string &text)
     {
         setName(text.c_str());
     }
 
-    inline void AtspiAccessibleInterface::setRole(Elm_Atspi_Role role)
+    inline void Atspi::setRole(Elm_Atspi_Role role)
     {
         elm_atspi_accessible_role_set(m_pEo, role);
     }
 
-    inline void AtspiAccessibleInterface::setReadingInfo(int type)
+    inline void Atspi::setReadingInfo(int type)
     {
         elm_atspi_accessible_reading_info_type_set(m_pEo, (Elm_Accessible_Reading_Info_Type)type);
     }
 
-    inline void AtspiAccessibleInterface::appendRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj)
+    inline void Atspi::appendRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj)
     {
         elm_atspi_accessible_relationship_append(m_pEo, type, obj);
     }
 
-    inline void AtspiAccessibleInterface::removeRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj)
+    inline void Atspi::removeRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj)
     {
         elm_atspi_accessible_relationship_remove(m_pEo, type, obj);
     }
 
-    inline void AtspiAccessibleInterface::canHighlight(bool canHighlight)
+    inline void Atspi::canHighlight(bool canHighlight)
     {
         elm_atspi_accessible_can_highlight_set(m_pEo, canHighlight);
     }
 
-    inline void AtspiAccessibleInterface::setDescriptionCb(Elm_Atspi_Reading_Info_Cb descriptionCb, const void *data)
+    inline void Atspi::setDescriptionCb(Elm_Atspi_Reading_Info_Cb descriptionCb, const void *data)
     {
         elm_atspi_accessible_description_cb_set(m_pEo, descriptionCb, data);
     }
 }
 
-#endif /* AtspiAccessibleInterface_h_ */
+#endif /* Atspi_h_ */
index 6c6a099..b3760c5 100644 (file)
@@ -35,9 +35,9 @@ namespace TaskMngr {
 
             /**
              * @brief Gets AtspiAccessibleInterface wrapper
-             * @return wrapper to AtspiAccessibleInterface
+             * @return wrapper to Atspi
              */
-            AtspiAccessibleInterface getAtspi() const;
+            Atspi getAtspi() const;
 
         protected:
             void setEo(Eo *eo);
@@ -56,9 +56,9 @@ namespace TaskMngr {
     {
     }
 
-    inline AtspiAccessibleInterface BaseView::getAtspi() const
+    inline Atspi BaseView::getAtspi() const
     {
-        return AtspiAccessibleInterface(m_pEo);
+        return Atspi(m_pEo);
     }
 
     inline BaseView::operator Eo *() const