Пример #1
0
        public SearchController(IResourceService resourceService, IUserService userService, IProfileService profileService, ISearchService searchService, IStateService stateService, IConversationService conversationService)
            : base(resourceService, userService, profileService, stateService, conversationService)
        {
            _searchService = searchService;
            ResourceService = resourceService;

        }
Пример #2
0
        public ShellViewModel(
            IFileManagerEventSource fileManagerEventSource,
            IFileManager fileManager,
            IStateService stateService,
            IClipboardService clipboardService)
        {
            _clipboardService = clipboardService;
            _stateService = stateService;
            _stateService.SavingEvent.Subscribe(this.SaveState);
            _fileManager = fileManager;
            fileManagerEventSource.OpenFileEventStream.Subscribe(this.OpenFile);

            this.DisplayName = "Eagle";

            this.FollowTail = true;

            if (Execute.InDesignMode)
            {
                this.IsFileOpen = true;
                this.File = new FileViewModel("Test File");
            }
            else
            {
                //this.FilePicker.Items.Add(new FileLocationViewModel("Documents") { SubLocations = { new FileLocationViewModel("File1"), new FileLocationViewModel("File2"), new FileLocationViewModel("File3") } });
                //this.FilePicker.Items.Add(new FileLocationViewModel("Projects"));
                //this.FilePicker.Items.Add(new FileLocationViewModel("Logs"));
            }
        }
Пример #3
0
 public TrainingCenterController(ICityService cityService, IUnitOfWork unitOfWork, ITrainingCenterService TrainingCenterService, IStateService StateService)
 {
     _unitOfWork = unitOfWork;
     _trainingCenterService = TrainingCenterService;
     _stateService = StateService;
     _cityService = cityService;
 }
 public SettingsController(IStateService stateService, ISpecialityService specialityService,
     IServicePlaceService servicePlaceService)
 {
     _stateService = stateService;
     _specialityService = specialityService;
     _servicePlaceService = servicePlaceService;
 }
Пример #5
0
        public LoginService(IRepository rep, IMenuService menuService, IUserService userService, IStateService stateService)
        {
            _rep = rep;
            _menuService = menuService;
            _userService = userService;
            _stateService = stateService;

        }
Пример #6
0
 public AddressService(IUnitOfWork unitOfWork, IApplicationUserManager userManager, IMappingEngine mappingEngine, IStateService stateService, ICityService cityService)
 {
     _userManager = userManager;
     _unitOfWork = unitOfWork;
     _addresses = _unitOfWork.Set<Address>();
     _mappingEngine = mappingEngine;
     _cityService = cityService;
     _stateService = stateService;
 }
Пример #7
0
 public WorkExperienceService(IUnitOfWork unitOfWork, ICityService cityService, IStateService stateService, IApplicationUserManager userManager, IMappingEngine mappingEngine)
 {
     _userManager = userManager;
     _unitOfWork = unitOfWork;
     _workExperiences = _unitOfWork.Set<WorkExperience>();
     _mappingEngine = mappingEngine;
     _cityService = cityService;
     _stateService = stateService;
 }
Пример #8
0
 public UserService(IProductService productService, INotificationService notificationService, IUserRepositoryDB repository, IProfileRepositoryRavenDB profileRepositoryRaven, IKatushaGlobalCacheContext globalCacheContext, IStateService stateService)
 {
     _productService = productService;
     _notificationService = notificationService;
     _repository = repository;
     _profileRepositoryRaven = profileRepositoryRaven;
     _katushaGlobalCache = globalCacheContext; // new KatushaRavenCacheContext(new CacheObjectRepositoryRavenDB());
     _stateService = stateService;
 }
 protected KatushaBaseController(IResourceService resourceService, IUserService userService, IProfileService profileService, IStateService stateService, IConversationService conversationService)
 {
     ResourceService = resourceService;
     ConversationService = conversationService;
     ProfileService = profileService;
     UserService = userService;
     StateService = stateService;
     UniqueVisitorsResultConverter.GetInstance().ProfileService = profileService;
     ConversationResultTypeConverter.GetInstance().ProfileService = profileService;
 }
Пример #10
0
 public ApiController(IResourceService resourceService, IUserService userService, IProfileService profileService, 
     IConversationService conversationService, IStateService stateService, IUtilityService utilityService,
     ISearchService searchService, IPhotosService photoService
     )
     : base(resourceService, userService, profileService, stateService, conversationService)
 {
     _searchService = searchService;
     _photoService = photoService;
     _utilityService = utilityService;
 }
Пример #11
0
 public ProfileController(IAccountService accountService,
     IStateService stateService,
     ICityService cityService,
     IMessageService messageService)
 {
     this.accountService = accountService;
     this.stateService = stateService;
     this.cityService = cityService;
     this.messageService = messageService;
 }
Пример #12
0
        public TerminalVm(IStateService stateService, ITerminalEvents terminalEvents, ITerminalTasks terminalTasks)
        {
            this.terminalTasks = terminalTasks.notNull();
            this.stateService = stateService.notNull();
            this.terminalEvents = terminalEvents.notNull();

            currentState = stateService.CurrentState;
            terminalEvents.EndOfService += (s, e) => terminalEvents_EndOfTask_handling();
            terminalEvents.OnTouchNumber += (s, e) => terminalEvents_OnTouchNumber_handling();
        }
Пример #13
0
 public InstallController(IEventService eventService, IMenuService menuService, IPageService pageService, IPostService postService, ISettingService settingService, 
     IStateService stateService, ITenantService tenantService)
 {
     _eventService = eventService;
     _menuService = menuService;
     _pageService = pageService;
     _postService = postService;
     _settingService = settingService;
     _stateService = stateService;
     _tenantService = tenantService;
 }
 public PatientsController(IPatientService patientService, IStateService stateService,
     IPracticeService practiceService, INPIService npiService, IPayerService payerService,
     IInsuranceService insuranceService)
 {
     _patientService = patientService;
     _stateService = stateService;
     _practiceService = practiceService;
     _npiService = npiService;
     _payerService = payerService;
     _insuranceService = insuranceService;
 }
Пример #15
0
 public EmployeeController(IEmpDBContext empDBContext, IEmployeeService empService, ICityService cityService, IStateService stateService, IJobService jobService, IDepartmentService departmentService, IWorkingDayService workingdaysService, IShiftService shiftsService)
 {
     db = empDBContext;
     _empService = empService;
     _stateService = stateService;
     _cityService = cityService;
     _jobService = jobService;
     _departmentService = departmentService;
     _workingdayService = workingdaysService;
     _shiftService = shiftsService;
 }
