Implemented progressbar for web application 98/134798/2 accepted/tizen/unified/20170630.083209 submit/tizen/20170620.052945
authorjaekuk, lee <juku1999@samsung.com>
Tue, 20 Jun 2017 05:21:01 +0000 (14:21 +0900)
committerjaekuk lee <juku1999@samsung.com>
Tue, 20 Jun 2017 05:21:48 +0000 (05:21 +0000)
issue : http://suprem.sec.samsung.net/jira/browse/MPR-1117
        Hosted web app such as YouTube displays a white screen until the page finishes loading.

Modified WRT to display progressbar until the page finishes loading if progressbar-presence is enabled in config.xml.

Change-Id: I114d69543caea76161d0ace22cf57ae052c8f099
Signed-off-by: jaekuk, lee <juku1999@samsung.com>
runtime/browser/native_window.cc
runtime/browser/native_window.h
runtime/browser/web_application.cc
runtime/browser/web_application.h

index 6e723e5..43f6bef 100755 (executable)
@@ -23,6 +23,7 @@
 
 #include "common/arraysize.h"
 #include "common/logger.h"
+#include "common/platform_info.h"
 
 namespace runtime {
 
@@ -75,6 +76,8 @@ NativeWindow::NativeWindow()
       currentViewModeFullScreen_(false),
       focus_(NULL),
       content_(NULL),
+      progressbar_(NULL),
+      top_layout_(NULL),
       rotation_(0),
       handler_id_(0) {
 }
@@ -126,6 +129,7 @@ void NativeWindow::Initialize() {
   EVAS_SIZE_EXPAND_FILL(top_layout);
   elm_object_content_set(conformant, top_layout);
   evas_object_show(top_layout);
+  top_layout_ = top_layout;
 
   // focus
   Evas_Object* focus = elm_bg_add(top_layout);
@@ -139,6 +143,17 @@ void NativeWindow::Initialize() {
   evas_object_show(focus);
   focus_ = focus;
 
+  if (common::getProfile() == common::kPROFILE_MOBILE) {
+    // progressbar
+    Evas_Object *progressbar = elm_progressbar_add(top_layout);
+    EVAS_SIZE_EXPAND_FILL(progressbar);
+    elm_progressbar_unit_format_set(progressbar, "%1.1f%%");
+    elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
+    elm_object_part_content_set(top_layout, "elm.swallow.progress", progressbar);
+    evas_object_show(progressbar);
+    progressbar_ = progressbar;
+  }
+
   // focus callback
   auto focus_callback = [](void* user_data,
                            Evas_Object*,
@@ -304,4 +319,13 @@ void NativeWindow::ManualRotationDone() {
   }
 }
 
+void NativeWindow::SignalEmit(const char* emission,
+    const char* source) {
+  elm_object_signal_emit(top_layout_, emission, source);
+}
+
+void NativeWindow::UpdateProgress(double value) {
+  elm_progressbar_value_set(progressbar_, ELM_SCALE_SIZE(value));
+}
+
 }  // namespace runtime
index 0a5f23c..a305389 100755 (executable)
@@ -63,6 +63,8 @@ class NativeWindow {
   Type type() const { return window_type_;}
   void EnableManualRotation(bool enable);
   void ManualRotationDone();
+  void SignalEmit(const char* emission, const char* source);
+  void UpdateProgress(double value);
 
  protected:
   virtual Evas_Object* CreateWindowInternal() = 0;
@@ -80,6 +82,8 @@ class NativeWindow {
   bool currentViewModeFullScreen_;
   Evas_Object* focus_;
   Evas_Object* content_;
+  Evas_Object* progressbar_;
+  Evas_Object* top_layout_;
   int rotation_;
   int handler_id_;
   ScreenOrientation natural_orientation_;
index 4e3d730..b8a95bc 100755 (executable)
@@ -144,6 +144,10 @@ const char* kDefaultCSPRule =
 const char* kResWgtPath = "res/wgt/";
 const char* kAppControlMain = "http://tizen.org/appcontrol/operation/main";
 
+// window signal callback
+const char *kEdjeShowProgressSignal = "show,progress,signal";
+const char *kEdjeHideProgressSignal = "hide,progress,signal";
+
 const std::string kViewmodeTypeFullscreen = "fullscreen";
 const std::string kViewmodeTypeWindowed = "windowed";
 
@@ -1144,8 +1148,33 @@ void WebApplication::OnLoadStart(WebView* /*view*/) {
   LOGGER(DEBUG) << "LoadStart";
 }
 
+void WebApplication::OnLoadProgress(WebView* view, double persent) {
+  LOGGER(DEBUG) << "LoadProgress, progress ;"<<persent;
+  if (common::getProfile() == common::kPROFILE_MOBILE) {
+    if ((app_data_->setting_info() != NULL &&
+         app_data_->setting_info()->progressbar_presence()) ||
+         (app_data_->widget_info() != NULL &&
+         app_data_->widget_info()->view_modes() == kViewmodeTypeWindowed)) {
+      if (persent == 1.0) {
+        window_->SignalEmit(kEdjeHideProgressSignal, "");
+      } else {
+        window_->SignalEmit(kEdjeShowProgressSignal, "");
+        window_->UpdateProgress(persent);
+      }
+    }
+  }
+}
+
 void WebApplication::OnLoadFinished(WebView* /*view*/) {
   LOGGER(DEBUG) << "LoadFinished";
+  if (common::getProfile() == common::kPROFILE_MOBILE) {
+    if ((app_data_->setting_info() != NULL &&
+         app_data_->setting_info()->progressbar_presence()) ||
+         (app_data_->widget_info() != NULL &&
+         app_data_->widget_info()->view_modes() == kViewmodeTypeWindowed)) {
+      window_->SignalEmit(kEdjeHideProgressSignal, "");
+    }
+  }
   splash_screen_->HideSplashScreen(SplashScreen::HideReason::LOADFINISHED);
 }
 
index 0614f1f..99e56d0 100755 (executable)
@@ -71,6 +71,7 @@ class WebApplication : public WebView::EventListener {
   virtual void OnHardwareKey(WebView* view, const std::string& keyname);
   virtual void OnConsoleMessage(const std::string& msg, int level);
   virtual void OnLoadStart(WebView* view);
+  virtual void OnLoadProgress(WebView* view, double persent);
   virtual void OnLoadFinished(WebView* view);
   virtual void OnRendered(WebView* view);
   virtual void OnLanguageChanged();