2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
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.
19 #include "input_method_setting_list.h"
20 #include "input_method_setting_list_ui.h"
23 app_create(void *data)
26 /* Hook to take necessary actions before main event loop starts
27 Initialize UI resources and application's data
28 If this function returns true, the main loop of application starts
29 If this function returns false, the application is terminated */
34 app_control(app_control_h app_control, void *data)
36 /* Handle the launch request. */
37 appdata *ad = (appdata *)data;
46 if (ad->app_state == APP_STATE_PAUSE || ad->app_state == APP_STATE_RESUME)
50 elm_win_activate(ad->win);
51 im_setting_list_update_window(ad);
53 ad->app_state = APP_STATE_SERVICE;
57 ad->app_type = APP_TYPE_NORMAL;
59 res = app_control_get_extra_data(app_control, "caller", &type);
60 if (APP_CONTROL_ERROR_NONE == res && NULL != type) {
61 if (strcmp(type, "settings") == 0) {
62 ad->app_type = APP_TYPE_SETTING;
63 } else if (strcmp(type, "settings_no_rotation") == 0) {
64 ad->app_type = APP_TYPE_SETTING_NO_ROTATION;
68 ad->app_state = APP_STATE_SERVICE;
69 im_setting_list_app_create(ad);
79 appdata *ad = (appdata *)data;
81 /* Take necessary actions when application becomes invisible. */
87 evas_object_del(ad->popup);
90 ad->app_state = APP_STATE_PAUSE;
94 app_resume(void *data)
96 appdata *ad = (appdata *)data;
98 /* Take necessary actions when application becomes visible. */
102 if (ad->app_state == APP_STATE_PAUSE)
106 elm_win_activate(ad->win);
108 im_setting_list_app_resume(ad);
109 ad->app_state = APP_STATE_RESUME;
112 ad->app_state = APP_STATE_RESUME;
116 app_terminate(void *data)
118 appdata *ad = (appdata *)data;
120 /* Release all resources. */
124 ad->app_state = APP_STATE_TERMINATE;
125 im_setting_list_app_terminate(ad);
129 ui_app_lang_changed(app_event_info_h event_info, void *user_data)
131 /*APP_EVENT_LANGUAGE_CHANGED*/
133 app_event_get_language(event_info, &lang);
135 LOGD("lang : %s", lang);
138 elm_language_set(lang);
144 ui_app_orient_changed(app_event_info_h event_info, void *user_data)
147 /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
151 ui_app_region_changed(app_event_info_h event_info, void *user_data)
154 /*APP_EVENT_REGION_FORMAT_CHANGED*/
158 ui_app_low_battery(app_event_info_h event_info, void *user_data)
161 /*APP_EVENT_LOW_BATTERY*/
165 ui_app_low_memory(app_event_info_h event_info, void *user_data)
168 /*APP_EVENT_LOW_MEMORY*/
172 main(int argc, char *argv[])
177 ui_app_lifecycle_callback_s event_callback = {0, };
178 app_event_handler_h handlers[5] = {NULL, };
180 event_callback.create = app_create;
181 event_callback.terminate = app_terminate;
182 event_callback.pause = app_pause;
183 event_callback.resume = app_resume;
184 event_callback.app_control = app_control;
186 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
187 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
188 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
189 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
190 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
192 ret = ui_app_main(argc, argv, &event_callback, &ad);
193 if (ret != APP_ERROR_NONE) {
194 LOGW("ui_app_main failed, Err=%d\n", ret);