Пример #16
0
 public TrainingCenterService(IUnitOfWork unitOfWork, IApplicationUserManager userManager,
     IStateService StateService, ICityService cityService,
     IMappingEngine mappingEngine)
 {
     _userManager = userManager;
     _unitOfWork = unitOfWork;
     _trainingCenters = _unitOfWork.Set<TrainingCenter>();
     _mappingEngine = mappingEngine;
     _cityService = cityService;
     _stateService = StateService;
 }
Пример #17
0
 public ApplicantService(HttpContextBase httpContextBase, IUnitOfWork unitOfWork, IApplicationUserManager userManager,
     IMappingEngine mappingEngine, IStateService stateService, ICityService cityService
     )
 {
     _userManager = userManager;
     _unitOfWork = unitOfWork;
     _applicants = _unitOfWork.Set<Applicant>();
     _mappingEngine = mappingEngine;
     _cityService = cityService;
     _stateService = stateService;
     _httpContextBase = httpContextBase;
 }
Пример #18
0
 public TeacherController(IUnitOfWork unitOfWork, IApplicationUserManager userManager, IReferentialTeacherService referentialTeacherService,
     ITrainingCenterService trainingCenterService, ITrainingCourseService trainingCourseService, ITitleService titleService,
     ITeacherService TeacherService, IStateService stateService, ICityService cityService)
 {
     _unitOfWork = unitOfWork;
     _userManager = userManager;
     _TeacherService = TeacherService;
     _stateService = stateService;
     _cityService = cityService;
     _trainingCenterService = trainingCenterService;
     _titleService = titleService;
     _referentialTeacherService = referentialTeacherService;
 }
 public UtilitiesController(INotificationService notificationService, IResourceService resourceService, IUserService userService, IProfileService profileService, 
     ISamplesService samplesService, IVisitService visitService, IConversationService conversationService, IStateService stateService,
     IPhotosService photosService, IUtilityService utilityService, IKatushaGlobalCacheContext globalCacheContext
     )
     : base(resourceService, userService, profileService, stateService, conversationService)
 {
     _notificationService = notificationService;
     _globalCacheContext = globalCacheContext;
     _samplesService = samplesService;
     _visitService = visitService;
     _conversationService = conversationService;
     _photosService = photosService;
     _utilityService = utilityService;
 }
Пример #20
0
 public ThingController(
     IThingService thingService,
     ITagService tagService,
     IMaterialService materialService,
     IFormatService formatService,
     IStateService stateService,
     IUserService userService)
 {
     _thingService = thingService;
     _tagService = tagService;
     _materialService = materialService;
     _formatService = formatService;
     _stateService = stateService;
     _userService = userService;
 }
Пример #21
0
 public TeacherService(HttpContextBase httpContextBase, IUnitOfWork unitOfWork, IApplicationUserManager userManager, ITrainingCenterService trainingCenter, ITrainingCourseService trainingCourse,
     IMappingEngine mappingEngine, IReferentialTeacherService referentialTeacherService, ITitleService titleService, IStateService stateService, ICityService cityService
     )
 {
     _userManager = userManager;
     _unitOfWork = unitOfWork;
     _Teachers = _unitOfWork.Set<Teacher>();
     _mappingEngine = mappingEngine;
     _cityService = cityService;
     _stateService = stateService;
     _titleService = titleService;
     _httpContextBase = httpContextBase;
     _referentialTeacherService = referentialTeacherService;
     _trainingCenterService = trainingCenter;
     _trainingCourseService = trainingCourse;
 }
        public ExerciseProgramsViewModelBuilder()
        {
            this.audioService = new AudioServiceMock(MockBehavior.Loose);
            this.delayService = new DelayServiceMock(MockBehavior.Loose);
            this.exerciseDocumentService = new ExerciseDocumentServiceMock(MockBehavior.Loose);
            this.loggerService = new LoggerServiceMock(MockBehavior.Loose);
            this.schedulerService = new SchedulerServiceMock(MockBehavior.Loose);
            this.speechService = new SpeechServiceMock(MockBehavior.Loose);
            this.stateService = new StateServiceMock(MockBehavior.Loose);
            this.hostScreen = new ScreenMock(MockBehavior.Loose);
            this.exerciseProgramViewModelFactory =
                model =>
                    new ExerciseProgramViewModelBuilder()
                        .WithModel(model)
                        .Build();

            this.WithCachedDocument(null);
        }
Пример #23
0
 public AppController(
     IUserService userService,
     ILoginService loginService,
     IPositionService positionService,
     IAlarmService alarmService,
     IMileageReportService mileageReportService,
     IDeviceService deviceService,
     IAUserService aUserService,
     IStateService stateService, IAreaService areaService, 
     IInstructionSendService instructionSendService)
 {
     _userService = userService;
     _aUserService = aUserService;
     _loginService = loginService;
     _positionService = positionService;
     _mileageReportService = mileageReportService;
     _deviceService = deviceService;
     _stateService = stateService;
     _areaService = areaService;
     _instructionSendService = instructionSendService;
     _alarmService = alarmService;
 }
Пример #24
0
        public FilePickerViewModel(
            IObjectPropertiesProvider objectPropertyProvider,
            IFileManager fileManager,
            RecentItemsFolderViewModel recentItemsFolderViewModel,
            IStateService stateService)
        {
            _stateService = stateService;
            _objectPropertyProvider = objectPropertyProvider;
            this.Items = new ObservableCollection<IFilePickerItem>();
            this.ContextMenuItems = new ObservableCollection<MenuItemViewModel>
            {
                new MenuItemViewModel("Add Folder", this.AddLocation)
            };

            if (recentItemsFolderViewModel != null)
            {
                if (_stateService != null)
                {
                    FilePickerState state;
                    if (_stateService.TryGetState("FilePicker", out state))
                    {
                        foreach (var item in state.RecentItems)
                        {
                            recentItemsFolderViewModel.ChildItems.Add(new FileLocationViewModel(item, fileManager));
                        }
                    }
                }
                this.Items.Add(recentItemsFolderViewModel);
            }

            if (_stateService != null)
                _stateService.SavingEvent.Subscribe(SaveState);

            _disposables.Add(this
                .ObserveProperty(v => v.SelectedItemProperties)
                .ObserveLatest(properties => properties.Items)
                .ObserveLatest(items => items.Count)
                .Subscribe(count => this.ShowItemProperties = count > 0));
        }
 public CentralGovernmentController(IStateService stateService, ICandidatesService candidatesService)
 {
     _stateService      = stateService;
     _candidatesService = candidatesService;
 }
