Esempio n. 1
0
        private async void Login_Clicked(object sender, RoutedEventArgs e)
        {
            try
            {
                var uri = await PocketHandler.GetInstance().LoginUriAsync();

                var auth = await WebAuthenticationBroker.
                           AuthenticateAsync(WebAuthenticationOptions.None, uri, new Uri(App.Protocol));

                if (auth.ResponseStatus != WebAuthenticationStatus.Success)
                {
                    return;
                }
                if (await PocketHandler.GetInstance().LoginAsync())
                {
                    Frame.Navigate(typeof(MainContent));
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                var dialog = new MessageDialog("Error.");
                dialog.Commands.Add(new UICommand("Close"));
                await dialog.ShowAsync();
            }
        }
Esempio n. 2
0
        private async void ContentDialog_Loaded(object sender, RoutedEventArgs e)
        {
            var userStatistics = await PocketHandler.GetInstance().UserStatistics();

            if (userStatistics == null)
            {
                return;
            }
            RadialProgressBarControl.Maximum = userStatistics.CountAll;
            RadialProgressBarControl.Value   = userStatistics.CountRead;
            StatisticsCtrl.Header            = $"{userStatistics.CountAll} Articles";
            StatisticsCtrl.Text = $"{userStatistics.CountUnread} Unread Articles";
        }
Esempio n. 3
0
        private static async Task AddToPocketAsync(string arg, bool exit = true)
        {
            try
            {
                var(item1, item2) = await PocketHandler.GetInstance().AddFromShare(new Uri(arg));

                Utils.ToastIt(item1, item2);
                if (exit)
                {
                    Current.Exit();
                }
            }
            catch { }
        }
Esempio n. 4
0
        private async void TopAppBarClick(object sender, RoutedEventArgs e)
        {
            var dialog = new SettingsDialog();
            await dialog.ShowAsync();

            if (dialog.Tag?.ToString() == Keys.Logout)
            {
                PocketHandler.GetInstance().Logout();
                Frame?.Navigate(typeof(Views.LoginPage));
                Frame?.BackStack.Clear();
                return;
            }
            Bindings.Update();
        }
Esempio n. 5
0
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            if (!(Window.Current?.Content is Frame rootFrame))
            {
                rootFrame = new Frame();
                rootFrame.NavigationFailed += OnNavigationFailed;
                Window.Current.Content      = rootFrame;
            }

            if (e != null && e?.PrelaunchActivated != false)
            {
                return;
            }
            if (rootFrame.Content == null)
            {
                var handler = PocketHandler.GetInstance();
                handler.LoadCacheClient();
                rootFrame.Navigate(handler.Client == null ? typeof(LoginPage) : typeof(MainContent), e?.Arguments);
            }
            Window.Current.Activate();
        }