public SettingsPage(IFileRepository fileRepository, IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents) { Title = "Settings"; _fileRepository = fileRepository; _applicationEvents = applicationEvents; InitializeStorageSettings(fileRepository); InitializeDropboxSettings(externalBrowserService, applicationEvents); var autoSyncValue = new EntryCell { Label = "Interval in minutes", IsEnabled = PersistedState.SyncInterval > 0, Text = PersistedState.SyncInterval > 0 ? PersistedState.SyncInterval.ToString() : string.Empty }; var autoSyncSwitch = new SwitchCell { Text = "Auto sync", On = PersistedState.SyncInterval > 0 }; autoSyncSwitch.OnChanged += (sender, args) => { if (args.Value) { autoSyncValue.Text = "10"; autoSyncValue.IsEnabled = true; SetSyncInterval(10); } else { autoSyncValue.Text = string.Empty; autoSyncValue.IsEnabled = false; SetSyncInterval(0); } }; autoSyncValue.Completed += (sender, args) => { int value; SetSyncInterval(int.TryParse(autoSyncValue.Text, out value) ? value : 0); }; Content = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection("Storage") { _customStorageSwitch, _customStorageDirectoryEntry }, new TableSection("Cloud sync") { autoSyncSwitch, autoSyncValue, _dropboxSwitch } } }; }
public async void AskUserForPermission(IExternalBrowserService externalBrowserService) { _client = new DropNetClient(AppKey, AppSecret); var token = await _client.GetRequestToken(); var url = _client.BuildAuthorizeUrl(token); externalBrowserService.OpenUrl(url); }
public async void AskUserForPermission(IExternalBrowserService externalBrowserService) { _client = new DropNetClient(AppKey, AppSecret); var token = await _client.GetRequestToken(); var url = _client.BuildAuthorizeUrl(token); externalBrowserService.OpenUrl(url); }
public static void Initialize(PageService pageService, IFileRepository fileRepository, IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents) { Current = new PageFactory { _pageService = pageService, _fileRepository = fileRepository, _externalBrowserService = externalBrowserService, _applicationEvents = applicationEvents }; }
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()); }
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()); }
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); }; }
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); }; }
public EmaWebView(IExternalBrowserService externalBrowserService) { _externalBrowserService = externalBrowserService; VerticalOptions = LayoutOptions.FillAndExpand; Navigating += WebViewOnNavigating; }
/// <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 }); }
/// <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 }); }
public static void Initialize(PageService pageService, IFileRepository fileRepository, IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents) { Current = new PageFactory { _pageService = pageService, _fileRepository = fileRepository, _externalBrowserService = externalBrowserService, _applicationEvents = applicationEvents }; }
public EmaWebView(IExternalBrowserService externalBrowserService) { _externalBrowserService = externalBrowserService; VerticalOptions = LayoutOptions.FillAndExpand; Navigating += WebViewOnNavigating; }
public SettingsPage(IFileRepository fileRepository, IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents) { Title = "Settings"; _fileRepository = fileRepository; _applicationEvents = applicationEvents; InitializeStorageSettings(fileRepository); InitializeDropboxSettings(externalBrowserService, applicationEvents); var autoSyncValue = new EntryCell { Label = "Interval in minutes", IsEnabled = PersistedState.SyncInterval > 0, Text = PersistedState.SyncInterval > 0 ? PersistedState.SyncInterval.ToString() : string.Empty }; var autoSyncSwitch = new SwitchCell { Text = "Auto sync", On = PersistedState.SyncInterval > 0 }; autoSyncSwitch.OnChanged += (sender, args) => { if (args.Value) { autoSyncValue.Text = "10"; autoSyncValue.IsEnabled = true; SetSyncInterval(10); } else { autoSyncValue.Text = string.Empty; autoSyncValue.IsEnabled = false; SetSyncInterval(0); } }; autoSyncValue.Completed += (sender, args) => { int value; SetSyncInterval(int.TryParse(autoSyncValue.Text, out value) ? value : 0); }; Content = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection("Storage") { _customStorageSwitch, _customStorageDirectoryEntry }, new TableSection("Cloud sync") { autoSyncSwitch, autoSyncValue, _dropboxSwitch } } }; }