Beispiel #1
0
        public App()
        {
            if (Config == null)
            {
                Config = new Configuration();
                IPlatformInfo platformInfo = DependencyService.Get <IPlatformInfo>();
                CrossLogger.Current.Info("Kala", "Model: " + platformInfo.GetModel());
                CrossLogger.Current.Info("Kala", "Version: " + platformInfo.GetVersion());
                CrossLogger.Current.Info("Kala", "Wifi MAC address: " + platformInfo.GetWifiMacAddress());

                CrossLogger.Current.Debug("Kala", @"URL Settings: '" + Settings.Protocol + "://" + Settings.Server + ":" + Settings.Port.ToString() + "'");
                CrossLogger.Current.Debug("Kala", @"Auth Settings: '" + Settings.Username + " / " + Settings.Password + "'");
                CrossLogger.Current.Debug("Kala", @"Sitemap Settings: '" + Settings.Sitemap + "'");
            }

            //Initialize FFImageLoading with Authentication
            FFImageLoading.AuthenticatedHttpImageClientHandler.Initialize();

            //TabbedPage setup
            if (Tp.Children.Count == 0)
            {
                Tp.BackgroundColor    = Config.BackGroundColor;
                Tp.BarBackgroundColor = Config.BackGroundColor;
                Tp.BarTextColor       = Config.TextColor;

                Tp.CurrentPageChanged += (sender, e) =>
                {
                    //Reset screensaver timer
                    Config.LastActivity = DateTime.Now;
                    CrossLogger.Current.Debug("Kala", "Reset Screensaver timer");
                };

                //Auto configured sitemap?
                var WifiMac = DependencyService.Get <IPlatformInfo>().GetWifiMacAddress();
                Sitemaps = Sitemap.GetActiveSitemap(WifiMac);

                if (Sitemaps == null)
                {
                    Sitemaps = Sitemap.GetActiveSitemap(Settings.Sitemap);

                    //Selected sitemap was not found, display settings page to make change
                    if (Sitemaps == null)
                    {
                        //Add settings tab with Wifi Mac as default
                        Settings.Sitemap = WifiMac;
                        MainPage         = new Pages.Settings();
                    }
                }

                if (Sitemaps != null)
                {
                    Sitemap sitemap = new Sitemap();
                    sitemap.GetUpdates();
                    sitemap.CreateSitemap(Sitemaps);
                    CrossLogger.Current.Debug("Kala", "Got Sitemaps");

                    if (Config.Settings)
                    {
                        //Add settings tab last
                        Tp.Children.Add(new Pages.Settings());
                    }
                    MainPage = Tp;
                }
            }
            else
            {
                MainPage = Tp;
            }
            Config.Initialized = true;
        }