This class is designed for application framework abstractor.
Change-Id: I5edfdd56f957d105b5234b04993c57656aec3ff2
#include "page2.h"
#include "page1.h"
+class sample_app : public ui_app
+{
+public:
+ sample_app(const char*pkg, const char *locale_dir);
+ ~sample_app();
+
+ bool on_create();
+};
+
+sample_app::sample_app(const char *pkg, const char *locale_dir)
+ : ui_app(pkg, locale_dir)
+{
+}
+
+sample_app::~sample_app()
+{
+}
+
+bool sample_app::on_create()
+{
+ if (!ui_app::on_create())
+ {
+ return false;
+ }
+
+ create_page1();
+
+ return true;
+}
+
+
Elm_Toolbar*
create_toolbar(Evas_Object *parent, const char *style)
{
return scroller;
}
-static void create_base_gui(void)
-{
- create_page1();
- UI_VIEWMGR->activate();
-}
-
-static bool app_create(void *data)
-{
- /* Hook to take necessary actions before main event loop starts
- Initialize UI resources and application's data
- If this function returns true, the main loop of application starts
- If this function returns false, the application is terminated */
-
- elm_app_base_scale_set(2.6);
-
- /* Bind package locale file */
- bindtextdomain(PACKAGE, LOCALE_DIR);
- textdomain(PACKAGE);
-
- //FIXME: Hide this creation.
- ui_viewmgr *viewmgr = new ui_viewmgr(PACKAGE);
-
- create_base_gui();
-
- return true;
-}
-
-static void app_control(app_control_h app_control, void *data)
-{
- /* Handle the launch request. */
-}
-
-static void app_pause(void *data)
-{
-}
-
-static void app_resume(void *data)
-{
- UI_VIEWMGR->activate();
-}
-
-static void app_terminate(void *data)
-{
-}
-
-static void ui_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LANGUAGE_CHANGED*/
- char *locale = NULL;
- system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
- elm_language_set(locale);
- free(locale);
- return;
-}
-
-static void ui_app_orient_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
- return;
-}
-
-static void ui_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void ui_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void ui_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_MEMORY*/
-}
-
int main(int argc, char *argv[])
{
- appdata_s ad;
- int ret = 0;
-
- 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, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED,
- ui_app_orient_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed,
- &ad);
- ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
-
- ret = ui_app_main(argc, argv, &event_callback, &ad);
- if (ret != APP_ERROR_NONE)
- {
- dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);
- }
-
- return ret;
+ sample_app app(PACKAGE, LOCALE_DIR);
+ return app.start(argc, argv);
}
* limitations under the License.
*
*/
-#include <app.h>
-#include <system_settings.h>
#include <dlog.h>
#include "ui_viewmanager.h"
using namespace efl_viewmgr;
-typedef struct appdata {
-} appdata_s;
-
Evas_Object *create_landscape_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb);
Evas_Object *create_content(Evas_Object *parent, const char *text, Evas_Smart_Cb prev_btn_clicked_cb, Evas_Smart_Cb next_btn_clicked_cb);
Evas_Object *create_scrolling_content(Evas_Object *parent);
--- /dev/null
+/*
+ * 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_APP_H
+#define UI_APP_H
+
+#include "../ui_base_viewmanager.h"
+
+namespace efl_viewmgr
+{
+
+class ui_viewmgr;
+
+class ui_app
+{
+private:
+ ui_viewmgr *viewmgr;
+ Eina_Stringshare *pkg;
+ Eina_Stringshare *locale_dir;
+
+public:
+ ui_app(const char *pkg, const char *locale_dir);
+ virtual ~ui_app();
+
+ virtual int start(int argc, char **argv);
+ virtual bool on_create();
+ virtual void on_terminate();
+ virtual void on_pause();
+ virtual void on_resume();
+ virtual void on_control(app_control_h app_control);
+
+ virtual void on_low_battery(app_event_info_h event_info);
+ virtual void on_low_memory(app_event_info_h event_info);
+ virtual void on_region_changed(app_event_info_h event_info);
+ virtual void on_orient_changed(app_event_info_h event_info);
+ virtual void on_lang_changed(app_event_info_h event_info);
+};
+
+}
+
+#endif /* UI_APP_H */
*
*/
#include <dlog.h>
+#include <system_settings.h>
#ifdef LOG_TAG
#undef LOG_TAG
#include "ui_viewmgr.h"
#include "ui_menu.h"
#include "ui_popup.h"
+#include "ui_app.h"
#define UI_VIEWMGR dynamic_cast<ui_viewmgr *>(efl_viewmgr::ui_base_viewmgr::get_instance())
{
class ui_view;
-class ui_viewmgr;
class ui_viewmgr: public ui_base_viewmgr
{
efl/ui_base_viewmgr.cpp
efl/ui_base_key_listener.cpp
efl/ui_base_overlay.cpp
+ efl/mobile/ui_app.cpp
efl/mobile/ui_menu.cpp
efl/mobile/ui_popup.cpp
efl/mobile/ui_view.cpp
--- /dev/null
+/*
+ * 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/efl/mobile/ui_viewmanager.h"
+
+using namespace efl_viewmgr;
+using namespace viewmgr;
+
+static bool app_create(void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ return app->on_create();
+}
+
+static void app_terminate(void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_terminate();
+}
+
+static void app_pause(void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_pause();
+}
+
+static void app_resume(void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_resume();
+}
+
+static void app_control(app_control_s *app_control, void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_control(app_control);
+}
+
+static void ui_app_lang_changed(app_event_info_h event_info, void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_lang_changed(event_info);
+}
+
+static void ui_app_orient_changed(app_event_info_h event_info, void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_orient_changed(event_info);
+}
+
+static void ui_app_region_changed(app_event_info_h event_info, void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_region_changed(event_info);
+}
+
+static void ui_app_low_battery(app_event_info_h event_info, void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_low_battery(event_info);
+}
+
+static void ui_app_low_memory(app_event_info_h event_info, void *data)
+{
+ ui_app *app = static_cast<ui_app *>(data);
+ app->on_low_memory(event_info);
+}
+
+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()
+{
+ LOGE("create!!");
+
+ //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;
+}
+
+void ui_app::on_pause()
+{
+ this->viewmgr->deactivate();
+}
+
+void ui_app::on_resume()
+{
+}
+
+void ui_app::on_control(app_control_h app_control)
+{
+ /* Handle the launch request. */
+ this->viewmgr->activate();
+}
+
+void ui_app::on_terminate()
+{
+}
+
+ui_app::ui_app(const char *pkg, const char *locale_dir)
+ : viewmgr(NULL)
+{
+ pkg = eina_stringshare_add(pkg);
+ locale_dir = eina_stringshare_add(locale_dir);
+}
+
+int ui_app::start(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::~ui_app()
+{
+ eina_stringshare_del(this->pkg);
+ delete (this->viewmgr);
+}