From: Soorya R Date: Fri, 20 Jul 2018 14:04:34 +0000 (+0530) Subject: Initial implementation of watch app X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90cd327c18a51380adab2331d6d4adc11b0f4538;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Initial implementation of watch app Change-Id: Id5ee0d012756014f94c646504255b15476acb063 Signed-off-by: Soorya R --- diff --git a/atom/app/runtime.cc b/atom/app/runtime.cc index ad61e2d55..fcfda5ee4 100644 --- a/atom/app/runtime.cc +++ b/atom/app/runtime.cc @@ -16,7 +16,11 @@ #include "atom/app/runtime.h" #include "atom/app/ui_runtime.h" +#include "atom/app/watch_runtime.h" +#include "atom/browser/native_window_efl.h" #include "base/logging.h" +#include "efl/window_factory.h" +#include "tizen/common/application_data.h" namespace runtime { @@ -31,15 +35,13 @@ std::unique_ptr Runtime::MakeRuntime(content::ContentMainParams *params else if (app_data->app_type() == common::ApplicationData::IME) { return std::unique_ptr(new ImeRuntime(app_data)); } -#endif // IME_FEATURE_SUPPORT -#ifdef WATCH_FACE_FEATURE_SUPPORT - else if (app_data->app_type() == common::ApplicationData::WATCH) { - return std::unique_ptr(new WatchRuntime(app_data)); - } -#endif // WATCH_FACE_FEATURE_SUPPORT - else { */ +#endif // IME_FEATURE_SUPPORT */ + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + efl::WindowFactory::SetDelegate(&atom::NativeWindowEfl::GetHostWindowDelegate); + if (app_data->app_type() == common::ApplicationData::WATCH) + return std::unique_ptr(new WatchRuntime(params)); + else return std::unique_ptr(new UiRuntime(params)); - //} } } // namespace runtime diff --git a/atom/app/watch_runtime.cc b/atom/app/watch_runtime.cc new file mode 100644 index 000000000..1309b53dc --- /dev/null +++ b/atom/app/watch_runtime.cc @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2018 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 +#include + +#include "atom/app/atom_main_delegate.h" +#include "atom/app/watch_runtime.h" +#include "atom/browser/atom_browser_client.h" +#include "atom/browser/atom_browser_main_parts.h" +#include "atom/browser/browser.h" +#include "atom/common/atom_command_line.h" +#include "base/logging.h" +#include "content/public/app/content_main.h" +#include "gin/v8_initializer.h" +#include "tizen/common/app_control.h" +#include "tizen/common/app_db.h" +#include "tizen/common/application_data.h" +#include "tizen/common/command_line.h" +#include "tizen/common/constants.h" + +namespace runtime { + +WatchRuntime::WatchRuntime(content::ContentMainParams *params) + : _params(params) { + // This line's position is essential as this creates the Browser + // object which is needed later on by watch_runtime in its watch_loop callbacks + atom::AtomBrowserMainParts::SetNodeEnvironment(); +} + +WatchRuntime::~WatchRuntime() { +} + +void WatchRuntime::SetParam(content::ContentMainParams *params) { + if (_params) + LOG(ERROR) << "Use SetParam only when params is null"; + else + _params = params; +} + +bool WatchRuntime::OnCreate() { + auto appdata = common::ApplicationDataManager::GetCurrentAppData(); + if (appdata->splash_screen_info()) { + atom::Browser* browser_model = atom::Browser::Get(); + browser_model->SetSplashScreen(); + } + + return true; +} + +void WatchRuntime::OnTerminate() { + LOG(ERROR) << "OnTerminate()"; + atom::Browser *browser_model = atom::Browser::Get(); +} + +void WatchRuntime::OnPause() { + LOG(ERROR) << "OnPause()"; + atom::Browser *browser_model = atom::Browser::Get(); + browser_model->Hide(); +} + +void WatchRuntime::OnResume() { + LOG(ERROR) << "OnResume()"; + atom::Browser *browser_model = atom::Browser::Get(); + browser_model->Show(); +} + +void WatchRuntime::OnAppControl(app_control_h app_control) { + LOG(ERROR) << "OnAppControl()"; + std::unique_ptr + appcontrol(new common::AppControl(app_control)); + common::AppDB* appdb = common::AppDB::GetInstance(); + appdb->Set(kAppDBRuntimeSection, kAppDBRuntimeBundle, + appcontrol->encoded_bundle()); + atom::Browser *browser_model = atom::Browser::Get(); + if (browser_model->launched()) { + browser_model->AppControl(std::move(appcontrol)); + } else { + browser_model->Initialize(); + browser_model->Launch(std::move(appcontrol)); + } +} + +void WatchRuntime::OnLanguageChanged(const std::string& language) { + LOG(ERROR) << "OnLanguageChanged()"; +} + +void WatchRuntime::OnLowMemory() { + LOG(ERROR) << "OnLowMemory()"; +} + +int WatchRuntime::Exec() { + watch_app_lifecycle_callback_s ops = {NULL, NULL, NULL, NULL, NULL}; + + // onCreate + ops.create = [](int width, int height, void *data) -> bool { + LOG(ERROR) << "Create Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnCreate(); + content::ContentMain(*runtime->_params); + return true; + }; + + // onTerminate + ops.terminate = [](void* data) -> void { + LOG(ERROR) << "Terminate Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnTerminate(); + }; + + // onPause + ops.pause = [](void* data) -> void { + LOG(ERROR) << "Pause Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnPause(); + }; + + // onResume + ops.resume = [](void* data) -> void { + LOG(ERROR) << "Resume Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnResume(); + }; + + // onAppControl + ops.app_control = [](app_control_h app_control, void* data) -> void { + LOG(ERROR) << "app_control Tizen App."; + WatchRuntime *runtime = (WatchRuntime*)data; + runtime->OnAppControl(app_control); + }; + + return watch_app_main(_params->argc, const_cast(_params->argv), &ops, this); +} +} //namespace diff --git a/atom/app/watch_runtime.h b/atom/app/watch_runtime.h new file mode 100644 index 000000000..43636bcea --- /dev/null +++ b/atom/app/watch_runtime.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018 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 WATCH_RUNTIME_H_ +#define WATCH_RUNTIME_H_ + +#include +#include +#include +#include "atom/app/runtime.h" +#include "content/public/app/content_main.h" + +namespace runtime { + +class WatchRuntime : public Runtime { + public: + WatchRuntime(content::ContentMainParams *params); + virtual ~WatchRuntime(); + + virtual int Exec(); + virtual void SetParam(content::ContentMainParams *params); + + protected: + virtual bool OnCreate(); + virtual void OnTerminate(); + virtual void OnPause(); + virtual void OnResume(); + virtual void OnAppControl(app_control_h app_control); + virtual void OnLanguageChanged(const std::string& language); + virtual void OnLowMemory(); + + private: + content::ContentMainParams *_params; +}; + +} // namespace runtime + +#endif // XWALK_RUNTIME_BROWSER_WATCH_RUNTIME_H_ diff --git a/atom/browser/native_window_efl.cc b/atom/browser/native_window_efl.cc index bcbe50975..b71e5638a 100644 --- a/atom/browser/native_window_efl.cc +++ b/atom/browser/native_window_efl.cc @@ -5,11 +5,14 @@ #include "atom/browser/native_window_efl.h" #include +#include +#include #include "atom/common/options_switches.h" #include "base/command_line.h" #include "content/public/browser/web_contents.h" #include "efl/window_factory.h" +#include "tizen/common/application_data.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/image/image.h" @@ -31,6 +34,7 @@ namespace atom { namespace { +std::map window_map_; const int kDefaultWindowWidthDip = 800; const int kDefaultWindowHeightDip = 600; @@ -58,6 +62,28 @@ const char* kMenuKeyEventScript = #endif } +Evas_Object* NativeWindowEfl::GetHostWindowDelegate(const content::WebContents* web_contents) { + LOG(ERROR) << "NativeWindowEfl::GetHostWindowDelegate"; + if (window_map_.find(web_contents) != window_map_.end()) + return window_map_[web_contents]; + + Evas_Object* win = NULL; + auto app_data = common::ApplicationDataManager::GetCurrentAppData(); + if (app_data->app_type() == common::ApplicationData::WATCH) { + elm_config_accel_preference_set("opengl"); + watch_app_get_elm_win(&win); + elm_win_alpha_set(win, EINA_TRUE); + evas_object_render_op_set(win, EVAS_RENDER_COPY); + } + else { + win = elm_win_util_standard_add("", ""); + elm_win_autodel_set(win, EINA_TRUE); + } + + window_map_[web_contents] = win; + return win; +} + NativeWindowEfl::NativeWindowEfl( brightray::InspectableWebContents* inspectable_web_contents, const mate::Dictionary& options, diff --git a/atom/browser/native_window_efl.h b/atom/browser/native_window_efl.h index b7f40249b..5d93937bb 100644 --- a/atom/browser/native_window_efl.h +++ b/atom/browser/native_window_efl.h @@ -6,6 +6,7 @@ #define ATOM_BROWSER_NATIVE_WINDOW_EFL_H_ #include "atom/browser/native_window.h" +#include "content/public/browser/web_contents_delegate.h" #include @@ -26,6 +27,8 @@ class NativeWindowEfl : public NativeWindow { const mate::Dictionary& options, NativeWindow* parent); + static Evas_Object* GetHostWindowDelegate(const content::WebContents*); + void Close() override; void CloseImmediately() override; void Focus(bool focus) override; diff --git a/efl/build/system.gyp b/efl/build/system.gyp index c15c218cb..2d41270ba 100644 --- a/efl/build/system.gyp +++ b/efl/build/system.gyp @@ -239,5 +239,47 @@ }], ], }, # capi-media-player + { + 'target_name': 'capi-appfw-watch-application', + 'type': 'none', + 'conditions': [ + ['is_tizen==1', { + 'direct_dependent_settings': { + 'cflags': [ + '