Пример #26
0
 public WorkExperienceService(IUnitOfWork unitOfWork, ICityService cityService, IStateService stateService, IApplicationUserManager userManager, IMappingEngine mappingEngine)
 {
     _userManager     = userManager;
     _unitOfWork      = unitOfWork;
     _workExperiences = _unitOfWork.Set <WorkExperience>();
     _mappingEngine   = mappingEngine;
     _cityService     = cityService;
     _stateService    = stateService;
 }
Пример #27
0
 public ShippingMethodViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     if (PaymentInfo != null &&
         PaymentInfo.Form != null &&
         PaymentInfo.ValidatedInfo != null &&
         PaymentInfo.ValidatedInfo.ShippingOptions != null)
     {
         for (var i = 0; i < PaymentInfo.ValidatedInfo.ShippingOptions.Count; i++)
         {
             PaymentInfo.ValidatedInfo.ShippingOptions[i].IsSelected = i == 0;
             foreach (var price in PaymentInfo.ValidatedInfo.ShippingOptions[i].Prices)
             {
                 price.Currency = PaymentInfo.Form.Invoice.Currency;
             }
         }
     }
 }
Пример #28
0
 public IssueTrackerFacade(IIssueService issueService, IStateService stateService, IProjectService projectService)
 {
     _issueService   = issueService;
     _projectService = projectService;
     _stateService   = stateService;
 }
Пример #29
0
 public VideoPlayerViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     IsoFileName = StateService.IsoFileName;
     StateService.IsoFileName = null;
 }
        public CancelConfirmResetViewModel(IExtendedDeviceInfoService extendedDeviceInfoService, DebugViewModel debug, ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _extendedDeviceInfoService = extendedDeviceInfoService;
#if DEBUG
            HelpVisibility = Visibility.Visible;
#endif
            _type                 = stateService.Type;
            stateService.Type     = null;
            _nextType             = stateService.NextType;
            stateService.NextType = null;
            Subtitle              = GetSubtitle();

            var length = _type as ILength;
            CodeLength = length != null ? length.Length.Value : Constants.DefaultCodeLength;

            Timeout = stateService.SendCallTimeout;
            ResendCodeVisibility = stateService.SendCallTimeout != null && stateService.SendCallTimeout.Value > 0
                ? Visibility.Collapsed
                : Visibility.Visible;

            UpdateDebugString();

            EventAggregator.Subscribe(this);
            SuppressUpdateStatus = true;

            Debug = debug;

            if (StateService.ChangePhoneNumber)
            {
                _changePhoneNumber             = true;
                StateService.ChangePhoneNumber = false;
            }

            _sentCode             = StateService.SentCode;
            StateService.SentCode = null;

            //_updatesService = updatesService;

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => Code))
                {
                    NotifyOfPropertyChange(() => CanConfirm);

                    if (!string.IsNullOrEmpty(Code) && Code.Length == CodeLength)
                    {
                        Confirm();
                    }
                }
            };

            _callTimer.Tick += (sender, args) =>
            {
                _timeCounter = Timeout == null ? 0 : (int)(Timeout.Value - (DateTime.Now - _startTime).TotalSeconds);

                if (_timeCounter > 0)
                {
#if DEBUG
                    TimeCounterString = _timeCounter.ToString(CultureInfo.InvariantCulture);
#endif

                    if (_nextType is TLCodeTypeCall)
                    {
                        TimeCounterString = string.Format(AppResources.WeWillCallYou, TimeSpan.FromSeconds(TimeCounter).ToString(@"m\:ss"));
                    }
                }
                else
                {
                    _timeCounter = 0;
                    if (_nextType is TLCodeTypeCall)
                    {
                        TimeCounterString = AppResources.TelegramDialedYourNumber;
                    }

                    HelpVisibility       = Visibility.Visible;
                    ResendCodeVisibility = Visibility.Visible;
                    _callTimer.Stop();
                }

                NotifyOfPropertyChange(() => TimeCounter);
            };
        }
Пример #31
0
 protected KatushaController(IResourceService resourceService, IUserService userService, IProfileService profileService, IStateService stateService, IConversationService conversationService)
     : base(resourceService, userService, profileService, stateService, conversationService)
 {
 }
Пример #32
0
        public ChooseDialogViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            LogFileName = StateService.LogFileName;
            StateService.LogFileName = null;

            ForwardedMessages            = StateService.ForwardMessages;
            StateService.ForwardMessages = null;

            SharedContact = StateService.SharedContact;
            StateService.SharedContact = null;

            _accessToken             = StateService.AccessToken;
            StateService.AccessToken = null;

            _bot             = StateService.Bot;
            StateService.Bot = null;

            _webLink             = StateService.WebLink;
            StateService.WebLink = null;

            _url             = StateService.Url;
            StateService.Url = null;

            _text = StateService.UrlText;
            StateService.UrlText = null;

            Status = AppResources.Loading;

            BeginOnThreadPool(() =>
            {
                var isAuthorized = SettingsHelper.GetValue <bool>(Constants.IsAuthorizedKey);
                if (isAuthorized)
                {
                    var dialogs = CacheService.GetDialogs();

                    var dialogsCache   = new Dictionary <int, TLDialogBase>();
                    var clearedDialogs = new List <TLDialogBase>();
                    foreach (var dialog in dialogs)
                    {
                        if (!dialogsCache.ContainsKey(dialog.Index))
                        {
                            if (dialog is TLDialog || dialog is TLBroadcastDialog)
                            {
                                if (!SkipDialog(_bot, dialog))
                                {
                                    clearedDialogs.Add(dialog);
                                }
                                dialogsCache[dialog.Index] = dialog;
                            }
                        }
                        else
                        {
                            var cachedDialog = dialogsCache[dialog.Index];
                            if (cachedDialog.Peer is TLPeerUser && dialog.Peer is TLPeerUser)
                            {
                                CacheService.DeleteDialog(dialog);
                                continue;
                            }
                            if (cachedDialog.Peer is TLPeerChat && dialog.Peer is TLPeerChat)
                            {
                                CacheService.DeleteDialog(dialog);
                                continue;
                            }
                        }
                    }

                    BeginOnUIThread(() =>
                    {
                        foreach (var clearedDialog in clearedDialogs)
                        {
                            LazyItems.Add(clearedDialog);
                        }

                        var lastDialog = clearedDialogs.LastOrDefault(x => x.TopMessageId != null);
                        _maxId         = lastDialog != null ? lastDialog.TopMessageId.Value : 0;

                        Status = LazyItems.Count == 0 ? AppResources.Loading : string.Empty;

                        for (var i = 0; i < LazyItems.Count && i < FirstSliceLength; i++)
                        {
                            Items.Add(LazyItems[i]);
                        }

                        BeginOnUIThread(TimeSpan.FromSeconds(0.5), () =>
                        {
                            for (var i = FirstSliceLength; i < LazyItems.Count; i++)
                            {
                                Items.Add(LazyItems[i]);
                            }
                            LazyItems.Clear();

                            LoadNextSlice();
                        });
                    });
                }
            });
        }
