summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Wozniak <t.wozniak@samsung.com>2016-10-06 04:49:27 -0700
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2016-10-06 04:49:27 -0700
commit5445d32e58b22789ae5be8c641f52955f44aa6c1 (patch)
tree48ff8ee4a00df153072a1fac01365f340746e0d4
parentb35da07097a0742ebcc35e9faa0e946c140569a5 (diff)
parent306e858b234aedeb113c9052454318914958f57e (diff)
downloadelm-demo-tizen-mobile-5445d32e58b22789ae5be8c641f52955f44aa6c1.tar.gz
elm-demo-tizen-mobile-5445d32e58b22789ae5be8c641f52955f44aa6c1.tar.bz2
elm-demo-tizen-mobile-5445d32e58b22789ae5be8c641f52955f44aa6c1.zip
Merge "[Accessibility] demo code for direct reading API" into tizen
-rw-r--r--edc_resource/accessibility/screen_reader/direct_reading.edc213
-rw-r--r--inc/main.h1
-rw-r--r--res/elm-demo-tizen-mobile.edc1
-rw-r--r--src/accessibility/screen_reader.c1
-rw-r--r--src/accessibility/screen_reader/direct_reading.c194
5 files changed, 410 insertions, 0 deletions
diff --git a/edc_resource/accessibility/screen_reader/direct_reading.edc b/edc_resource/accessibility/screen_reader/direct_reading.edc
new file mode 100644
index 0000000..73d59b6
--- /dev/null
+++ b/edc_resource/accessibility/screen_reader/direct_reading.edc
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+group { name: "direct_reading_layout";
+ parts {
+ part { name: "bg";
+ type: RECT;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ color: 120 136 170 255;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1.relative: 0.00 0.00;
+ rel2.relative: 1.00 1.00;
+ }
+ }
+ part { name: "screen";
+ type: SWALLOW;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1.relative: 0.00 0.00;
+ rel2.relative: 1.00 0.40;
+ }
+ }
+ part { name: "top_left_button";
+ type: SWALLOW;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1 {
+ relative: 0 1;
+ to: "screen";
+ }
+ rel2 {
+ relative: 0.49 1.2;
+ to: "screen";
+ }
+ }
+ }
+ part { name: "top_right_button";
+ type: SWALLOW;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1 {
+ relative: 0.51 1;
+ to: "screen";
+ }
+ rel2 {
+ relative: 1 1.2;
+ to: "screen";
+ }
+ }
+ }
+ part { name: "bottom_button";
+ type: SWALLOW;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1 {
+ relative: 0 1.1;
+ to: "top_left_button";
+ }
+ rel2 {
+ relative: 1 2.1;
+ to: "top_right_button";
+ }
+ }
+ }
+ part { name: "event_info_label";
+ type: RECT;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ color: 0 136 170 255;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1 {
+ relative: 0 1.05;
+ to: "bottom_button";
+ }
+ rel2.relative: 0.498 0.64;
+ }
+ }
+ part { name: "text_label";
+ type: RECT;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ color: 0 136 170 255;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1 {
+ relative: 1.015 0;
+ to: "event_info_label";
+ }
+ rel2.relative: 1.00 0.64;
+ }
+ }
+ part { name: "event_info_label_text";
+ type: TEXT;
+ scale: 1;
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ color: 255 255 255 255;
+ visible: 1;
+ text {
+ size:35;
+ font: "Sans";
+ text: "Event";
+ align: 0.5 0.5;
+ min: 0 0;
+ }
+ rel1.relative: 0.00 0.57;
+ rel2.relative: 0.5 0.64;
+ }
+ }
+ part { name: "text_label_text";
+ type: TEXT;
+ scale: 1;
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ color: 255 255 255 255;
+ visible: 1;
+ text {
+ size: 35;
+ font: "Sans";
+ text: "Object";
+ align: 0.5 0.5;
+ min: 0 0;
+ }
+ rel1.relative: 0.5 0.57;
+ rel2.relative: 1.00 0.64;
+ }
+ }
+ part { name: "log_info_signal";
+ type: SWALLOW;
+ scale: 1;
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1 {
+ relative: 0 1;
+ to: "event_info_label_text";
+ }
+ rel2.relative: 0.5 1;
+ }
+ }
+ part { name: "log_info_text";
+ type: SWALLOW;
+ scale: 1;
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ align: 0.5 0.5;
+ fixed: 0 0;
+ min: 0 0;
+ visible: 1;
+ rel1 {
+ relative: 0 1;
+ to: "text_label_text";
+ }
+ rel2.relative: 1 1.00;
+ }
+ }
+ }
+}
diff --git a/inc/main.h b/inc/main.h
index 2f52a6e..63b0e1a 100644
--- a/inc/main.h
+++ b/inc/main.h
@@ -102,4 +102,5 @@ void screen_reader_terminate(void);
int screen_reader_vconf_status(void);
void performance_cb(void *data, Evas_Object *obj, void *event_info);
void svg_cb(void *data, Evas_Object *obj, void *event_info);
+void direct_reading_cb(void *data, Evas_Object *obj, void *event_info);
diff --git a/res/elm-demo-tizen-mobile.edc b/res/elm-demo-tizen-mobile.edc
index 4ff85c5..85b48f6 100644
--- a/res/elm-demo-tizen-mobile.edc
+++ b/res/elm-demo-tizen-mobile.edc
@@ -33,6 +33,7 @@ collections {
#include "../edc_resource/accessibility/screen_reader/reading_order.edc"
#include "../edc_resource/accessibility/screen_reader/custom_frame.edc"
#include "../edc_resource/accessibility/screen_reader/access_object.edc"
+ #include "../edc_resource/accessibility/screen_reader/direct_reading.edc"
#include "../edc_resource/svg.edc"
}
diff --git a/src/accessibility/screen_reader.c b/src/accessibility/screen_reader.c
index 7eff79f..1884ee0 100644
--- a/src/accessibility/screen_reader.c
+++ b/src/accessibility/screen_reader.c
@@ -108,6 +108,7 @@ screen_reader_cb(void *data, Evas_Object *obj, void *event_info)
screen_reader_onoff_check);
elm_list_item_append(list, "List Sample", NULL, NULL, reading_list_cb, nf);
elm_list_item_append(list, "Overwriting Reading Info", NULL, NULL, overwrite_reading_info_cb, nf);
+ elm_list_item_append(list, "Direct Reading", NULL, NULL, direct_reading_cb, nf);
elm_list_go(list);
diff --git a/src/accessibility/screen_reader/direct_reading.c b/src/accessibility/screen_reader/direct_reading.c
new file mode 100644
index 0000000..bcd950a
--- /dev/null
+++ b/src/accessibility/screen_reader/direct_reading.c
@@ -0,0 +1,194 @@
+/*
+* Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* 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 "main.h"
+#include <string.h>
+
+#define ERROR(format, arg...) LOGE(format, ##arg)
+#define TEXT_PARTS_NUMBER 50
+
+Evas_Object *GLOBAL_ENTRY_BOX;
+Evas_Object *LOG_SIGNAL_BOX;
+Evas_Object *LOG_TEXT_BOX;
+
+static void add_log_info(char *object_text, char *signal)
+{
+ elm_entry_cursor_begin_set(LOG_SIGNAL_BOX);
+ elm_entry_entry_insert(LOG_SIGNAL_BOX, signal);
+ elm_entry_entry_insert(LOG_SIGNAL_BOX, "<br>");
+
+ elm_entry_cursor_begin_set(LOG_TEXT_BOX);
+ elm_entry_entry_insert(LOG_TEXT_BOX, object_text);
+ elm_entry_entry_insert(LOG_TEXT_BOX, "<br>");
+}
+
+static void say_smart_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ char *signal = data;
+ char *object_text = elm_object_text_get(obj);
+
+ add_log_info(object_text, signal);
+}
+
+void say_cb(void *data, const char *signal)
+{
+ add_log_info("ENTRY", signal);
+}
+
+void non_discardable_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_atspi_bridge_utils_say(elm_entry_entry_get(GLOBAL_ENTRY_BOX), EINA_FALSE, say_cb, NULL);
+}
+
+void discardable_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_atspi_bridge_utils_say(elm_entry_entry_get(GLOBAL_ENTRY_BOX), EINA_TRUE, say_cb, NULL);
+}
+
+void clean_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_entry_entry_set(GLOBAL_ENTRY_BOX, "");
+}
+
+Evas_Object *create_entry(Evas_Object *layout, char *swallow_part)
+{
+ Evas_Object *display_window = elm_entry_add(layout);
+
+ if (display_window != NULL) {
+ evas_object_size_hint_align_set(display_window, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(display_window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(layout, swallow_part, display_window);
+ evas_object_show(display_window);
+
+ elm_entry_editable_set(display_window, EINA_FALSE);
+ elm_entry_scrollable_set(display_window, EINA_TRUE);
+
+ elm_scroller_policy_set(display_window, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON);
+ }
+
+ return display_window;
+}
+
+Evas_Object *create_button(Evas_Object *layout,char *object_text, char *part_name, Evas_Smart_Cb cb)
+{
+ Evas_Object *btn = elm_button_add(layout);
+
+ if (btn != NULL) {
+ elm_object_text_set(btn, object_text);
+ elm_object_style_set(btn, "default");
+ elm_object_part_content_set(layout, part_name, btn);
+
+ evas_object_smart_callback_add(btn, "clicked", cb, NULL);
+ evas_object_smart_callback_add(btn, "access,read,cancel", (Evas_Smart_Cb) say_smart_cb, "access,read,cancel");
+ evas_object_smart_callback_add(btn, "access,read,stop", (Evas_Smart_Cb) say_smart_cb, "access,read,stop");
+ evas_object_smart_callback_add(btn, "access,read,skip", (Evas_Smart_Cb) say_smart_cb, "access,read,skip");
+ }
+
+ return btn;
+}
+
+void add_sample_text()
+{
+ char *short_text = "This program reads the text and displays it in entry. Click some button to see what happens. ";
+ int len = strlen(short_text);
+ char *long_text = malloc(sizeof(char) * (len+4) * TEXT_PARTS_NUMBER + 1);
+ int i;
+ int size = 0;
+
+ for (i = 0; i < TEXT_PARTS_NUMBER; i++) {
+ memcpy(long_text+size, short_text, len);
+ size += len;
+ sprintf(long_text+size, " %2d ", i+1);
+ size += 4;
+ }
+
+ elm_entry_entry_set(GLOBAL_ENTRY_BOX, long_text);
+
+ free(long_text);
+}
+
+static Evas_Object
+*create_layout(Evas_Object *parent)
+{
+ Evas_Object *layout;
+ Evas_Object *btn;
+
+ layout = elm_layout_add(parent);
+ if (layout == NULL) {
+ ERROR("elm_layout_add() failed");
+ return NULL;
+ }
+
+ elm_layout_file_set(layout, ELM_DEMO_EDJ, "direct_reading_layout");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ btn = create_button(layout, "Non-Discardable", "top_left_button", non_discardable_cb);
+ if (btn == NULL) {
+ ERROR("elm_button_add() for Non-Discardable button failed");
+ return NULL;
+ }
+
+ btn = create_button(layout, "Discardable", "top_right_button", discardable_cb);
+ if (btn == NULL) {
+ ERROR("elm_button_add() for Discardable button failed");
+ return NULL;
+ }
+
+ btn = create_button(layout, "CLEAN", "bottom_button", clean_cb);
+ if (btn == NULL) {
+ ERROR("elm_button_add() for CLEAN button failed");
+ return NULL;
+ }
+
+ GLOBAL_ENTRY_BOX = create_entry(layout, "screen");
+ if (GLOBAL_ENTRY_BOX == NULL) {
+ ERROR("elm_entry_add() for GLOBAL_ENTRY_BOX failed");
+ return NULL;
+ }
+
+ LOG_SIGNAL_BOX = create_entry(layout, "log_info_signal");
+ if (LOG_SIGNAL_BOX == NULL) {
+ ERROR("elm_entry_add() for LOG_SIGNAL_BOX failed");
+ return NULL;
+ }
+
+ LOG_TEXT_BOX = create_entry(layout, "log_info_text");
+ if (LOG_TEXT_BOX == NULL) {
+ ERROR("elm_entry_add() for LOG_TEXT_BOX failed");
+ return NULL;
+ }
+
+ elm_entry_editable_set(GLOBAL_ENTRY_BOX, EINA_TRUE);
+
+ add_sample_text();
+
+ return layout;
+}
+
+void
+direct_reading_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *layout;
+ Evas_Object *nf = data;
+
+ layout = create_layout(nf);
+
+ if (layout != NULL)
+ elm_naviframe_item_push(nf, "Direct Reading", NULL, NULL, layout, NULL);
+ else
+ ERROR("UI creation failed");
+}