private void AddAcTestData(List<CustomCellGroup> cellGroups){ acTableCellGroup = new CustomCellGroup{ Name = "A" }; cellGroups.Add (acTableCellGroup); GroupMemberCell cell = GroupMemberCell.Create (); cell.SetName ("Jonny Appleseed"); cell.removeButton.Hidden = true; acTableCellGroup.Cells.Add (cell); acTableCellGroup = new CustomCellGroup{ Name = "B" }; cellGroups.Add (acTableCellGroup); cell = GroupMemberCell.Create (); cell.SetName ("Jen Bowman"); cell.removeButton.Hidden = true; acTableCellGroup.Cells.Add (cell); acTableCellGroup = new CustomCellGroup{ Name = "C" }; cellGroups.Add (acTableCellGroup); cell = GroupMemberCell.Create (); cell.SetName ("Jackie Chan"); cell.removeButton.Hidden = true; acTableCellGroup.Cells.Add (cell); acTableCellGroup = new CustomCellGroup{ Name = "D" }; cellGroups.Add (acTableCellGroup); cell = GroupMemberCell.Create (); cell.SetName ("Matt Duke"); cell.removeButton.Hidden = true; acTableCellGroup.Cells.Add (cell); acTableCellGroup = new CustomCellGroup{ Name = "F" }; cellGroups.Add (acTableCellGroup); cell = GroupMemberCell.Create (); cell.SetName ("Jeff Franco"); cell.removeButton.Hidden = true; acTableCellGroup.Cells.Add (cell); acTableCellGroup = new CustomCellGroup{ Name = "S" }; cellGroups.Add (acTableCellGroup); cell = GroupMemberCell.Create (); cell.SetName ("David Smith"); cell.removeButton.Hidden = true; acTableCellGroup.Cells.Add (cell); acTableCellGroup = new CustomCellGroup{ Name = "T" }; cellGroups.Add (acTableCellGroup); cell = GroupMemberCell.Create (); cell.SetName ("Ryan Tillman"); cell.removeButton.Hidden = true; acTableCellGroup.Cells.Add (cell); }
public void PopulateTable(){ List<CustomCellGroup> cellGroups = new List<CustomCellGroup> (); tableCellGroup = new CustomCellGroup (); cellGroups.Add (tableCellGroup); for (int x = 0; x <= 8; x++) { ContactKeysCell chatCell = ContactKeysCell.Create (); chatCell.SetHeader("John Doe (" + x + ")"); chatCell.SetSubHeader("XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX"); tableCellGroup.Cells.Add (chatCell); } source = new CustomCellTableSource(cellGroups); source.RowSelectedAction = RowSelected; table.Source = source; }
private void LoadTable(ChatBubbleCell _cell) { List<CustomCellGroup> cellGroups = new List<CustomCellGroup>(); tableCellGroup = new CustomCellGroup(); cellGroups.Add(tableCellGroup); ChatBubbleCell cell; for (int x = 0; x < messages.Count; x++) { cell = new ChatBubbleCell(isLeft[x], false, isdelivered[x]); cell.Update(messages[x], timeStamps[x]); cell.SetMessageID(message_ids[x]); if (!isdelivered[x]) cell.SetAsUndelivered(); tableCellGroup.Cells.Add(cell); } if (_cell != null) { tableCellGroup.Cells.Add(_cell); } SetTableSize(); // //Pending // cell = new ChatBubbleCell(false); // cell.Update ("This is a pending cell", "8:00 PM"); // cell.SetAsPending (); // tableCellGroup.Cells.Add (cell); // // //Undelivered // cell = new ChatBubbleCell(true); // cell.Update ("This is a undelivered cell", "8:05 PM"); // cell.SetAsUndelivered (); // tableCellGroup.Cells.Add (cell); source = new CustomCellTableSource(cellGroups); source.RowSelectedAction = RowSelected; source.DeleteAction = DeleteSelected; source.DeleteTitle = "Delete"; table.Source = source; }
public void PopulateTable(){ List<CustomCellGroup> cellGroups = new List<CustomCellGroup> (); tableCellGroup = new CustomCellGroup (); cellGroups.Add (tableCellGroup); SettingsCell cell; SettingsHeader hCell; hCell = SettingsHeader.Create (); hCell.SetHeader("REGISTRATION"); tableCellGroup.Cells.Add (hCell); cell = SettingsCell.Create (); cell.sectionDetail.Text = "Turn this off to unregister your account"; tableCellGroup.Cells.Add (cell); hCell = SettingsHeader.Create (); hCell.SetHeader("NOTIFICATIONS"); tableCellGroup.Cells.Add (hCell); hCell = SettingsHeader.Create (); hCell.SetSubheader("Notifications"); tableCellGroup.Cells.Add (hCell); cell = SettingsCell.Create (); cell.sectionDetail.Text = "Display message notifications in the status bar"; tableCellGroup.Cells.Add (cell); hCell = SettingsHeader.Create (); hCell.SetSubheader("In-thread notifications"); tableCellGroup.Cells.Add (hCell); cell = SettingsCell.Create (); cell.sectionDetail.Text = "Display message notifications in status bar"; tableCellGroup.Cells.Add (cell); hCell = SettingsHeader.Create (); hCell.SetHeader("INPUT SETTINGS"); tableCellGroup.Cells.Add (hCell); hCell = SettingsHeader.Create (); hCell.SetSubheader("Enter sends"); tableCellGroup.Cells.Add (hCell); cell = SettingsCell.Create (); cell.sectionDetail.Text = "Pressing the enter key will send text messages"; tableCellGroup.Cells.Add (cell); // hCell = SettingsHeader.Create (); // hCell.SetHeader("APPEARANCE"); // tableCellGroup.Cells.Add (hCell); // // hCell = SettingsHeader.Create (); // hCell.SetSubheader("Theme"); // tableCellGroup.Cells.Add (hCell); // // hCell = SettingsHeader.Create (); // hCell.SetSubheader("Language"); // tableCellGroup.Cells.Add (hCell); hCell = SettingsHeader.Create (); hCell.SetHeader("STORAGE"); tableCellGroup.Cells.Add (hCell); hCell = SettingsHeader.Create (); hCell.SetSubheader("Delete old messages"); tableCellGroup.Cells.Add (hCell); cell = SettingsCell.Create (); cell.sectionDetail.Text = "Automatically delete older messages once a conversation thread reaches a certain length"; cell.sectionButton.ValueChanged += delegate { }; tableCellGroup.Cells.Add (cell); // hCell = SettingsHeader.Create (); // hCell.SetSubheader("Conversation limit length"); // tableCellGroup.Cells.Add (hCell); // // hCell = SettingsHeader.Create (); // hCell.SetSubheader("Trim all threads now"); // tableCellGroup.Cells.Add (hCell); hCell = SettingsHeader.Create (); hCell.SetHeader("ADVANCED"); tableCellGroup.Cells.Add (hCell); hCell = SettingsHeader.Create (); hCell.SetSubheader("Complete key exchanges"); tableCellGroup.Cells.Add (hCell); cell = SettingsCell.Create (); cell.sectionDetail.Text = "Automatically complete key exchanges for new session or for existing sessions with the same identity key"; tableCellGroup.Cells.Add (cell); hCell = SettingsHeader.Create (); hCell.SetSubheader("Screen security"); tableCellGroup.Cells.Add (hCell); cell = SettingsCell.Create (); cell.sectionDetail.Text = "Disable screen security to allow screen shots"; tableCellGroup.Cells.Add (cell); hCell = SettingsHeader.Create (); hCell.SetSubheader("Refresh Push Directory"); tableCellGroup.Cells.Add (hCell); source = new CustomCellTableSource(cellGroups); source.RowSelectedAction = RowSelected; table.Source = source; }
private void AddContactsData(String contactFilter) { // Figure out where the SQLite database will be. bool showAll = contactFilter != "Securecom users"; var conn = new SQLite.SQLiteConnection(AppDelegate._dbPath); List<PushContact> pc = conn.Query<PushContact>("select * from PushContact"); conn.Close(); List<String> registeredContacts = new List<String>(); List<String> groups = new List<String>(); foreach (PushContact c in pc) registeredContacts.Add(c.Number); var phoneUtil = PhoneNumberUtil.GetInstance(); if (!showAll) { Dictionary<String, List<String>> map = new Dictionary<String, List<String>>(); foreach (PushContact c in pc) { String n = c.Name ?? c.Number; if (!map.ContainsKey(n)) map[n] = new List<String>(); map[n].Add(c.Number); } foreach (KeyValuePair<String, List<String>> entry in map.OrderBy(c => c.Key)) { String group = entry.Key.Substring(0, 1).ToUpper(); bool newGroup = !groups.Contains(group); foreach (CustomCellGroup ccg in cellGroups) { if (ccg.Name.Equals(group)) { newGroup = false; tableCellGroup = ccg; } } ContactListCell cell = ContactListCell.Create(); cell.SetName(entry.Key); foreach (String number in entry.Value) { if (number.Contains("@")) cell.SetEmail(number); else cell.SetPhone(number); } if (newGroup) { tableCellGroup = new CustomCellGroup { Name = group }; cellGroups.Add(tableCellGroup); } tableCellGroup.Cells.Add(cell); } return; } AddressBook book = new AddressBook(); book.RequestPermission().ContinueWith(t => { if (!t.Result) { Console.WriteLine("Permission denied by user or manifest"); return; } }, TaskScheduler.FromCurrentSynchronizationContext()); foreach (Contact contact in book.OrderBy(c => c.DisplayName)) { if (!showAll && registeredContacts.Count == 0) break; if (String.IsNullOrEmpty(contact.DisplayName)) continue; String group = contact.DisplayName.Substring(0, 1).ToUpper(); bool newGroup = !groups.Contains(group); foreach (CustomCellGroup ccg in cellGroups) { if (ccg.Name.Equals(group)) { newGroup = false; tableCellGroup = ccg; } } ContactListCell cell = ContactListCell.Create(); cell.SetName(contact.DisplayName); cell.SetEmail(null); cell.SetPhone(null); if (contact.Phones.Any()) { foreach (Phone p in contact.Phones) { if (showAll) { cell.SetPhone(p.Number); cell.registeredState = ContactListCell.STATE_PENDING; break; } if (p.Number.Contains("*") || p.Number.Contains("#")) continue; String number; try { number = phoneUtil.Format(phoneUtil.Parse(p.Number, AppDelegate.GetCountryCode()), PhoneNumberFormat.E164); } catch (Exception e) { continue; } if (!registeredContacts.Contains(number)) continue; registeredContacts.Remove(number); cell.SetPhone(p.Number); cell.registeredState = ContactListCell.STATE_REGISTERED; //conn.Execute("UPDATE PushContact Set Name = ? WHERE Number = ?", contact.DisplayName, number); break; } } if (contact.Emails.Any()) { foreach (Email e in contact.Emails) { if (showAll) { cell.SetEmail(e.Address); cell.registeredState = ContactListCell.STATE_PENDING; break; } if (!registeredContacts.Contains(e.Address)) continue; registeredContacts.Remove(e.Address); cell.SetEmail(e.Address); cell.registeredState = ContactListCell.STATE_REGISTERED; //conn.Execute("UPDATE PushContact Set Name = ? WHERE Number = ?", contact.DisplayName, e.Address); break; } } if (cell._email == null && cell.mobile == null) continue; if (newGroup) { tableCellGroup = new CustomCellGroup { Name = group }; cellGroups.Add(tableCellGroup); } tableCellGroup.Cells.Add(cell); } //conn.Close(); }
private void ProcessSearchOnAllContacts(string searchText) { List<CustomCellGroup> mCellGroups = new List<CustomCellGroup>(); CustomCellGroup mTableCellGroup = new CustomCellGroup(); AddressBook book = new AddressBook(); foreach (Contact contact in book.OrderBy(c => c.DisplayName)) { if (String.IsNullOrEmpty(contact.DisplayName)) continue; bool found = false; //Decide contact group based on the first character String group = contact.DisplayName.Substring(0, 1).ToUpper(); if (contact.DisplayName.ToLower().Contains(searchText)) { found = true; } else if (contact.Phones.Any()) { foreach (Phone p in contact.Phones) { String temp = p.Number .Replace("(", string.Empty) .Replace(")", string.Empty) .Replace("-", string.Empty) .Replace(" ", string.Empty); found |= temp.Contains(searchText); } } else if (contact.Emails.Any()) { foreach (Email e in contact.Emails) { found |= e.Address.ToLower().Contains(searchText); } } if (!found) continue; ContactListCell cell = ContactListCell.Create(); cell.SetName(contact.DisplayName); foreach (Phone p in contact.Phones) { cell.SetPhone(p.Number); break; } foreach (Email e in contact.Emails) { cell.SetEmail(e.Address); break; } mTableCellGroup.Cells.Add(cell); } mTableCellGroup.Name = mTableCellGroup.Cells.Count == 0 ? "No Results" : "Search Results"; mCellGroups.Add(mTableCellGroup); source = new CustomCellTableSource(mCellGroups); source.RowSelectedAction = RowSelected; table.Source = source; }
private void ProcessSearchOnSecurecomContacts(string searchText) { List<CustomCellGroup> mCellGroups = new List<CustomCellGroup>(); List<PushContact> pc; CustomCellGroup mTableCellGroup = new CustomCellGroup { Name = "No Results" }; using (var conn = new SQLite.SQLiteConnection(AppDelegate._dbPath)) { pc = conn.Query<PushContact>("select * from PushContact"); } foreach (PushContact _c in pc) { if (String.IsNullOrEmpty(_c.Name)) continue; if (_c.Name.ToLower().Contains(searchText) || _c.Number.Contains(searchText)) { mTableCellGroup.Name = "Search Results"; ContactListCell cell = ContactListCell.Create(); cell.SetName(_c.Name); if (_c.Number.Contains("@")) { cell.SetEmail(_c.Number); } else { cell.SetPhone(_c.Number); } mTableCellGroup.Cells.Add(cell); } } mCellGroups.Add(mTableCellGroup); source = new CustomCellTableSource(mCellGroups); source.RowSelectedAction = RowSelected; table.Source = source; }
public void PopulateTable(){ List<CustomCellGroup> cellGroups = new List<CustomCellGroup> (); tableCellGroup = new CustomCellGroup (); cellGroups.Add (tableCellGroup); AddTestData (); source = new CustomCellTableSource(cellGroups); source.RowSelectedAction = RowSelected; table.Source = source; }
public override void ViewDidLoad() { base.ViewDidLoad(); this.appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate; appDelegate.chatView.setThreadID(0); ShowEditButton(); this.composeButton.Clicked += (sender, e) => { ComposeAction(); }; this.editButton.Clicked += (sender, e) => { ShowDoneButton(); }; this.doneButton.Clicked += (sender, e) => { ShowEditButton(); }; this.keysButton.Clicked += (sender, e) => { this.appDelegate.GoToView(this.appDelegate.myIdKeyView); }; this.markAllReadButton.Clicked += (sender, e) => { this.appDelegate.alert.showOkAlert("Mark All Read", "Marking all chat messages as read."); }; settingsButton.Clicked += (sender, e) => { //this.appDelegate.GoToView(this.appDelegate.settingsView); SettingsAction(); }; search.CancelButtonClicked += (sender, e) => { search.Text = ""; search.ResignFirstResponder(); search.SetShowsCancelButton(false, true); PopulateTable(); }; search.TextChanged += async (object sender, UISearchBarTextChangedEventArgs e) => { search.SetShowsCancelButton(true, true); String searchText = e.SearchText.ToLower(); if (e.SearchText.Equals("")) { PopulateTable(); return; } List<CustomCellGroup> mCellGroups = new List<CustomCellGroup>(); CustomCellGroup mTableCellGroup = new CustomCellGroup(); int count = 0; foreach (PushChatThread thread in pct) { if (String.IsNullOrEmpty(thread.Number)) continue; if (!thread.Number.ToLower().Contains(searchText) && !thread.DisplayName.ToLower().Contains(searchText)) continue; ChatCell chatCell = ChatCell.Create(); chatCell.SetHeader(thread.DisplayName + " (" + thread.Number + ")"); chatCell.SetSubheading(thread.Snippet); chatCell.SetThreadID(thread.ID); chatCell.SetNumber(thread.Number); chatCell.SetAvatar(null); DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(thread.TimeStamp / 1000).ToLocalTime(); chatCell.SetLabelTime(epoch.ToString("HH:mm")); chatCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; mTableCellGroup.Cells.Insert(count, chatCell); count++; } mTableCellGroup.Name = (count == 0) ? "No Results" : "Search Results"; mCellGroups.Add(mTableCellGroup); source = new CustomCellTableSource(mCellGroups); source.RowSelectedAction = RowSelected; source.DeleteAction = DeleteSelected; source.DeleteTitle = "Delete"; table.Source = source; table.ReloadData(); }; }
public void PopulateTable() { table.ReloadData(); UIImage thumbnail = null; List<CustomCellGroup> cellGroups = new List<CustomCellGroup>(); tableCellGroup = new CustomCellGroup(); cellGroups.Add(tableCellGroup); PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance(); AddressBook book = new AddressBook(); var conn = new SQLite.SQLiteConnection(AppDelegate._dbPath); pct = conn.Query<PushChatThread>("SELECT * FROM PushChatThread ORDER BY TimeStamp DESC"); conn.Close(); int count = 0; foreach (PushChatThread thread in pct) { String display_name = thread.DisplayName; ChatCell chatCell = ChatCell.Create(); chatCell.SetHeader(display_name + " (" + thread.Number + ")"); chatCell.SetSubheading(thread.Snippet); chatCell.SetThreadID(thread.ID); chatCell.SetNumber(thread.Number); chatCell.SetAvatar(thumbnail); DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(thread.TimeStamp / 1000).ToLocalTime(); chatCell.SetLabelTime("" + epoch.ToString("HH:mm")); chatCell.Accessory = UITableViewCellAccessory.DisclosureIndicator; if (thread.Read != 0) chatCell.BackgroundColor = UIColor.Green; tableCellGroup.Cells.Insert(count, chatCell); count++; } source = new CustomCellTableSource(cellGroups); source.RowSelectedAction = RowSelected; source.DeleteAction = DeleteSelected; source.DeleteTitle = "Delete"; table.Source = source; ShowEditButton(); }