public async void NeverExecute() { UserPrivacySettingRuleRestrictUsers result = null; switch (_inputKey) { case UserPrivacySettingAllowCalls allowCalls: result = await NavigationService.NavigateWithResult <UserPrivacySettingRuleRestrictUsers>(typeof(SettingsPrivacyNeverAllowCallsPage), _rules); break; case UserPrivacySettingAllowChatInvites allowChatInvites: result = await NavigationService.NavigateWithResult <UserPrivacySettingRuleRestrictUsers>(typeof(SettingsPrivacyNeverAllowChatInvitesPage), _rules); break; case UserPrivacySettingShowStatus showStatus: result = await NavigationService.NavigateWithResult <UserPrivacySettingRuleRestrictUsers>(typeof(SettingsPrivacyNeverShowStatusPage), _rules); break; } if (result != null) { Disallowed = result; } }
protected override void SendExecute() { Rule = new UserPrivacySettingRuleRestrictUsers(SelectedItems.Select(x => x.Id).ToList()); //if (_tsc != null) //{ // _tsc.SetResult(new UserPrivacySettingRuleRestrictUsers(SelectedItems.Select(x => x.Id).ToList())); //} //NavigationService.GoBack(); }
private void UpdatePrivacy(UserPrivacySettingRules rules) { var disallowed = rules.Rules.FirstOrDefault(x => x is UserPrivacySettingRuleRestrictUsers) as UserPrivacySettingRuleRestrictUsers; if (disallowed == null) { disallowed = new UserPrivacySettingRuleRestrictUsers(new int[0]); } var users = ProtoService.GetUsers(disallowed.UserIds); BeginOnUIThread(() => { SelectedItems.AddRange(users); }); }
private void UpdatePrivacy(UserPrivacySettingRules rules) { _rules = rules; var badge = string.Empty; PrivacyValue?primary = null; UserPrivacySettingRuleRestrictUsers disallowed = null; UserPrivacySettingRuleAllowUsers allowed = null; foreach (var current in rules.Rules) { if (current is UserPrivacySettingRuleAllowAll) { primary = PrivacyValue.AllowAll; badge = Strings.Resources.LastSeenEverybody; } else if (current is UserPrivacySettingRuleAllowContacts) { primary = PrivacyValue.AllowContacts; badge = Strings.Resources.LastSeenContacts; } else if (current is UserPrivacySettingRuleRestrictAll) { primary = PrivacyValue.DisallowAll; badge = Strings.Resources.LastSeenNobody; } else if (current is UserPrivacySettingRuleRestrictUsers disallowUsers) { disallowed = disallowUsers; } else if (current is UserPrivacySettingRuleAllowUsers allowUsers) { allowed = allowUsers; } } if (primary == null) { primary = PrivacyValue.DisallowAll; badge = Strings.Resources.LastSeenNobody; } var list = new List <string>(); if (disallowed != null) { list.Add("-" + disallowed.UserIds.Count); } if (allowed != null) { list.Add("+" + allowed.UserIds.Count); } if (list.Count > 0) { badge = string.Format("{0} ({1})", badge, string.Join(", ", list)); } BeginOnUIThread(() => { Badge = badge; SelectedItem = primary ?? PrivacyValue.DisallowAll; Allowed = allowed ?? new UserPrivacySettingRuleAllowUsers(new int[0]); Disallowed = disallowed ?? new UserPrivacySettingRuleRestrictUsers(new int[0]); }); }
private void UpdatePrivacy(UserPrivacySettingRules rules) { _rules = rules; var badge = string.Empty; PrivacyValue?primary = null; var restricted = 0; var allowed = 0; UserPrivacySettingRuleAllowUsers allowedUsers = null; UserPrivacySettingRuleAllowChatMembers allowedChatMembers = null; UserPrivacySettingRuleRestrictUsers restrictedUsers = null; UserPrivacySettingRuleRestrictChatMembers restrictedChatMembers = null; foreach (var current in rules.Rules) { if (current is UserPrivacySettingRuleAllowAll) { primary = PrivacyValue.AllowAll; badge = Strings.Resources.LastSeenEverybody; } else if (current is UserPrivacySettingRuleAllowContacts) { primary = PrivacyValue.AllowContacts; badge = Strings.Resources.LastSeenContacts; } else if (current is UserPrivacySettingRuleRestrictAll) { primary = PrivacyValue.DisallowAll; badge = Strings.Resources.LastSeenNobody; } else if (current is UserPrivacySettingRuleRestrictUsers disallowUsers) { restrictedUsers = disallowUsers; restricted += disallowUsers.UserIds.Count; } else if (current is UserPrivacySettingRuleAllowUsers allowUsers) { allowedUsers = allowUsers; allowed += allowUsers.UserIds.Count; } else if (current is UserPrivacySettingRuleRestrictChatMembers restrictChatMembers) { restrictedChatMembers = restrictChatMembers; foreach (var chatId in restrictChatMembers.ChatIds) { var chat = CacheService.GetChat(chatId); if (chat == null) { continue; } if (CacheService.TryGetBasicGroup(chat, out BasicGroup basicGroup)) { restricted += basicGroup.MemberCount; } else if (CacheService.TryGetSupergroup(chat, out Supergroup supergroup)) { restricted += supergroup.MemberCount; } } } else if (current is UserPrivacySettingRuleAllowChatMembers allowChatMembers) { allowedChatMembers = allowChatMembers; foreach (var chatId in allowChatMembers.ChatIds) { var chat = CacheService.GetChat(chatId); if (chat == null) { continue; } if (CacheService.TryGetBasicGroup(chat, out BasicGroup basicGroup)) { allowed += basicGroup.MemberCount; } else if (CacheService.TryGetSupergroup(chat, out Supergroup supergroup)) { allowed += supergroup.MemberCount; } } } } if (primary == null) { primary = PrivacyValue.DisallowAll; badge = Strings.Resources.LastSeenNobody; } var list = new List <string>(); if (restricted > 0) { list.Add("-" + restricted); } if (allowed > 0) { list.Add("+" + allowed); } if (list.Count > 0) { badge = string.Format("{0} ({1})", badge, string.Join(", ", list)); } _restrictedUsers = restrictedUsers ?? new UserPrivacySettingRuleRestrictUsers(new int[0]); _restrictedChatMembers = restrictedChatMembers ?? new UserPrivacySettingRuleRestrictChatMembers(new long[0]); _allowedUsers = allowedUsers ?? new UserPrivacySettingRuleAllowUsers(new int[0]); _allowedChatMembers = allowedChatMembers ?? new UserPrivacySettingRuleAllowChatMembers(new long[0]); BeginOnUIThread(() => { SelectedItem = primary ?? PrivacyValue.DisallowAll; Badge = badge; AllowedBadge = allowed > 0 ? Locale.Declension("Users", allowed) : Strings.Resources.EmpryUsersPlaceholder; RestrictedBadge = restricted > 0 ? Locale.Declension("Users", restricted) : Strings.Resources.EmpryUsersPlaceholder; }); }