<commit_before>﻿namespace XamarinEvolve.iOS
{
    using System;
    using System.Collections.Generic;

    using CoreSpotlight;

    using FormsToolkit;
    using FormsToolkit.iOS;

    using Foundation;

    using Google.AppIndexing;

    using Refractored.XamForms.PullToRefresh.iOS;

    using Social;

    using UIKit;

    using Xamarin;
    using Xamarin.Forms;
    using Xamarin.Forms.Platform.iOS;

    using XamarinEvolve.Clients.Portable;
    using XamarinEvolve.Clients.UI;
    using XamarinEvolve.DataStore.Mock.Abstractions;
    using XamarinEvolve.Utils.Helpers;

    [Register("AppDelegate")]
    public partial class AppDelegate : FormsApplicationDelegate
    {
        public static class ShortcutIdentifier
        {
            public const string Tweet = AboutThisApp.PackageName + ".tweet";

            public const string Announcements = AboutThisApp.PackageName + ".announcements";

            public const string Events = AboutThisApp.PackageName + ".events";
        }

        internal static UIColor PrimaryColor = null;

        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
#if !ENABLE_TEST_CLOUD
            if (!string.IsNullOrWhiteSpace(ApiKeys.HockeyAppiOS) && ApiKeys.HockeyAppiOS != nameof(ApiKeys.HockeyAppiOS))
            {
               
                var manager = BITHockeyManager.SharedHockeyManager;
                manager.Configure(ApiKeys.HockeyAppiOS);

                //Disable update manager
                manager.DisableUpdateManager = true;

                manager.StartManager();
                //manager.Authenticator.AuthenticateInstallation();
                   
            }
#endif
            // Code for starting up the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
            //Mapping StyleId to iOS Labels
            Forms.ViewInitialized += (object sender, ViewInitializedEventArgs e) =>
                {
                    if (null != e.View.StyleId)
                    {
                        e.NativeView.AccessibilityIdentifier = e.View.StyleId;
                    }
                };
#endif

            Forms.Init();

            SetMinimumBackgroundFetchInterval();

            InitializeDependencies();

            LoadApplication(new App());

            InitializeThemeColors();

            // Process any potential notification data from launch
            ProcessNotification(launchOptions);

            NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidBecomeActiveNotification, DidBecomeActive);

            var shouldPerformAdditionalDelegateHandling = true;

            // Get possible shortcut item
            if (launchOptions != null)
            {
                LaunchedShortcutItem =
                    launchOptions[UIApplication.LaunchOptionsShortcutItemKey] as UIApplicationShortcutItem;
                shouldPerformAdditionalDelegateHandling = (LaunchedShortcutItem == null);
            }

            return base.FinishedLaunching(uiApplication, launchOptions); // && shouldPerformAdditionalDelegateHandling;
        }

        void DidBecomeActive(NSNotification notification)
        {
            ((XamarinEvolve.Clients.UI.App)Xamarin.Forms.Application.Current).SecondOnResume();
        }

        static void InitializeDependencies()
        {
            FormsMaps.Init();
            Toolkit.Init();

            AppIndexing.SharedInstance.RegisterApp(PublicationSettings.iTunesAppId);

            Plugin.Share.ShareImplementation.ExcludedUIActivityTypes = new List<NSString>
                                                                           {
                                                                               UIActivityType
                                                                                   .PostToFacebook,
                                                                               UIActivityType
                                                                                   .AssignToContact,
                                                                               UIActivityType
                                                                                   .OpenInIBooks,
                                                                               UIActivityType
                                                                                   .PostToVimeo,
                                                                               UIActivityType
                                                                                   .PostToFlickr,
                                                                               UIActivityType
                                                                                   .SaveToCameraRoll
                                                                           };
            ImageCircle.Forms.Plugin.iOS.ImageCircleRenderer.Init();
            NonScrollableListViewRenderer.Initialize();
            SelectedTabPageRenderer.Initialize();
            TextViewValue1Renderer.Init();
            PullToRefreshLayoutRenderer.Init();
        }

        static void InitializeThemeColors()
        {
            // Set up appearance after loading theme resources in App.xaml
            PrimaryColor = ((Color)Xamarin.Forms.Application.Current.Resources["Primary"]).ToUIColor();
            UINavigationBar.Appearance.BarTintColor =
                ((Color)Xamarin.Forms.Application.Current.Resources["BarBackgroundColor"]).ToUIColor();
            UINavigationBar.Appearance.TintColor = PrimaryColor; //Tint color of button items
            UIBarButtonItem.Appearance.TintColor = PrimaryColor; //Tint color of button items
            UITabBar.Appearance.TintColor = PrimaryColor;
            UISwitch.Appearance.OnTintColor = PrimaryColor;
            UIAlertView.Appearance.TintColor = PrimaryColor;

            UIView.AppearanceWhenContainedIn(typeof(UIAlertController)).TintColor = PrimaryColor;
            UIView.AppearanceWhenContainedIn(typeof(UIActivityViewController)).TintColor = PrimaryColor;
            UIView.AppearanceWhenContainedIn(typeof(SLComposeViewController)).TintColor = PrimaryColor;
        }

        public override void WillEnterForeground(UIApplication uiApplication)
        {
            base.WillEnterForeground(uiApplication);
            ((XamarinEvolve.Clients.UI.App)Xamarin.Forms.Application.Current).SecondOnResume();
        }

        public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken)
        {

#if ENABLE_TEST_CLOUD
#else

            if (ApiKeys.AzureServiceBusUrl == nameof(ApiKeys.AzureServiceBusUrl))
                return;

            // Connection string from your azure dashboard
            var cs = SBConnectionString.CreateListenAccess(
                new NSUrl(ApiKeys.AzureServiceBusUrl),
                ApiKeys.AzureKey);

            // Register our info with Azure
            var hub = new SBNotificationHub (cs, ApiKeys.AzureHubName);
            hub.RegisterNativeAsync (deviceToken, null, err => {
                if (err != null)
                    Console.WriteLine("Error: " + err.Description);
                else
                    Console.WriteLine("Success");
            });
#endif
        }

        public override void ReceivedRemoteNotification(UIApplication app, NSDictionary userInfo)
        {
            // Process a notification received while the app was already open
            ProcessNotification(userInfo);
        }

        public override bool HandleOpenURL(UIApplication application, NSUrl url)
        {
            if (!string.IsNullOrEmpty(url.AbsoluteString))
            {
                ((XamarinEvolve.Clients.UI.App)App.Current).SendOnAppLinkRequestReceived(new Uri(url.AbsoluteString));
                return true;
            }
            return false;
        }

        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
        {
            if (!string.IsNullOrEmpty(url.AbsoluteString))
            {
                ((XamarinEvolve.Clients.UI.App)App.Current).SendOnAppLinkRequestReceived(new Uri(url.AbsoluteString));
                return true;
            }
            return false;
        }

        public override bool OpenUrl(
            UIApplication application,<commit_msg>iOS build fixes<commit_after>﻿namespace XamarinEvolve.iOS
{
    using System;
    using System.Collections.Generic;

    using CoreSpotlight;

    using FormsToolkit;
    using FormsToolkit.iOS;

    using Foundation;

    using Google.AppIndexing;

    using Refractored.XamForms.PullToRefresh.iOS;

    using Social;

    using UIKit;

    using Xamarin;
    using Xamarin.Forms;
    using Xamarin.Forms.Platform.iOS;

    using XamarinEvolve.Clients.Portable;
    using XamarinEvolve.Clients.UI;
    using XamarinEvolve.DataStore.Mock.Abstractions;
    using XamarinEvolve.Utils.Helpers;

    [Register("AppDelegate")]
    public partial class AppDelegate : FormsApplicationDelegate
    {
        public static class ShortcutIdentifier
        {
            public const string Tweet = AboutThisApp.PackageName + ".tweet";

            public const string Announcements = AboutThisApp.PackageName + ".announcements";

            public const string Events = AboutThisApp.PackageName + ".events";
        }

        internal static UIColor PrimaryColor = null;

        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
//#if !ENABLE_TEST_CLOUD
//            //if (!string.IsNullOrWhiteSpace(ApiKeys.HockeyAppiOS) && ApiKeys.HockeyAppiOS != nameof(ApiKeys.HockeyAppiOS))
//            //{
               
//            //    var manager = BITHockeyManager.SharedHockeyManager;
//            //    manager.Configure(ApiKeys.HockeyAppiOS);

//            //    //Disable update manager
//            //    manager.DisableUpdateManager = true;

//            //    manager.StartManager();
//            //    //manager.Authenticator.AuthenticateInstallation();
                   
//            //}
//#endif
//            // Code for starting up the Xamarin Test Cloud Agent
//#if ENABLE_TEST_CLOUD
//            Xamarin.Calabash.Start();
//            //Mapping StyleId to iOS Labels
//            Forms.ViewInitialized += (object sender, ViewInitializedEventArgs e) =>
//                {
//                    if (null != e.View.StyleId)
//                    {
//                        e.NativeView.AccessibilityIdentifier = e.View.StyleId;
//                    }
//                };
//#endif

            Forms.Init();

            SetMinimumBackgroundFetchInterval();

            InitializeDependencies();

            LoadApplication(new App());

            InitializeThemeColors();

            // Process any potential notification data from launch
            ProcessNotification(launchOptions);

            NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidBecomeActiveNotification, DidBecomeActive);

            var shouldPerformAdditionalDelegateHandling = true;

            // Get possible shortcut item
            if (launchOptions != null)
            {
                LaunchedShortcutItem =
                    launchOptions[UIApplication.LaunchOptionsShortcutItemKey] as UIApplicationShortcutItem;
                shouldPerformAdditionalDelegateHandling = (LaunchedShortcutItem == null);
            }

            return base.FinishedLaunching(uiApplication, launchOptions); // && shouldPerformAdditionalDelegateHandling;
        }

        void DidBecomeActive(NSNotification notification)
        {
            ((XamarinEvolve.Clients.UI.App)Xamarin.Forms.Application.Current).SecondOnResume();
        }

        static void InitializeDependencies()
        {
            FormsMaps.Init();
            Toolkit.Init();

            AppIndexing.SharedInstance.RegisterApp(PublicationSettings.iTunesAppId);

            Plugin.Share.ShareImplementation.ExcludedUIActivityTypes = new List<NSString>
                                                                           {
                                                                               UIActivityType
                                                                                   .PostToFacebook,
                                                                               UIActivityType
                                                                                   .AssignToContact,
                                                                               UIActivityType
                                                                                   .OpenInIBooks,
                                                                               UIActivityType
                                                                                   .PostToVimeo,
                                                                               UIActivityType
                                                                                   .PostToFlickr,
                                                                               UIActivityType
                                                                                   .SaveToCameraRoll
                                                                           };
            ImageCircle.Forms.Plugin.iOS.ImageCircleRenderer.Init();
            NonScrollableListViewRenderer.Initialize();
            SelectedTabPageRenderer.Initialize();
            TextViewValue1Renderer.Init();
            PullToRefreshLayoutRenderer.Init();
        }

        static void InitializeThemeColors()
        {
            // Set up appearance after loading theme resources in App.xaml
            PrimaryColor = ((Color)Xamarin.Forms.Application.Current.Resources["Primary"]).ToUIColor();
            UINavigationBar.Appearance.BarTintColor =
                ((Color)Xamarin.Forms.Application.Current.Resources["BarBackgroundColor"]).ToUIColor();
            UINavigationBar.Appearance.TintColor = PrimaryColor; //Tint color of button items
            UIBarButtonItem.Appearance.TintColor = PrimaryColor; //Tint color of button items
            UITabBar.Appearance.TintColor = PrimaryColor;
            UISwitch.Appearance.OnTintColor = PrimaryColor;
            UIAlertView.Appearance.TintColor = PrimaryColor;

            UIView.AppearanceWhenContainedIn(typeof(UIAlertController)).TintColor = PrimaryColor;
            UIView.AppearanceWhenContainedIn(typeof(UIActivityViewController)).TintColor = PrimaryColor;
            UIView.AppearanceWhenContainedIn(typeof(SLComposeViewController)).TintColor = PrimaryColor;
        }

        public override void WillEnterForeground(UIApplication uiApplication)
        {
            base.WillEnterForeground(uiApplication);
            ((XamarinEvolve.Clients.UI.App)Xamarin.Forms.Application.Current).SecondOnResume();
        }

        public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken)
        {

//#if ENABLE_TEST_CLOUD
//#else

//            if (ApiKeys.AzureServiceBusUrl == nameof(ApiKeys.AzureServiceBusUrl))
//                return;

//            // Connection string from your azure dashboard
//            var cs = SBConnectionString.CreateListenAccess(
//                new NSUrl(ApiKeys.AzureServiceBusUrl),
//                ApiKeys.AzureKey);

//            // Register our info with Azure
//            var hub = new SBNotificationHub (cs, ApiKeys.AzureHubName);
//            hub.RegisterNativeAsync (deviceToken, null, err => {
//                if (err != null)
//                    Console.WriteLine("Error: " + err.Description);
//                else
//                    Console.WriteLine("Success");
//            });
//#endif
        }

        public override void ReceivedRemoteNotification(UIApplication app, NSDictionary userInfo)
        {
            // Process a notification received while the app was already open
            ProcessNotification(userInfo);
        }

        public override bool HandleOpenURL(UIApplication application, NSUrl url)
        {
            if (!string.IsNullOrEmpty(url.AbsoluteString))
            {
                ((XamarinEvolve.Clients.UI.App)App.Current).SendOnAppLinkRequestReceived(new Uri(url.AbsoluteString));
                return true;
            }
            return false;
        }

        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
        {
            if (!string.IsNullOrEmpty(url.AbsoluteString))
            {
                ((XamarinEvolve.Clients.UI.App)App.Current).SendOnAppLinkRequestReceived(new Uri(url.AbsoluteString));
                return true;
            }
            return false;
        }

        public override bool OpenUrl(
            UIApplication application,
{'fraction_non_alphanumeric': 0.07124352331606218, 'fraction_numerical': 0.00011775788977861517, 'mean_word_length': 1.4755866491765048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 86, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3920688', 'n_tokens_mistral': 3762, 'n_tokens_neox': 3672, 'n_words': 687}