Exemple #1
0
        private async void ApplicationEventsOnResumed(object sender, EventArgs eventArgs)
        {
            _applicationEvents.Resumed -= ApplicationEventsOnResumed;
            if (_dropboxUserPermission != null)
            {
                var userPermission = await _dropboxUserPermission.VerifiedUserPermission();

                if (string.IsNullOrEmpty(userPermission.Token))
                {
                    _dropboxSwitch.On = false;
                    await DisplayAlert("Not good", "Dropbox did not return a valid token.", "OK");
                }
                else
                {
                    PersistedState.UserLogin = userPermission;
                }
            }
            SyncBootstrapper.RefreshDropboxSync(_fileRepository);
        }
Exemple #2
0
        public App(IFileRepository fileRepository, IExternalBrowserService externalBrowserService)
        {
            var service = new PageService(new WikiStorage(fileRepository), new HtmlWrapper(fileRepository), new MarkdownImpl());

            _applicationEvents = new ApplicationEvents();

            try
            {
                fileRepository.StorageDirectory = PersistedState.CustomStorageDirectory;
            }
            catch
            {
                //can't do much about it now.
            }

            PageFactory.Initialize(service, fileRepository, externalBrowserService, _applicationEvents);

            SyncBootstrapper.RefreshDropboxSync(fileRepository);
            SyncBootstrapper.RefreshFromSyncInterval();

            MainPage = new NavigationPage(PageFactory.Current.CreateEmaWikiPage());
        }
Exemple #3
0
 private void InitializeDropboxSettings(IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents)
 {
     _dropboxSwitch = new SwitchCell
     {
         Text = "Use Dropbox",
         On   = PersistedState.UserLogin != null && !string.IsNullOrEmpty(PersistedState.UserLogin.Secret)
     };
     _dropboxSwitch.OnChanged += (sender, args) =>
     {
         if (args.Value)
         {
             applicationEvents.Resumed += ApplicationEventsOnResumed;
             _dropboxUserPermission     = new DropboxUserPermission();
             _dropboxUserPermission.AskUserForPermission(externalBrowserService);
             //(continue in ApplicationEventsOnResumed())
         }
         else
         {
             PersistedState.UserLogin = null;
         }
         SyncBootstrapper.RefreshDropboxSync(_fileRepository);
     };
 }