2 * Copyright 2018 Samsung Electronics Co., Ltd
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "AccessibilitySettingLog.hpp"
18 #include "MainPagePresenter.hpp"
19 #include "Singleton.hpp"
20 #include "setting-accessibility.h"
23 #include <appcore-common.h>
25 static bool on_app_create(void *priv)
27 Singleton<AppContext>::instance().push(std::make_unique<MainPagePresenter>());
31 static void on_app_terminate(void *priv)
35 static void on_app_pause(void *priv)
37 auto p = Singleton<AppContext>::instance().back();
42 static void on_app_resume(void *priv)
44 auto p = Singleton<AppContext>::instance().back();
49 static void on_app_control(app_control_h service, void *priv)
52 TODO: restore below functionality
54 auto ad = static_cast<SettingAccessibility *>(priv);
55 RETURN_IF(!ad, "Data parameter is NULL");
57 if (!app_control_get_extra_data(service, "SHOW_US_SETTINGS", &value) && value != NULL && !strcmp(value, "1")) {
58 ad->launched_by_app_control = true;
59 if (ad->universal_switch_settings_item) {
60 elm_naviframe_item_pop_to(ad->universal_switch_settings_item);
61 } else if (ad->universal_switch_main_item) {
62 elm_naviframe_item_pop_to(ad->universal_switch_main_item);
63 ad->universalSwitchSettingsPage_ = std::make_unique<UniversalSwitchSettingsPage>(ad);
65 ad->universalSwitchPage_ = std::make_unique<UniversalSwitchPage>(ad);
72 static void _lang_changed(app_event_info_h event_info, void *data)
75 if (app_event_get_language(event_info, &lang) == APP_ERROR_NONE) {
76 DEBUG("Setting - language is changed : %s", lang);
77 elm_language_set(lang);
78 elm_config_all_flush();
81 ERROR("Cannot get language from event_info");
85 int main(int argc, char *argv[])
87 app_event_handler_h handlers[5] = {
90 ui_app_lifecycle_callback_s ops = {.create = on_app_create,
91 .terminate = on_app_terminate,
92 .pause = on_app_pause,
93 .resume = on_app_resume,
94 .app_control = on_app_control};
96 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL);
97 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, NULL);
98 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _lang_changed, NULL);
99 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL);
100 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL);
102 return ui_app_main(argc, argv, &ops, nullptr);