private async void LoginSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var login = e.SelectedItem as VaultListPageModel.AutofillLogin;

            if (login == null)
            {
                return;
            }

            if (Uri.StartsWith("http") && _deviceInfoService.Version < 21)
            {
                MoreClickedAsync(login);
            }
            else
            {
                bool doAutofill = true;
                if (login.Fuzzy)
                {
                    doAutofill = await UserDialogs.ConfirmAsync(
                        string.Format(AppResources.BitwardenAutofillServiceMatchConfirm, _name),
                        okText : AppResources.Yes, cancelText : AppResources.No);
                }

                if (doAutofill)
                {
                    GoogleAnalyticsService.TrackExtensionEvent("AutoFilled", Uri.StartsWith("http") ? "Website" : "App");
                    MessagingCenter.Send(Application.Current, "Autofill", login as VaultListPageModel.Login);
                }
            }

            ((ListView)sender).SelectedItem = null;
        }
        private async void CipherSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var cipher = e.SelectedItem as AutofillCipher;

            if (cipher == null)
            {
                return;
            }

            if (_deviceInfoService.Version < 21)
            {
                Helpers.CipherMoreClickedAsync(this, cipher, true);
            }
            else
            {
                bool doAutofill = true;
                if (cipher.Fuzzy)
                {
                    doAutofill = await DisplayAlert(null,
                                                    string.Format(AppResources.BitwardenAutofillServiceMatchConfirm, _name),
                                                    AppResources.Yes, AppResources.No);
                }

                if (doAutofill)
                {
                    GoogleAnalyticsService.TrackExtensionEvent("AutoFilled", Uri.StartsWith("http") ? "Website" : "App");
                    DeviceActionService.Autofill(cipher);
                }
            }

            ((ListView)sender).SelectedItem = null;
        }
Exemple #3
0
 partial void SelectBarButton_Activated(UIBarButtonItem sender)
 {
     GoogleAnalyticsService.TrackExtensionEvent("SelectedGeneratedPassword");
     DismissViewController(true, () =>
     {
         Parent.PasswordCell.TextField.Text = PasswordLabel.Text;
     });
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!SettingsSEO.GoogleAnalyticsApiEnabled)
            {
                return;
            }

            var data = GoogleAnalyticsService.GetData();

            if (data == null)
            {
                return;
            }

            chartData =
                string.Format(
                    "[{{label: '{0}', data:[{1}]}}, {{label: '{2}', data:[{3}]}}, {{label: '{4}', data:[{5}]}}]",
                    Resources.Resource.Admin_Statistics_PageViews, data.Select((pair, valuePair) => string.Format("[{0}, {1}]", GetTimestamp(pair.Key), pair.Value.PageViews)).AggregateString(','),
                    Resources.Resource.Admin_Statistics_Visits, data.Select((pair, valuePair) => string.Format("[{0}, {1}]", GetTimestamp(pair.Key), pair.Value.Visits)).AggregateString(','),
                    Resources.Resource.Admin_Statistics_Visitors, data.Select((pair, valuePair) => string.Format("[{0}, {1}]", GetTimestamp(pair.Key), pair.Value.Visitors)).AggregateString(',')
                    );

            if (data.ContainsKey(DateTime.Now.Date))
            {
                lblViewPagesToday.Text = data[DateTime.Now.Date].PageViews.ToString();
                lblVisitsToday.Text    = data[DateTime.Now.Date].Visits.ToString();
                lblVisitorsToday.Text  = data[DateTime.Now.Date].Visitors.ToString();
            }
            if (data.ContainsKey(DateTime.Now.AddDays(-1).Date))
            {
                lblViewPagesYesterday.Text = data[DateTime.Now.AddDays(-1).Date].PageViews.ToString();
                lblVisitsYesterday.Text    = data[DateTime.Now.AddDays(-1).Date].Visits.ToString();
                lblVisitorsYesterday.Text  = data[DateTime.Now.AddDays(-1).Date].Visitors.ToString();
            }
            if (GoogleAnalyticsService.GetLastModifiedDate() != DateTime.MinValue)
            {
                lDate.Text = string.Format(Resources.Resource.Admin_Statistics_Date, GoogleAnalyticsService.GetLastModifiedDate().ToString(SettingsMain.AdminDateFormat));
            }
        }
 protected override bool OnBackButtonPressed()
 {
     GoogleAnalyticsService.TrackExtensionEvent("BackClosed", Uri.StartsWith("http") ? "Website" : "App");
     DeviceActionService.CloseAutofill();
     return(true);
 }
