コード例 #1
0
        private async void OpenDeveloperMessage(DeveloperMessage message)
        {
            await Task.Delay(700);

            developerMessageFlyout.InitFlyout(message);
            developerMessageFlyout.Visibility = Visibility.Visible;
            VisualStateManager.GoToState(this, "OverlayScreen", false);

            AnalyticsHelper.Log("flyoutShow", "developerMessage", message.id);
        }
コード例 #2
0
        private void WhatsNewFlyout_FlyoutCloseRequest(object sender, EventArgs e)
        {
            CloseOverlays();

            // If there's a new developer message available, show it now.
            if (developerMessage != null)
            {
                OpenDeveloperMessage(developerMessage);
                developerMessage = null;
            }
        }
コード例 #3
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize);

                SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;

                // Update app constants from server
                AppConstants.Update();

                // Update assets from server
                AssetManager.UpdateAssets();

                // Play silent sound to avoid suspending the app when it's minimized.
                silentMediaPlayer.Play();

                // Media controls are necessary for the audio to continue when app is minimized.
                MediaControlsHelper.Init(Dispatcher);
                MediaControlsHelper.TrackChanged += (ss, trackChangedArgs) =>
                {
                    if (nowPlaying.IsOpen)
                    {
                        nowPlaying.PlayChangeTrackAnimation(
                            reverse: (trackChangedArgs.Direction == TrackChangeDirection.Backward));
                    }
                };

                // Show what's new if necessary
                if (WhatsNewHelper.ShouldShowWhatsNew())
                {
                    shouldShowWhatsNew = true;
                }

                LyricsViewerIntegrationHelper.InitIntegration();
                LiveTileHelper.InitLiveTileUpdates();
                JumpListHelper.DeleteRecentJumplistEntries();

                AnalyticsHelper.PageView("MainPage", setNewSession: true);
                AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString());

                developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage();

                // Window.Current.CoreWindow.KeyDown does not capture Alt events, but AcceleratorKeyActivated does.
                // NOTE: This event captures all key events, even when WebView is focused.
                CoreWindow.GetForCurrentThread().Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;
            }
            catch (Exception ex)
            {
                AnalyticsHelper.Log("mainPageLoadedException", ex.Message, ex.ToString());
                await new MessageDialog(ex.ToString(), "MainPage:Loaded unhandled exception").ShowAsync();
            }
        }
コード例 #4
0
        private void OnWebViewLoadCompleted()
        {
            if (shouldShowWhatsNew)
            {
                flyoutContainer.OpenWhatsNew();
                shouldShowWhatsNew = false;
            }

            if (developerMessage != null)
            {
                flyoutContainer.OpenDeveloperMessage(developerMessage);
                developerMessage = null;
            }
        }
コード例 #5
0
        public async void OpenDeveloperMessage(DeveloperMessage message)
        {
            await Task.Delay(700);

            while (whatsNewFlyout.Visibility == Visibility.Visible)
            {
                await Task.Delay(500);
            }

            developerMessageFlyout.InitFlyout(message);
            developerMessageFlyout.Visibility = Visibility.Visible;
            VisualStateManager.GoToState(this, nameof(OverlayVisibleVisualState), false);

            AnalyticsHelper.Log("flyoutShow", "developerMessage", message.id);
        }
コード例 #6
0
ファイル: MainPage.xaml.cs プロジェクト: SergeyZa/Xpotify
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize);

            SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;

            // Update app constants from server
            AppConstants.Update();

            // Update assets from server
            AssetManager.UpdateAssets();

            // Play silent sound to avoid suspending the app when it's minimized.
            silentMediaPlayer.Play();

            // Media controls are necessary for the audio to continue when app is minimized.
            MediaControlsHelper.Init(Dispatcher);
            MediaControlsHelper.TrackChanged += (ss, trackChangedArgs) =>
            {
                if (nowPlaying.IsOpen)
                {
                    nowPlaying.PlayChangeTrackAnimation(
                        reverse: (trackChangedArgs.Direction == TrackChangeDirection.Backward));
                }
            };

            // Show what's new if necessary
            if (WhatsNewHelper.ShouldShowWhatsNew())
            {
                shouldShowWhatsNew = true;
            }

            AnalyticsHelper.PageView("MainPage");
            AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString());

            developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage();

            LyricsViewerIntegrationHelper.InitIntegration();
            LiveTileHelper.InitLiveTileUpdates();
            JumpListHelper.DeleteRecentJumplistEntries();
        }
コード例 #7
0
 public void InitFlyout(DeveloperMessage message)
 {
     messageTitle.Text   = message.title;
     messageContent.Text = message.content;
     messageDate.Text    = TimeAgo(message.messageDate);
 }
コード例 #8
0
 public Task SetDeveloperMessagesAsync(DeveloperMessage messages) => SetRecordDataAsync(RecordType.DeveloperMessages, messages);