Пример #33
0
 public MessagesController(IResourceService resourceService, IUserService userService, IProfileService profileService, IConversationService conversationService, IStateService stateService)
     : base(resourceService, userService, profileService, stateService, conversationService)
 {
     _profileService = profileService;
     _conversationService = conversationService;
 }
 public LocationsController(IPracticeService practiceService,IStateService stateService,IServicePlaceService servicePlaceService)
 {
     _practiceService = practiceService;
     _stateService = stateService;
     _servicePlaceService = servicePlaceService;
 }
        public ChangePasscodeViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            PasscodeTypes = new List <PasscodeTypeItem>();
            PasscodeTypes.Add(new PasscodeTypeItem(AppResources.Pin, PasscodeType.Pin));
            PasscodeTypes.Add(new PasscodeTypeItem(AppResources.Passcode, PasscodeType.Passcode));

            _selectedPasscodeType                = PasscodeTypes.First();
            _selectedAutolockTimeout             = StateService.SelectedAutolockTimeout;
            StateService.SelectedAutolockTimeout = 0;
        }
Пример #36
0
        public AddAdminsViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            Status = AppResources.Loading;

            _currentChat             = StateService.CurrentChat;
            StateService.CurrentChat = null;

            var chat = _currentChat as TLChat40;

            _adminsEnabled = chat != null && chat.AdminsEnabled.Value;

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => AdminsEnabled))
                {
                    if (!AdminsEnabled)
                    {
                        foreach (var item in Items)
                        {
                            item.IsSelected = !AdminsEnabled;
                        }
                    }
                    else
                    {
                        UpdateAdmins(_currentChat.Participants as IChatParticipants);
                    }

                    NotifyOfPropertyChange(() => AddAdminsDescription);
                }
            };
        }
Пример #37
0
        public GroupsInCommonViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            _currentUser = StateService.CurrentContact;
            StateService.CurrentContact = null;

            Status = AppResources.Loading;

            BeginOnThreadPool(() =>
            {
                if (_currentUser == null)
                {
                    return;
                }

                MTProtoService.GetCommonChatsAsync(_currentUser.ToInputUser(), new TLInt(0), new TLInt(100),
                                                   result => BeginOnUIThread(() =>
                {
                    Status = result.Chats.Count > 0 ? string.Empty : AppResources.NoGroupsHere;

                    const int firstSliceCount = 11;
                    var firstSlice            = new List <TLChatBase>();
                    var secondSlice           = new List <TLChatBase>();

                    for (var i = 0; i < result.Chats.Count; i++)
                    {
                        _resultsDict[result.Chats[i].Index] = result.Chats[i];

                        if (i < firstSliceCount)
                        {
                            firstSlice.Add(result.Chats[i]);
                        }
                        else
                        {
                            secondSlice.Add(result.Chats[i]);
                        }
                    }

                    Items.Clear();
                    foreach (var chat in firstSlice)
                    {
                        Items.Add(chat);
                    }

                    if (secondSlice.Count > 0)
                    {
                        BeginOnUIThread(() =>
                        {
                            foreach (var chat in secondSlice)
                            {
                                Items.Add(chat);
                            }
                        });
                    }
                }),
                                                   error => BeginOnUIThread(() =>
                {
                    Status = AppResources.NoGroupsHere;
                    Telegram.Api.Helpers.Execute.ShowDebugMessage("messages.getCommonChats error=" + error);
                }));
            });
        }
Пример #38
0
 public StateController()
 {
     _StateService = new StateService();
 }
Пример #39
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            var eventUploadIntent = new Intent(this, typeof(EventUploadReceiver));

            _eventUploadPendingIntent = PendingIntent.GetBroadcast(this, 0, eventUploadIntent,
                                                                   PendingIntentFlags.UpdateCurrent);
            var alarmIntent = new Intent(this, typeof(LockAlarmReceiver));

            _lockAlarmPendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent,
                                                                 PendingIntentFlags.UpdateCurrent);
            var clearClipboardIntent = new Intent(this, typeof(ClearClipboardAlarmReceiver));

            _clearClipboardPendingIntent = PendingIntent.GetBroadcast(this, 0, clearClipboardIntent,
                                                                      PendingIntentFlags.UpdateCurrent);

            var policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build();

            StrictMode.SetThreadPolicy(policy);

            _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _messagingService    = ServiceContainer.Resolve <IMessagingService>("messagingService");
            _broadcasterService  = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService");
            _userService         = ServiceContainer.Resolve <IUserService>("userService");
            _appIdService        = ServiceContainer.Resolve <IAppIdService>("appIdService");
            _storageService      = ServiceContainer.Resolve <IStorageService>("storageService");
            _stateService        = ServiceContainer.Resolve <IStateService>("stateService");
            _eventService        = ServiceContainer.Resolve <IEventService>("eventService");

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            UpdateTheme(ThemeManager.GetTheme(true));
            base.OnCreate(savedInstanceState);
            if (!CoreHelpers.InDebugMode())
            {
                Window.AddFlags(Android.Views.WindowManagerFlags.Secure);
            }

