From: Hermet Park Date: Tue, 31 May 2016 09:55:52 +0000 (+0900) Subject: introduce ui_base_app class. X-Git-Tag: submit/tizen/20160617.075742~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F72292%2F1;p=platform%2Fcore%2Fuifw%2Fui-viewmgr.git introduce ui_base_app class. this is a base app class for all profiles. Change-Id: I4e49810aae0246db9cbfc9465b5055e882f4f5d6 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 52a2bb9..48ed9d5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,4 +3,5 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/lib) ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(lib) -ADD_SUBDIRECTORY(examples/efl/c) +ADD_SUBDIRECTORY(examples/efl/cpp) +#ADD_SUBDIRECTORY(examples/efl/c) diff --git a/src/include/efl/mobile/ui_app.h b/src/include/efl/mobile/ui_app.h index 7467c15..61d314b 100644 --- a/src/include/efl/mobile/ui_app.h +++ b/src/include/efl/mobile/ui_app.h @@ -22,7 +22,7 @@ namespace efl_viewmanager class ui_viewmgr; -class ui_app +class ui_app : public ui_base_app { public: /** @@ -50,89 +50,7 @@ public: */ static ui_app *get_instance(); - /** - * @brief Application life-cycle start and add application event callback functions add. - * - * @note This is calling ui_app_main function to start application life-cycle start. - * and adding all of the functions for application events handling such as - * create, terminate, pause, resume, app_control, APP_EVENT_LOW_BATTERY, APP_EVENT_LOW_MEMORY - * APP_EVENT_DEVICE_ORIENTATION_CHANGED, APP_EVENT_LANGUAGE_CHANGED, APP_EVENT_REGION_FORMAT_CHANGED. - * Application can add those events using wrapping functions by viewmgr supported. - */ - virtual int run(int argc, char **argv); - -protected: - /** - * @brief Calling before the main event loop start. - * - * @note Take necessary actions like a Initialize UI resources and application data. - * - * @return If this function returns true, the application main loop starts. - * If this function returns false, the application terminates. - */ - virtual bool on_create(); - - /** - * @brief Calling before the main event loop finish. - * - * @note Release all resources here. - */ - virtual void on_terminate(); - - /** - * @brief Calling when application becomes invisible. - */ - virtual void on_pause(); - - /** - * @brief Calling when application becomes visible. - */ - virtual void on_resume(); - - /** - * @brief Calling when gets a launch request event. - * - * @param app_control_h The instance of app_control_h. - */ - virtual void on_control(app_control_h app_control); - - /** - * @brief Calling when device low battery. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_low_battery(app_event_info_h event_info); - - /** - * @brief Calling when device low memory. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_low_memory(app_event_info_h event_info); - - /** - * @brief Calling when device region changed. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_region_changed(app_event_info_h event_info); - - /** - * @brief Calling when device orient changed. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_orient_changed(app_event_info_h event_info); - - /** - * @brief Calling when language changed. - * - * @param app_event_info_h The instance of app_event_info_h. - */ - virtual void on_lang_changed(app_event_info_h event_info); - private: - _UI_DECLARE_PRIVATE_IMPL(ui_app); _UI_DISABLE_COPY_AND_ASSIGN(ui_app); }; diff --git a/src/include/efl/mobile/ui_viewmgr.h b/src/include/efl/mobile/ui_viewmgr.h index 1a29c55..d285c5c 100644 --- a/src/include/efl/mobile/ui_viewmgr.h +++ b/src/include/efl/mobile/ui_viewmgr.h @@ -47,7 +47,6 @@ protected: virtual ~ui_viewmgr(); private: - _UI_DECLARE_PRIVATE_IMPL(ui_viewmgr); _UI_DISABLE_COPY_AND_ASSIGN(ui_viewmgr); _UI_DECLARE_FRIENDS(ui_view); _UI_DECLARE_FRIENDS(ui_app); diff --git a/src/include/efl/ui_base_app.h b/src/include/efl/ui_base_app.h new file mode 100644 index 0000000..7f50d57 --- /dev/null +++ b/src/include/efl/ui_base_app.h @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef _UI_BASE_APP_H_ +#define _UI_BASE_APP_H_ + +namespace efl_viewmanager +{ + +class ui_base_viewmgr; + +class ui_base_app +{ +public: + /** + * @brief This is a constructor for initializing ui_base_app. + * + * @param pkg The name of package. + * @param loale_dir The path of locale directory. + * @param viewmgr instance of ui_viewmgr. + */ + ui_base_app(const char *pkg, const char *locale_dir, ui_base_viewmgr *viewmgr); + + ///Destructor. + virtual ~ui_base_app(); + + /** + * @brief Return the viewmgr instance. + * + * @return ui_viewmgr instance. + */ + ui_base_viewmgr *get_viewmgr(); + + /** + * @brief Return ui_base_app instance. + * + * @return The instance of ui_base_app. + */ + static ui_base_app *get_instance(); + + /** + * @brief Application life-cycle start and add application event callback functions add. + * + * @note This is calling ui_base_app_main function to start application life-cycle start. + * and adding all of the functions for application events handling such as + * create, terminate, pause, resume, app_control, APP_EVENT_LOW_BATTERY, APP_EVENT_LOW_MEMORY + * APP_EVENT_DEVICE_ORIENTATION_CHANGED, APP_EVENT_LANGUAGE_CHANGED, APP_EVENT_REGION_FORMAT_CHANGED. + * Application can add those events using wrapping functions by viewmgr supported. + */ + virtual int run(int argc, char **argv); + +protected: + /** + * @brief Calling before the main event loop start. + * + * @note Take necessary actions like a Initialize UI resources and application data. + * + * @return If this function returns true, the application main loop starts. + * If this function returns false, the application terminates. + */ + virtual bool on_create(); + + /** + * @brief Calling before the main event loop finish. + * + * @note Release all resources here. + */ + virtual void on_terminate(); + + /** + * @brief Calling when application becomes invisible. + */ + virtual void on_pause(); + + /** + * @brief Calling when application becomes visible. + */ + virtual void on_resume(); + + /** + * @brief Calling when gets a launch request event. + * + * @param app_control_h The instance of app_control_h. + */ + virtual void on_control(app_control_h app_control); + + /** + * @brief Calling when device low battery. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_low_battery(app_event_info_h event_info); + + /** + * @brief Calling when device low memory. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_low_memory(app_event_info_h event_info); + + /** + * @brief Calling when device region changed. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_region_changed(app_event_info_h event_info); + + /** + * @brief Calling when device orient changed. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_orient_changed(app_event_info_h event_info); + + /** + * @brief Calling when language changed. + * + * @param app_event_info_h The instance of app_event_info_h. + */ + virtual void on_lang_changed(app_event_info_h event_info); + +private: + _UI_DECLARE_PRIVATE_IMPL(ui_base_app); + _UI_DISABLE_COPY_AND_ASSIGN(ui_base_app); +}; + +} + +#endif /* _UI_BASE_APP_H_ */ diff --git a/src/include/efl/ui_base_viewmanager.h b/src/include/efl/ui_base_viewmanager.h index ff4f840..5c715c4 100644 --- a/src/include/efl/ui_base_viewmanager.h +++ b/src/include/efl/ui_base_viewmanager.h @@ -28,6 +28,7 @@ #include "ui_base_key_listener.h" #include "ui_base_viewmgr.h" #include "ui_base_view.h" +#include "ui_base_app.h" #define UI_BASE_VIEWMGR dynamic_cast(ui_iface_viewmgr::get_instance()) diff --git a/src/include/efl/ui_base_viewmgr.h b/src/include/efl/ui_base_viewmgr.h index b44fdc8..c124368 100644 --- a/src/include/efl/ui_base_viewmgr.h +++ b/src/include/efl/ui_base_viewmgr.h @@ -192,6 +192,7 @@ private: _UI_DECLARE_PRIVATE_IMPL(ui_base_viewmgr); _UI_DISABLE_COPY_AND_ASSIGN(ui_base_viewmgr); _UI_DECLARE_FRIENDS(ui_base_view); + _UI_DECLARE_FRIENDS(ui_base_app); }; } diff --git a/src/include/ui_viewmanager.h b/src/include/ui_viewmanager.h index be890fa..e1fbd09 100644 --- a/src/include/ui_viewmanager.h +++ b/src/include/ui_viewmanager.h @@ -15,5 +15,5 @@ * */ //FIXME: C++ app include below. -//#include "efl/mobile/ui_mobile_viewmanager.h" -#include "efl/mobile/c/ui_mobile_viewmanager.h" +#include "efl/mobile/ui_mobile_viewmanager.h" +//#include "efl/mobile/c/ui_mobile_viewmanager.h" diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 0edf575..150b892 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -2,6 +2,7 @@ SET(SRCS interface/ui_iface_overlay.cpp interface/ui_iface_view.cpp interface/ui_iface_viewmgr.cpp + efl/ui_base_app.cpp efl/ui_base_view.cpp efl/ui_base_viewmgr.cpp efl/ui_base_key_listener.cpp @@ -13,11 +14,11 @@ SET(SRCS efl/mobile/ui_standard_view.cpp efl/mobile/ui_key_listener.cpp efl/mobile/ui_viewmgr.cpp - efl/mobile/c/ui_app.cpp - efl/mobile/c/ui_menu.cpp - efl/mobile/c/ui_popup.cpp - efl/mobile/c/ui_view.cpp - efl/mobile/c/ui_viewmgr.cpp +# efl/mobile/c/ui_app.cpp +# efl/mobile/c/ui_menu.cpp +# efl/mobile/c/ui_popup.cpp +# efl/mobile/c/ui_view.cpp +# efl/mobile/c/ui_viewmgr.cpp ) ADD_LIBRARY(${LIBNAME} SHARED ${SRCS}) diff --git a/src/lib/efl/mobile/ui_app.cpp b/src/lib/efl/mobile/ui_app.cpp index 0737421..ce71b9e 100644 --- a/src/lib/efl/mobile/ui_app.cpp +++ b/src/lib/efl/mobile/ui_app.cpp @@ -20,305 +20,26 @@ /***********************************************************************************************/ /* Internal class Implementation */ /***********************************************************************************************/ -namespace efl_viewmanager -{ - -class ui_app_impl -{ - friend class ui_app; - -private: - ui_app *app; - ui_viewmgr *viewmgr; - Eina_Stringshare *pkg; - Eina_Stringshare *locale_dir; - -public: - ui_app_impl(ui_app *ui_app, const char *pkg, const char *locale_dir); - ~ui_app_impl(); - - int run(int argc, char **argv); - ui_viewmgr *get_viewmgr(); - - bool init(); - bool on_create(); - void on_terminate(); - void on_pause(); - 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); - void on_orient_changed(app_event_info_h event_info); - void on_lang_changed(app_event_info_h event_info); -}; - -} - -static bool app_create(void *data) -{ - ui_app_impl *app = static_cast(data); - return app->on_create(); -} - -static void app_terminate(void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_terminate(); -} - -static void app_pause(void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_pause(); -} - -static void app_resume(void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_resume(); -} - -static void app_control(app_control_s *app_control, void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_control(app_control); -} - -static void ui_app_lang_changed(app_event_info_h event_info, void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_lang_changed(event_info); -} - -static void ui_app_orient_changed(app_event_info_h event_info, void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_orient_changed(event_info); -} - -static void ui_app_region_changed(app_event_info_h event_info, void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_region_changed(event_info); -} - -static void ui_app_low_battery(app_event_info_h event_info, void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_low_battery(event_info); -} - -static void ui_app_low_memory(app_event_info_h event_info, void *data) -{ - ui_app_impl *app = static_cast(data); - app->on_low_memory(event_info); -} - -bool ui_app_impl::init() -{ - //FIXME: this scale value should be configurable. - elm_app_base_scale_set(2.6); - - /* Bind package locale file */ - bindtextdomain(this->pkg, this->locale_dir); - textdomain(this->pkg); - - /* Default View Manager */ - this->viewmgr = new ui_viewmgr(this->pkg); - if (!this->viewmgr) - { - LOGE("Failed to create a viewmgr(%s)", this->pkg); - return false; - } - return true; -} - -ui_app_impl::ui_app_impl(ui_app *app, const char *pkg, const char *locale_dir) - : app(app), viewmgr(NULL) -{ - this->pkg = eina_stringshare_add(pkg); - this->locale_dir = eina_stringshare_add(locale_dir); -} - -int ui_app_impl::run(int argc, char **argv) -{ - ui_app_lifecycle_callback_s event_callback = - { 0, }; - app_event_handler_h handlers[5] = - { NULL, }; - - event_callback.create = app_create; - event_callback.terminate = app_terminate; - event_callback.pause = app_pause; - event_callback.resume = app_resume; - event_callback.app_control = app_control; - - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, this); - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, this); - ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, this); - ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, this); - ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, this); - - int ret = ui_app_main(argc, argv, &event_callback, this); - - if (ret != APP_ERROR_NONE) - { - LOGE("ui_app_main() is failed. err = %d", ret); - } - - return ret; -} - -ui_app_impl::~ui_app_impl() -{ - delete (this->viewmgr); - eina_stringshare_del(this->pkg); - eina_stringshare_del(this->locale_dir); -} - -ui_viewmgr *ui_app_impl::get_viewmgr() -{ - return this->viewmgr; -} - -void ui_app_impl::on_lang_changed(app_event_info_h event_info) -{ - this->app->on_lang_changed(event_info); -} - -void ui_app_impl::on_low_memory(app_event_info_h event_info) -{ - this->app->on_low_memory(event_info); -} - -void ui_app_impl::on_low_battery(app_event_info_h event_info) -{ - this->app->on_low_battery(event_info); -} - -void ui_app_impl::on_region_changed(app_event_info_h event_info) -{ - this->app->on_region_changed(event_info); -} - -void ui_app_impl::on_orient_changed(app_event_info_h event_info) -{ - this->app->on_orient_changed(event_info); -} - -bool ui_app_impl::on_create() -{ - return this->app->on_create(); -} - -void ui_app_impl::on_pause() -{ - this->app->on_pause(); -} - -void ui_app_impl::on_resume() -{ - this->app->on_resume(); -} - -void ui_app_impl::on_control(app_control_h app_control) -{ - this->app->on_control(app_control); -} - -void ui_app_impl::on_terminate() -{ - this->app->on_terminate(); -} /***********************************************************************************************/ /* External class Implementation */ /***********************************************************************************************/ -static ui_app *inst = NULL; - -void ui_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); -} - -void ui_app::on_low_memory(app_event_info_h event_info) -{ - -} - -void ui_app::on_low_battery(app_event_info_h event_info) -{ - -} - -void ui_app::on_region_changed(app_event_info_h event_info) -{ - -} - -void ui_app::on_orient_changed(app_event_info_h event_info) -{ - -} - -bool ui_app::on_create() -{ - return this->impl->init(); -} - -void ui_app::on_pause() -{ - this->impl->get_viewmgr()->deactivate(); -} - -void ui_app::on_resume() -{ -// this->impl->get_viewmgr()->activate(); -} - -void ui_app::on_control(app_control_h app_control) -{ - /* Handle the launch request. */ - this->impl->get_viewmgr()->activate(); -} - -void ui_app::on_terminate() -{ - delete(this); -} - ui_app::ui_app(const char *pkg, const char *locale_dir) + : ui_base_app(pkg, locale_dir, new ui_viewmgr(pkg)) { - if (inst) - { - LOGE("You created ui_app multiple times!!"); - } - inst = this; - this->impl = new ui_app_impl(this, pkg, locale_dir); -} - -int ui_app::run(int argc, char **argv) -{ - return this->impl->run(argc, argv); } ui_app::~ui_app() { - delete (this->impl); - inst = NULL; } ui_viewmgr *ui_app::get_viewmgr() { - return this->impl->get_viewmgr(); + return dynamic_cast(ui_base_app::get_viewmgr()); } ui_app *ui_app::get_instance() { - return inst; + return dynamic_cast(ui_base_app::get_instance()); } diff --git a/src/lib/efl/ui_base_app.cpp b/src/lib/efl/ui_base_app.cpp new file mode 100644 index 0000000..6e43db9 --- /dev/null +++ b/src/lib/efl/ui_base_app.cpp @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include +#include "../../include/efl/ui_base_viewmanager.h" + +/***********************************************************************************************/ +/* Internal class Implementation */ +/***********************************************************************************************/ +namespace efl_viewmanager +{ + +class ui_base_app_impl +{ +public: + friend class ui_base_app; + + ui_base_app *app; + ui_base_viewmgr *viewmgr; + Eina_Stringshare *pkg; + Eina_Stringshare *locale_dir; + + ui_base_app_impl(ui_base_app *app, const char *pkg, const char *locale_dir, ui_base_viewmgr* viewmgr); + ~ui_base_app_impl(); + + int run(int argc, char **argv); + + bool init(); + bool on_create(); + void on_terminate(); + void on_pause(); + 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); + void on_orient_changed(app_event_info_h event_info); + void on_lang_changed(app_event_info_h event_info); +}; + +} + +static bool app_create(void *data) +{ + ui_base_app_impl *app = static_cast(data); + return app->on_create(); +} + +static void app_terminate(void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_terminate(); +} + +static void app_pause(void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_pause(); +} + +static void app_resume(void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_resume(); +} + +static void app_control(app_control_s *app_control, void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_control(app_control); +} + +static void ui_app_lang_changed(app_event_info_h event_info, void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_lang_changed(event_info); +} + +static void ui_app_orient_changed(app_event_info_h event_info, void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_orient_changed(event_info); +} + +static void ui_app_region_changed(app_event_info_h event_info, void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_region_changed(event_info); +} + +static void ui_app_low_battery(app_event_info_h event_info, void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_low_battery(event_info); +} + +static void ui_app_low_memory(app_event_info_h event_info, void *data) +{ + ui_base_app_impl *app = static_cast(data); + app->on_low_memory(event_info); +} + +bool ui_base_app_impl::init() +{ + //FIXME: this scale value should be configurable. + elm_app_base_scale_set(2.6); + + /* Bind package locale file */ + bindtextdomain(this->pkg, this->locale_dir); + textdomain(this->pkg); + + return true; +} + +ui_base_app_impl::ui_base_app_impl(ui_base_app *app, const char *pkg, const char *locale_dir, ui_base_viewmgr *viewmgr) + : app(app), viewmgr(viewmgr) +{ + this->pkg = eina_stringshare_add(pkg); + this->locale_dir = eina_stringshare_add(locale_dir); +} + +int ui_base_app_impl::run(int argc, char **argv) +{ + ui_app_lifecycle_callback_s event_callback = + { 0, }; + app_event_handler_h handlers[5] = + { NULL, }; + + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.pause = app_pause; + event_callback.resume = app_resume; + event_callback.app_control = app_control; + + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, this); + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, this); + ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, this); + ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, this); + ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, this); + + int ret = ui_app_main(argc, argv, &event_callback, this); + + if (ret != APP_ERROR_NONE) + { + LOGE("ui_app_main() is failed. err = %d", ret); + } + + return ret; +} + +ui_base_app_impl::~ui_base_app_impl() +{ + delete (this->viewmgr); + eina_stringshare_del(this->pkg); + eina_stringshare_del(this->locale_dir); +} + +void ui_base_app_impl::on_lang_changed(app_event_info_h event_info) +{ + this->app->on_lang_changed(event_info); +} + +void ui_base_app_impl::on_low_memory(app_event_info_h event_info) +{ + this->app->on_low_memory(event_info); +} + +void ui_base_app_impl::on_low_battery(app_event_info_h event_info) +{ + this->app->on_low_battery(event_info); +} + +void ui_base_app_impl::on_region_changed(app_event_info_h event_info) +{ + this->app->on_region_changed(event_info); +} + +void ui_base_app_impl::on_orient_changed(app_event_info_h event_info) +{ + this->app->on_orient_changed(event_info); +} + +bool ui_base_app_impl::on_create() +{ + return this->app->on_create(); +} + +void ui_base_app_impl::on_pause() +{ + this->app->on_pause(); +} + +void ui_base_app_impl::on_resume() +{ + this->app->on_resume(); +} + +void ui_base_app_impl::on_control(app_control_h app_control) +{ + this->app->on_control(app_control); +} + +void ui_base_app_impl::on_terminate() +{ + this->app->on_terminate(); +} + +/***********************************************************************************************/ +/* External class Implementation */ +/***********************************************************************************************/ + +static ui_base_app *inst = NULL; + +void ui_base_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); +} + +void ui_base_app::on_low_memory(app_event_info_h event_info) +{ + +} + +void ui_base_app::on_low_battery(app_event_info_h event_info) +{ + +} + +void ui_base_app::on_region_changed(app_event_info_h event_info) +{ + +} + +void ui_base_app::on_orient_changed(app_event_info_h event_info) +{ + +} + +bool ui_base_app::on_create() +{ + return this->impl->init(); +} + +void ui_base_app::on_pause() +{ + this->impl->viewmgr->deactivate(); +} + +void ui_base_app::on_resume() +{ +// this->impl->viewmgr->activate(); +} + +void ui_base_app::on_control(app_control_h app_control) +{ + /* Handle the launch request. */ + this->impl->viewmgr->activate(); +} + +void ui_base_app::on_terminate() +{ + delete(this); +} + +ui_base_app::ui_base_app(const char *pkg, const char *locale_dir, ui_base_viewmgr *viewmgr) +{ + if (inst) + { + LOGE("You created ui_base_app multiple times!!"); + } + inst = this; + + this->impl = new ui_base_app_impl(this, pkg, locale_dir, viewmgr); +} + +int ui_base_app::run(int argc, char **argv) +{ + return this->impl->run(argc, argv); +} + +ui_base_app::~ui_base_app() +{ + delete (this->impl); + inst = NULL; +} + +ui_base_viewmgr *ui_base_app::get_viewmgr() +{ + return this->impl->viewmgr; +} + +ui_base_app *ui_base_app::get_instance() +{ + return inst; +}