Beispiel #1
0
 public MusicViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     DisplayName = LowercaseConverter.Convert(AppResources.SharedMusic);
 }
 public PaymentFormStep1ViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
     : base(protoService, cacheService, aggregator)
 {
 }
Beispiel #3
0
        public SettingsStatsViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, IStatsService statsService)
            : base(protoService, cacheService, aggregator)
        {
            _statsService = statsService;

            Items = new MvxObservableCollection <SettingsStatsNetwork>
            {
                new SettingsStatsNetwork(statsService, "Mobile", NetworkType.Mobile),
                new SettingsStatsNetwork(statsService, "Wi-Fi", NetworkType.WiFi),
                new SettingsStatsNetwork(statsService, "Roaming", NetworkType.Roaming)
            };
        }
Beispiel #4
0
 public ChannelEditViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, IUploadFileManager uploadFileManager)
     : base(protoService, cacheService, aggregator, uploadFileManager)
 {
 }
 public CreateChannelStep2ViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
     : base(protoService, cacheService, aggregator)
 {
     AdminedPublicChannels = new MvxObservableCollection <TLChannel>();
     PropertyChanged      += OnPropertyChanged;
 }
Beispiel #6
0
        public LiveLocationService(IMTProtoService protoService, ILocationService locationService, ITelegramEventAggregator aggregator)
        {
            _protoService    = protoService;
            _locationService = locationService;
            _aggregator      = aggregator;

            _aggregator.Subscribe(this);

            Items = new MvxObservableCollection <TLMessage>();
        }
Beispiel #7
0
 public LogViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     DisplayName = "log";
 }
        public UsersSelectionViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
            : base(protoService, cacheService, aggregator)
        {
            Items         = new SortedObservableCollection <TLUser>(new TLUserComparer(false));
            Search        = new ObservableCollection <KeyedList <string, TLObject> >();
            SelectedItems = new ObservableCollection <TLUser>();
            SelectedItems.CollectionChanged += OnCollectionChanged;

            SendCommand = new RelayCommand(SendExecute, () => Minimum <= SelectedItems.Count && Maximum >= SelectedItems.Count);
        }
 public EnterPasswordViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
 }
Beispiel #10
0
 public SecretMediaViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator) :
     base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     Items = new ObservableCollection <TLDecryptedMessage>();
 }
Beispiel #11
0
 public ShareViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, DialogsViewModel dialogs)
     : base(protoService, cacheService, aggregator)
 {
     Dialogs      = dialogs;
     GroupedItems = new ObservableCollection <ShareViewModel> {
         this
     };
 }
        public ChannelEditViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, IUploadFileManager uploadFileManager)
            : base(protoService, cacheService, aggregator)
        {
            _uploadFileManager = uploadFileManager;

            AdminedPublicChannels = new MvxObservableCollection <TLChannel>();

            SendCommand           = new RelayCommand(SendExecute);
            EditPhotoCommand      = new RelayCommand <StorageFile>(EditPhotoExecute);
            EditStickerSetCommand = new RelayCommand(EditStickerSetExecute);
            RevokeLinkCommand     = new RelayCommand <TLChannel>(RevokeLinkExecute);
            DeleteCommand         = new RelayCommand(DeleteExecute);
        }
        public SecretContactDetailsViewModel(IMTProtoService mtProtoService, IStateService stateService, INavigationService navigationService, ITelegramEventAggregator eventAggregator, ICacheService cacheService)
        {
            _stateService      = stateService;
            _navigationService = navigationService;
            _eventAggregator   = eventAggregator;
            _mtProtoService    = mtProtoService;
            _cacheService      = cacheService;

            TimerSpans = new List <TimerSpan>
            {
                new TimerSpan(AppResources.OffMasculine, string.Empty, 0),
                new TimerSpan(AppResources.SecondNominativeSingular, "1", 1),
                new TimerSpan(AppResources.SecondNominativePlural, "2", 2),
                new TimerSpan(AppResources.SecondNominativePlural, "3", 3),
                new TimerSpan(AppResources.SecondNominativePlural, "4", 4),
                new TimerSpan(AppResources.SecondGenitivePlural, "5", 5),
                new TimerSpan(AppResources.SecondGenitivePlural, "6", 6),
                new TimerSpan(AppResources.SecondGenitivePlural, "7", 7),
                new TimerSpan(AppResources.SecondGenitivePlural, "8", 8),
                new TimerSpan(AppResources.SecondGenitivePlural, "9", 9),
                new TimerSpan(AppResources.SecondGenitivePlural, "10", 10),
                new TimerSpan(AppResources.SecondGenitivePlural, "11", 11),
                new TimerSpan(AppResources.SecondGenitivePlural, "12", 12),
                new TimerSpan(AppResources.SecondGenitivePlural, "13", 13),
                new TimerSpan(AppResources.SecondGenitivePlural, "14", 14),
                new TimerSpan(AppResources.SecondGenitivePlural, "15", 15),
                new TimerSpan(AppResources.SecondGenitivePlural, "30", 30),
                new TimerSpan(AppResources.MinuteNominativeSingular, "1", 60),
                new TimerSpan(AppResources.HourNominativeSingular, "1", (int)TimeSpan.FromHours(1.0).TotalSeconds),
                new TimerSpan(AppResources.DayNominativeSingular, "1", (int)TimeSpan.FromDays(1.0).TotalSeconds),
                new TimerSpan(AppResources.WeekNominativeSingular, "1", (int)TimeSpan.FromDays(7.0).TotalSeconds),
            };

            _selectedSpan = TimerSpans.First();

            _eventAggregator.Subscribe(this);
        }