#if !FDROID
            var hockeyAppListener = new HockeyAppCrashManagerListener(_appIdService, _userService);
            var hockeyAppTask     = hockeyAppListener.InitAsync();
            HockeyApp.Android.CrashManager.Register(this, HockeyAppId, hockeyAppListener);
#endif

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            Xamarin.Forms.Forms.Init(this, savedInstanceState);
            _appOptions = GetOptions();
            LoadApplication(new App.App(_appOptions));

            _broadcasterService.Subscribe(_activityKey, (message) =>
            {
                if (message.Command == "scheduleLockTimer")
                {
                    var alarmManager      = GetSystemService(AlarmService) as AlarmManager;
                    var lockOptionMinutes = (int)message.Data;
                    var lockOptionMs      = lockOptionMinutes * 60000;
                    var triggerMs         = Java.Lang.JavaSystem.CurrentTimeMillis() + lockOptionMs + 10;
                    alarmManager.Set(AlarmType.RtcWakeup, triggerMs, _lockAlarmPendingIntent);
                }
                else if (message.Command == "cancelLockTimer")
                {
                    var alarmManager = GetSystemService(AlarmService) as AlarmManager;
                    alarmManager.Cancel(_lockAlarmPendingIntent);
                }
                else if (message.Command == "startEventTimer")
                {
                    StartEventAlarm();
                }
                else if (message.Command == "stopEventTimer")
                {
                    var task = StopEventAlarmAsync();
                }
                else if (message.Command == "finishMainActivity")
                {
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(() => Finish());
                }
                else if (message.Command == "listenYubiKeyOTP")
                {
                    ListenYubiKey((bool)message.Data);
                }
                else if (message.Command == "updatedTheme")
                {
                    RestartApp();
                }
                else if (message.Command == "exit")
                {
                    ExitApp();
                }
                else if (message.Command == "copiedToClipboard")
                {
                    var task = ClearClipboardAlarmAsync(message.Data as Tuple <string, int?, bool>);
                }
            });
        }
Пример #40
0
 public ItemTaxController(IUtilityService utilityService, IItemTaxService itemtaxService, IItemService itemservice, IItemCategoryService itemcategoryService, IItemSubCategoryService itemsubcategoryservice, ICityService cityservice, IUserCredentialService usercredentialservice, IModuleService iIModuleService, IStateService StateService)
 {
     this._utilityService         = utilityService;
     this._itemtaxService         = itemtaxService;
     this._itemservice            = itemservice;
     this._itemcategoryService    = itemcategoryService;
     this._itemsubcategoryservice = itemsubcategoryservice;
     this._cityservice            = cityservice;
     this._IUserCredentialService = usercredentialservice;
     this._iIModuleService        = iIModuleService;
     this._StateService           = StateService;
 }
Пример #41
0
 public CustomerController(ICustomerService customerService, CustomerSettings customerSettings,
                           ILocalizationService localizationService, IDateTimeHelper dateTimeHelper, IStateService stateService, IShoppingCartService shoppingCartService)
 {
     _customerService     = customerService;
     _customerSettings    = customerSettings;
     _localizationService = localizationService;
     _dateTimeHelper      = dateTimeHelper;
     _stateService        = stateService;
     _shoppingCartService = shoppingCartService;
 }
Пример #42
0
 public LessonService(LernContext context, IHttpContextAccessor httpContextAccessor, IAuthorizationService authorizationService, IStateService stateService) : base(context, httpContextAccessor)
 {
     _authorizationService = authorizationService;
     _stateService         = stateService;
 }
Пример #43
0
        public SearchVenuesViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            Items  = new ObservableCollection <TLObject>();
            Status = AppResources.NoResults;

            if (StateService.GeoCoordinate != null)
            {
                Location = StateService.GeoCoordinate;
                StateService.GeoCoordinate = null;
            }

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => Text))
                {
                    if (!string.IsNullOrEmpty(Text))
                    {
                        Search(Text);
                    }
                    else
                    {
                        Items.Clear();
                        Status = AppResources.NoResults;
                    }
                }
            };
        }
Пример #44
0
 public StatesScriptModule(IStateService stateService)
 {
     _stateService = stateService;
 }
Пример #45
0
        public AboutViewModel(IExtendedDeviceInfoService extendedDeviceInfoService, ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _extendedDeviceInfoService = extendedDeviceInfoService;

            var datePicker = new DatePicker();
        }
Пример #46
0
 public UserModel(ITenant <TenantReadModel> tenant, IMediator mediator, ILoggerFactory loggerFactory, IStateService stateService)
     : base(tenant, mediator, loggerFactory)
 {
     _stateService = stateService;
 }
Пример #47
0
        public ContactsViewModel(IFileManager fileManager, ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _fileManager = fileManager;

            Items = new AlphaKeyGroup <TLUserBase>("@");

            _contacts = new ObservableCollection <AlphaKeyGroup <TLUserBase> > {
                (AlphaKeyGroup <TLUserBase>)Items
            };

            DisplayName = LowercaseConverter.Convert(AppResources.Contacts);
            Status      = AppResources.Loading;
        }
 public SavedCardInfoViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     if (PaymentInfo != null && PaymentInfo.Form != null && PaymentInfo.Form.SavedCredentials != null)
     {
         _savedCredentialsCard = PaymentInfo.Form.SavedCredentials as TLPaymentSavedCredentialsCard;
         if (_savedCredentialsCard != null)
         {
             Title = _savedCredentialsCard.Title.ToString();
         }
     }
 }
Пример #49
0
        public static async Task <bool> PerformUpdateTasksAsync(ISyncService syncService,
                                                                IDeviceActionService deviceActionService, IStateService stateService)
        {
            var currentBuild = deviceActionService.GetBuildNumber();
            var lastBuild    = await stateService.GetLastBuildAsync();

            if (lastBuild == null || lastBuild != currentBuild)
            {
                // Updated
                var tasks = Task.Run(() => syncService.FullSyncAsync(true));
                await stateService.SetLastBuildAsync(currentBuild);

                return(true);
            }
            return(false);
        }
