public static void Initialize(global::Android.App.Activity a)
        {
            activity = a;
            CustomTabsActivityManager = new CustomTabsActivityManager(a);
            CustomTabsIntentBuilder   = new CustomTabsIntent.Builder(CustomTabsActivityManager.Session);
            CustomTabActivityHelper   = new CustomTabActivityHelper();

            return;
        }
Example #2
0
        public static void Initialize(global::Android.App.Activity a)
        {
            activity = a;

            List <string> packages = PackageManagerHelper.GetPackageNameToUse
                                     (
                global::Android.App.Application.Context,
                "http://xamarin.com"
                                     );

            PackagesSupportingCustomTabs = PackageManagerHelper.PackagesSupportingCustomTabs;
            PackageForCustomTabs         = PackagesSupportingCustomTabs.FirstOrDefault().Value;

            CustomTabsActivityManager = new CustomTabsActivityManager(a);
            CustomTabsIntentBuilder   = new CustomTabsIntent.Builder(CustomTabsActivityManager.Session);
            CustomTabActivityHelper   = new CustomTabActivityHelper();

            return;
        }
Example #3
0
        public static void UICustomization()
        {
            ActivityFlags =
                global::Android.Content.ActivityFlags.NoHistory
                |
                global::Android.Content.ActivityFlags.SingleTop
                |
                global::Android.Content.ActivityFlags.NewTask
                |
                global::Android.Content.ActivityFlags.ClearTop
            ;

            /*
             * CustomTabsIntentBuilder
             *  .SetToolbarColor(color_xamarin_blue)
             *  .SetShowTitle(true)
             *  .EnableUrlBarHiding()
             *  .AddDefaultShareMenuItem()
             *  ;
             */

            if (ToolbarColor != null)
            {
                CustomTabsIntentBuilder
                .SetToolbarColor(ToolbarColor)
                ;
            }
            if (IsShowTitleUsed == true)
            {
                CustomTabsIntentBuilder
                .SetShowTitle(true)
                ;
            }
            if (IsUrlBarHidingUsed == true)
            {
                CustomTabsIntentBuilder
                .EnableUrlBarHiding()
                ;
            }
            if (IsDefaultShareMenuItemUsed == true)
            {
                CustomTabsIntentBuilder
                .AddDefaultShareMenuItem()
                ;
            }


            if (IsActionButtonUsed == true)
            {
                PendingIntent pi = null;
                //............................................................
                // Action Button Bitmap
                // Generally do not decode bitmaps in the UI thread.
                // Decoding it in the UI thread to keep the example short.
                ActionButtonIconBitmap = global::Android.Graphics.BitmapFactory.DecodeResource
                                         (
                    activity.Resources,
                    global::Android.Resource.Drawable.IcMenuShare
                                         );
                pi = CreatePendingIntent(CustomTabsActionsBroadcastReceiver.ACTION_ACTION_BUTTON);

                CustomTabsIntentBuilder
                .SetActionButton(ActionButtonIconBitmap, ActionLabel, pi)
                ;

                // TODO: ufff leaks?
                // ActionButtonIconBitmap = null;
                // pi = null;
            }


            //............................................................
            // menu
            if (!string.IsNullOrEmpty(MenuItemTitle))
            {
                PendingIntent pi_menu_item = CreatePendingIntent(CustomTabsActionsBroadcastReceiver.ACTION_MENU_ITEM);
                CustomTabsIntentBuilder.AddMenuItem(MenuItemTitle, pi_menu_item);

                // TODO: ufff leaks?
                // ActionButtonIconBitmap = null;
                // pi_menu_item = null;
            }
            //............................................................


            int TOOLBAR_ITEM_ID = 1;

            if (IsActionBarToolbarIconUsed == true)
            {
                //............................................................
                // Action Label Toolbar
                // Generally do not decode bitmaps in the UI thread.
                // Decoding it in the UI thread to keep the example short.
                ActionBarToolbarIconBitmap = global::Android.Graphics.BitmapFactory.DecodeResource
                                             (
                    activity.Resources,
                    global::Android.Resource.Drawable.IcMenuShare
                                             );
                PendingIntent pi = CreatePendingIntent(CustomTabsActionsBroadcastReceiver.ACTION_ACTION_BUTTON);
                pi = CreatePendingIntent(CustomTabsActionsBroadcastReceiver.ACTION_TOOLBAR);

                CustomTabsIntentBuilder.AddToolbarItem(TOOLBAR_ITEM_ID, ActionBarToolbarIconBitmap, ActionLabel, pi);
                //............................................................

                // TODO: ufff leaks?
                // ActionBarToolbarIconBitmap = null;
                // pi = null;
            }

            if (IsCloseButtonIconUsed == true)
            {
                //............................................................
                // Custom Back Button Bitmap
                // Generally do not decode bitmaps in the UI thread.
                // Decoding it in the UI thread to keep the example short.
                CustomTabsIntentBuilder
                .SetCloseButtonIcon
                (
                    global::Android.Graphics.BitmapFactory.DecodeResource
                    (
                        activity.Resources,
                        Resource.Drawable.ic_arrow_back
                    )
                );
                //............................................................
            }

            if (AreAnimationsUsed == true)
            {
                //............................................................
                // Animations
                CustomTabsIntentBuilder
                .SetStartAnimations
                (
                    activity,
                    Resource.Animation.slide_in_right,
                    Resource.Animation.slide_out_left
                )
                .SetExitAnimations
                (
                    activity,
                    global::Android.Resource.Animation.SlideInLeft,
                    global::Android.Resource.Animation.SlideOutRight
                );
                //............................................................
            }

            //............................................................
            // TODO: bottom bar
            //............................................................
            //------------------------------------------------------------

            if (UriAndroidOS != null)
            {
                //------------------------------------------------------------
                //      Optimisations
                //      [OPTIONAL] [RECOMENDED]
                //          *   WarmUp,
                //          *   Prefetching
                //
                bool launchable_uri = CustomTabActivityHelper.MayLaunchUrl
                                      (
                    UriAndroidOS,
                    null,
                    null
                                      );
            }

            //------------------------------------------------------------
            //  CustomTabsIntent property getter will call
            //      CustomTabsIntent.Builder.Build() internally
            CustomTabsIntent.Intent.AddFlags(ActivityFlags);

            return;
        }