support additional view events. 69/72769/1
authorHermet Park <hermet@hermet.pe.kr>
Thu, 2 Jun 2016 10:22:04 +0000 (19:22 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Thu, 2 Jun 2016 10:22:04 +0000 (19:22 +0900)
- on_language_changed()
- on_region_changed()
- on_low_battery()
- on_low_memory()

Change-Id: I77dae85c535a8a782ad6d940fefa7e58afe16650

src/include/interface/ui_iface_app.h
src/include/interface/ui_iface_view.h
src/lib/interface/ui_iface_app.cpp
src/lib/interface/ui_iface_view.cpp

index 6eb4aa348bb03df1d344bb15f8b45dbc499daeb9..b73319380c208236088d1928da29333d6de83984 100644 (file)
@@ -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);
 };
 
 }
index 7107eb24d8e13edebe9117f92771e9fb7b6f3bd4..ba43284cd2fd523519a6f0c94d38b7b15c8b11d8 100644 (file)
@@ -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);
 };
 
 }
index ecaec2d6beb7f0e916caf6dd121a5e7a9a38d97e..468ca692a173d1eb099512a04510b4da5bbf53e1 100644 (file)
@@ -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, &region);
+       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()
index 37aeb9633f34ffb9a8b2a7989f8b44a319939306..bdd0c486e672b3facb055c5651b83038fa9b9e15 100644 (file)
@@ -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)
+{
+}