From: Hermet Park Date: Thu, 2 Jun 2016 10:22:04 +0000 (+0900) Subject: support additional view events. X-Git-Tag: submit/tizen/20160617.075742~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73b967c0f748c3785cbac33c6b8492bbc8213a39;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git support additional view events. - on_language_changed() - on_region_changed() - on_low_battery() - on_low_memory() Change-Id: I77dae85c535a8a782ad6d940fefa7e58afe16650 --- diff --git a/src/include/interface/ui_iface_app.h b/src/include/interface/ui_iface_app.h index 6eb4aa3..b733193 100644 --- a/src/include/interface/ui_iface_app.h +++ b/src/include/interface/ui_iface_app.h @@ -134,6 +134,7 @@ protected: private: _UI_DECLARE_PRIVATE_IMPL(ui_iface_app); _UI_DISABLE_COPY_AND_ASSIGN(ui_iface_app); + _UI_DECLARE_FRIENDS(ui_iface_view); }; } diff --git a/src/include/interface/ui_iface_view.h b/src/include/interface/ui_iface_view.h index 7107eb2..ba43284 100644 --- a/src/include/interface/ui_iface_view.h +++ b/src/include/interface/ui_iface_view.h @@ -250,6 +250,37 @@ protected: */ virtual void on_destroy(); + /** + * @brief Low Memory Event + * + * @note This event function is responsible for saving data in the main memory to a persistent memory or storage to avoid data loss in case the Tizen + * platform Low Memory Killer kills your application to get more free memory. This event function must also release any cached data in the main + * memory to secure more free memory. + */ + virtual void on_low_memory(); + + /** + * @brief Low Battery Event + * + * @note This event function is responsible for saving data in the main memory to a persistent memory or storage to avoid data loss in case the power goes + * off completely. This event function must also stop heavy CPU consumption or power consumption activities to save the remaining power. + */ + virtual void on_low_battery(); + + /** + * @brief Region Changed Event + * + * @note This event function is responsible for refreshing the display into the new time zone. + */ + virtual void on_region_changed(const char *region); + + /** + * @brief Language Changed Event + * + * @note This event function is responsible for refreshing the display into the new language. + */ + virtual void on_language_changed(const char *language); + private: /** * @brief Connect with given viewmgr. @@ -274,6 +305,7 @@ private: _UI_DECLARE_PRIVATE_IMPL(ui_iface_view); _UI_DISABLE_COPY_AND_ASSIGN(ui_iface_view); _UI_DECLARE_FRIENDS(ui_iface_viewmgr); + _UI_DECLARE_FRIENDS(ui_iface_app); }; } diff --git a/src/lib/interface/ui_iface_app.cpp b/src/lib/interface/ui_iface_app.cpp index ecaec2d..468ca69 100644 --- a/src/lib/interface/ui_iface_app.cpp +++ b/src/lib/interface/ui_iface_app.cpp @@ -45,7 +45,6 @@ public: void on_resume(); void on_control(app_control_h app_control); - // void on_low_battery(app_event_info_h event_info); void on_low_memory(app_event_info_h event_info); void on_region_changed(app_event_info_h event_info); @@ -226,30 +225,48 @@ static ui_iface_app *inst = NULL; void ui_iface_app::on_lang_changed(app_event_info_h event_info) { - char *locale = NULL; - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); - elm_language_set(locale); - free(locale); + char *language = NULL; + int ret = app_event_get_language(event_info, &language); + if (ret != APP_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "app_event_get_language() failed. Err = %d.", ret); + return; + } + + if (language != NULL) { + elm_language_set(language); + ui_iface_view *view = this->impl->viewmgr->get_last_view(); + view->on_language_changed(language); + free(language); + } } void ui_iface_app::on_low_memory(app_event_info_h event_info) { - + ui_iface_view *view = this->impl->viewmgr->get_last_view(); + view->on_low_memory(); } void ui_iface_app::on_low_battery(app_event_info_h event_info) { - + ui_iface_view *view = this->impl->viewmgr->get_last_view(); + view->on_low_battery(); } void ui_iface_app::on_region_changed(app_event_info_h event_info) { + char *region = NULL; + int ret = app_event_get_region_format(event_info, ®ion); + if (ret != APP_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "model_app_event_get_region_format() failed. Err = %d", ret); + return; + } + ui_iface_view *view = this->impl->viewmgr->get_last_view(); + view->on_region_changed(region); } void ui_iface_app::on_orient_changed(app_event_info_h event_info) { - } bool ui_iface_app::on_create() diff --git a/src/lib/interface/ui_iface_view.cpp b/src/lib/interface/ui_iface_view.cpp index 37aeb96..bdd0c48 100644 --- a/src/lib/interface/ui_iface_view.cpp +++ b/src/lib/interface/ui_iface_view.cpp @@ -349,3 +349,18 @@ ui_iface_viewmgr *ui_iface_view::get_viewmgr() return this->impl->viewmgr; } +void ui_iface_view::on_low_memory() +{ +} + +void ui_iface_view::on_low_battery() +{ +} + +void ui_iface_view::on_region_changed(const char *region) +{ +} + +void ui_iface_view::on_language_changed(const char *language) +{ +}