Пример #50
0
        public AddEditPageViewModel()
        {
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _cipherService        = ServiceContainer.Resolve <ICipherService>("cipherService");
            _folderService        = ServiceContainer.Resolve <IFolderService>("folderService");
            _stateService         = ServiceContainer.Resolve <IStateService>("stateService");
            _organizationService  = ServiceContainer.Resolve <IOrganizationService>("organizationService");
            _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _auditService         = ServiceContainer.Resolve <IAuditService>("auditService");
            _messagingService     = ServiceContainer.Resolve <IMessagingService>("messagingService");
            _collectionService    = ServiceContainer.Resolve <ICollectionService>("collectionService");
            _eventService         = ServiceContainer.Resolve <IEventService>("eventService");
            _policyService        = ServiceContainer.Resolve <IPolicyService>("policyService");
            _logger = ServiceContainer.Resolve <ILogger>("logger");

            GeneratePasswordCommand   = new Command(GeneratePassword);
            TogglePasswordCommand     = new Command(TogglePassword);
            ToggleCardNumberCommand   = new Command(ToggleCardNumber);
            ToggleCardCodeCommand     = new Command(ToggleCardCode);
            CheckPasswordCommand      = new Command(CheckPasswordAsync);
            UriOptionsCommand         = new Command <LoginUriView>(UriOptions);
            FieldOptionsCommand       = new Command <AddEditPageFieldViewModel>(FieldOptions);
            PasswordPromptHelpCommand = new Command(PasswordPromptHelp);
            Uris          = new ExtendedObservableCollection <LoginUriView>();
            Fields        = new ExtendedObservableCollection <AddEditPageFieldViewModel>();
            Collections   = new ExtendedObservableCollection <CollectionViewModel>();
            AllowPersonal = true;

            TypeOptions = new List <KeyValuePair <string, CipherType> >
            {
                new KeyValuePair <string, CipherType>(AppResources.TypeLogin, CipherType.Login),
                new KeyValuePair <string, CipherType>(AppResources.TypeCard, CipherType.Card),
                new KeyValuePair <string, CipherType>(AppResources.TypeIdentity, CipherType.Identity),
                new KeyValuePair <string, CipherType>(AppResources.TypeSecureNote, CipherType.SecureNote),
            };
            CardBrandOptions = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>($"-- {AppResources.Select} --", null),
                new KeyValuePair <string, string>("Visa", "Visa"),
                new KeyValuePair <string, string>("Mastercard", "Mastercard"),
                new KeyValuePair <string, string>("American Express", "Amex"),
                new KeyValuePair <string, string>("Discover", "Discover"),
                new KeyValuePair <string, string>("Diners Club", "Diners Club"),
                new KeyValuePair <string, string>("JCB", "JCB"),
                new KeyValuePair <string, string>("Maestro", "Maestro"),
                new KeyValuePair <string, string>("UnionPay", "UnionPay"),
                new KeyValuePair <string, string>(AppResources.Other, "Other")
            };
            CardExpMonthOptions = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>($"-- {AppResources.Select} --", null),
                new KeyValuePair <string, string>($"01 - {AppResources.January}", "1"),
                new KeyValuePair <string, string>($"02 - {AppResources.February}", "2"),
                new KeyValuePair <string, string>($"03 - {AppResources.March}", "3"),
                new KeyValuePair <string, string>($"04 - {AppResources.April}", "4"),
                new KeyValuePair <string, string>($"05 - {AppResources.May}", "5"),
                new KeyValuePair <string, string>($"06 - {AppResources.June}", "6"),
                new KeyValuePair <string, string>($"07 - {AppResources.July}", "7"),
                new KeyValuePair <string, string>($"08 - {AppResources.August}", "8"),
                new KeyValuePair <string, string>($"09 - {AppResources.September}", "9"),
                new KeyValuePair <string, string>($"10 - {AppResources.October}", "10"),
                new KeyValuePair <string, string>($"11 - {AppResources.November}", "11"),
                new KeyValuePair <string, string>($"12 - {AppResources.December}", "12")
            };
            IdentityTitleOptions = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>($"-- {AppResources.Select} --", null),
                new KeyValuePair <string, string>(AppResources.Mr, AppResources.Mr),
                new KeyValuePair <string, string>(AppResources.Mrs, AppResources.Mrs),
                new KeyValuePair <string, string>(AppResources.Ms, AppResources.Ms),
                new KeyValuePair <string, string>(AppResources.Dr, AppResources.Dr),
            };
            FolderOptions    = new List <KeyValuePair <string, string> >();
            OwnershipOptions = new List <KeyValuePair <string, string> >();
        }
