예제 #1
0
    public void showShopikaAndRegisterForEvents()
    {
                #if UNITY_EDITOR
        //en editor no hay webview
        return;
                #endif

        videoModal.SetActive(true);
        if (ShopikaManager.GetCastedInstance <ShopikaManager> ().currentUserId == ShopikaManager.GetCastedInstance <ShopikaManager> ().ANONYMOUS_USER)
        {
            if (((DataManagerKubera)DataManagerKubera.GetInstance()).currentUser.firstTimeShopping)
            {
                ((DataManagerKubera)DataManagerKubera.GetInstance()).currentUser.firstTimeShopping = false;
            }
            showShopikaLogin();
        }
        else
        {
            loginToShopika(ShopikaManager.GetCastedInstance <ShopikaManager> ().currentUserId,
                           ShopikaManager.GetCastedInstance <ShopikaManager> ().currentUser.accesToken);
        }

        isWaiting = true;
        WebViewManager.GetInstance().OnFinishLoading += showToolBar;
        registerForMessages();
    }
예제 #2
0
 public void onCustomUrl(string url)
 {
     if (url.StartsWith("unity:"))
     {
         WebViewManager.ProcessGotoEvent(url.Replace("unity:", string.Empty));
     }
 }
예제 #3
0
        Widget _buildNavigationBar()
        {
            return(new CustomAppBar(
                       () => {
                this._onClose = true;
                this.setState(() => { });
                if (Router.navigator.canPop())
                {
                    Router.navigator.pop();
                }

                if (!Application.isEditor)
                {
                    this._webViewObject.SetVisibility(false);
                    WebViewManager.destroyWebView();
                }
            },
                       rightWidget: new CustomButton(
                           onPressed: () => StoreProvider.store.dispatcher.dispatch(new OpenUrlAction {
                url = this.widget.url
            }),
                           child: new Icon(
                               icon: Icons.open_in_browser,
                               size: 24,
                               color: CColors.Icon
                               )
                           )
                       ));
        }
예제 #4
0
        public override void dispose()
        {
            if (this._timer != null)
            {
                this._timer.cancel();
                this._timer.Dispose();
            }

            if (!Application.isEditor)
            {
                this._webViewObject.SetVisibility(false);
                WebViewManager.destroyWebView();
                if (this.widget.landscape)
                {
                    Screen.orientation = ScreenOrientation.Portrait;
                }

                if (this.widget.fullScreen)
                {
                    Screen.fullScreen = false;
                }
            }

            Router.routeObserve.unsubscribe(this);

            base.dispose();
        }
예제 #5
0
        Widget _buildNavigationBar()
        {
            return(new CustomAppBar(
                       () => {
                this._onClose = true;
                this.setState(() => { });
                if (Router.navigator.canPop())
                {
                    Router.navigator.pop();
                }

                if (!Application.isEditor)
                {
                    this._webViewObject.SetVisibility(false);
                    WebViewManager.destroyWebView();
                }
            },
                       rightWidget: this.widget.showOpenInBrowser ?
                       (Widget) new CustomButton(
                           onPressed: () => StoreProvider.store.dispatcher.dispatch(new OpenUrlAction {
                url = this.widget.url
            }),
                           child: new Icon(
                               icon: Icons.open_in_browser,
                               size: 24,
                               color: CColors.Icon
                               )
                           )
                    : new Container(),
                       backgroundColor: this._progress == 1 && this.widget.fullScreen ? CColors.Black : null,
                       bottomSeparatorColor: this._progress == 1 && this.widget.fullScreen ? CColors.Black : null
                       ));
        }
예제 #6
0
 public void didPop()
 {
     if (!Application.isEditor)
     {
         this._webViewObject.SetVisibility(false);
         WebViewManager.destroyWebView();
     }
 }
예제 #7
0
 internal Task RemoveFromWebViewManagerAsync(WebViewManager webviewManager)
 {
     if (string.IsNullOrWhiteSpace(Selector))
     {
         throw new InvalidOperationException($"{nameof(RootComponent)} requires a value for its {nameof(Selector)} property, but no value was set.");
     }
     return(webviewManager.RemoveRootComponentAsync(Selector));
 }
예제 #8
0
 static public void Init(WebViewObject webObj)
 {
     if (instance == null)
     {
         instance = new WebViewManager();
         instance.webViewObject = webObj;
         instance.InitWebView();
     }
 }
예제 #9
0
 public void closeWebView()
 {
     if (videoModal.activeInHierarchy)
     {
         videoModal.SetActive(false);
     }
     WebViewManager.GetInstance().OnFinishLoading -= showToolBar;
     WebViewManager.GetInstance().stopLoading();
     WebViewManager.GetInstance().hideWebView();
     customToolBar.SetActive(false);
 }
