示例#1
0
        /// <summary>
        /// Warmup
        /// Tells the browser of a likely future navigation to a URL.
        /// </summary>
        /// <seealso cref= <seealso cref="CustomTabsSession#mayLaunchUrl(Uri, Bundle, List)"/>. </seealso>
        /// <returns> true if call to mayLaunchUrl was accepted. </returns>
        public virtual bool MayLaunchUrl(Uri uri, Bundle extras, IList <Bundle> other_likely_bundles)
        {
            if (custom_tabs_client == null)
            {
                return(false);
            }

            CustomTabsSession cts = this.Session;

            if (cts == null)
            {
                return(false);
            }

            return(cts.MayLaunchUrl(uri, extras, other_likely_bundles));
        }
示例#2
0
        /// <seealso cref= <seealso cref="CustomTabsSession#mayLaunchUrl(Uri, Bundle, List)"/>. </seealso>
        /// <returns> true if call to mayLaunchUrl was accepted. </returns>
        public virtual bool mayLaunchUrl(Uri uri, Bundle extras, IList <Bundle> otherLikelyBundles)
        {
            if (mClient == null)
            {
                return(false);
            }

            CustomTabsSession session = Session;

            if (session == null)
            {
                return(false);
            }

            return(session.MayLaunchUrl(uri, extras, otherLikelyBundles));
        }
示例#3
0
        public void OnClick(View view)
        {
            string url = mEditText.Text;
            bool   success;

            switch (view.Id)
            {
            case Resource.Id.connect_button:
                BindCustomTabsService();
                break;

            case Resource.Id.warmup_button:
                success = false;
                if (mClient != null)
                {
                    success = mClient.Warmup(0);
                }
                mWarmupButton.Enabled &= success;
                break;

            case Resource.Id.may_launch_button:
                CustomTabsSession session = GetSession();
                success = false;
                if (mClient != null)
                {
                    success = session.MayLaunchUrl(Uri.Parse(url), null, null);
                }
                mMayLaunchButton.Enabled &= success;
                break;

            case Resource.Id.launch_button:
                var builder = new CustomTabsIntent.Builder(GetSession());
                builder.SetToolbarColor(Color.ParseColor(TOOLBAR_COLOR)).SetShowTitle(true);
                PrepareMenuItems(builder);
                PrepareActionButton(builder);
                PrepareBottombar(builder);
                builder.SetStartAnimations(this, Resource.Animation.slide_in_right, Resource.Animation.slide_out_left);
                builder.SetExitAnimations(this, Resource.Animation.slide_in_left, Resource.Animation.slide_out_right);
                builder.SetCloseButtonIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_arrow_back));
                CustomTabsIntent customTabsIntent = builder.Build();
                CustomTabsHelper.AddKeepAliveExtra(this, customTabsIntent.Intent);
                customTabsIntent.LaunchUrl(this, Uri.Parse(url));
                break;
            }
        }
        /// <summary>
        /// Warmup
        /// Tells the browser of a likely future navigation to a URL.
        /// </summary>
        /// <seealso cref= <seealso cref="CustomTabsSession#mayLaunchUrl(Uri, Bundle, List)"/>. </seealso>
        /// <returns> true if call to mayLaunchUrl was accepted. </returns>
        public virtual bool MayLaunchUrl
        (
            Android.Net.Uri uri,
            Bundle extras,
            IList <Bundle> other_likely_bundles
        )
        {
            if (custom_tabs_client == null)
            {
                return(false);
            }

            custom_tabs_session = custom_tabs_activity_manager.Session;

            if (custom_tabs_session == null)
            {
                return(false);
            }

            return(custom_tabs_session.MayLaunchUrl(uri, extras, other_likely_bundles));
        }
示例#5
0
        public void OnClick(View v)
        {
            string url    = mEditText.Text.ToString();
            int    viewId = v.Id;

            if (viewId == Resource.Id.connect_button)
            {
                BindCustomTabsService();
            }
            else if (viewId == Resource.Id.warmup_button)
            {
                bool success = false;
                if (custom_tabs_client != null)
                {
                    success = custom_tabs_client.Warmup(0);
                }
                if (!success)
                {
                    mWarmupButton.Enabled = false;
                }
            }
            else if (viewId == Resource.Id.may_launch_button)
            {
                CustomTabsSession session = Session;
                bool success = false;
                if (custom_tabs_client != null)
                {
                    success = session.MayLaunchUrl(Android.Net.Uri.Parse(url), null, null);
                }
                if (!success)
                {
                    mMayLaunchButton.Enabled = false;
                }
            }
            else if (viewId == Resource.Id.launch_button)
            {
                CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(Session);
                builder.SetToolbarColor(Color.ParseColor(TOOLBAR_COLOR)).SetShowTitle(true);
                PrepareMenuItems(builder);
                PrepareActionButton(builder);
                PrepareBottomBar(builder);

                builder.SetStartAnimations
                (
                    this,
                    Resource.Animation.slide_in_right,
                    Resource.Animation.slide_out_left
                );
                builder.SetExitAnimations
                (
                    this,
                    Android.Resource.Animation.SlideInLeft,
                    Android.Resource.Animation.SlideOutRight
                );
                builder.SetCloseButtonIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_arrow_back));


                CustomTabsIntent customTabsIntent = builder.Build();
                // derived class used - thus FQNS
                HolisticWare.Android.Support.CustomTabs.Chromium.SharedUtilities.
                CustomTabsHelper.AddKeepAliveExtra(this, customTabsIntent.Intent);

                try
                {
                    customTabsIntent.LaunchUrl(this, Android.Net.Uri.Parse(url));
                }
                catch (System.Exception exc)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("CustomTabsIntent.LaunchUrl Exception");
                }
                return;
            }
        }