--- /dev/null
+#include "MainPage.hpp"
+
+#include "setting-accessibility.h"
+
+#include <vconf.h>
+#include <app.h>
+
+MainPage::MainPage(SettingAccessibility *ad)
+{
+ ad->md.initView(_("IDS_ST_BODY_ACCESSIBILITY"));
+ elm_object_style_set(ad->md.getGenlist(), "dialogue");
+
+ ad->md.addBackButton(cancelCb, ad);
+
+ Evas_Object *scroller = ad->md.getGenlist();
+ createGendialTitleItem(scroller, &(itc_group_item), "IDS_ST_HEADER_VISION");
+
+ int screen_reader = 0;
+ auto r = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &screen_reader);
+ if (!r)
+ SETTING_TRACE_ERROR("Could not get value for key: %s", VCONFKEY_SETAPPL_ACCESSIBILITY_TTS);
+
+ screenReaderItem_ = createGendialGroupItem(
+ scroller, &itc_2text,
+ onScreenReaderItemClicked,
+ ad, SwallowType::INVALID, 1,
+ "IDS_ST_MBODY_SCREEN_READER_HTTS",
+ screen_reader ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF",
+ NULL);
+ if (screenReaderItem_) {
+ screenReaderItem_->userdata = ad;
+ __BACK_POINTER_SET(screenReaderItem_);
+ }
+
+ universalSwitchItem_ = createGendialGroupItem(
+ scroller, &ad->itc_multiline_sub,
+ onUniversalSwitchItemClicked,
+ ad, SwallowType::INVALID, 1,
+ "IDS_ACCS_UNIVERSAL_SWITCH",
+ "IDS_ACCS_UNIVERSAL_SWITCH_HINT",
+ NULL);
+ if (universalSwitchItem_) {
+ universalSwitchItem_->userdata = ad;
+ __BACK_POINTER_SET(universalSwitchItem_);
+ }
+
+ accessibilityLauncherItem_ = createGendialGroupItem(
+ scroller, &ad->itc_multiline_sub,
+ onAccessibilityLauncherItemClicked,
+ ad, SwallowType::INVALID, 1,
+ "IDS_ACCS_ACCESSIBILITY_LAUNCHER",
+ "IDS_ACCS_ACCESSIBILITY_LAUNCHER_HINT",
+ NULL);
+ if (accessibilityLauncherItem_) {
+ accessibilityLauncherItem_->userdata = ad;
+ __BACK_POINTER_SET(accessibilityLauncherItem_);
+ }
+
+ int vconf_ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, onScreenReaderVconfKeyChanged, screenReaderItem_);
+ if (vconf_ret != 0) {
+ SETTING_TRACE("FAIL: vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS)");
+ }
+}
+
+Eina_Bool MainPage::cancelCb(void *data, Elm_Object_Item *it)
+{
+ auto ad = static_cast<SettingAccessibility *>(data);
+ retv_if(!ad, EINA_FALSE);
+
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, onScreenReaderVconfKeyChanged);
+ ui_app_exit();
+ return EINA_TRUE;
+}
+
+void MainPage::onScreenReaderVconfKeyChanged(keynode_t *key, void *user_data)
+{
+ auto screen_reader_item = static_cast<GenGroupItemData *>(user_data);
+ screen_reader_item->sub_desc = vconf_keynode_get_bool(key) ? _("IDS_ST_BODY_ON") : _("IDS_ST_BODY_OFF");
+
+ elm_genlist_item_update(screen_reader_item->item);
+}
+
+void MainPage::onScreenReaderItemClicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+ auto ad = static_cast<SettingAccessibility *>(data);
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ ad->screenReaderPage_ = std::make_unique<ScreenReaderPage>(ad);
+}
+
+void MainPage::onUniversalSwitchItemClicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+ auto ad = static_cast<SettingAccessibility *>(data);
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ ad->universalSwitchPage_ = std::make_unique<UniversalSwitchPage>(ad);
+}
+
+void MainPage::onAccessibilityLauncherItemClicked(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+ auto ad = static_cast<SettingAccessibility *>(data);
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ ad->accessibilityLauncherPage_ = std::make_unique<AccessibilityLauncherPage>(ad);
+}
--- /dev/null
+#ifndef MAIN_PAGE_HPP
+#define MAIN_PAGE_HPP
+
+#include "SettingAccessibility.hpp"
+
+class MainPage
+{
+public:
+ MainPage(SettingAccessibility *ad);
+
+private:
+ static Eina_Bool cancelCb(void *data, Elm_Object_Item *it);
+ static void onScreenReaderVconfKeyChanged(keynode_t *key, void *user_data);
+ static void onScreenReaderItemClicked(void *data, Evas_Object *obj, void *event_info);
+ static void onUniversalSwitchItemClicked(void *data, Evas_Object *obj, void *event_info);
+ static void onAccessibilityLauncherItemClicked(void *data, Evas_Object *obj, void *event_info);
+
+ GenGroupItemData *screenReaderItem_;
+ GenGroupItemData *universalSwitchItem_;
+ GenGroupItemData *accessibilityLauncherItem_;
+};
+
+#endif
#include "UniversalSwitchSettingsPage.hpp"
#include "SetValuePage.hpp"
#include "SettingPopup.hpp"
+#include "MainPage.hpp"
#include <tts.h>
class UniversalSwitchPage;
class UniversalSwitchSettingsPage;
class SetValuePage;
+class MainPage;
typedef void (*switch_action_cb)(SettingAccessibility *ad, const std::string &action, void *user_data);
Elm_Object_Item *naviframe_it;
SetValueLayout set_value_layout;
- GenGroupItemData *screen_reader_item;
- GenGroupItemData *universal_switch_item;
GenGroupItemData *universal_switch_off_checkbox;
GenGroupItemData *universal_switch_comment;
GenGroupItemData *universal_switch_add_switch_screen;
int switches_to_remove_counter;
bool launched_by_app_control;
+ std::unique_ptr<MainPage> mainPage_;
std::unique_ptr<AccessibilityLauncherPage> accessibilityLauncherPage_;
std::unique_ptr<ScreenReaderSettingsPage> screenReaderSettingsPage_;
std::unique_ptr<ScreenReaderPage> screenReaderPage_;
+++ /dev/null
-/*
- * Copyright 2018 Samsung Electronics Co., Ltd
- *
- * 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 "setting-accessibility.h"
-
-#include <vconf.h>
-#include <app.h>
-
-static int setting_accessibility_main_create(void *cb);
-static int setting_accessibility_main_destroy(void *cb);
-static int setting_accessibility_main_update(void *cb);
-static int setting_accessibility_main_cleanup(void *cb);
-
-setting_view setting_view_accessibility_main = {
- .create = setting_accessibility_main_create,
- .destroy = setting_accessibility_main_destroy,
- .update = setting_accessibility_main_update,
- .cleanup = setting_accessibility_main_cleanup,
-};
-
-static void setting_accessibility_screen_reader_key_change_vconf_cb(
- keynode_t *key, void *user_data)
-{
-
- auto screen_reader_item = static_cast<GenGroupItemData *>(user_data);
- screen_reader_item->sub_desc = vconf_keynode_get_bool(key) ? _("IDS_ST_BODY_ON") : _("IDS_ST_BODY_OFF");
-
- elm_genlist_item_update(screen_reader_item->item);
-}
-
-/**
- * @brief Do process when cancelling application
- *
- * @param data application context
- * @param UNUSED
- */
-static Eina_Bool _cancel_cb(void *data, Elm_Object_Item *it)
-{
-
- auto ad = static_cast<SettingAccessibility *>(data);
- retv_if(!ad, EINA_FALSE);
-
- vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS,
- setting_accessibility_screen_reader_key_change_vconf_cb);
- ui_app_exit();
- return EINA_TRUE;
-}
-
-static void setting_accessibility_vision_screen_reader_mouse_up_Gendial_list_cb(
- void *data, Evas_Object *obj, void *event_info)
-{
-
- Elm_Object_Item *item = (Elm_Object_Item *)event_info;
- auto ad = static_cast<SettingAccessibility *>(data);
- elm_genlist_item_selected_set(item, EINA_FALSE);
- ad->screenReaderPage_ = std::make_unique<ScreenReaderPage>(ad);
-
-}
-
-static void setting_accessibility_universal_switch_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
-{
-
- Elm_Object_Item *item = (Elm_Object_Item *)event_info;
- auto ad = static_cast<SettingAccessibility *>(data);
- elm_genlist_item_selected_set(item, EINA_FALSE);
- ad->universalSwitchPage_ = std::make_unique<UniversalSwitchPage>(ad);
-
-}
-
-static void setting_accessibility_accessibility_launcher_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
-{
-
- Elm_Object_Item *item = (Elm_Object_Item *)event_info;
- auto ad = static_cast<SettingAccessibility *>(data);
- elm_genlist_item_selected_set(item, EINA_FALSE);
- ad->accessibilityLauncherPage_ = std::make_unique<AccessibilityLauncherPage>(ad);
-
-}
-
-/**
- * @brief create main view genlist items
- *
- * @param data application data
- *
- * @return FALSE for call it once and then destory the timer, TRUE for always
- * call it when the timer is reached.
- */
-int setting_accessibility_main_generate_genlist(void *data)
-{
-
- /* error check */
- retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
-
- auto ad = static_cast<SettingAccessibility *>(data);
- Evas_Object *scroller = ad->md.getGenlist();
- createGendialTitleItem(scroller, &(itc_group_item), "IDS_ST_HEADER_VISION");
-
- int screen_reader = 0;
- auto r = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &screen_reader);
- if (!r)
- SETTING_TRACE_ERROR("Could not get value for key: %s", VCONFKEY_SETAPPL_ACCESSIBILITY_TTS);
-
- ad->screen_reader_item = createGendialGroupItem(
- scroller, &itc_2text,
- setting_accessibility_vision_screen_reader_mouse_up_Gendial_list_cb,
- ad, SwallowType::INVALID, 1,
- "IDS_ST_MBODY_SCREEN_READER_HTTS",
- screen_reader ? "IDS_ST_BODY_ON" : "IDS_ST_BODY_OFF",
- NULL);
- if (ad->screen_reader_item) {
- ad->screen_reader_item->userdata = ad;
- __BACK_POINTER_SET(ad->screen_reader_item);
- }
-
- ad->universal_switch_item = createGendialGroupItem(
- scroller, &ad->itc_multiline_sub,
- setting_accessibility_universal_switch_mouse_up_Gendial_list_cb,
- ad, SwallowType::INVALID, 1,
- "IDS_ACCS_UNIVERSAL_SWITCH",
- "IDS_ACCS_UNIVERSAL_SWITCH_HINT",
- NULL);
- if (ad->universal_switch_item) {
- ad->universal_switch_item->userdata = ad;
- __BACK_POINTER_SET(ad->universal_switch_item);
- }
-
- GenGroupItemData *item = createGendialGroupItem(
- scroller, &ad->itc_multiline_sub,
- setting_accessibility_accessibility_launcher_mouse_up_Gendial_list_cb,
- ad, SwallowType::INVALID, 1,
- "IDS_ACCS_ACCESSIBILITY_LAUNCHER",
- "IDS_ACCS_ACCESSIBILITY_LAUNCHER_HINT",
- NULL);
- if (item) {
- item->userdata = ad;
- __BACK_POINTER_SET(item);
- }
-
- int vconf_ret = vconf_notify_key_changed(
- VCONFKEY_SETAPPL_ACCESSIBILITY_TTS,
- setting_accessibility_screen_reader_key_change_vconf_cb,
- ad->screen_reader_item);
- if (vconf_ret != 0) {
- SETTING_TRACE("FAIL: vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS)");
- return SETTING_RETURN_FAIL;
- }
-
-
- return SETTING_RETURN_SUCCESS;
-}
-
-static int setting_accessibility_main_create(void *cb)
-{
-
- auto ad = static_cast<SettingAccessibility *>(cb);
- retv_if(ad == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
-
- ad->md.initView(_("IDS_ST_BODY_ACCESSIBILITY"));
- elm_object_style_set(ad->md.getGenlist(), "dialogue");
-
- ad->md.addBackButton(_cancel_cb, ad);
-
- setting_accessibility_main_generate_genlist((void *)ad);
-
- setting_view_accessibility_main.is_create = 1;
-
- return SETTING_RETURN_SUCCESS;
-}
-
-static int setting_accessibility_main_destroy(void *cb)
-{
-
- /* error check */
- retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
-
- setting_view_accessibility_main.is_create = 0;
-
-
- return SETTING_RETURN_SUCCESS;
-}
-
-static int setting_accessibility_main_update(void *cb)
-{
-
- /* error check */
- retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
-
-
- return SETTING_RETURN_SUCCESS;
-}
-
-static int setting_accessibility_main_cleanup(void *cb)
-{
-
- /* error check */
- retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
-
-
- return SETTING_RETURN_SUCCESS;
-}
#include "setting-debug.h"
#include "setting-accessibility.h"
+#include "MainPage.hpp"
static const char *get_tts_error(int r)
{
return false;
}
- /* register view node table */
- setting_view_node_table_intialize();
- setting_view_node_table_register(&setting_view_accessibility_main,
- NULL);
-
- setting_view_node_set_cur_view(&setting_view_accessibility_main);
-
- /* creating a view. */
ret = create_tts_handle(ad);
if (ret == -1) destroy_tts_handle(ad);
- setting_view_create(&setting_view_accessibility_main, (void *)ad);
+ ad->mainPage_ = std::make_unique<MainPage>(ad);
evas_object_show(ad->md.getWindow());
return true;
}
-static void on_app_pause(void *priv)
-{
-
-
-}
-
-static void on_app_resume(void *priv)
-{
-
-
-}
-
static void on_app_terminate(void *priv)
{
-
auto ad = static_cast<SettingAccessibility *>(priv);
destroy_tts_handle(ad);
- setting_view_destroy(&setting_view_accessibility_main, ad);
-
}
static void on_app_control(app_control_h service, void *priv)
ui_app_lifecycle_callback_s ops = {
.create = on_app_create,
.terminate = on_app_terminate,
- .pause = on_app_pause,
- .resume = on_app_resume,
+ .pause = nullptr,
+ .resume = nullptr,
.app_control = on_app_control
};
SettingAccessibility app_data;
#include <Elementary.h>
#include <tts.h>
#include "setting-common-draw-widget.h"
-#include "setting-common-view.h"
#include "setting-accessibility-universal-switch-dbus.h"
#include "SettingAccessibility.hpp"
#define VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_MANAGE_RECENT_APPS VCONF_PROJECT_PREFIX "SHOW_RECENT_APPS_MENU_ITEM"
#define VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_MANAGE_BACK VCONF_PROJECT_PREFIX "SHOW_BACK_MENU_ITEM"
-extern setting_view setting_view_accessibility_main;
-
#endif /*__SETTING_ACCESSIBILITY_H__ */
+++ /dev/null
-/*
- * Copyright 2018 Samsung Electronics Co., Ltd
- *
- * 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 "setting-common-view.h"
-
-#include <Elementary.h>
-
-#include "setting-common-data-error.h"
-#include "setting-debug.h"
-
-#define MAX_VIEWNODE_NUM 15
-typedef struct _SettingViewNode {
- setting_view *view;
- setting_view *topview;
-} SettingViewNode;
-static setting_view *g_cur_view; /* use by 'End Key' process */
-static SettingViewNode g_view_node_table[MAX_VIEWNODE_NUM];
-static int g_view_node_table_cur_size = 0;
-
-/**
- * @brief Set current loaded view
- *
- * @param view The view to set
- * @return #0 on success, else on failed
- */
-int setting_view_node_set_cur_view(setting_view *view)
-{
- g_cur_view = view;
- return 0;
-}
-
-/**
- * @brief intialize the node table
- *
- * @return #0 on success, else on failed
- */
-int setting_view_node_table_intialize()
-{
- g_cur_view = NULL;
- g_view_node_table_cur_size = 0;
- return 0;
-}
-
-/**
- * @brief Register a node for a viwe and its top view
- *
- * @param view The current view
- * @param view The top view of current view
- * @return #0 on success, else on failed
- */
-int setting_view_node_table_register(setting_view *view,
- setting_view *topview)
-{
- /*SETTING_TRACE_BEGIN; */
- if (g_view_node_table_cur_size >= MAX_VIEWNODE_NUM)
- return SETTING_RETURN_FAIL;
-
- int idx = 0;
- for (; idx < g_view_node_table_cur_size; idx++) {
- if (view == g_view_node_table[idx].view
- && topview == g_view_node_table[idx].topview) {
- SETTING_TRACE("view node has been registered, ignore");
- return SETTING_RETURN_FAIL;
- }
- }
-
- g_view_node_table[g_view_node_table_cur_size].view = view;
- g_view_node_table[g_view_node_table_cur_size].topview = topview;
- g_view_node_table_cur_size++;
- return 0;
-}
-
-/**
- * @brief Callback of view creating
- *
- * @param view The created view
- * @param cb The view data passed between all callbacks
- * @return #0 on success, else on failed
- */
-int setting_view_create(setting_view *view, void *cb)
-{
- LAUNCH_SETTING_IN();
- /* error check */
- setting_retvm_if(!view, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "Invalid arguement");
-
- int ret = SETTING_RETURN_FAIL;
-
- /*error handle:create only when the view doesn't exit */
- if (view->is_create)
- SETTING_TRACE_DEBUG("view i already created");
- else if (!view->create)
- SETTING_TRACE_DEBUG("create callback is null");
- else
- ret = view->create(cb);
-
- LAUNCH_SETTING_OUT();
- return ret;
-}
-
-/**
- * @brief Callback of view destroying
- *
- * @param view The view being destroyed
- * @param cb The view data passed between all callbacks
- * @return #0 on success, else on failed
- */
-int setting_view_destroy(setting_view *view, void *cb)
-{
- /* error check */
- setting_retvm_if(!view || !cb, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER,
- "Invalid arguement");
-
- int ret = SETTING_RETURN_FAIL;
-
- /*error handle:destroy only when the view exits */
- if (view->is_create && view->destroy)
- ret = view->destroy(cb);
-
- return ret;
-}
+++ /dev/null
-/*
- * Copyright 2018 Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-/**
- *@defgroup setting-common-view
- *each UG is able to have multiple views.
- */
-#ifndef __SETTING_COMMON_VIEW_H__
-#define __SETTING_COMMON_VIEW_H__
-
-struct setting_view {
- int (*create)(void *cb);
- int (*destroy)(void *cb);
- int (*update)(void *cb);
- int (*cleanup)(void *cb);
- int (*langchanged)(void *cb);
-
- int is_create; /* 1:exist */
-};
-/**
- * @brief Set current loaded view
- *
- * @param view The view to set
- * @return #0 on success, else on failed
- */
-int setting_view_node_set_cur_view(setting_view *view);
-
-/**
- * @brief intialize the node table
- *
- * @return #0 on success, else on failed
- */
-int setting_view_node_table_intialize();
-
-/**
- * @brief Register a node for a viwe and its top view
- *
- * @param view The current view
- * @param view The top view of current view
- * @return #0 on success, else on failed
- */
-int setting_view_node_table_register(setting_view *view,
- setting_view *topview);
-
-/**
- * @brief Callback of view creating
- *
- * @param view The created view
- * @param cb The view data passed between all callbacks
- * @return #0 on success, else on failed
- */
-int setting_view_create(setting_view *view, void *cb);
-
-/**
- * @brief Callback of view destroying
- *
- * @param view The view being destroyed
- * @param cb The view data passed between all callbacks
- * @return #0 on success, else on failed
- */
-int setting_view_destroy(setting_view *view, void *cb);
-
-#endif /* __SETTING_COMMON_VIEW_H__ */