Beispiel #14
0
        public StickersViewModel(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;
        }
Beispiel #15
0
 public GallerySecretViewModel(TLInputPeerBase peer, TLMessage message, IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
     : base(protoService, cacheService, aggregator)
 {
     SelectedItem = new GallerySecretMessageItem(message);
 }
        protected PasswordViewModelBase(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            PasswordBase = StateService.Password as TLPassword;

            if (PasswordBase != null)
            {
                PasswordHint = !TLString.IsNullOrEmpty(PasswordBase.Hint) ? PasswordBase.Hint.ToString() : string.Empty;
            }
        }
Beispiel #17
0
 public SignInSentCodeViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
     : base(protoService, cacheService, aggregator)
 {
 }
Beispiel #18
0
 public SettingsSecurityEnterPasswordViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
     : base(protoService, cacheService, aggregator)
 {
     SendCommand   = new RelayCommand(SendExecute, () => !IsLoading);
     ForgotCommand = new RelayCommand(ForgotExecute);
 }
Beispiel #19
0
 public ChannelDetailsViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, IUploadFileManager uploadFileManager)
     : base(protoService, cacheService, aggregator, null)
 {
     _uploadFileManager = uploadFileManager;
 }
Beispiel #20
0
        public DialogsViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
            : base(protoService, cacheService, aggregator)
        {
            Items        = new MvxObservableCollection <TLDialog>();
            Search       = new ObservableCollection <KeyedList <string, TLObject> >();
            SearchTokens = new Dictionary <string, CancellationTokenSource>();

            Execute.BeginOnThreadPool(() => LoadFirstSlice());
        }
        public ChooseDialogViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            FilteredItems = new CollectionViewSource {
                Source = Items
            }.View;
            FilteredItems.Filter += item =>
            {
                var dialog = item as TLDialog;
                if (dialog != null)
                {
                    var chat = dialog.With as TLChat41;
                    if (chat != null)
                    {
                        return(!chat.IsMigrated);
                    }

                    var user = dialog.With as TLUser;
                    if (user != null)
                    {
                        return(!user.IsSelf);
                    }
                }

                var dialog71 = dialog as TLDialog71;
                if (dialog71 != null)
                {
                    return(!dialog71.IsPromo);
                }

                return(true);
            };

            EventAggregator.Subscribe(this);

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

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

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

            _gameString             = StateService.GameString;
            StateService.GameString = null;

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

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

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

            _storageItems             = StateService.StorageItems;
            StateService.StorageItems = null;

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

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

            _switchInlineButton             = StateService.SwitchInlineButton;
            StateService.SwitchInlineButton = 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))
                        {
                            var user = dialog.With as TLUser;
                            if (user != null && user.IsSelf)
                            {
                                CurrentUser = dialog;
                            }

                            if (dialog is TLDialog || dialog is TLBroadcastDialog)
                            {
                                if (!SkipDialogForBot(_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;
                            }
                        }
                    }

                    if (CurrentUser == null)
                    {
                        var currentUser = CacheService.GetUser(new TLInt(StateService.CurrentUserId));
                        if (currentUser != null)
                        {
                            var dialog = new TLDialog71
                            {
                                With  = currentUser,
                                Flags = new TLInt(0),
                                Peer  = new TLPeerUser {
                                    Id = currentUser.Id
                                },
                                Messages            = new ObservableCollection <TLMessageBase>(),
                                TopMessageId        = new TLInt(0),
                                ReadInboxMaxId      = new TLInt(0),
                                ReadOutboxMaxId     = new TLInt(0),
                                UnreadCount         = new TLInt(0),
                                UnreadMentionsCount = new TLInt(0),
                                NotifySettings      = new TLPeerNotifySettings78 {
                                    Flags = new TLInt(0), MuteUntil = new TLInt(0), Sound = new TLString("Default")
                                }
                            };
                            CurrentUser = dialog;
                        }
                    }

                    BeginOnUIThread(() =>
                    {
                        NotifyOfPropertyChange(() => CurrentUser);

                        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;
                        var importantCount = 0;
                        var count          = 0;
                        for (var i = 0; i < LazyItems.Count && importantCount < FirstSliceLength; i++, count++)
                        {
                            Items.Add(LazyItems[i]);
                            var chat41 = LazyItems[i].With as TLChat41;
                            if (chat41 == null || chat41.MigratedTo == null)
                            {
                                importantCount++;
                            }
                        }

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

                            LoadNextSlice();
                        });
                    });
                }
            });
        }
