private async void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (_suppressUpdating) { return; } if (e.PropertyName.Equals(nameof(InAppVibrate)) && InAppVibrate && IsVibrationAvailable) { await _vibrationService.VibrateAsync(); } }
private async void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (_suppressUpdating) { return; } if (e.PropertyName.Equals(nameof(InAppVibrate)) && InAppVibrate && IsVibrationAvailable) { await _vibrationService.VibrateAsync(); } if (e.PropertyName.Equals(nameof(PrivateAlert)) || e.PropertyName.Equals(nameof(PrivatePreview)) || e.PropertyName.Equals(nameof(PrivateSound))) { if (e.PropertyName.Equals(nameof(PrivateSound)) && !string.IsNullOrEmpty(PrivateSound)) { } await ProtoService.UpdateNotifySettingsAsync(new TLInputNotifyUsers(), new TLInputPeerNotifySettings { MuteUntil = _privateAlert ? 0 : int.MaxValue, IsShowPreviews = _privatePreview, //Sound = _privateSound }); } else if (e.PropertyName.Equals(nameof(GroupAlert)) || e.PropertyName.Equals(nameof(GroupPreview)) || e.PropertyName.Equals(nameof(GroupSound))) { if (e.PropertyName.Equals(nameof(GroupSound)) && !string.IsNullOrEmpty(GroupSound)) { } await ProtoService.UpdateNotifySettingsAsync(new TLInputNotifyChats(), new TLInputPeerNotifySettings { MuteUntil = _groupAlert ? 0 : int.MaxValue, IsShowPreviews = _groupPreview, //Sound = _privateSound }); } }
private async Task AcceptCandidateAsync(Candidate candidate) { await recruitmentQueryService.AcceptCandidateAsync(candidate); await vibrationService.VibrateAsync(); }
public void Notify(TLMessageCommonBase messageCommon) { //if (this._stateService.SuppressNotifications) //{ // return; //} if (messageCommon.IsOut) { return; } if (!messageCommon.IsUnread) { return; } if (messageCommon is TLMessage message && message.IsSilent) { return; } TLUser from = null; if (messageCommon.FromId != null && messageCommon.FromId.Value >= 0) { from = CacheService.GetUser(messageCommon.FromId) as TLUser; if (from == null) { return; } } try { TLObject activeDialog = CheckActiveDialog(); TLPeerBase toId = messageCommon.ToId; var fromId = messageCommon.FromId; var suppress = false; TLDialog dialog = null; if (toId is TLPeerChat && activeDialog is TLChat && toId.Id == ((TLChat)activeDialog).Id) { suppress = true; } if (toId is TLPeerChannel && activeDialog is TLChannel && toId.Id == ((TLChannel)activeDialog).Id) { suppress = true; } else if (toId is TLPeerUser && activeDialog is TLUserBase && ((from != null && from.IsSelf) || fromId.Value == ((TLUserBase)activeDialog).Id)) { suppress = true; } if (!suppress) { TLChatBase chat = null; TLUser user = null; TLChannel channel = null; if (messageCommon.ToId is TLPeerChat) { chat = CacheService.GetChat(messageCommon.ToId.Id); dialog = CacheService.GetDialog(new TLPeerChat { Id = messageCommon.ToId.Id }); } else if (messageCommon.ToId is TLPeerChannel) { chat = CacheService.GetChat(messageCommon.ToId.Id); channel = (chat as TLChannel); dialog = CacheService.GetDialog(new TLPeerChannel { ChannelId = messageCommon.ToId.Id }); } else if (messageCommon.IsOut) { user = CacheService.GetUser(messageCommon.ToId.Id) as TLUser; dialog = CacheService.GetDialog(new TLPeerUser { UserId = messageCommon.ToId.Id }); } else { user = CacheService.GetUser(messageCommon.FromId) as TLUser; dialog = CacheService.GetDialog(new TLPeerUser { UserId = messageCommon.FromId.Value }); } var now = TLUtils.DateToUniversalTimeTLInt(ProtoService.ClientTicksDelta, DateTime.Now); if (chat != null) { var notifySettingsBase = CacheService.GetFullChat(chat.Id)?.NotifySettings; if (notifySettingsBase == null) { notifySettingsBase = ((dialog != null) ? dialog.NotifySettings : null); } if (notifySettingsBase == null) { if (channel != null) { ProtoService.GetFullChannelAsync(channel.ToInputChannel(), chatFull => { //chat.NotifySettings = chatFull.FullChat.NotifySettings; if (dialog != null) { dialog.NotifySettings = chatFull.FullChat.NotifySettings; Execute.BeginOnUIThread(() => { dialog.RaisePropertyChanged(() => dialog.NotifySettings); dialog.RaisePropertyChanged(() => dialog.Self); }); } }, null); } else { ProtoService.GetFullChatAsync(chat.Id, chatFull => { //chat.NotifySettings = chatFull.FullChat.NotifySettings; if (dialog != null) { dialog.NotifySettings = chatFull.FullChat.NotifySettings; Execute.BeginOnUIThread(() => { dialog.RaisePropertyChanged(() => dialog.NotifySettings); dialog.RaisePropertyChanged(() => dialog.Self); }); } }, null); } } var notifySettings = notifySettingsBase as TLPeerNotifySettings; suppress = (notifySettings == null || notifySettings.MuteUntil > now); } if (user != null) { var notifySettingsBase = CacheService.GetFullUser(user.Id)?.NotifySettings; if (notifySettingsBase == null) { notifySettingsBase = ((dialog != null) ? dialog.NotifySettings : null); } if (notifySettingsBase == null) { ProtoService.GetFullUserAsync(user.ToInputUser(), userFull => { //user.NotifySettings = userFull.NotifySettings; if (dialog != null) { dialog.NotifySettings = userFull.NotifySettings; Execute.BeginOnUIThread(() => { dialog.RaisePropertyChanged(() => dialog.NotifySettings); dialog.RaisePropertyChanged(() => dialog.Self); }); } }, null); } var notifySettings = notifySettingsBase as TLPeerNotifySettings; suppress = (notifySettings == null || notifySettings.MuteUntil > now || user.IsSelf); } if (!suppress) { if (dialog != null) { suppress = CheckLastNotificationTime(dialog, now); } if (!suppress) { if (ApplicationSettings.Current.InAppPreview) { // TODO } if (_lastNotificationTime.HasValue) { var totalSeconds = (DateTime.Now - _lastNotificationTime.Value).TotalSeconds; if (totalSeconds > 0.0 && totalSeconds < 2.0) { suppress = true; } } _lastNotificationTime = DateTime.Now; if (suppress) { Log.Write(string.Format("Cancel notification reason=[lastNotificationTime] msg_id={0} last_notification_time={1}, now={2}", messageCommon.Id, _lastNotificationTime, DateTime.Now), null); } else { if (ApplicationSettings.Current.InAppVibrate) { _vibrationService.VibrateAsync(); } if (ApplicationSettings.Current.InAppSounds) { //if (_notificationPlayer == null) //{ // _notificationPlayer = new MediaPlayer(); // _notificationPlayer.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/Sounds/Default.wav")); //} //_notificationPlayer.Pause(); //_notificationPlayer.PlaybackSession.Position = TimeSpan.Zero; //_notificationPlayer.Play(); //string text = "Sounds/Default.wav"; //if (toId is TLPeerChat && !string.IsNullOrEmpty(s.GroupSound)) //{ // text = "Sounds/" + s.GroupSound + ".wav"; //} //else if (!string.IsNullOrEmpty(s.ContactSound)) //{ // text = "Sounds/" + s.ContactSound + ".wav"; //} //if (toId is TLPeerChat && chat != null && chat.NotifySettings is TLPeerNotifySettings) //{ // text = "Sounds/" + ((TLPeerNotifySettings)chat.NotifySettings).Sound.Value + ".wav"; //} //else if (toId is TLPeerUser && user != null && user.NotifySettings is TLPeerNotifySettings) //{ // text = "Sounds/" + ((TLPeerNotifySettings)user.NotifySettings).Sound.Value + ".wav"; //} //if (!Utils.XapContentFileExists(text)) //{ // text = "Sounds/Default.wav"; //} //System.IO.Stream stream = TitleContainer.OpenStream(text); //SoundEffect soundEffect = SoundEffect.FromStream(stream); //FrameworkDispatcher.Update(); //soundEffect.Play(); } } } } } } catch (System.Exception ex) { TLUtils.WriteLine(ex.ToString(), LogSeverity.Error); } }