Change reading rules in voice support mode 16/170716/5
authorPawel Kurowski <p.kurowski2@samsung.com>
Wed, 21 Feb 2018 17:28:08 +0000 (18:28 +0100)
committerLukasz Oleksak <l.oleksak@samsung.com>
Fri, 2 Mar 2018 17:22:24 +0000 (17:22 +0000)
PointScanner reads found element with its accessible name.

RowScanner reads current element in row with its accessible name,
reads "multi-element" row with "row X", where X is the row number starting at 1,
reads "one-element" row same as element in this row,
reads "escape" frame.

Change-Id: I57488cf9a16a08316e85e24937c85ce02c936240

res/po/en_US.po
src/PointScanner.cpp
src/RowScanner.cpp
src/ScreenScannerManager.cpp

index bdc409a..977f127 100644 (file)
@@ -374,6 +374,12 @@ msgstr "Granularity menu"
 msgid "IDS_NAVIGATE_UP"
 msgstr "Navigate up"
 
+msgid "IDS_ROW"
+msgstr "Row "
+
+msgid "IDS_ESCAPE"
+msgstr "Escape"
+
 
 # BINDABLE ACTIVITIES
 
index ced142d..24c6715 100644 (file)
@@ -22,6 +22,7 @@
 #include "UniversalSwitch.hpp"
 #include "UniversalSwitchLog.hpp"
 #include "Window.hpp"
+#include "TextToSpeech.hpp"
 
 #include <Elementary.h>
 
@@ -74,6 +75,9 @@ void PointScanner::getAtPoint(const std::shared_ptr<NavigationElement> &root, Po
                atspi->getAtPoint(pt, Atspi::CoordType::Screen, elem->getVisibleRoot(),
                [ = ](DBus::ValueOrError<std::shared_ptr<AtspiAccessible>> elem) {
                        auto uiElem = std::make_shared<UIElement>(elem ? std::move(std::get<0>(elem)) : nullptr, pt, application);
+                       auto tts = Singleton<UniversalSwitch>::instance().getTextToSpeech();
+                       if (tts)
+                               tts->speak(uiElem->getObject());
                        callback(std::move(uiElem));
                });
        } else {
index 89c39b4..77dc68a 100644 (file)
 
 namespace
 {
-       void playFeedback(const AtspiAccessiblePtr &atspiElem)
-       {
-               auto tts = Singleton<UniversalSwitch>::instance().getTextToSpeech();
-               if (tts->isEnabled()) {
-                       Singleton<UniversalSwitch>::instance().getTextToSpeech()->speak(atspiElem);
-               }
-               Singleton<UniversalSwitch>::instance().getSoundFeedback()->play(SoundFeedback::Sound::NAVIGATION_ITERATED);
-       }
-
-       static const std::string BACK_BUTTON_CODE = "XF86Back";
+       const char *BACK_BUTTON_CODE = "XF86Back";
+       const char *IDS_ESCAPE = "IDS_ESCAPE";
+       const char *IDS_ROW = "IDS_ROW";
 }
 
 /**
@@ -112,6 +105,7 @@ private:
        void moveToNextPosition(bool invertDirection = false, bool movedByAutoScan = false);
        int getFirstElementIndex(const std::shared_ptr<NavigationElement> &parent, bool invertDirection = false);
        int getIncrementForCalculatingNextElement(const std::shared_ptr<NavigationElement> &parent, bool invertDirection = false);
+       void playFeedback();
 
        ecore::Timer timer;
        evas::Shape frame;
@@ -153,18 +147,16 @@ RowScannerImpl::~RowScannerImpl()
 void RowScannerImpl::selectNewElement(NavigationState navState)
 {
        currentNavState = std::move(navState);
-       Rectangle pos;
-       if (currentNavState.childIndex) {
-               auto c = currentNavState.parent->getChildren()[static_cast<size_t>(*currentNavState.childIndex)];
-               pos = c->getBounds();
-               playFeedback(c->getElement());
-       } else {
-               pos = currentNavState.parent->getBounds();
-               playFeedback(nullptr);
-       }
-
-       drawFrame(pos, currentNavState.childIndex ?
-                         NavigationInterface::BoxPositionMode::NORMAL : NavigationInterface::BoxPositionMode::DASHED, properties.getColor());
+       auto &element = currentNavState.childIndex ?
+                                       currentNavState.parent->getChildren()[*currentNavState.childIndex] :
+                                       currentNavState.parent;
+
+       playFeedback();
+       drawFrame(element->getBounds(),
+                         currentNavState.childIndex ?
+                         NavigationInterface::BoxPositionMode::NORMAL :
+                         NavigationInterface::BoxPositionMode::DASHED,
+                         properties.getColor());
 }
 
 void RowScannerImpl::clearCursor()
@@ -209,7 +201,7 @@ void RowScannerImpl::acceptAutoscanningPhase(std::function<void(Optional<std::sh
                                selectNewElement({ std::move(p), index });
                        }
                } else {
-                       auto c = currentNavState.parent->getChildren()[static_cast<size_t>(*currentNavState.childIndex)];
+                       auto c = currentNavState.parent->getChildren()[*currentNavState.childIndex];
                        ASSERT(c);
                        while (c->getChildren().size() == 1) {
                                c = c->getChildren()[0];
@@ -371,3 +363,30 @@ void RowScannerImpl::moveToNextPosition(bool invertDirection, bool movedByAutoSc
 
        selectNewElement({currentNavState.parent, getFirstElementIndex(currentNavState.parent, invertDirection)});
 }
+
+void RowScannerImpl::playFeedback()
+{
+       Singleton<UniversalSwitch>::instance().getSoundFeedback()->play(SoundFeedback::Sound::NAVIGATION_ITERATED);
+       auto tts = Singleton<UniversalSwitch>::instance().getTextToSpeech();
+       if (!tts->isEnabled())
+               return;
+
+       if (!currentNavState.childIndex) {
+               tts->speak(std::string(_(IDS_ESCAPE)));
+               return;
+       }
+
+       auto &navigationElementHandler = currentNavState.parent->getChildren()[*currentNavState.childIndex];
+
+       if (currentNavState.parent->getScanningDirection() == NavigationElement::Direction::VERTICAL) {
+               if (navigationElementHandler->getChildren().size() == 1) {
+                       tts->speak(navigationElementHandler->getChildren().front()->getElement());
+                       return;
+               }
+
+               tts->speak(std::string(_(IDS_ROW)) + std::to_string(*currentNavState.childIndex + 1));
+               return;
+       }
+
+       tts->speak(navigationElementHandler->getElement());
+}
index 7a300e7..d97bf80 100644 (file)
@@ -18,7 +18,6 @@
 #include "UniversalSwitchLog.hpp"
 #include "Window.hpp"
 #include "SoundFeedback.hpp"
-#include "TextToSpeech.hpp"
 #include "UniversalSwitch.hpp"
 
 #include <functional>
@@ -187,10 +186,8 @@ void ScreenScannerManager::acceptAutoscanning()
        auto handle = [](Optional<std::shared_ptr<UIElement>> elem) {
                if (elem) {
                        auto self = Singleton<UniversalSwitch>::instance().getScreenScannerManager();
-                       if (self) {
-                               Singleton<UniversalSwitch>::instance().getTextToSpeech()->speak((*elem)->getObject());
+                       if (self)
                                self->notify(*elem);
-                       }
                }
        };
        if (!screenScanner) {