Beispiel #22
0
 public ChangePasswordViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     _passwordBase         = StateService.Password;
     StateService.Password = null;
 }
Beispiel #23
0
        public MainViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, IPushService pushService, IContactsService contactsService, DialogsViewModel dialogs)
            : base(protoService, cacheService, aggregator)
        {
            _pushService        = pushService;
            _typingManagers     = new ConcurrentDictionary <int, InputTypingManager>();
            _chatTypingManagers = new ConcurrentDictionary <int, InputTypingManager>();

            //Dialogs = new DialogCollection(protoService, cacheService);
            SearchDialogs = new ObservableCollection <TLDialog>();
            Dialogs       = dialogs;
            Contacts      = new ContactsViewModel(protoService, cacheService, aggregator, contactsService);
            Calls         = new CallsViewModel(protoService, cacheService, aggregator);

            aggregator.Subscribe(this);
        }
Beispiel #24
0
        public DialogSendLocationViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, ILocationService foursquareService)
            : base(protoService, cacheService, aggregator)
        {
            _locationService = foursquareService;

            Items = new ObservableCollection <LocationVenue>();
            OnNavigatedToAsync(null, NavigationMode.New, null);
        }
        public CreateChannelStep1ViewModel(IUploadFileManager uploadManager, ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            EventAggregator.Subscribe(this);

            _uploadManager = uploadManager;

            PropertyChanged += (sender, args) =>
            {
                if (Property.NameEquals(args.PropertyName, () => Title))
                {
                    NotifyOfPropertyChange(() => PlaceholderText);
                    NotifyOfPropertyChange(() => CanCreateChannel);
                }
            };
        }
Beispiel #26
0
 public ChannelAdminsViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
     : base(protoService, cacheService, aggregator, new TLChannelParticipantsAdmins())
 {
 }
 public SettingsPhoneIntroViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
     : base(protoService, cacheService, aggregator)
 {
 }
        public NotificationsViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            BeginOnThreadPool(() => StateService.GetNotifySettingsAsync(
                                  s =>
            {
                Settings = s;

                //Settings

                var sound             = StateService.Sounds.FirstOrDefault(x => string.Equals(x, Settings.ContactSound, StringComparison.OrdinalIgnoreCase));
                Settings.ContactSound = sound ?? StateService.Sounds[0];

                sound = StateService.Sounds.FirstOrDefault(x => string.Equals(x, Settings.GroupSound, StringComparison.OrdinalIgnoreCase));
                Settings.GroupSound = sound ?? StateService.Sounds[0];

                Settings.PropertyChanged += OnSettingsChanged;

                MTProtoService.GetNotifySettingsAsync(new TLInputNotifyUsers(),
                                                      result =>
                {
                    _suppressUpdating = true;

                    var settings = result as TLPeerNotifySettings;
                    if (settings != null)
                    {
                        Settings.ContactAlert          = settings.MuteUntil.Value == 0;
                        Settings.ContactMessagePreview = settings.ShowPreviews.Value;

                        sound = StateService.Sounds.FirstOrDefault(x => string.Equals(x, settings.Sound.Value, StringComparison.OrdinalIgnoreCase));
                        Settings.ContactSound = sound ?? StateService.Sounds[0];
                    }

                    _suppressUpdating = false;

                    SaveSettings();
                });

                MTProtoService.GetNotifySettingsAsync(new TLInputNotifyChats(),
                                                      result =>
                {
                    _suppressUpdating = true;

                    var settings = result as TLPeerNotifySettings;
                    if (settings != null)
                    {
                        Settings.GroupAlert          = settings.MuteUntil.Value == 0;
                        Settings.GroupMessagePreview = settings.ShowPreviews.Value;

                        sound = StateService.Sounds.FirstOrDefault(x => string.Equals(x, settings.Sound.Value, StringComparison.OrdinalIgnoreCase));
                        Settings.GroupSound = sound ?? StateService.Sounds[0];
                    }

                    _suppressUpdating = false;

                    SaveSettings();
                });

                SaveSettings();
            }));
        }
        public SettingsStickersArchivedViewModelBase(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, IStickersService stickersService, StickerType type)
            : base(protoService, cacheService, aggregator)
        {
            _type            = type;
            _stickersService = stickersService;
            _stickersService.NeedReloadArchivedStickers += OnNeedReloadArchivedStickers;

            Items = new ItemsCollection(protoService, type);
        }
        public SettingsStickersViewModelBase(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator, IStickersService stickersService, StickerType type)
            : base(protoService, cacheService, aggregator)
        {
            _type            = type;
            _stickersService = stickersService;
            _stickersService.StickersDidLoaded              += OnStickersDidLoaded;
            _stickersService.FeaturedStickersDidLoaded      += OnFeaturedStickersDidLoaded;
            _stickersService.ArchivedStickersCountDidLoaded += OnArchivedStickersCountDidLoaded;

            Items = new MvxObservableCollection <TLMessagesStickerSet>();
        }