Esempio n. 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (navParam == NavigationParameter.UriLaunch &&
                NavigationContext.QueryString.ContainsKey("backup"))
            {
                _settingsViewModel.ProcessBackupLink();
            }

            if (navParam == NavigationParameter.AutoCameraUpload)
            {
                App.AppInformation.IsStartedAsAutoUpload = false;
                MainSettingsPivot.SelectedItem           = PivotAutoUpload;
            }

            DebugPanel.DataContext = DebugService.DebugSettings;

            #if WINDOWS_PHONE_81
            ((SettingsViewModel)this.DataContext).StandardDownloadLocation = SettingsService.LoadSetting <string>(
                SettingsResources.DefaultDownloadLocation, UiResources.DefaultDownloadLocation);
            #endif
        }
Esempio n. 2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (Convert.ToBoolean(SdkService.MegaSdk.isLoggedIn()))
            {
                SdkService.MegaSdk.logout(new LogOutRequestListener(false));
            }

            if (NavigationContext.QueryString.ContainsKey("Pivot"))
            {
                var index       = NavigationContext.QueryString["Pivot"];
                var indexParsed = int.Parse(index);
                Pivot_LoginAndCreateAccount.SelectedIndex = indexParsed;
            }

            // Remove the main page from the stack. If user presses back button it will then exit the application
            // Also removes the create account page after the user has created the account succesful
            // Also removes the settings page when the user has selected app in auto upload but was not logged in.
            while (NavigationService.CanGoBack)
            {
                NavigationService.RemoveBackEntry();
            }

            if (NavigateService.ProcessQueryString(NavigationContext.QueryString) == NavigationParameter.UriLaunch &&
                NavigationContext.QueryString.ContainsKey("newsignup"))
            {
                _loginAndCreateAccountViewModelContainer.CreateAccountViewModel.NewSignUpCode =
                    HttpUtility.UrlDecode(NavigationContext.QueryString["newsignup"]);

                SdkService.MegaSdk.querySignupLink(_loginAndCreateAccountViewModelContainer.CreateAccountViewModel.NewSignUpCode,
                                                   new CreateAccountRequestListener(_loginAndCreateAccountViewModelContainer.CreateAccountViewModel, this));
            }
        }
