[Timer TTS] Add screen reader support in timer view 93/120393/7
authorKamil Lipiszko <k.lipiszko@samsung.com>
Wed, 22 Mar 2017 15:54:47 +0000 (16:54 +0100)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 28 Mar 2017 12:54:45 +0000 (05:54 -0700)
Change-Id: I35099837c7e40912a95be432be428d3de49c5b33
Conflicts:
clock/src/View/TimerView.cpp

clock/inc/Utils/Accessibility.h
clock/inc/View/TimerView.h
clock/res/po/en.po
clock/src/Utils/Accessibility.cpp
clock/src/View/TimerView.cpp

index 39e85c67b5df22a08f1d08ace2f4886ab729020f..95921caa7b83f98582af210d561e74f563b955b8 100644 (file)
@@ -44,6 +44,7 @@ public:
         *
         */
        static void SetName(Evas_Object *obj, std::string name);
+       static void SetReadingOrder(int count, ...);
 };
 
 }
index 81405558f332612108e9a075d7557494559231bf..d49f313270f249682629066343509031087921a4 100644 (file)
@@ -184,9 +184,9 @@ namespace view {
                                const char *part, Evas_Smart_Cb cb);
 
                void CreateSelector();
-               void CreateSelectorsButton(const char* type, ButtonArrowDirection direction);
+               Evas_Object *CreateSelectorsButton(const char* type, ButtonArrowDirection direction, const char *description);
                void CreateMenuButtons();
-               void CreateEntry(Evas_Object *parent, const char *part);
+               Evas_Object *CreateEntry(Evas_Object *parent, const char *part, const char *description);
                void CreateEntries(Evas_Object *parent);
 
                void UpdateView();
index c1bbfc1b0ec7543132df1734812e1e694042296b..8db699ddaebba7cb55f6087ce411d4c64e29b62c 100644 (file)
@@ -26,12 +26,27 @@ msgstr "Resume"
 msgid "IDS_COM_BODY_HOURS"
 msgstr "Hours"
 
+msgid "IDS_COM_BODY_HOUR"
+msgstr "hour"
+
 msgid "IDS_COM_BODY_MINUTES"
 msgstr "Minutes"
 
+msgid "IDS_COM_BODY_MINUTE"
+msgstr "minute"
+
 msgid "IDS_COM_BODY_SECONDS"
 msgstr "Seconds"
 
+msgid "IDS_COM_BODY_SECOND"
+msgstr "second"
+
+msgid "IDS_COM_BODY_INCREASE_BY"
+msgstr "Increase by one"
+
+msgid "IDS_COM_BODY_DECREASE_BY"
+msgstr "Decrease by one"
+
 msgid "IDS_CLOCK_TPOP_CANT_ADD_MORE_THAN_PD_CITIES"
 msgstr "Can't add more than %d cities."
 
index 73fcd851cd4109d1ac92865b801c546cff19208e..2bccad60e471dfcb255bcc40912843023308e046 100644 (file)
@@ -34,5 +34,30 @@ void Accessibility::SetName(Evas_Object *obj, std::string name)
        elm_atspi_accessible_name_set(obj, name.c_str());
 }
 
+void Accessibility::SetReadingOrder(int count, ...)
+{
+       va_list args;
+       va_start(args, count);
+
+       Evas_Object *next = NULL;
+       Evas_Object *current = va_arg(args, Evas_Object*);
+       if (!current) {
+               va_end(args);
+               return;
+       }
+
+       for (int i = 0; i < count - 1; ++i) {
+
+               next = va_arg(args, Evas_Object *);
+
+               elm_atspi_accessible_relationship_append(current, ELM_ATSPI_RELATION_FLOWS_TO, next);
+               elm_atspi_accessible_relationship_append(next, ELM_ATSPI_RELATION_FLOWS_FROM, current);
+
+               current = next;
+       }
+
+       va_end(args);
+}
+
 }
 
index 0a3546b596bd7716738438176b1918accd9bbda6..be6f3eafdcec405168ff08b42dddae7351a888a1 100644 (file)
@@ -22,6 +22,8 @@
 #include "Utils/TizenAppUtils.h"
 #include "Utils/Log.h"
 #include "Utils/ThemeExtension.h"
+#include "Utils/Translate.h"
+#include "Utils/Accessibility.h"
 
 namespace view {
 
@@ -208,7 +210,7 @@ void TimerView::GetTime(int *hour, int *minute, int *second)
        *second = set_time_.Sec;
 }
 
