Add update of GenlistItem fields when text and description are changed
[profile/mobile/apps/native/accessibility-setting.git] / src / main.cpp
1 /*
2  * Copyright 2018 Samsung Electronics Co., Ltd
3  *
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
7  *
8  *  http://www.apache.org/licenses/LICENSE-2.0
9
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.
15  */
16
17 #include "AccessibilitySettingLog.hpp"
18 #include "MainPagePresenter.hpp"
19 #include "Singleton.hpp"
20 #include "setting-accessibility.h"
21
22 #include <app.h>
23 #include <appcore-common.h>
24
25 static bool on_app_create(void *priv)
26 {
27         Singleton<AppContext>::instance().push(std::make_unique<MainPagePresenter>());
28         return true;
29 }
30
31 static void on_app_terminate(void *priv)
32 {
33 }
34
35 static void on_app_pause(void *priv)
36 {
37         auto p = Singleton<AppContext>::instance().back();
38         if (p)
39                 p->onAppPause();
40 }
41
42 static void on_app_resume(void *priv)
43 {
44         auto p = Singleton<AppContext>::instance().back();
45         if (p)
46                 p->onAppResume();
47 }
48
49 static void on_app_control(app_control_h service, void *priv)
50 {
51         /*
52          TODO: restore below functionality
53
54         auto ad = static_cast<SettingAccessibility *>(priv);
55         RETURN_IF(!ad, "Data parameter is NULL");
56         char *value = 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);
64                 } else {
65                         ad->universalSwitchPage_ = std::make_unique<UniversalSwitchPage>(ad);
66                 }
67         }
68         free(value);
69         */
70 }
71
72 static void _lang_changed(app_event_info_h event_info, void *data)
73 {
74         char *lang = NULL;
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();
79                 free(lang);
80         } else {
81                 ERROR("Cannot get language from event_info");
82         }
83 }
84
85 int main(int argc, char *argv[])
86 {
87         app_event_handler_h handlers[5] = {
88                 NULL,
89         };
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};
95
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);
101
102         return ui_app_main(argc, argv, &ops, nullptr);
103 }