Пример #51
0
 public PermissionService(IStateService stateService)
 {
     _stateService = stateService;
 }
 protected StateServiceBaseHandler(IStateService stateService)
 {
     if (stateService == null) throw new ArgumentNullException("stateService");
     _stateService = stateService;
 }
        public ExerciseProgramsViewModel(
            IAudioService audioService,
            IDelayService delayService,
            IExerciseDocumentService exerciseDocumentService,
            ILoggerService loggerService,
            IScheduler mainScheduler,
            IScheduler taskPoolScheduler,
            ISpeechService speechService,
            IStateService stateService,
            IScreen hostScreen,
            ExerciseProgramViewModelFactory exerciseProgramViewModelFactory)
        {
            Ensure.ArgumentNotNull(audioService, nameof(audioService));
            Ensure.ArgumentNotNull(delayService, nameof(delayService));
            Ensure.ArgumentNotNull(exerciseDocumentService, nameof(exerciseDocumentService));
            Ensure.ArgumentNotNull(loggerService, nameof(loggerService));
            Ensure.ArgumentNotNull(mainScheduler, nameof(mainScheduler));
            Ensure.ArgumentNotNull(taskPoolScheduler, nameof(taskPoolScheduler));
            Ensure.ArgumentNotNull(speechService, nameof(speechService));
            Ensure.ArgumentNotNull(stateService, nameof(stateService));
            Ensure.ArgumentNotNull(hostScreen, nameof(hostScreen));
            Ensure.ArgumentNotNull(exerciseProgramViewModelFactory, nameof(exerciseProgramViewModelFactory));

            this.exerciseDocumentService = exerciseDocumentService;
            this.stateService            = stateService;
            this.logger      = loggerService.GetLogger(this.GetType());
            this.hostScreen  = hostScreen;
            this.disposables = new CompositeDisposable();

            var documentsFromCache = this
                                     .stateService
                                     .Get <string>(exerciseProgramsCacheKey)
                                     .Where(x => x != null)
                                     .Select(x => new DocumentSourceWith <string>(DocumentSource.Cache, x));

            var documentsFromService = this
                                       .exerciseDocumentService
                                       .ExerciseDocument
                                       .Where(x => x != null)
                                       .Select(x => new DocumentSourceWith <string>(DocumentSource.Service, x));

            var documents = documentsFromCache
                            .Catch((Exception ex) => Observable.Empty <DocumentSourceWith <string> >())
                            .Concat(documentsFromService)
                            .Do(x => this.logger.Debug("Received document from {0}.", x.Source))
                            .Publish();

            var safeDocuments = documents
                                .Catch((Exception ex) => Observable.Empty <DocumentSourceWith <string> >());

            var results = documents
                          .ObserveOn(taskPoolScheduler)
                          .Select(
                x =>
            {
                IResult <ExercisePrograms> parsedExercisePrograms;

                using (this.logger.Perf("Parsing exercise programs from {0}.", x.Source))
                {
                    parsedExercisePrograms = ExercisePrograms.TryParse(x.Item, audioService, delayService, loggerService, speechService);
                }

                return(new DocumentSourceWith <IResult <ExercisePrograms> >(x.Source, parsedExercisePrograms));
            })
                          .Publish();

            var safeResults = results
                              .Catch((Exception ex) => Observable.Empty <DocumentSourceWith <IResult <ExercisePrograms> > >());

            safeResults
            .Select(x => x.Item.WasSuccessful ? null : x.Item.ToString())
            .ObserveOn(mainScheduler)
            .Subscribe(x => this.ParseErrorMessage = x)
            .AddTo(this.disposables);

            results
            .Select(x => !x.Item.WasSuccessful ? ExerciseProgramsViewModelStatus.ParseFailed : x.Source == DocumentSource.Cache ? ExerciseProgramsViewModelStatus.LoadedFromCache : ExerciseProgramsViewModelStatus.LoadedFromService)
            .Catch((Exception ex) => Observable.Return(ExerciseProgramsViewModelStatus.LoadFailed))
            .ObserveOn(mainScheduler)
            .Subscribe(x => this.Status = x)
            .AddTo(this.disposables);

            safeResults
            .Select(x => x.Item.WasSuccessful ? x.Item.Value : null)
            .ObserveOn(mainScheduler)
            .Subscribe(x => this.Model = x)
            .AddTo(this.disposables);

            this.WhenAnyValue(x => x.Model)
            .Select(x => x == null ? null : x.Programs.CreateDerivedCollection(y => exerciseProgramViewModelFactory(y)))
            .ObserveOn(mainScheduler)
            .Subscribe(x => this.Programs = x)
            .AddTo(this.disposables);

            safeDocuments
            .Where(x => x.Source == DocumentSource.Service)
            .SelectMany(x => this.stateService.Set(exerciseProgramsCacheKey, x.Item))
            .Subscribe()
            .AddTo(this.disposables);

            results
            .Connect()
            .AddTo(this.disposables);

            documents
            .Connect()
            .AddTo(this.disposables);

            this
            .WhenAnyValue(x => x.SelectedProgram)
            .Where(x => x != null)
            .Subscribe(x => this.hostScreen.Router.Navigate.ExecuteAsync(x))
            .AddTo(this.disposables);

            this
            .hostScreen
            .Router
            .CurrentViewModel
            .OfType <ExerciseProgramsViewModel>()
            .Subscribe(x => x.SelectedProgram = null)
            .AddTo(this.disposables);
        }
Пример #54
0
        public override async void ViewDidLoad()
        {
            _vaultTimeoutService  = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService");
            _cryptoService        = ServiceContainer.Resolve <ICryptoService>("cryptoService");
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _stateService         = ServiceContainer.Resolve <IStateService>("stateService");
            _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService");
            _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _biometricService     = ServiceContainer.Resolve <IBiometricService>("biometricService");
            _keyConnectorService  = ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService");

            // We re-use the lock screen for autofill extension to verify master password
            // when trying to access protected items.
            if (autofillExtension && await _stateService.GetPasswordRepromptAutofillAsync())
            {
                _passwordReprompt      = true;
                _isPinProtected        = false;
                _isPinProtectedWithKey = false;
                _pinLock       = false;
                _biometricLock = false;
            }
            else
            {
                (_isPinProtected, _isPinProtectedWithKey) = await _vaultTimeoutService.IsPinLockSetAsync();

                _pinLock = (_isPinProtected && await _stateService.GetPinProtectedKeyAsync() != null) ||
                           _isPinProtectedWithKey;
                _biometricLock = await _vaultTimeoutService.IsBiometricLockSetAsync() &&
                                 await _cryptoService.HasKeyAsync();

                _biometricIntegrityValid = await _biometricService.ValidateIntegrityAsync(BiometricIntegrityKey);

                _usesKeyConnector = await _keyConnectorService.GetUsesKeyConnector();

                _biometricUnlockOnly = _usesKeyConnector && _biometricLock && !_pinLock;
            }

            if (_pinLock)
            {
                BaseNavItem.Title = AppResources.VerifyPIN;
            }
            else if (_usesKeyConnector)
            {
                BaseNavItem.Title = AppResources.UnlockVault;
            }
            else
            {
                BaseNavItem.Title = AppResources.VerifyMasterPassword;
            }

            BaseCancelButton.Title = AppResources.Cancel;

            if (_biometricUnlockOnly)
            {
                BaseSubmitButton.Title   = null;
                BaseSubmitButton.Enabled = false;
            }
            else
            {
                BaseSubmitButton.Title = AppResources.Submit;
            }

            var descriptor = UIFontDescriptor.PreferredBody;

            if (!_biometricUnlockOnly)
            {
                MasterPasswordCell.Label.Text = _pinLock ? AppResources.PIN : AppResources.MasterPassword;
                MasterPasswordCell.TextField.SecureTextEntry = true;
                MasterPasswordCell.TextField.ReturnKeyType   = UIReturnKeyType.Go;
                MasterPasswordCell.TextField.ShouldReturn   += (UITextField tf) =>
                {
                    CheckPasswordAsync().GetAwaiter().GetResult();
                    return(true);
                };
                if (_pinLock)
                {
                    MasterPasswordCell.TextField.KeyboardType = UIKeyboardType.NumberPad;
                }
                MasterPasswordCell.Button.TitleLabel.Font = UIFont.FromName("bwi-font", 28f);
                MasterPasswordCell.Button.SetTitle(BitwardenIcons.Eye, UIControlState.Normal);
                MasterPasswordCell.Button.TouchUpInside += (sender, e) => {
                    MasterPasswordCell.TextField.SecureTextEntry = !MasterPasswordCell.TextField.SecureTextEntry;
                    MasterPasswordCell.Button.SetTitle(MasterPasswordCell.TextField.SecureTextEntry ? BitwardenIcons.Eye : BitwardenIcons.EyeSlash, UIControlState.Normal);
                };
            }

            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 70;
            TableView.Source             = new TableSource(this);
            TableView.AllowsSelection    = true;

            base.ViewDidLoad();

            if (_biometricLock)
            {
                if (!_biometricIntegrityValid)
                {
                    return;
                }
                var tasks = Task.Run(async() =>
                {
                    await Task.Delay(500);
                    NSRunLoop.Main.BeginInvokeOnMainThread(async() => await PromptBiometricAsync());
                });
            }
        }
