Example #1
0
        public static uint GetMaximumCacheSize(this ISettingsService @this)
        {
            if (@this == null)
            {
                throw new ArgumentNullException("this");
            }

            if (InAppPurchases.HasFeature(GoogleMusicFeatures.Offline))
            {
                return(@this.GetValue <uint>(MaximumCacheSizeKey, defaultValue: MaximumOfflineSongsCount));
            }

            return(MaximumOfflineSongsCount);
        }
        private void UpdateAdControl()
        {
            if (InAppPurchases.HasFeature(GoogleMusicFeatures.AdFree))
            {
                if (this.adControl != null)
                {
                    this.SnappedGrid.Children.Remove(this.adControl);
                    this.adControl.ErrorOccurred -= this.AdControlOnErrorOccurred;
                    this.adControl = null;

                    this.SnappedGrid.Children.Remove(this.adReplacementButton);
                    this.adReplacementButton = null;
                }
            }
            else
            {
                if (this.adControl == null)
                {
                    this.adReplacementButton = new HyperlinkButton
                    {
                        Style = (Style)Application.Current.Resources["SnappedViewAdReplacement"]
                    };

                    Grid.SetRow(this.adReplacementButton, 6);
                    Canvas.SetZIndex(this.adReplacementButton, 0);
                    this.SnappedGrid.Children.Add(this.adReplacementButton);

                    this.adControl = new AdControl
                    {
                        ApplicationId       = "8eb9e14b-2133-40db-9500-14eff7c05aab",
                        AdUnitId            = "156438",
                        Width               = 300,
                        Height              = 250,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        UseStaticAnchor     = true
                    };

                    this.adControl.ErrorOccurred += this.AdControlOnErrorOccurred;
                    Grid.SetRow(this.adControl, 6);
                    Canvas.SetZIndex(this.adControl, 100);
                    this.SnappedGrid.Children.Add(this.adControl);
                }
            }
        }
        public static void Initialize(IApplicationSettingViewsService service, IApplicationResources resources)
        {
            service.RegisterSettings <AccountsView>("accounts", resources.GetString("SettingsAccountTitle"));
            service.RegisterSettings <AppSettingsView>("appsettings", resources.GetString("SettingsAppSettingsTitle"));
            service.RegisterSettings <OfflineCacheView>("offlinecache", resources.GetString("OfflineCacheAppSettingsTitle"), ApplicationSettingLayoutType.Large);

            bool upgradeViewRegistered = false;

            if (!InAppPurchases.HasFeature(GoogleMusicFeatures.All))
            {
                service.RegisterSettings <UpgradeView>("upgrade", resources.GetString("SettingsUpgradeTitle"));
                upgradeViewRegistered = true;
            }

            service.RegisterSettings <SupportView>("support", resources.GetString("SettingsSupportTitle"));
            service.RegisterSettings <PrivacyView>("privacy", resources.GetString("SettingsPrivacyPolicyTitle"));
            service.RegisterSettings <LegalView>("legal", resources.GetString("SettingsLegalTitle"));

            InAppPurchases.LicenseChanged += () =>
            {
                if (!InAppPurchases.HasFeature(GoogleMusicFeatures.All))
                {
                    if (!upgradeViewRegistered)
                    {
                        service.RegisterSettings <UpgradeView>("upgrade", "SettingsUpgradeTitle", ApplicationSettingLayoutType.Standard, "accounts");
                        upgradeViewRegistered = true;
                    }
                }
                else
                {
                    if (upgradeViewRegistered)
                    {
                        service.UnregisterSettings("upgrade");
                        upgradeViewRegistered = false;
                    }
                }
            };

#if DEBUG
            InAppPurchases.SimulatorInAppPurchasesInitialization();
#endif
        }