예제 #10
0
    protected void loginToShopika(string userID, string tokenID)
    {
        string tempHtml = "<script type=\"text/javascript\">\n\tvar tokenId = \"{{TokenID}}\";\n\tvar userId = \"{{UserID}}\";\n</script>\n<form method=\"post\" action=\"http://shopika-store.cuatromedios.net/token-login\" id=\"tokenLoginForm\">\n\t<input type=\"hidden\" name=\"action\" value=\"token-login\">\n\t<input type=\"hidden\" name=\"tokenId\">\n\t<input type=\"hidden\" name=\"userId\">\n</form>\n<script type=\"text/javascript\">\n\tvar form = document.getElementById(\"tokenLoginForm\");\n\tform.tokenId.value = tokenId;\n\tform.userId.value = userId;\n\tform.submit();\n</script> ";

        tempHtml = tempHtml.Replace("{{TokenID}}", tokenID);
        tempHtml = tempHtml.Replace("{{UserID}}", userID);

        videoModal.SetActive(true);

        WebViewManager.GetInstance().createWebView(tempHtml, webViewSize, webViewRectCanvasCamera, true);
        //WebViewManager.GetInstance ().displayWebView.CanBounce = true;
    }
예제 #11
0
 void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         _instance = this;
     }
     DontDestroyOnLoad(transform.gameObject);
 }
예제 #12
0
    void Start()
    {
        exitBTN.gameObject.SetActive(false);

        title.text = MultiLanguageTextManager.instance.getTextByID(MultiLanguageTextManager.CONNECTING_SHOPIKA_TITLE);
        Info.text  = MultiLanguageTextManager.instance.getTextByID(MultiLanguageTextManager.CONNECTING_SHOPIKA_INFO);

        utils.gems.sync.ShopikaSyncManager.GetCastedInstance <utils.gems.sync.ShopikaSyncManager> ().OnDataRetrieved        += popUpCompleted;
        utils.gems.sync.ShopikaSyncManager.GetCastedInstance <utils.gems.sync.ShopikaSyncManager> ().OnDataRetrievedFailure += failure;
        utils.gems.sync.ShopikaSyncManager.GetCastedInstance <utils.gems.sync.ShopikaSyncManager> ().OnLoginFailure         += failure;

        WebViewManager.GetInstance().OnFinishLoading += webClosed;
    }
예제 #13
0
 void Update()
 {
     if (isWaiting)
     {
         waitForAnswerTime += Time.deltaTime;
         if (waitForAnswerTime >= totalTime)
         {
             closeWebView();
             isWaiting         = false;
             waitForAnswerTime = 0;
             WebViewManager.GetInstance().OnFinishLoading(WebViewManager.GetInstance().displayWebView);
         }
     }
 }
예제 #14
0
        public override void dispose()
        {
            if (this._timer != null)
            {
                this._timer.cancel();
                this._timer.Dispose();
            }

            if (!Application.isEditor)
            {
                this._webViewObject.SetVisibility(false);
                WebViewManager.destroyWebView();
            }

            base.dispose();
        }
예제 #15
0
    public void showShopikaLanding()
    {
        videoModal.SetActive(true);

        string url = shopikaLandingURI;

        if (ShopikaManager.GetCastedInstance <ShopikaManager> ().currentUserId != ShopikaManager.GetCastedInstance <ShopikaManager> ().ANONYMOUS_USER)
        {
            url += "?userId=" + ShopikaManager.GetCastedInstance <ShopikaManager> ().currentUserId;
        }

        isWaiting = true;
        WebViewManager.GetInstance().OnFinishLoading += showToolBar;
        registerForMessages();

        WebViewManager.GetInstance().createWebView(url, webViewSize, webViewRectCanvasCamera, false);
    }
예제 #16
0
        Widget _buildNavigationBar()
        {
            return(new CustomAppBar(
                       () => {
                this._onClose = true;
                this.setState(() => { });
                if (Router.navigator.canPop())
                {
                    Router.navigator.pop();
                }

                if (!Application.isEditor)
                {
                    this._webViewObject.SetVisibility(false);
                    WebViewManager.destroyWebView();
                }
            }
                       ));
        }