Пример #55
0
 public FormHandler(IMailSender mailSender, IStateService lookups, Store.IStore store)
 {
     _mailSender = mailSender;
     _lookupContext = lookups;
     _store = store;
 }
Пример #56
0
 public CacheService(IStateService stateService)
 {
     this.Clear();
     stateService.Register(this);
 }
Пример #57
0
 public StatesController(IStateService stateService)
 {
     _stateService = stateService;
 }
        public ChooseCountryViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            const string Groups = "abcdefghijklmnopqrstuvwxyz";

            Items = new ObservableCollection <CountriesInGroup>();

            SearchItems     = new ObservableCollection <Country>();
            LazySearchItems = new List <Country>();

            var countries = new List <CountriesInGroup>(Groups.Length);
            var groups    = new Dictionary <string, CountriesInGroup>();

            foreach (var c in Groups)
            {
                var group = new CountriesInGroup(c.ToString(CultureInfo.InvariantCulture));
                countries.Add(group);
                groups[c.ToString(CultureInfo.InvariantCulture)] = group;
            }

            foreach (var country in CountryUtils.CountriesSource)
            {
                groups[country.GetKey()].Add(country);
            }

            var count = 1;

            for (var i = 0; i < count; i++)
            {
                Items.Add(countries[i]);
            }

            for (var i = count; i < countries.Count; i++)
            {
                LazyItems.Add(countries[i]);
            }

            if (StateService.HideCountryCode)
            {
                StateService.HideCountryCode = false;
                HideCountryCode = true;
            }

            _residenceCountry             = StateService.ResidenceCountry;
            StateService.ResidenceCountry = false;

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => IsSearching))
                {
                    if (!IsSearching)
                    {
                        Text = string.Empty;
                    }
                }
            };
        }
 protected abstract object HandleQuestion(IThermometerQuestion question, IStateService stateService);
Пример #60
0
        public App(AppOptions appOptions)
        {
            Options = appOptions ?? new AppOptions();
            if (Options.IosExtension)
            {
                Current = this;
                return;
            }
            _broadcasterService   = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService");
            _messagingService     = ServiceContainer.Resolve <IMessagingService>("messagingService");
            _stateService         = ServiceContainer.Resolve <IStateService>("stateService");
            _vaultTimeoutService  = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService");
            _syncService          = ServiceContainer.Resolve <ISyncService>("syncService");
            _authService          = ServiceContainer.Resolve <IAuthService>("authService");
            _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService");
            _secureStorageService = ServiceContainer.Resolve <IStorageService>("secureStorageService");
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _accountsManager      = ServiceContainer.Resolve <IAccountsManager>("accountsManager");

            _accountsManager.Init(() => Options, this);

            Bootstrap();
            _broadcasterService.Subscribe(nameof(App), async(message) =>
            {
                try
                {
                    if (message.Command == "showDialog")
                    {
                        var details     = message.Data as DialogDetails;
                        var confirmed   = true;
                        var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ?
                                          AppResources.Ok : details.ConfirmText;
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            if (!string.IsNullOrWhiteSpace(details.CancelText))
                            {
                                confirmed = await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText,
                                                                                details.CancelText);
                            }
                            else
                            {
                                await Current.MainPage.DisplayAlert(details.Title, details.Text, confirmText);
                            }
                            _messagingService.Send("showDialogResolve", new Tuple <int, bool>(details.DialogId, confirmed));
                        });
                    }
                    else if (message.Command == "resumed")
                    {
                        if (Device.RuntimePlatform == Device.iOS)
                        {
                            ResumedAsync().FireAndForget();
                        }
                    }
                    else if (message.Command == "slept")
                    {
                        if (Device.RuntimePlatform == Device.iOS)
                        {
                            await SleptAsync();
                        }
                    }
                    else if (message.Command == "migrated")
                    {
                        await Task.Delay(1000);
                        await _accountsManager.NavigateOnAccountChangeAsync();
                    }
                    else if (message.Command == "popAllAndGoToTabGenerator" ||
                             message.Command == "popAllAndGoToTabMyVault" ||
                             message.Command == "popAllAndGoToTabSend" ||
                             message.Command == "popAllAndGoToAutofillCiphers")
                    {
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            if (Current.MainPage is TabsPage tabsPage)
                            {
                                while (tabsPage.Navigation.ModalStack.Count > 0)
                                {
                                    await tabsPage.Navigation.PopModalAsync(false);
                                }
                                if (message.Command == "popAllAndGoToAutofillCiphers")
                                {
                                    Current.MainPage = new NavigationPage(new AutofillCiphersPage(Options));
                                }
                                else if (message.Command == "popAllAndGoToTabMyVault")
                                {
                                    Options.MyVaultTile = false;
                                    tabsPage.ResetToVaultPage();
                                }
                                else if (message.Command == "popAllAndGoToTabGenerator")
                                {
                                    Options.GeneratorTile = false;
                                    tabsPage.ResetToGeneratorPage();
                                }
                                else if (message.Command == "popAllAndGoToTabSend")
                                {
                                    tabsPage.ResetToSendPage();
                                }
                            }
                        });
                    }
                    else if (message.Command == "convertAccountToKeyConnector")
                    {
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            await Application.Current.MainPage.Navigation.PushModalAsync(
                                new NavigationPage(new RemoveMasterPasswordPage()));
                        });
                    }
                }
                catch (Exception ex)
                {
                    LoggerHelper.LogEvenIfCantBeResolved(ex);
                }
            });
        }