[M108 Migration][WRTjs][VD] Merge splash screen feature 19/290519/3
authorzhaosy <shiyusy.zhao@samsung.com>
Tue, 28 Mar 2023 05:19:19 +0000 (13:19 +0800)
committerBot Blink <blinkbot@samsung.com>
Wed, 29 Mar 2023 01:21:30 +0000 (01:21 +0000)
1.Support landscape/portrait splash screen
landscape/portrait splash screen should be supported.
https://docs.tizen.org/application/tizen-studio/web-tools/config-editor/#tizen-launch-screen-2
<tizen:launch_screen ready_when="custom">
  <tizen:ls_default background_color="#00ff00" image="images/default.png" image_border="0px stretch"/>
  <tizen:ls_landscape background_color="#ff0000" image="images/landscape.png" image_border="0px stretch"/>
  <tizen:ls_portrait background_color="#0000ff" image="images/portrait.png" image_border="0px stretch"/>
</tizen:launch_screen>

2.splash screen image support SHARE path
LYNKCloud app need to download splash screen image from server.
They save image to SHARE path(/opt/usr/home/owner/share),
WRT set this image as splash screen image.

Reference:
https://review.tizen.org/gerrit/289862/
https://review.tizen.org/gerrit/289246/

Change-Id: I4cf8d770e2698af9c40a6e8242da109d048098e1
Signed-off-by: zhaosy <shiyusy.zhao@samsung.com>
wrt/src/browser/splash_screen.cc

index f2bfe70..8b225c9 100755 (executable)
@@ -19,6 +19,9 @@
 #include "wrt/src/browser/wrt_native_window.h"
 
 #if BUILDFLAG(IS_TIZEN_TV)
+#include <display-rotator-api.h>
+#include <vconf.h>
+
 #include "wrt/src/browser/tv/video_splash_screen.h"
 #endif
 
@@ -28,6 +31,11 @@ namespace {
 
 std::unique_ptr<SplashScreen> splash_screen_;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+const char* kSharePath = "/opt/usr/home/owner/share";
+const char* kVconfRotationState = "db/sysman/rotation_state";
+#endif
+
 enum class BorderOption { REPEAT = 1, STRETCH, ROUND };
 
 bool ParseImageBorder(const std::vector<std::string>& borders,
@@ -75,7 +83,22 @@ bool SplashScreen::ShowSplashScreen() {
     splash_screen_.reset(new SplashScreen);
 
     auto orientation = wgt::parse::ScreenOrientation::AUTO;
+#if BUILDFLAG(IS_TIZEN_TV)
+    int rotation_state = DISPLAY_ROTATOR_ORIENTATION_LANDSCAPE;
+    vconf_get_int(kVconfRotationState, &rotation_state);
+    if (rotation_state == DISPLAY_ROTATOR_ORIENTATION_PORTRAIT ||
+        rotation_state == DISPLAY_ROTATOR_ORIENTATION_PORTRAIT_R)
+      orientation = wgt::parse::ScreenOrientation::PORTRAIT;
+    else
+      orientation = wgt::parse::ScreenOrientation::LANDSCAPE;
+#endif
+
     auto* screen_data = screen_info.GetLaunchScreenData(orientation);
+    // get default images if fail to get LANDSCAPE/PORTRAIT images
+    if (!screen_data || screen_data->images.empty())
+      screen_data =
+          screen_info.GetLaunchScreenData(wgt::parse::ScreenOrientation::AUTO);
+
     auto* window = WRTNativeWindow::GetTopWindow();
     auto dimensions = splash_screen_->GetDimensions(window);
 
@@ -226,8 +249,18 @@ void SplashScreen::SetImage(
   int location_y = (window_h - image_h) / 2;
   evas_object_geometry_set(image_, location_x, location_y, image_w, image_h);
 #else
-  const std::string& image_path = splash_data->images.front().first;
-  elm_image_file_set(image_, (app_path + image_path).c_str(), nullptr);
+  std::string image_path = splash_data->images.front().first;
+#if BUILDFLAG(IS_TIZEN_TV)
+  if (image_path.find("$SHARE") != std::string::npos)
+    image_path.replace(0, strlen("$SHARE"), kSharePath);
+  else
+    image_path = app_path + image_path;
+#else
+  image_path = app_path + image_path;
+#endif // IS_TIZEN_TV
+
+  LOG(INFO) << "image_path: " << image_path;
+  elm_image_file_set(image_, image_path.c_str(), nullptr);
   evas_object_resize(image_, bound.first, bound.second);
 #endif
   evas_object_show(image_);