예제 #17
0
    public void messageCallBack(WebView webview, WebViewMessage message)
    {
        /*Debug.Log ("Soy el registrado");
         * Debug.Log (message.Host);
         * Debug.Log (message.Scheme);
         * Debug.Log (message.URL);
         * Debug.Log (message.Arguments.ToJSON().ToString());*/

        Debug.Log(message.Arguments ["tokenId"]);
        Debug.Log(message.Arguments ["userId"]);

        string tempHtml = "<script type=\"text/javascript\">\n\tvar tokenId = \"{{TokenID}}\";\n\tvar userId = \"{{UserID}}\";\n</script>\n<form method=\"post\" action=\"http://45.55.222.58:3003/token-login\" id=\"tokenLoginForm\">\n\t<input type=\"hidden\" name=\"action\" value=\"token-login\">\n\t<input type=\"hidden\" name=\"tokenId\">\n\t<input type=\"hidden\" name=\"userId\">\n</form>\n<script type=\"text/javascript\">\n\tvar form = document.getElementById(\"tokenLoginForm\");\n\tform.tokenId.value = tokenId;\n\tform.userId.value = userId;\n\tform.submit();\n</script> ";

        tempHtml = tempHtml.Replace("{{TokenID}}", message.Arguments ["tokenId"]);
        tempHtml = tempHtml.Replace("{{UserID}}", message.Arguments ["userId"]);

        Debug.Log(tempHtml);

        WebViewManager.GetInstance().createWebView(tempHtml, true);
    }
예제 #18
0
        internal Task AddToWebViewManagerAsync(WebViewManager webViewManager)
        {
            // As a characteristic of XAML,we can't rely on non-default constructors. So we have to
            // validate that the required properties were set. We could skip validating this and allow
            // the lower-level renderer code to throw, but that would be harder for developers to understand.

            if (string.IsNullOrWhiteSpace(Selector))
            {
                throw new InvalidOperationException($"{nameof(RootComponent)} requires a value for its {nameof(Selector)} property, but no value was set.");
            }

            if (ComponentType is null)
            {
                throw new InvalidOperationException($"{nameof(RootComponent)} requires a value for its {nameof(ComponentType)} property, but no value was set.");
            }

            var parameterView = Parameters == null ? ParameterView.Empty : ParameterView.FromDictionary(Parameters);

            return(webViewManager.AddRootComponentAsync(ComponentType, Selector, parameterView));
        }
예제 #19
0
 protected void showShopikaLogin()
 {
     videoModal.SetActive(true);
     WebViewManager.GetInstance().createWebView("http://shopika-store.cuatromedios.net/standalone-login", webViewSize, webViewRectCanvasCamera, false);
     //WebViewManager.GetInstance ().displayWebView.CanBounce = true;
 }
예제 #20
0
 public void createWebView()
 {
     WebViewManager.GetInstance().createWebView("http://45.55.222.58:3003/standalone-login", webViewSize, webViewRectCanvasCamera, false);
 }
예제 #21
0
 public void showToolBar(WebView webview)
 {
     WebViewManager.GetInstance().showWebView();
     customToolBar.SetActive(true);
     isWaiting = false;
 }
예제 #22
0
 protected void registerForMessages()
 {
     WebViewManager.GetInstance().registerToReceiveMessageFromWebView(WEBVIEW_SCHEME, messageCallBack);
 }
예제 #23
0
        internal Task AddToWebViewManagerAsync(WebViewManager webViewManager)
        {
            var parameterView = Parameters == null ? ParameterView.Empty : ParameterView.FromDictionary(Parameters);

            return(webViewManager.AddRootComponentAsync(ComponentType, Selector, parameterView));
        }
예제 #24
0
 void Awake() {
     _instance = this;        
 }
예제 #25
0
 public void unregisterForTelMessage()
 {
     WebViewManager.GetInstance().unRegisterFromMessage("tel", messageCallBack);
 }
예제 #26
0
 public void setCloseButton()
 {
     WebViewManager.GetInstance().changeViewControls(eWebviewControlType.CLOSE_BUTTON);
 }
예제 #27
0
 public void setWholeHUD()
 {
     WebViewManager.GetInstance().changeViewControls(eWebviewControlType.TOOLBAR);
 }
예제 #28
0
 public void registerForMailToMessage()
 {
     WebViewManager.GetInstance().registerToReceiveMessageFromWebView("mailto", messageCallBack);
 }
예제 #29
0
 public void registerForTelMessage()
 {
     WebViewManager.GetInstance().registerToReceiveMessageFromWebView("login", messageCallBack);
 }
