Example #1
0
        private async Task Synchronize()
        {
            if (!SyncBootstrapper.CanSync)
            {
                await DisplayAlert("Synchronization", "Please configure the synchronizationoptions first (via settings)", "OK");
            }
            else
            {
                await SyncBootstrapper.StartNow();

                var ex = SyncBootstrapper.ConsumeSyncException();
                if (ex != null)
                {
                    await DisplayAlert("Not good", "An error occurred while synchronizing: " + ex.Message, "OK");
                }
            }
        }
Example #2
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);
        }
Example #3
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());
        }
Example #4
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);
     };
 }
Example #5
0
        /// <summary>
        /// constructor; builds the page and controls.
        /// </summary>
        public EmaWikiPage(PageService pageService, IExternalBrowserService externalBrowserService)
        {
            _pageService = pageService;

            _searchBar = new SearchBar
            {
                Placeholder = "Search in wiki",
                IsVisible   = false
            };
            _searchBar.SearchButtonPressed += SearchBarOnSearchButtonPressed;

            var syncProgress = new SyncProgressContentView {
                IsVisible = false
            };

            SyncBootstrapper.ShowSyncProgressIn(syncProgress);

            //prominent: the webview.
            _webView              = new EmaWebView(externalBrowserService);
            _webView.RequestPage += (sender, args) => GoTo(args.PageName);
            _webView.RequestEdit += (sender, args) => EditCurrentPage();

            Content = new StackLayout
            {
                Children =
                {
                    _searchBar,
                    syncProgress,
                    _webView
                }
            };

            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Home",
                Icon    = "ic_menu_home.png",
                Command = new Command(() => GoTo(PageService.DefaultPage)),
                Order   = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Edit",
                Icon    = "ic_menu_edit.png",
                Command = new Command(EditCurrentPage),
                Order   = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Search",
                Icon    = "ic_menu_search.png",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(() =>
                {
                    _searchBar.Text      = "";
                    _searchBar.IsVisible = !_searchBar.IsVisible;

                    if (_searchBar.IsVisible)
                    {
                        _searchBar.Focus();
                    }
                })
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Refresh",
                Command = new Command(Refresh),
                Order   = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Icon    = "ic_menu_upload.png",
                Text    = "Synchronize",
                Command = new Command(async() => await Synchronize()),
                Order   = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Preferences",
                Icon    = "ic_menu_preferences.png",
                Command = new Command(Settings),
                Order   = ToolbarItemOrder.Secondary
            });
        }
Example #6
0
 private void SetSyncInterval(int interval)
 {
     PersistedState.SyncInterval = interval;
     SyncBootstrapper.RefreshFromSyncInterval();
 }