Exemple #6
0
        private async void CipherSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var cipher = e.SelectedItem as AutofillCipher;

            if (cipher == null)
            {
                return;
            }

            if (_deviceInfoService.Version < 21)
            {
                Helpers.CipherMoreClickedAsync(this, cipher, true);
            }
            else
            {
                var autofillResponse = AppResources.Yes;
                if (cipher.Fuzzy)
                {
                    var options = new List <string> {
                        AppResources.Yes
                    };
                    if (cipher.Type == CipherType.Login && _connectivity.IsConnected)
                    {
                        options.Add(AppResources.YesAndSave);
                    }

                    autofillResponse = await DeviceActionService.DisplayAlertAsync(null,
                                                                                   string.Format(AppResources.BitwardenAutofillServiceMatchConfirm, _name), AppResources.No,
                                                                                   options.ToArray());
                }

                if (autofillResponse == AppResources.YesAndSave && cipher.Type == CipherType.Login)
                {
                    if (!_connectivity.IsConnected)
                    {
                        Helpers.AlertNoConnection(this);
                    }
                    else
                    {
                        var uris = cipher.CipherModel.Login?.Uris?.ToList();
                        if (uris == null)
                        {
                            uris = new List <LoginUri>();
                        }

                        uris.Add(new LoginUri
                        {
                            Uri   = Uri.Encrypt(cipher.CipherModel.OrganizationId),
                            Match = null
                        });

                        cipher.CipherModel.Login.Uris = uris;

                        await DeviceActionService.ShowLoadingAsync(AppResources.Saving);

                        var saveTask = await _cipherService.SaveAsync(cipher.CipherModel);

                        await DeviceActionService.HideLoadingAsync();

                        if (saveTask.Succeeded)
                        {
                            GoogleAnalyticsService.TrackAppEvent("AddedLoginUriDuringAutofill");
                        }
                    }
                }

                if (autofillResponse == AppResources.Yes || autofillResponse == AppResources.YesAndSave)
                {
                    GoogleAnalyticsService.TrackExtensionEvent("AutoFilled",
                                                               Uri.StartsWith("http") ? "Website" : "App");
                    DeviceActionService.Autofill(cipher);
                }
            }

            ((ListView)sender).SelectedItem = null;
        }
 protected override bool OnBackButtonPressed()
 {
     GoogleAnalyticsService.TrackExtensionEvent("BackClosed", Uri.StartsWith("http") ? "Website" : "App");
     MessagingCenter.Send(Application.Current, "Autofill", (VaultListPageModel.Login)null);
     return(true);
 }
        public override void ViewDidLoad()
        {
            _passwordGenerationService = Resolver.Resolve <IPasswordGenerationService>();
            _settings = Resolver.Resolve <ISettings>();
            GoogleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();

            BaseNavItem.Title         = AppResources.PasswordGenerator;
            BaseCancelButton.Title    = AppResources.Cancel;
            BaseSelectBarButton.Title = AppResources.Select;
            View.BackgroundColor      = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);

            var descriptor = UIFontDescriptor.PreferredBody;

            BasePasswordLabel.Font                      = UIFont.FromName("Menlo-Regular", descriptor.PointSize * 1.3f);
            BasePasswordLabel.LineBreakMode             = UILineBreakMode.TailTruncation;
            BasePasswordLabel.Lines                     = 1;
            BasePasswordLabel.AdjustsFontSizeToFitWidth = false;

            var controller = ChildViewControllers.LastOrDefault();

            if (controller != null)
            {
                OptionsTableViewController = controller as UITableViewController;
            }

            if (OptionsTableViewController != null)
            {
                OptionsTableViewController.TableView.RowHeight          = UITableView.AutomaticDimension;
                OptionsTableViewController.TableView.EstimatedRowHeight = 70;
                OptionsTableViewController.TableView.Source             = new TableSource(this);
                OptionsTableViewController.TableView.AllowsSelection    = true;
                OptionsTableViewController.View.BackgroundColor         = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
            }

            UppercaseCell.Switch.On = _settings.GetValueOrDefault(App.Constants.PasswordGeneratorUppercase, true);
            LowercaseCell.Switch.On = _settings.GetValueOrDefault(App.Constants.PasswordGeneratorLowercase, true);
            SpecialCell.Switch.On   = _settings.GetValueOrDefault(App.Constants.PasswordGeneratorSpecial, true);
            NumbersCell.Switch.On   = _settings.GetValueOrDefault(App.Constants.PasswordGeneratorNumbers, true);
            MinNumbersCell.Value    = _settings.GetValueOrDefault(App.Constants.PasswordGeneratorMinNumbers, 1);
            MinSpecialCell.Value    = _settings.GetValueOrDefault(App.Constants.PasswordGeneratorMinSpecial, 1);
            LengthCell.Value        = _settings.GetValueOrDefault(App.Constants.PasswordGeneratorLength, 10);

            UppercaseCell.ValueChanged  += Options_ValueChanged;
            LowercaseCell.ValueChanged  += Options_ValueChanged;
            NumbersCell.ValueChanged    += Options_ValueChanged;
            SpecialCell.ValueChanged    += Options_ValueChanged;
            MinNumbersCell.ValueChanged += Options_ValueChanged;
            MinSpecialCell.ValueChanged += Options_ValueChanged;
            LengthCell.ValueChanged     += Options_ValueChanged;

            // Adjust based on context password options
            if (PasswordOptions != null)
            {
                if (PasswordOptions.RequireDigits)
                {
                    NumbersCell.Switch.On      = true;
                    NumbersCell.Switch.Enabled = false;

                    if (MinNumbersCell.Value < 1)
                    {
                        MinNumbersCell.Value = 1;
                    }

                    MinNumbersCell.Stepper.MinimumValue = 1;
                }

                if (PasswordOptions.RequireSymbols)
                {
                    SpecialCell.Switch.On      = true;
                    SpecialCell.Switch.Enabled = false;

                    if (MinSpecialCell.Value < 1)
                    {
                        MinSpecialCell.Value = 1;
                    }

                    MinSpecialCell.Stepper.MinimumValue = 1;
                }

                if (PasswordOptions.MinLength < PasswordOptions.MaxLength)
                {
                    if (PasswordOptions.MinLength > 0 && PasswordOptions.MinLength > LengthCell.Slider.MinValue)
                    {
                        if (LengthCell.Value < PasswordOptions.MinLength)
                        {
                            LengthCell.Slider.Value = PasswordOptions.MinLength;
                        }

                        LengthCell.Slider.MinValue = PasswordOptions.MinLength;
                    }

                    if (PasswordOptions.MaxLength > 5 && PasswordOptions.MaxLength < LengthCell.Slider.MaxValue)
                    {
                        if (LengthCell.Value > PasswordOptions.MaxLength)
                        {
                            LengthCell.Slider.Value = PasswordOptions.MaxLength;
                        }

                        LengthCell.Slider.MaxValue = PasswordOptions.MaxLength;
                    }
                }
            }

            GeneratePassword();
            if (_isAutofill)
            {
                GoogleAnalyticsService.TrackAutofillExtensionEvent("GeneratedPassword");
            }
            else
            {
                GoogleAnalyticsService.TrackExtensionEvent("GeneratedPassword");
            }
            base.ViewDidLoad();
        }
 public MotionAiApiController(TelegramService client, GoogleAnalyticsService ga)
 {
     _client = client;
     _ga     = ga;
 }