예제 #30
0
        public void OpenContentPage()
        {
            if (IsHidden)
            {
                // This fragment is hidden, need not open page
                return;
            }

            if (wvContent == null ||            // WebView does not requested
                DataCache.INSTATNCE.Toc == null // Toc has not been retrieved
                )
            {
                return;
            }



            var pub = ((ContentActivity)Activity).Publication;

            if (!DataCache.INSTATNCE.Toc.IsCurrentPublication(pub.Value.BookId))
            {
                // The toc is not belong to current publication
                return;
            }

            var tocNode = DataCache.INSTATNCE.Toc.ShowingLeafNode;
            var tag     = wvContent.Tag as JavaObjWrapper <WebViewTag>;

            if (tag != null && tag.Value.IsCurrentTOC(pub.Value.BookId, tocNode.ID))
            {
                /*
                 *              wvContent.Tag = new JavaObjWrapper<WebViewTag>(
                 *                      WebViewTag.CreateWebViewTagByTOC(
                 *                              pub.Value.BookId,
                 *                              tocNode.ID));
                 */

                ((ContentActivity)Activity).ClosePleaseWaitPageLoadDialog();
                UpdateNavigationIcon();

                if (!tag.Value.IsCurrentNavigationItem())
                {
                    wvContent.LoadUrl("javascript:android.red.applyHighLight();android.red.scrollByNavigation();");
                    tag.Value.BindNavigationItem();

                    if (((ContentActivity)Activity).IsPbo())
                    {
                        var pboPageItem = AsyncHelpers.RunSync <PageItem>(
                            () => PageSearchUtil.Instance.GetFirstPageItem(pub.Value.BookId, tocNode.ID));
                        currentPboPage = pboPageItem != null?pboPageItem.Identifier.ToString() : null;
                    }

                    //UpdatePboPage();
                }

                return;
            }

            var result = AsyncHelpers.RunSync <string>(
                () => PublicationContentUtil.Instance.GetContentFromTOC(pub.Value.BookId, tocNode, true, false));

            //result = SlideToc(result);

            // Only large content need show wait dialog
            if (result.Length > WebViewManager.ShowWaitContentMinLength ||
                WebViewManager.CountATag(result) > WebViewManager.ShowWaitMinATagCount)
            {
                ((ContentActivity)Activity).ShowPleaseWaitDialog();
                Task.Run(() =>
                {
                    Thread.Sleep(100);

                    result = PublicationContentUtil.Instance.RenderHyperLink(result, pub.Value.BookId);
                    result = "<div id='toc_" + tocNode.ID + "' class='tocpagediv' >" + result + "</div>";

                    Application.SynchronizationContext.Post(_ =>
                    {
                        tag = new JavaObjWrapper <WebViewTag>(
                            WebViewTag.CreateWebViewTagByTOC(
                                pub.Value.BookId,
                                tocNode.ID));
                        tag.Value.BindNavigationItem();
                        wvContent.Tag = tag;

                        wvContent.LoadDataWithBaseURL(
                            "file:///android_asset/html/",
                            WebViewManager.Instance.ApplyTemplate(WebViewManager.WebViewType.Content, result),
                            "text/html",
                            "utf-8",
                            null);

                        if (((ContentActivity)Activity).IsPbo())
                        {
                            var pboPageItem = AsyncHelpers.RunSync <PageItem>(
                                () => PageSearchUtil.Instance.GetFirstPageItem(pub.Value.BookId, tocNode.ID));
                            currentPboPage = pboPageItem != null ? pboPageItem.Identifier.ToString() : null;
                        }

                        UpdatePboPage();
                        UpdateNavigationIcon();
                    }, null);
                });

                return;
            }

            //result = PublicationContentUtil.Instance.RenderHyperLink(result, pub.Value.BookId);
            //result = "<div id='toc_" + tocNode.ID + "' class='tocpagediv' >" + result + "</div>";



            //DumpToc(pub.Value.BookId, tocNode.ID, WebViewManager.Instance.ApplyTemplate(WebViewManager.WebViewType.Content, result));

            //tag = new JavaObjWrapper<WebViewTag>(
            //    WebViewTag.CreateWebViewTagByTOC(
            //        pub.Value.BookId,
            //        tocNode.ID));
            //tag.Value.BindNavigationItem();
            //wvContent.Tag = tag;

            //wvContent.LoadDataWithBaseURL(
            //    "file:///android_asset/html/",
            //    WebViewManager.Instance.ApplyTemplate(WebViewManager.WebViewType.Content, result),
            //    "text/html",
            //    "utf-8",
            //    null);

            //if (((ContentActivity)Activity).IsPbo())
            //{
            //    var pboPageItem = AsyncHelpers.RunSync<PageItem>(
            //        () => PageSearchUtil.Instance.GetFirstPageItem(pub.Value.BookId, tocNode.ID));
            //    currentPboPage = pboPageItem != null ? pboPageItem.Identifier.ToString() : null;
            //}

            //UpdatePboPage();
            //UpdateNavigationIcon();
        }
예제 #31
0
 public void unregisterForMailToMessage()
 {
     WebViewManager.GetInstance().unRegisterFromMessage("mailto", messageCallBack);
 }