void OpenCustomTab()
        {
            string url = mUrlEditText.Text;

            int color          = GetColor(mCustomTabColorEditText);
            int secondaryColor = GetColor(mCustomTabSecondaryColorEditText);

            CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
            intentBuilder.SetToolbarColor(color);
            intentBuilder.SetSecondaryToolbarColor(secondaryColor);

            if (mShowActionButtonCheckbox.Checked)
            {
                //Generally you do not want to decode bitmaps in the UI thread. Decoding it in the
                //UI thread to keep the example short.
                string        actionLabel   = GetString(Resource.String.label_action);
                Bitmap        icon          = BitmapFactory.DecodeResource(Resources, Android.Resource.Drawable.IcMenuShare);
                PendingIntent pendingIntent = CreatePendingIntent(ActionBroadcastReceiver.ACTION_ACTION_BUTTON);
                intentBuilder.SetActionButton(icon, actionLabel, pendingIntent);
            }

            if (mAddMenusCheckbox.Checked)
            {
                string        menuItemTitle         = GetString(Resource.String.menu_item_title);
                PendingIntent menuItemPendingIntent = CreatePendingIntent(ActionBroadcastReceiver.ACTION_MENU_ITEM);
                intentBuilder.AddMenuItem(menuItemTitle, menuItemPendingIntent);
            }

            if (mAddDefaultShareCheckbox.Checked)
            {
                intentBuilder.AddDefaultShareMenuItem();
            }

            if (mToolbarItemCheckbox.Checked)
            {
                //Generally you do not want to decode bitmaps in the UI thread. Decoding it in the
                //UI thread to keep the example short.
                string        actionLabel   = GetString(Resource.String.label_action);
                Bitmap        icon          = BitmapFactory.DecodeResource(Resources, Android.Resource.Drawable.IcMenuShare);
                PendingIntent pendingIntent = CreatePendingIntent(ActionBroadcastReceiver.ACTION_TOOLBAR);
                intentBuilder.AddToolbarItem(TOOLBAR_ITEM_ID, icon, actionLabel, pendingIntent);
            }

            intentBuilder.SetShowTitle(mShowTitleCheckBox.Checked);

            if (mAutoHideAppBarCheckbox.Checked)
            {
                intentBuilder.EnableUrlBarHiding();
            }

            if (mCustomBackButtonCheckBox.Checked)
            {
                intentBuilder.SetCloseButtonIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_arrow_back));
            }
            intentBuilder.SetStartAnimations(this, Resource.Animation.slide_in_right, Resource.Animation.slide_out_left);
            intentBuilder.SetExitAnimations(this, Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);

            CustomTabActivityHelper.OpenCustomTab(
                this, intentBuilder.Build(), Uri.Parse(url), new WebviewFallback());
        }
Ejemplo n.º 2
0
        protected void custom_tabs_activit_manager_CustomTabsServiceConnected
        (
            Content.ComponentName name,
            CustomTabsClient client
        )
        {
            builder = new CustomTabsIntent.Builder(custom_tabs_activit_manager.Session);
            builder.EnableUrlBarHiding();

            if (CustomTabsConfiguration.IsWarmUpUsed)
            {
                long flags = -1;
                client.Warmup(flags);
            }

            if (CustomTabsConfiguration.AreAnimationsUsed)
            {
                builder.SetStartAnimations
                (
                    activity,
                    Xamarin.Auth.Resource.Animation.slide_in_right,
                    Xamarin.Auth.Resource.Animation.slide_out_left
                );
                builder.SetExitAnimations
                (
                    activity,
                    global::Android.Resource.Animation.SlideInLeft,
                    global::Android.Resource.Animation.SlideOutRight
                );
            }

            custom_tabs_activit_manager.LaunchUrl(uri.ToString(), builder.Build());

            return;
        }
        protected void custom_tabs_activit_manager_CustomTabsServiceConnected
        (
            Content.ComponentName name,
            CustomTabsClient client
        )
        {
            custom_tabs_intent_builder = new CustomTabsIntent.Builder(custom_tabs_activity_manager.Session);

            custom_tabs_intent_builder.EnableUrlBarHiding();

            if (CustomTabsConfiguration.IsWarmUpUsed)
            {
                System.Diagnostics.Debug.WriteLine("CustomTabsActivityManager.WarmUp()");
                client.Warmup(0);
                //custom_tabs_activity_manager.Warmup();
            }

            if (CustomTabsConfiguration.IsPrefetchUsed)
            {
                System.Diagnostics.Debug.WriteLine("CustomTabsActivityManager PREFETCH");
                custom_tabs_activity_manager.MayLaunchUrl(uri.ToString(), null, null);
            }

            if (CustomTabsConfiguration.AreAnimationsUsed)
            {
                custom_tabs_intent_builder.SetStartAnimations
                (
                    activity,
                    Xamarin.Auth.Resource.Animation.slide_in_right,
                    Xamarin.Auth.Resource.Animation.slide_out_left
                );
                custom_tabs_intent_builder.SetExitAnimations
                (
                    activity,
                    global::Android.Resource.Animation.SlideInLeft,
                    global::Android.Resource.Animation.SlideOutRight
                );
            }

            custom_tabs_activity_manager.LaunchUrl(uri.ToString(), custom_tabs_intent_builder.Build());

            return;
        }
Ejemplo n.º 4
0
        void BeginLoadingInitialUrl()
        {
            var initalUri = state.Authenticator.GetInitialUrlAsync().Result;
            var mgr       = new CustomTabsActivityManager(this);

            mgr.CustomTabsServiceConnected += delegate {
                var builder = new CustomTabsIntent.Builder(mgr.Session);
                builder.EnableUrlBarHiding();
                builder.SetStartAnimations(this, Resource.Animation.slide_in_right, Resource.Animation.slide_out_left);
                builder.SetExitAnimations(this, global::Android.Resource.Animation.SlideInLeft, global::Android.Resource.Animation.SlideOutRight);
                mgr.LaunchUrl(initalUri.AbsoluteUri, builder.Build());
            };
            if (!mgr.BindService())
            {
                var intent = new Intent(Intent.ActionView);
                intent.SetData(global::Android.Net.Uri.Parse(initalUri.AbsoluteUri));
                StartActivity(intent);
            }
        }