コード例 #9
0
        private async void MainWebView_LoadCompleted(object sender, NavigationEventArgs e)
        {
            if (e.Uri.ToString().StartsWith(Authorization.SpotifyLoginUri) && LocalConfiguration.IsLoggedInByFacebook)
            {
                if (await WebViewHelper.TryPushingFacebookLoginButton())
                {
                    logger.Info("Pushed the facebook login button.");
                    return;
                }
            }

            if (e.Uri.ToString().StartsWith("https://open.spotify.com/static/offline.html?redirectUrl="))
            {
                var url = e.Uri.ToString();

                logger.Info("Clearing local storage and redirecting...");
                var result = await WebViewHelper.ClearPlaybackLocalStorage();

                try
                {
                    if (result.Length > 0)
                    {
                        initialPlaybackState = JsonConvert.DeserializeObject <LocalStoragePlayback>(result);
                        logger.Info("initial playback volume = " + initialPlaybackState.volume);
                    }
                    else
                    {
                        logger.Info("localStorage.playback was undefined.");
                    }
                }
                catch
                {
                    logger.Warn("Decoding localStorage.playback failed.");
                    logger.Info("localStorage.playback content was: " + result);
                }

                var urlDecoder = new WwwFormUrlDecoder(url.Substring(url.IndexOf('?') + 1));
                WebViewHelper.Navigate(new Uri(urlDecoder.GetFirstValueByName("redirectUrl")));

                return;
            }

            if (e.Uri.ToString().ToLower().Contains(WebViewHelper.SpotifyPwaUrlBeginsWith.ToLower()))
            {
                var justInjected = await WebViewHelper.InjectInitScript(ThemeHelper.GetCurrentTheme() == Theme.Light);

                if (justInjected)
                {
                    SetInitialPlaybackState();
                }

                if (autoPlayAction != AutoPlayAction.None)
                {
                    AutoPlayOnStartup(autoPlayAction);
                    autoPlayAction = AutoPlayAction.None;
                }
            }

            var currentStateName = VisualStateManager.GetVisualStateGroups(mainGrid).FirstOrDefault().CurrentState.Name;

            if (currentStateName == "SplashScreen" || currentStateName == "LoadFailedScreen")
            {
                if (e.Uri.ToString().ToLower().Contains(WebViewHelper.SpotifyPwaUrlBeginsWith.ToLower()))
                {
                    VisualStateManager.GoToState(this, "MainScreen", false);
                }
                else
                {
                    VisualStateManager.GoToState(this, "MainScreenQuick", false);
                }

                if (shouldShowWhatsNew)
                {
                    OpenWhatsNew();
                }
                else if (developerMessage != null)
                {
                    // Don't show developer message now if what's new is being shown.
                    // It'll be shown after user closes the what's new flyout.
                    OpenDeveloperMessage(developerMessage);
                    developerMessage = null;
                }
            }

            if (e.Uri.ToString().StartsWith(Authorization.RedirectUri))
            {
                FinalizeAuthorization(e.Uri.ToString());
            }

            if (!await WebViewHelper.CheckLoggedIn())
            {
                Authorize("https://accounts.spotify.com/login?continue=https%3A%2F%2Fopen.spotify.com%2F", clearExisting: true);
                AnalyticsHelper.Log("mainEvent", "notLoggedIn");
            }
        }
コード例 #10
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            InitTitleBar();
            ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize);
            Window.Current.CoreWindow.Activated += Window_Activated;

            SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;

            // Update app constants from server
            AppConstants.Update();

            // Update assets from server
            AssetManager.UpdateAssets();

            // Play silent sound to avoid suspending the app when it's minimized.
            silentMediaPlayer.Play();

            // Media controls are necessary for the audio to continue when app is minimized.
            var mediaControls = SystemMediaTransportControls.GetForCurrentView();

            mediaControls.IsEnabled         = true;
            mediaControls.IsPreviousEnabled = true;
            mediaControls.IsNextEnabled     = true;
            mediaControls.IsPlayEnabled     = true;
            mediaControls.IsPauseEnabled    = true;
            mediaControls.PlaybackStatus    = MediaPlaybackStatus.Paused;
            mediaControls.ButtonPressed    += SystemControls_ButtonPressed;
            await mediaControls.DisplayUpdater.CopyFromFileAsync(MediaPlaybackType.Music,
                                                                 await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Media/silent.wav")));

            PlayStatusTracker.MediaControls = mediaControls;
            PlayStatusTracker.StartRegularRefresh();

            // Show what's new if necessary
            if (WhatsNewHelper.ShouldShowWhatsNew())
            {
                shouldShowWhatsNew = true;
            }

            webViewCheckTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1),
            };
            webViewCheckTimer.Tick += WebViewCheckTimer_Tick;
            webViewCheckTimer.Start();

            clipboardCheckTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(3),
            };
            clipboardCheckTimer.Tick += ClipboardCheckTimer_Tick;
            clipboardCheckTimer.Start();

            stuckDetectTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(4),
            };
            stuckDetectTimer.Tick += StuckDetectTimer_Tick;
            stuckDetectTimer.Start();

            AnalyticsHelper.PageView("MainPage");
            AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString());

            if (ThemeHelper.GetCurrentTheme() == Theme.Light)
            {
                splashScreenToLightStoryboard.Begin();
            }

            developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage();

            LyricsViewerIntegrationHelper.InitIntegration();
            LiveTileHelper.InitLiveTileUpdates();
            JumpListHelper.DeleteRecentJumplistEntries();
        }