From: Guneet K Date: Thu, 1 Feb 2018 13:38:51 +0000 (+0530) Subject: [compatibility] Implemented window resize for non circular apps X-Git-Tag: submit/tizen/20180928.065515^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc27f53837151ae4081f3568c2e7c0e0e8af5d4d;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git [compatibility] Implemented window resize for non circular apps Apps with 320x320 and square apps are not displayed properly. View is truncated. Resize the view to 320x320 so that maximum possible view is displayed in visible area. These kind of apps are identified by profile tag. --------------------------------------------- | SlNo| Profile | Value | Display | --------------------------------------------- | 1 | Not Present | NA | 320x320 | | 2 | Present | mobile | 320x320 | | 3 | Present | NULL | 320x320 | | 4 | Present | wearable | 360x360 | --------------------------------------------- [Reference] http://slp-info.sec.samsung.net/gerrit/#/c/3119525/ Change-Id: Id39ce8f39c939de083e1ae2a7bc9efcaae8ca39a Signed-off-by: Guneet K Signed-off-by: deepti --- diff --git a/common/application_data.cc b/common/application_data.cc index a205ecc44..cbcd2ad15 100755 --- a/common/application_data.cc +++ b/common/application_data.cc @@ -122,6 +122,11 @@ std::shared_ptr return csp_report_info_; } +std::shared_ptr + ApplicationData::profile_tag_info() const { + return profile_tag_info_; +} + const std::string ApplicationData::pkg_id() const { if (pkg_id_.empty()) { app_info_h app_info; @@ -244,6 +249,11 @@ bool ApplicationData::LoadManifestData() { widget_config_parser->GetManifestData( wgt::parse::CSPInfo::Report_only_key())); + profile_tag_info_ = + std::static_pointer_cast( + widget_config_parser->GetManifestData( + wgt::parse::ProfileTagInfo::Key())); + // Set default empty object if (widget_info_.get() == NULL) { widget_info_.reset(new wgt::parse::WidgetInfo); diff --git a/common/application_data.h b/common/application_data.h index aa910e21f..441912329 100755 --- a/common/application_data.h +++ b/common/application_data.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -78,6 +79,8 @@ class ApplicationData { csp_info() const; std::shared_ptr csp_report_info() const; + std::shared_ptr + profile_tag_info() const; const std::string application_path() const { return application_path_; } const std::string pkg_id() const; @@ -111,6 +114,10 @@ class ApplicationData { csp_info_; std::shared_ptr csp_report_info_; + + std::shared_ptr + profile_tag_info_; + ApplicationData::AppType GetAppType(); std::string application_path_; diff --git a/common/platform_info.h b/common/platform_info.h index 009c6f7fc..20732f77f 100644 --- a/common/platform_info.h +++ b/common/platform_info.h @@ -38,6 +38,8 @@ enum _profile { (common::getProfile() & ((common::kPROFILE_WEARABLE))) #define TIZEN_FEATURE_rotary_event_support \ (common::getProfile() & ((common::kPROFILE_WEARABLE))) +#define TIZEN_FEATURE_display_resize_support \ + (common::getProfile() & ((common::kPROFILE_WEARABLE))) extern enum _profile getProfile(void); diff --git a/runtime/browser/native_window.cc b/runtime/browser/native_window.cc index 5bbbc4ddb..7ca946e7c 100755 --- a/runtime/browser/native_window.cc +++ b/runtime/browser/native_window.cc @@ -80,9 +80,11 @@ NativeWindow::NativeWindow() top_layout_(NULL), rotation_(0), handler_id_(0), - natural_orientation_(ScreenOrientation::LANDSCAPE_PRIMARY) { + natural_orientation_(ScreenOrientation::PORTRAIT_PRIMARY), + display_shape_type_(Shape::STANDARD){ } + NativeWindow::~NativeWindow() { if (window_) evas_object_del(window_); @@ -126,7 +128,14 @@ void NativeWindow::Initialize() { // top layout Evas_Object* top_layout = elm_layout_add(conformant); - elm_layout_file_set(top_layout, kEdjePath, "web-application"); + if (display_shape_type_ == Shape::SQUARE) { + LOGGER(DEBUG) << "Device shape square"; + elm_layout_file_set(top_layout, kEdjePath, "web-applicationsview"); + } else { + LOGGER(DEBUG) << "Device shape standard"; + elm_layout_file_set(top_layout, kEdjePath, "web-application"); + } + EVAS_SIZE_EXPAND_FILL(top_layout); elm_object_content_set(conformant, top_layout); evas_object_show(top_layout); diff --git a/runtime/browser/native_window.h b/runtime/browser/native_window.h index 3cd094d2b..981f2d5de 100755 --- a/runtime/browser/native_window.h +++ b/runtime/browser/native_window.h @@ -38,6 +38,10 @@ class NativeWindow { NORMAL = 0, NOTIFICATION = 1 }; + enum class Shape { + STANDARD = 0, + SQUARE = 1 + }; typedef std::function RotationHandler; NativeWindow(); virtual ~NativeWindow(); @@ -65,6 +69,8 @@ class NativeWindow { Type type() const { return window_type_;} void EnableManualRotation(bool enable); void ManualRotationDone(); + void SetDisplayShape(Shape disp_shape) { display_shape_type_ = disp_shape; } + Shape GetDisplayShape() { return display_shape_type_; } void SignalEmit(const char* emission, const char* source); void UpdateProgress(double value); @@ -89,6 +95,7 @@ class NativeWindow { int rotation_; int handler_id_; ScreenOrientation natural_orientation_; + Shape display_shape_type_; std::map handler_table_; }; diff --git a/runtime/browser/preload_manager.cc b/runtime/browser/preload_manager.cc index fe1cce7ca..a8c482a2f 100755 --- a/runtime/browser/preload_manager.cc +++ b/runtime/browser/preload_manager.cc @@ -21,6 +21,7 @@ #include #include +#include "common/platform_info.h" #include "common/logger.h" #include "runtime/browser/native_app_window.h" #include "extensions/common/xwalk_extension_server.h" @@ -49,7 +50,8 @@ void PreloadManager::CreateCacheComponet() { ewk_context_new_with_injected_bundle_path(INJECTED_BUNDLE_PATH); context = context; // To prevent build warning cached_window_.reset(new NativeAppWindow()); - //cached_window_->Initialize(); + if (!TIZEN_FEATURE_display_resize_support) + cached_window_->Initialize(); } NativeWindow* PreloadManager::GetCachedNativeWindow() { diff --git a/runtime/browser/ui_runtime.cc b/runtime/browser/ui_runtime.cc index bb0e11ae6..45a465a14 100755 --- a/runtime/browser/ui_runtime.cc +++ b/runtime/browser/ui_runtime.cc @@ -27,6 +27,7 @@ #include "common/app_db.h" #include "common/command_line.h" #include "common/logger.h" +#include "common/platform_info.h" #include "common/profiler.h" #include "runtime/common/constants.h" #include "runtime/browser/native_app_window.h" @@ -40,9 +41,9 @@ namespace { const char kCategoryAlwaysOnTop[] = "http://tizen.org/category/always_on_top"; -static NativeWindow* CreateNativeWindow(NativeWindow::Type windowType) { +static NativeWindow* CreateNativeWindow(NativeWindow::Type windowType, + NativeWindow::Shape win_shape) { SCOPE_PROFILE(); - NativeWindow* window; switch (windowType) { @@ -58,6 +59,7 @@ static NativeWindow* CreateNativeWindow(NativeWindow::Type windowType) { } break; } + window->SetDisplayShape(win_shape); window->Initialize(); return window; @@ -76,6 +78,19 @@ bool AlwaysTopRequested(common::AppControl* appcontrol) { return appcontrol->data("always_on_top") == "true"; } +const char kConfigProfile[] = "mobile"; +NativeWindow::Shape GetWindowType(common::ApplicationData* app_data) { + // As profile tag is not present app will be treated as square app + if (!app_data->profile_tag_info()) { + return NativeWindow::Shape::SQUARE; + } + std::string type = app_data->profile_tag_info()->GetProfileType(); + if (!type.compare(kConfigProfile)) { + return NativeWindow::Shape::SQUARE; + } + return NativeWindow::Shape::STANDARD; +} + } // namespace UiRuntime::UiRuntime(common::ApplicationData* app_data) @@ -100,8 +115,9 @@ void UiRuntime::ResetWebApplication(NativeWindow::Type windowType) { application_.reset(); native_window_.reset(); - - native_window_.reset(CreateNativeWindow(windowType)); + if (TIZEN_FEATURE_display_resize_support) + native_window_.reset(CreateNativeWindow(windowType, GetWindowType(app_data_))); + else native_window_.reset(CreateNativeWindow(windowType, NativeWindow::Shape::STANDARD)); LOGGER(DEBUG) << "runtime.cc Created native window"; application_.reset(new WebApplication(native_window_.get(), app_data_, diff --git a/runtime/browser/watch_runtime.cc b/runtime/browser/watch_runtime.cc index 39302ca41..749e4f90f 100755 --- a/runtime/browser/watch_runtime.cc +++ b/runtime/browser/watch_runtime.cc @@ -35,7 +35,7 @@ namespace runtime { namespace { -static NativeWindow* CreateNativeWindow() { +static NativeWindow* CreateNativeWindow(NativeWindow::Shape win_shape) { SCOPE_PROFILE(); NativeWindow* window = NULL; auto cached = PreloadManager::GetInstance()->GetCachedNativeWindow(); @@ -43,11 +43,25 @@ static NativeWindow* CreateNativeWindow() { delete cached; } window = new NativeWatchWindow(); + window->SetDisplayShape(win_shape); window->Initialize(); return window; } +const char kConfigProfile[] = "mobile"; +NativeWindow::Shape GetWindowType(common::ApplicationData* app_data) { + // As profile tag is not present app will be treated as square app + if (!app_data->profile_tag_info()) { + return NativeWindow::Shape::SQUARE; + } + std::string type = app_data->profile_tag_info()->GetProfileType(); + if (!type.compare(kConfigProfile)) { + return NativeWindow::Shape::SQUARE; + } + return NativeWindow::Shape::STANDARD; +} + } // namespace WatchRuntime::WatchRuntime(common::ApplicationData* app_data) @@ -85,7 +99,7 @@ bool WatchRuntime::OnCreate() { appdb->Remove(kAppDBRuntimeSection, kAppDBRuntimeBundle); // Init WebApplication - native_window_ = CreateNativeWindow(); + native_window_ = CreateNativeWindow(GetWindowType(app_data_)); STEP_PROFILE_START("WebApplication Create"); application_ = new WebApplication(native_window_, app_data_); STEP_PROFILE_END("WebApplication Create"); diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index c74d4be47..c5f0c0adb 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -515,6 +515,8 @@ void WebApplication::Launch(std::unique_ptr appcontrol) { WebView* view = new WebView(window_, ewk_context_); SetupWebView(view); SetupWebViewCompatibilitySettings(view); + if (TIZEN_FEATURE_display_resize_support) + SetDisplayEffect(view); std::unique_ptr res = resource_manager_->GetStartResource(appcontrol.get()); @@ -1273,6 +1275,16 @@ void WebApplication::SetupWebViewCompatibilitySettings(WebView* view) { } } +void WebApplication::SetDisplayEffect(WebView* view) { + if (window_->GetDisplayShape() == NativeWindow::Shape::SQUARE) { + // Currently blur effect API is called on view, which is not + // correct. Needs to be moved to context. Once new API is + // provided on context below code will get changed. + LOGGER(DEBUG) << "WebApplication::Set Blur effect"; + ewk_view_mirrored_blur_set(view->evas_object(), true); + } +} + bool WebApplication::OnDidNavigation(WebView* /*view*/, const std::string& url) { // scheme handling diff --git a/runtime/browser/web_application.h b/runtime/browser/web_application.h index a724a0902..5b247b22b 100755 --- a/runtime/browser/web_application.h +++ b/runtime/browser/web_application.h @@ -125,6 +125,7 @@ class WebApplication : public WebView::EventListener { void LaunchInspector(common::AppControl* appcontrol); void SetupWebView(WebView* view); void SetupWebViewCompatibilitySettings(WebView* view); + void SetDisplayEffect(WebView* view); void RemoveWebViewFromStack(WebView* view); void SetupTizenVersion(); diff --git a/runtime/resources/xwalk_tizen.edc b/runtime/resources/xwalk_tizen.edc index a48c190a0..c612e642a 100755 --- a/runtime/resources/xwalk_tizen.edc +++ b/runtime/resources/xwalk_tizen.edc @@ -25,11 +25,6 @@ collections { type: SWALLOW; description { state: "default" 0.0; - fixed: 1 1; - rel1 { relative: 0.0 0.0; to: base; } - rel2 { relative: 1.0 1.0; to: base; } - align: 0.0 0.0; - } /* ratio 1x1 (only for gear3) */ description { @@ -94,6 +89,41 @@ collections { }//end of programs }//end of group + group { + name: "web-applicationsview"; + inherit: "web-application"; + parts{ + part { + name: "elm.swallow.content"; + scale: 0; + type: SWALLOW; + description { + state: "default" 0.0; + //rel1 { offset: 20 20; } + //rel2 { offset: -20 -20; } + min: 320 320; + max: 320 320; + fixed: 1 1; + } + // Below code will also do the same + /*description { + state: "default" 0.0; + rel1 { offset: 20 20; } + rel2 { offset: -20 -20; } + }*/ + + /* ratio 1x1 (only for gear3) */ + description { + state: "ratio1x1" 0.0; + fixed: 1 1; + aspect: 1 1; + aspect_preference: BOTH; + align: 0.5 0.5; + } + } + } + } + group { name: "PopupTextEntrySet"; parts{ diff --git a/runtime/runtime.gyp b/runtime/runtime.gyp index 5772a354b..e56deee0f 100755 --- a/runtime/runtime.gyp +++ b/runtime/runtime.gyp @@ -70,7 +70,8 @@ 'defines': ['TIZEN_PRODUCT_TV'], }], ['tizen_model_formfactor == "circle"', { - 'defines': ['MODEL_FORMFACTOR_CIRCLE'], + 'defines': ['MODEL_FORMFACTOR_CIRCLE', + 'DISPLAY_RESIZE_SUPPORT'], }], ['tizen_feature_rotary_event_support == 1', { 'defines': ['ROTARY_EVENT_FEATURE_SUPPORT'],