Esempio n. 3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (navParam == NavigationParameter.Downloads)
            {
                TransfersPivot.SelectedItem = DownloadsPivot;
            }
            else if (navParam == NavigationParameter.Uploads)
            {
                TransfersPivot.SelectedItem = UploadsPivot;
            }

            if (!NetworkService.IsNetworkAvailable())
            {
                UpdateGUI(false);
                return;
            }

            // Needed on every UI interaction
            SdkService.MegaSdk.retryPendingConnections();

            _transfersViewModel.Update();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (navParam == NavigationParameter.Downloads)
            {
                TransfersPivot.SelectedItem = DownloadsPivot;
            }

            if (navParam == NavigationParameter.PictureSelected)
            {
                NavigationService.RemoveBackEntry();
            }

            if (navParam == NavigationParameter.AlbumSelected || navParam == NavigationParameter.SelfieSelected)
            {
                NavigationService.RemoveBackEntry();
                NavigationService.RemoveBackEntry();
            }

            if (!NetworkService.IsNetworkAvailable())
            {
                UpdateGUI(false);
                return;
            }

            // Needed on every UI interaction
            App.MegaSdk.retryPendingConnections();

            TransfersService.UpdateMegaTransfersList(App.MegaTransfers);
            _transfersViewModel.MegaTransfers = App.MegaTransfers;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Remove the main page from the stack. If user presses back button it will then exit the application
            // Also removes the login page and the create account page after the user has created the account succesful
            while (NavigationService.CanGoBack)
            {
                NavigationService.RemoveBackEntry();
            }

            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            // Try to avoid display duplicate alerts
            if (isAlertAlreadyDisplayed)
            {
                return;
            }
            isAlertAlreadyDisplayed = true;

            switch (navParam)
            {
            case NavigationParameter.CreateAccount:
                // Show the success message
                new CustomMessageDialog(
                    AppMessages.ConfirmNeeded_Title,
                    AppMessages.ConfirmNeeded,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                break;

            case NavigationParameter.API_ESID:
                // Show a message notifying the error
                new CustomMessageDialog(
                    AppMessages.SessionIDError_Title,
                    AppMessages.SessionIDError,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                break;

            case NavigationParameter.API_EBLOCKED:
                // Show a message notifying the error
                new CustomMessageDialog(
                    AppMessages.AM_AccountBlocked_Title,
                    AppMessages.AM_AccountBlocked,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                break;

            case NavigationParameter.API_ESSL:
                // Show a message notifying the error
                new CustomMessageDialog(
                    AppMessages.SSLKeyError_Title,
                    AppMessages.SSLKeyError,
                    App.AppInformation,
                    MessageDialogButtons.Ok).ShowDialog();
                break;
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            _myAccountPageViewModel.Initialize(App.GlobalDriveListener);

            // Get last page (previous page)
            var backStack = ((PhoneApplicationFrame)Application.Current.RootVisual).BackStack;
            var lastPage  = backStack.FirstOrDefault();

            if (lastPage != null)
            {
                // If navigation is from the PaymentPage, remove the last entry of the back stack
                if (lastPage.Source.ToString().Contains((typeof(PaymentPage)).Name))
                {
                    ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                }
            }

            if (NavigateService.ProcessQueryString(NavigationContext.QueryString) == NavigationParameter.AccountUpdate)
            {
                _myAccountPageViewModel.IsAccountUpdate = true;
                PivotAccountInformation.SelectedItem    = PivotSubscription;
            }
            // Check if the navigation destiny is a specific pivot item
            else if (NavigationContext.QueryString.ContainsKey("Pivot"))
            {
                var index = NavigationContext.QueryString["Pivot"];
                if (!String.IsNullOrWhiteSpace(index))
                {
                    int indexParsed;
                    if ((int.TryParse(index, out indexParsed)) &&
                        (indexParsed < PivotAccountInformation.Items.Count))
                    {
                        PivotAccountInformation.SelectedIndex = indexParsed;
                    }
                }
            }

            if (!NetworkService.IsNetworkAvailable())
            {
                UpdateGUI(false);
                return;
            }

            SetAvatarColor();
        }
Esempio n. 7
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (e.NavigationMode == NavigationMode.Back)
            {
                App.CloudDrive.GoFolderUp();
                navParam = NavigationParameter.Browsing;
            }

            switch (navParam)
            {
            case NavigationParameter.Browsing:
            {
                App.CloudDrive.LoadNodes();
                break;
            }

            case NavigationParameter.Login:
            {
                // Remove the login page from the stack. If user presses back button it will then exit the application
                NavigationService.RemoveBackEntry();

                App.CloudDrive.FetchNodes();
                break;
            }

            case NavigationParameter.Unknown:
            {
                if (!SettingsService.LoadSetting <bool>(SettingsResources.RememberMe))
                {
                    NavigateService.NavigateTo(typeof(LoginPage), NavigationParameter.Normal);
                    return;
                }
                else
                {
                    App.MegaSdk.fastLogin(SettingsService.LoadSetting <string>(SettingsResources.UserMegaSession), new FastLoginRequestListener());
                    App.CloudDrive.FetchNodes();
                }
                break;
            }
            }

            base.OnNavigatedTo(e);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (Convert.ToBoolean(SdkService.MegaSdk.isLoggedIn()))
                SdkService.MegaSdk.logout(new LogOutRequestListener(false));

            // Remove all pages from the stack (including the MainPage).
            // If user presses back button should go to InitTourPage or exit the application            
            while (NavigationService.CanGoBack)
                NavigationService.RemoveBackEntry();

            if (NavigateService.ProcessQueryString(NavigationContext.QueryString) == NavigationParameter.UriLaunch
                && NavigationContext.QueryString.ContainsKey("confirm"))
            {
                _confirmAccountViewModel.ConfirmCode = HttpUtility.UrlDecode(NavigationContext.QueryString["confirm"]);                
                SdkService.MegaSdk.querySignupLink(_confirmAccountViewModel.ConfirmCode,
                    new ConfirmAccountRequestListener(_confirmAccountViewModel));
            }
        }
Esempio n. 9
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            SdkService.ApiUrlChanged += OnApiUrlChanged;

            var navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            switch (navParam)
            {
            case NavigationParameter.UriLaunch:
                if (NavigationContext.QueryString.ContainsKey("backup"))
                {
                    _settingsViewModel.ProcessBackupLink();
                }
                break;

            case NavigationParameter.AutoCameraUpload:
                App.AppInformation.IsStartedAsAutoUpload = false;
                this.MainPivot.SelectedItem = PivotAutoUpload;
                break;

            case NavigationParameter.SecuritySettings:
                this.MainPivot.SelectedItem = SecurityPivot;
                break;

            case NavigationParameter.MFA_Enabled:
                this.MainPivot.SelectedItem = SecurityPivot;
                DialogService.ShowMultiFactorAuthEnabledDialog();
                break;
            }

            DebugPanel.DataContext = DebugService.DebugSettings;

            #if WINDOWS_PHONE_81
            ((SettingsViewModel)this.DataContext).StandardDownloadLocation = SettingsService.LoadSetting <string>(
                SettingsResources.DefaultDownloadLocation, UiResources.DefaultDownloadLocation);
            #endif
        }
Esempio n. 10
0
        private void ProcessBackstack(Type page, bool navigateTo)
        {
            bool isMainPage = page == typeof(MainPage);
            var  backStack  = ((PhoneApplicationFrame)Application.Current.RootVisual).BackStack;
            var  lastPage   = backStack.FirstOrDefault();

            // If the previous page is the PasswordPage (PIN lock page), delete it from the stack
            var navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (navParam == NavigationParameter.PasswordLogin)
            {
                if (lastPage == null)
                {
                    return;
                }
                if (lastPage.Source.ToString().Contains(typeof(PasswordPage).Name))
                {
                    ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                }
            }

            // If the previous page is the "FolderLinkPage" delete it from the stack if the
            // current page is not "PreviewImagePage" or "NodeDetailsPage".
            if (page != typeof(PreviewImagePage) || page != typeof(NodeDetailsPage))
            {
                if (lastPage == null)
                {
                    return;
                }
                if (lastPage.Source.ToString().Contains(typeof(FolderLinkPage).Name))
                {
                    ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                }
            }

            if (isMainPage)
            {
                if (navigateTo)
                {
                    if (lastPage == null)
                    {
                        return;
                    }
                    if (lastPage.Source.ToString().Contains(page.Name) || navParam == NavigationParameter.FileLinkLaunch ||
                        navParam == NavigationParameter.FolderLinkLaunch)
                    {
                        ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                    }
                }
                else
                {
                    if (backStack.Count(p => p.Source.ToString().Contains(page.Name)) > 1)
                    {
                        ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                    }
                }
            }
            else
            {
                if (navigateTo)
                {
                    return;
                }
                ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (!NetworkService.IsNetworkAvailable())
            {
                UpdateGUI(false);
                return;
            }

            if (e.NavigationMode == NavigationMode.Reset)
            {
                return;
            }

            _cameraUploadsPageViewModel.Initialize(App.GlobalListener);

            NavigationParameter navParam = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            if (PhoneApplicationService.Current.StartupMode == StartupMode.Activate)
            {
                // Needed on every UI interaction
                SdkService.MegaSdk.retryPendingConnections();

#if WINDOWS_PHONE_81
                // Check to see if any files have been picked
                var app = Application.Current as App;
                if (app != null && app.FilePickerContinuationArgs != null)
                {
                    this.ContinueFileOpenPicker(app.FilePickerContinuationArgs);
                    return;
                }

                if (app != null && app.FolderPickerContinuationArgs != null)
                {
                    FolderService.ContinueFolderOpenPicker(app.FolderPickerContinuationArgs,
                                                           _cameraUploadsPageViewModel.CameraUploads);
                }
#endif
            }

            // Initialize the application bar of this page
            SetApplicationBarData();

            if (e.NavigationMode == NavigationMode.Back)
            {
                navParam = NavigationParameter.Browsing;
            }


            switch (navParam)
            {
            case NavigationParameter.Normal:
                // Check if nodes has been fetched. Because when starting app from OS photo setting to go to
                // Auto Camera Upload settings fetching has been skipped in the mainpage
                if (Convert.ToBoolean(SdkService.MegaSdk.isLoggedIn()) && !App.AppInformation.HasFetchedNodes)
                {
                    _cameraUploadsPageViewModel.FetchNodes();
                }
                else
                {
                    _cameraUploadsPageViewModel.LoadFolders();
                }
                break;

            case NavigationParameter.Login:
                break;

            case NavigationParameter.PasswordLogin:
                break;

            case NavigationParameter.UriLaunch:
                break;

            case NavigationParameter.Browsing:
                // Check if nodes has been fetched. Because when starting app from OS photo setting to go to
                // Auto Camera Upload settings fetching has been skipped in the mainpage
                if (Convert.ToBoolean(SdkService.MegaSdk.isLoggedIn()) && !App.AppInformation.HasFetchedNodes)
                {
                    _cameraUploadsPageViewModel.FetchNodes();
                }
                break;

            case NavigationParameter.BreadCrumb:
                break;

            case NavigationParameter.Uploads:
                break;

            case NavigationParameter.Downloads:
                break;

            case NavigationParameter.DisablePassword:
                break;

            case NavigationParameter.FileLinkLaunch:
            case NavigationParameter.FolderLinkLaunch:
            case NavigationParameter.None:
            {
                if (!App.AppInformation.HasPinLockIntroduced && SettingsService.LoadSetting <bool>(SettingsResources.UserPinLockIsEnabled))
                {
                    NavigateService.NavigateTo(typeof(PasswordPage), NavigationParameter.Normal, this.GetType());
                    return;
                }
                break;
            }
            }
        }
Esempio n. 12
0
        private void ProcessBackstack(Type page, bool navigateTo)
        {
            bool isMainPage = page == typeof(MainPage);
            var  backStack  = ((PhoneApplicationFrame)Application.Current.RootVisual).BackStack;
            var  lastPage   = backStack.FirstOrDefault();
            var  navParam   = NavigateService.ProcessQueryString(NavigationContext.QueryString);

            // In some cases we should remove the last page from the stack
            if (lastPage != null)
            {
                switch (navParam)
                {
                case NavigationParameter.PasswordLogin:
                    // If the previous page is the PasswordPage (PIN lock page)
                    if (lastPage.Source.ToString().Contains(typeof(PasswordPage).Name))
                    {
                        ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                    }
                    break;

                case NavigationParameter.SecuritySettings:
                case NavigationParameter.MFA_Enabled:
                    // If the previous page is the "MultiFactorAuthAppSetupPage"
                    if (lastPage.Source.ToString().Contains(typeof(MultiFactorAuthAppSetupPage).Name))
                    {
                        ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                    }
                    break;
                }

                // If the previous page is the "FolderLinkPage" and the
                // current page is not "PreviewImagePage" or "NodeDetailsPage".
                if (page != typeof(PreviewImagePage) || page != typeof(NodeDetailsPage))
                {
                    if (lastPage.Source.ToString().Contains(typeof(FolderLinkPage).Name))
                    {
                        ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                    }
                }
            }

            if (isMainPage)
            {
                if (navigateTo)
                {
                    if (lastPage == null)
                    {
                        return;
                    }
                    if (lastPage.Source.ToString().Contains(page.Name) || navParam == NavigationParameter.FileLinkLaunch ||
                        navParam == NavigationParameter.FolderLinkLaunch)
                    {
                        ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                    }
                }
                else
                {
                    if (backStack.Count(p => p.Source.ToString().Contains(page.Name)) > 1)
                    {
                        ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
                    }
                }
            }
            else
            {
                if (navigateTo)
                {
                    return;
                }
                ((PhoneApplicationFrame)Application.Current.RootVisual).RemoveBackEntry();
            }
        }