Пример #1
0
        //////////////////////////////////////////////////////////////////////////
        // DIALOG Section
        //////////////////////////////////////////////////////////////////////////
        public void ShowPresentationDialog(Context context, string title, string content, bool external = false)
        {
            LayoutInflater inflater            = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
            View           view                = inflater.Inflate(Resource.Layout.DialogWebView, null);
            WebView        presentationWebView = view.FindViewById <WebView>(Resource.Id.dialogWebView);

            StorehouseWebViewClient client = new StorehouseWebViewClient(external);

            presentationWebView.SetWebViewClient(client);
            presentationWebView.Settings.JavaScriptEnabled   = true;
            presentationWebView.Settings.BuiltInZoomControls = true;
            presentationWebView.VerticalScrollBarEnabled     = false;
            presentationWebView.Settings.DefaultFontSize     = GetWebViewTextSize(App.STATE.SeekBarTextSize);

            if (content.StartsWith("http"))
            {
                presentationWebView.LoadUrl(content);
            }
            else
            {
                presentationWebView.LoadDataWithBaseURL("file:///android_asset/", content, "text/html", "utf-8", null);
            }

            MaterialDialog dialog = null;

            MaterialDialog.Builder popup = new MaterialDialog.Builder(context);
            popup.SetCustomView(view, false);
            popup.SetNegativeText("X", (o, args) =>
            {
                // Close dialog
            });

            App.STATE.Activity.RunOnUiThread(() =>
            {
                dialog = popup.Show();

                // Set dialog width to width of screen
                WindowManagerLayoutParams layoutParams = new WindowManagerLayoutParams();
                layoutParams.CopyFrom(dialog.Window.Attributes);
                layoutParams.Width       = WindowManagerLayoutParams.MatchParent;
                dialog.Window.Attributes = layoutParams;
            });
        }
Пример #2
0
        private void InitializeWebView(ObservableWebView view)
        {
            StorehouseWebViewClient client = new StorehouseWebViewClient();

            view.SetWebViewClient(client);
            view.Settings.JavaScriptEnabled   = true;
            view.Settings.BuiltInZoomControls = false;
            view.VerticalScrollBarEnabled     = false;
            view.Settings.SetRenderPriority(WebSettings.RenderPriority.High);
            view.Settings.CacheMode = CacheModes.NoCache;
            view.AddJavascriptInterface(new KingJavaScriptInterface(Activity, view), "KingJavaScriptInterface");

            int size = App.FUNCTIONS.GetWebViewTextSize(App.STATE.SeekBarTextSize);

            view.Settings.DefaultFontSize = size;

            view.ScrollChangedCallback = this;
            view.ParentFragment        = this;
        }