[AlarmView TTS] Support screen reader 51/120851/3
authorKamil Lipiszko <k.lipiszko@samsung.com>
Fri, 24 Mar 2017 11:24:51 +0000 (12:24 +0100)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Mon, 27 Mar 2017 14:10:58 +0000 (07:10 -0700)
Change-Id: If28363ffdf9f80a90b2935096000c350cb4a8445

clock/inc/Utils/Accessibility.h [new file with mode: 0644]
clock/res/edje/alarm.edc
clock/res/po/en.po
clock/src/Utils/Accessibility.cpp [new file with mode: 0644]
clock/src/View/AlarmView.cpp

diff --git a/clock/inc/Utils/Accessibility.h b/clock/inc/Utils/Accessibility.h
new file mode 100644 (file)
index 0000000..39e85c6
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+* Copyright 2016  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef ACCESSIBILITY_H_
+#define ACCESSIBILITY_H_
+
+#include <string>
+
+namespace utils {
+
+class Accessibility {
+
+public:
+       /**
+        * @brief Sets text to read of the label part in layout object
+        *
+        * This method finds part of the layout being textblock and sets its
+        * description to passed as argument text.
+        *
+        * @param[in] obj The layout object
+        * @param[in] part Part of the layout
+        * @param[in] text Text to be set
+        */
+       static void SetLabelPartDescription(Evas_Object *obj, const char *part, std::string text);
+
+       /**
+        * @brief Sets accessibility name of the object
+        *
+        * @param[in] obj Object to be named
+        * @param[in] name Name of the object
+        *
+        */
+       static void SetName(Evas_Object *obj, std::string name);
+};
+
+}
+
+#endif //ACCESSIBILITY_H_
index 6f1e047..c5fd2ec 100644 (file)
@@ -251,24 +251,54 @@ collections {
                                        color: 255 255 255 255;
                                }
                        }
-                       textblock{ "text.main"; scale;
+                       spacer { "bg.upper.half";
                                desc { "default";
                                        rel1 { relative: 0.0 0.0; }
                                        rel2 { relative: 1.0 0.5; }
+                               }
+                       }
+                       spacer { "bg.lower.half"; scale;
+                               desc { "default";
+                                       rel1 { relative: 0.0 0.5; }
+                                       rel2 { relative: 1.0 1.0; }
+                               }
+                       }
+                       textblock{ "text.main"; scale;
+                               desc { "default";
+                                       rel1 {
+                                               relative: 0.0 0.0;
+                                               to: "bg.upper.half";
+                                       }
+                                       rel2 {
+                                               relative: 1.0 1.0;
+                                               to: "bg.upper.half";
+                                       }
+                                       align: 0.5 1.0;
                                        text {
                                                align: 0.5 1.0;
                                                style: "label_style";
+                                               min: 0 1;
+                                               max: 0 1;
                                                ellipsis: -1;
                                        }
                                }
                        }
                        textblock{ "text.sub"; scale;
                                desc { "default";
-                                       rel1 { relative: 0.0 0.5; }
-                                       rel2 { relative: 1.0 1.0; }
+                                       rel1 {
+                                               relative: 0.0 0.0;
+                                               to: "bg.lower.half";
+                                       }
+                                       rel2 {
+                                               relative: 1.0 1.0;
+                                               to: "bg.lower.half";
+                                       }
+                                       align: 0.5 0.0;
                                        text {
-                                               align: 0.5 0.0;
+                                               align: 0.5 1.0;
                                                style: "label_style";
+                                               min: 0 1;
+                                               max: 0 1;
                                                ellipsis: -1;
                                        }
                                }
index 8195346..e866267 100644 (file)
@@ -65,6 +65,9 @@ msgstr "No alarms"
 msgid "IDS_CLOCK_BODY_AFTER_YOU_CREATE_ALARMS_THEY_WILL_BE_SHOWN_HERE"
 msgstr "After you create alarms, they will be shown here."
 
+msgid "IDS_CLOCK_BODY_ADD_ALARM"
+msgstr "Add alarm"
+
 msgid "IDS_COM_BODY_STOPWATCH"
 msgstr "Stopwatch"
 
diff --git a/clock/src/Utils/Accessibility.cpp b/clock/src/Utils/Accessibility.cpp
new file mode 100644 (file)
index 0000000..73fcd85
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+* Copyright 2016  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <string>
+#include <Elementary.h>
+
+#include "Utils/Accessibility.h"
+
+namespace utils {
+
+void Accessibility::SetLabelPartDescription(Evas_Object *obj, const char *part, std::string text)
+{
+       Evas_Object *label = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(obj), part);
+       Evas_Object *atspi_label = elm_access_object_register(label, obj);
+       elm_atspi_accessible_role_set(atspi_label, ELM_ATSPI_ROLE_LABEL);
+       elm_atspi_accessible_name_set(atspi_label, text.c_str());
+}
+
+void Accessibility::SetName(Evas_Object *obj, std::string name)
+{
+       elm_atspi_accessible_name_set(obj, name.c_str());
+}
+
+}
+
index 4780b44..ef72192 100644 (file)
@@ -25,6 +25,8 @@
 #include "Utils/Log.h"
 #include "Utils/PopupManager.h"
 #include "Utils/ThemeExtension.h"
+#include "Utils/Translate.h"
+#include "Utils/Accessibility.h"
 
 using namespace view;
 using namespace model;
@@ -181,7 +183,6 @@ AlarmView::AlarmView(ui::IView &main) : label_(nullptr), popup_(nullptr)
        /* Floating Button */
        Evas_Object *fb = eext_floatingbutton_add(content_);
        elm_object_part_content_set(content_, "elm.swallow.floatingbutton", fb);
-
        /* Floating Button 1 */
        Evas_Object *btn = elm_button_add(fb);
        evas_object_smart_callback_add(btn, "clicked", AlarmView::ButtonClicked, this);
@@ -192,6 +193,8 @@ AlarmView::AlarmView(ui::IView &main) : label_(nullptr), popup_(nullptr)
 
        elm_object_part_content_set(fb, "button1", btn);
 
+       Accessibility::SetName(btn, Translate::Sprintf("IDS_CLOCK_BODY_ADD_ALARM"));
+
        ThemeExtension::AddTheme(TizenAppUtils::GetResourcePath(TizenAppUtils::APP_DIR_RESOURCE, "edje/alarm.edj"));
 
        eext_object_event_callback_add(content_, EEXT_CALLBACK_MORE,
@@ -319,6 +322,11 @@ void AlarmView::ShowNoAlarmsBackgroundLabel()
                evas_object_size_hint_align_set(label_, EVAS_HINT_FILL, EVAS_HINT_FILL);
                evas_object_show(label_);
 
+               Accessibility::SetLabelPartDescription(label_, "text.main",
+                               Translate::Sprintf("IDS_CLOCK_NPBODY_NO_ALARMS"));
+               Accessibility::SetLabelPartDescription(label_, "text.sub",
+                               Translate::Sprintf("IDS_CLOCK_BODY_AFTER_YOU_CREATE_ALARMS_THEY_WILL_BE_SHOWN_HERE"));
+
                // unload genlist
                elm_object_content_unset(content_);
                evas_object_hide(genlist_);