-void TimerView::CreateSelectorsButton(const char *part, ButtonArrowDirection direction)
+Evas_Object *TimerView::CreateSelectorsButton(const char *part, ButtonArrowDirection direction, const char *description)
 {
        Evas_Object *button = elm_button_add(layout_);
 
@@ -226,6 +228,14 @@ void TimerView::CreateSelectorsButton(const char *part, ButtonArrowDirection dir
        elm_button_autorepeat_initial_timeout_set(button, 0.7);
        elm_button_autorepeat_set(button, EINA_TRUE);
 
+       std::stringstream desc;
+       if (direction == ButtonArrowDirection::ARROW_UP)
+               desc << Translate::Sprintf("IDS_COM_BODY_INCREASE_BY");
+       else
+               desc << Translate::Sprintf("IDS_COM_BODY_DECREASE_BY");
+       desc << " " << Translate::Sprintf(description);
+       Accessibility::SetName(button, desc.str());
+
        if (!elm_object_style_set(button, "arrow"))
                ERR("Button style setting failed");
 
@@ -233,6 +243,8 @@ void TimerView::CreateSelectorsButton(const char *part, ButtonArrowDirection dir
                elm_object_signal_emit(button, "arrow.down", "timer");
 
        evas_object_show(button);
+
+       return button;
 }
 
 void TimerView::CreateSelector()
@@ -246,27 +258,30 @@ void TimerView::CreateSelector()
        if (!elm_layout_file_set(selector_, GetEdjeFilePath(), "Time_selector"))
                return;
 
-       CreateEntries(selector_);
-
        ThemeExtension::AddTheme(GetEdjeFilePath());
 
-       CreateSelectorsButton("sw.hour.inc", ButtonArrowDirection::ARROW_UP);
-       CreateSelectorsButton("sw.minute.inc", ButtonArrowDirection::ARROW_UP);
-       CreateSelectorsButton("sw.second.inc", ButtonArrowDirection::ARROW_UP);
-       CreateSelectorsButton("sw.hour.dec", ButtonArrowDirection::ARROW_DOWN);
-       CreateSelectorsButton("sw.minute.dec", ButtonArrowDirection::ARROW_DOWN);
-       CreateSelectorsButton("sw.second.dec", ButtonArrowDirection::ARROW_DOWN);
+       Accessibility::SetReadingOrder(9,
+                       CreateSelectorsButton("sw.hour.inc",
+                               ButtonArrowDirection::ARROW_UP, "IDS_COM_BODY_HOUR"),
+                       CreateEntry(selector_, "sw.entry.hour", "IDS_COM_BODY_HOURS"),
+                       CreateSelectorsButton("sw.hour.dec",
+                               ButtonArrowDirection::ARROW_DOWN, "IDS_COM_BODY_HOUR"),
 
-}
+                       CreateSelectorsButton("sw.minute.inc",
+                               ButtonArrowDirection::ARROW_UP, "IDS_COM_BODY_MINUTE"),
+                       CreateEntry(selector_, "sw.entry.minute", "IDS_COM_BODY_MINUTES"),
+                       CreateSelectorsButton("sw.minute.dec",
+                               ButtonArrowDirection::ARROW_DOWN, "IDS_COM_BODY_MINUTE"),
 
-void TimerView::CreateEntries(Evas_Object *parent)
-{
-       CreateEntry(parent, "sw.entry.hour");
-       CreateEntry(parent, "sw.entry.minute");
-       CreateEntry(parent, "sw.entry.second");
+                       CreateSelectorsButton("sw.second.inc",
+                               ButtonArrowDirection::ARROW_UP, "IDS_COM_BODY_SECOND"),
+                       CreateEntry(selector_, "sw.entry.second", "IDS_COM_BODY_SECONDS"),
+                       CreateSelectorsButton("sw.second.dec",
+                               ButtonArrowDirection::ARROW_DOWN, "IDS_COM_BODY_SECOND")
+       );
 }
 
-void TimerView::CreateEntry(Evas_Object *parent, const char *part)
+Evas_Object *TimerView::CreateEntry(Evas_Object *parent, const char *part, const char *description)
 {
        Evas_Object *entry = elm_entry_add(parent);
 
@@ -283,6 +298,8 @@ void TimerView::CreateEntry(Evas_Object *parent, const char *part)
        elm_entry_text_style_user_push(entry, "DEFAULT='font=Tizen:style=Thin color=#FAFAFA font_size=160 wrap=none align=center'");
        elm_entry_entry_set(entry, "00");
 
+       elm_object_part_text_set(entry, "elm.guide", Translate::Sprintf(description).c_str());
+
        evas_object_smart_callback_add(entry, "focused", EntryFocusedCb, this);
        evas_object_smart_callback_add(entry, "unfocused", EntryUnfocusedCb, part);
        evas_object_smart_callback_add(entry, "changed", EntryChangedCb, this);
@@ -292,6 +309,8 @@ void TimerView::CreateEntry(Evas_Object *parent, const char *part)
        elm_object_focus_custom_chain_append(parent, entry, NULL);
 
        evas_object_show(entry);
+
+       return entry;
 }
 
 void TimerView::EntryFocusedCb(void *data, Evas_Object *obj, void *event_info)