Esempio n. 1
0
        public void OnScroll(ObservableWebView view, int x, int y)
        {
            bool autoScroll = PreferenceManager.GetDefaultSharedPreferences(Activity.ApplicationContext).GetBoolean("autoScroll", true);

            if (!autoScroll)
            {
                return;
            }

            if (primaryWebview.IsDeflated || secondaryWebview.IsDeflated)
            {
                return;
            }

            float viewHeight      = view.Height;
            float primaryHeight   = primaryWebview.ContentHeight * primaryWebview.Scale;
            float secondaryHeight = secondaryWebview.ContentHeight * secondaryWebview.Scale;

            // Scroll primary
            if (view == primaryWebview)
            {
                float primaryYPos = Java.Lang.Math.Round(view.ScrollY * (secondaryHeight - viewHeight) / (primaryHeight - viewHeight));
                secondaryWebview.ScrollTo(x, (int)primaryYPos);
            }

            // Scroll secondary
            if (view == secondaryWebview)
            {
                float secondaryYPos = Java.Lang.Math.Round(view.ScrollY * (primaryHeight - viewHeight) / (secondaryHeight - viewHeight));
                primaryWebview.ScrollTo(x, (int)secondaryYPos);
            }
        }
Esempio n. 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;
        }
Esempio n. 3
0
 public WebViewGestureListener(ObservableWebView webview)
 {
     this.webview = webview;
 }
Esempio n. 4
0
 public WebViewActionBarCallback(ObservableWebView webview)
 {
     this.webview = webview;
 }
Esempio n. 5
0
        public void InitializeLayoutParadigm(View view)
        {
            // Set views
            primaryWebview   = view.FindViewById <ObservableWebView>(Resource.Id.primaryWebView);
            secondaryWebview = view.FindViewById <ObservableWebView>(Resource.Id.secondaryWebView);
            flipper          = view.FindViewById <ViewFlipper>(Resource.Id.view_flipper);
            gridViewTitle    = view.FindViewById <TextView>(Resource.Id.chapterTitle);
            gridView         = view.FindViewById <HeaderFooterGridView>(Resource.Id.chapterGridView);

            LayoutInflater layoutInflater = LayoutInflater.From(Activity);
            View           footerView     = layoutInflater.Inflate(Resource.Layout.FooterWebView, null);

            gridViewFooterWebview = footerView.FindViewById <ObservableWebView>(Resource.Id.footerWebView);

            // ViewFlipper animations
            flipper.SetInAnimation(Activity, Resource.Animation.push_down_in_no_alpha);
            flipper.SetOutAnimation(Activity, Resource.Animation.push_down_out_no_alpha);

            // Style views
            Typeface face = Typeface.CreateFromAsset(Activity.Assets, "fonts/Roboto-Regular.ttf");

            gridViewTitle.SetTypeface(face, TypefaceStyle.Normal);

            // WebView setup
            InitializeWebView(primaryWebview);
            InitializeWebView(secondaryWebview);
            InitializeWebView(gridViewFooterWebview);

            primaryWebview.Tag   = "primary";
            secondaryWebview.Tag = "secondary";

            ((LinearLayout)primaryWebview.Parent).LayoutParameters = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MatchParent,
                LinearLayout.LayoutParams.MatchParent,
                App.STATE.WebviewWeights[0]);
            ((LinearLayout)secondaryWebview.Parent).LayoutParameters = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MatchParent,
                LinearLayout.LayoutParams.MatchParent,
                App.STATE.WebviewWeights[1]);

            if (App.STATE.WebviewWeights[0] == 0)
            {
                primaryWebview.IsDeflated = true;
            }
            if (App.STATE.WebviewWeights[1] == 0)
            {
                secondaryWebview.IsDeflated = true;
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                gridView.ChoiceMode = ChoiceMode.Single;
            }

            gridView.ItemClick += SelectChapter;

            if (library == Library.Bible)
            {
                gridView.DoSetHeight = false;

                gridViewTitle.Click += text_Click;
                gridViewTitle.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_outline, 0, 0, 0);

                // Set Bible book outline
                NavStruct outline = new NavStruct()
                {
                    Book    = 0,
                    Chapter = SelectedArticle.Book,
                    Verse   = 0
                };
                OutlineContents = JwStore.QueryArticle("outline", outline, LibraryStorehouse.English).ArticleContent;
                gridView.AddFooterView(footerView);
                gridViewFooterWebview.LoadDataWithBaseURL("file:///android_asset/", OutlineContents, "text/html", "utf-8", null);
            }
        }