async private void Button_Click(object sender, RoutedEventArgs e) { // write contacts //ContactStore store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite); //var lists = await store.FindContactListsAsync(); //ContactList list = lists.FirstOrDefault((x) => x.DisplayName == "myPrivateList"); //if (list == null) //{ // list = await store.CreateContactListAsync("myPrivateList"); // list.OtherAppReadAccess = ContactListOtherAppReadAccess.Full; // list.OtherAppWriteAccess = ContactListOtherAppWriteAccess.SystemOnly; // await list.SaveAsync(); //} //Contact contact = new Contact(); //contact.Name = "John"; //contact.Phones.Add(new ContactPhone() { Kind = ContactPhoneKind.Mobile, Number = "0917987777211" }); //await list.SaveContactAsync(contact); // write phone call history PhoneCallHistoryStore store = PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesLimitedReadWrite).GetResults(); PhoneCallHistoryEntry entry = new PhoneCallHistoryEntry(); await store.SaveEntryAsync(entry); // write sms }
public static string Convert(PhoneCallHistoryEntry entry) { if (entry.IsIncoming) { if (entry.IsCallerIdBlocked) { return(Glyphs.CALL_HISTORY_BLOCKED); } else if (entry.IsMissed) { return(Glyphs.CALL_HISTORY_MISSED); } else { return(Glyphs.CALL_HISTORY_INCOMING); } } else { return(Glyphs.CALL_HISTORY_OUTGOING); } }
public static string Convert(PhoneCallHistoryEntry entry) { if (entry.IsIncoming) { if (entry.IsCallerIdBlocked) { return("Blocked"); } else if (entry.IsMissed) { return("Missed"); } else { return(App.Current.ResourceLoader.GetString(nameof(CallState) + '_' + nameof(CallState.Incoming))); } } else { return("Outgoing"); } }
public static string Convert(PhoneCallHistoryEntry entry) { if (entry.IsIncoming) { if (entry.IsCallerIdBlocked) { return(Glyphs.SHIELD); } else if (entry.IsMissed) { return(Glyphs.HANG_UP); } else { return(Glyphs.INCOMING_CALL); } } else { return(Glyphs.PHONE); } }
private async void Call_StateChanged(Call sender, CallStateChangedEventArgs args) { switch (args.NewState) { case CallState.Disconnected: switch (args.OldState) { case CallState.Incoming: App.Current.ToastNotifier.Show(App.Current.CreateMissedCallToastNotification(sender)); PhoneCallHistoryEntry missedCall = new PhoneCallHistoryEntry() { Address = new PhoneCallHistoryEntryAddress() { DisplayName = sender.Name, RawAddress = sender.Number, RawAddressKind = PhoneCallHistoryEntryRawAddressKind.PhoneNumber }, IsIncoming = true, IsMissed = true, Media = PhoneCallHistoryEntryMedia.Audio, OtherAppReadAccess = PhoneCallHistoryEntryOtherAppReadAccess.Full, //SourceId = sender.Line.Id.ToString(), //SourceIdKind = PhoneCallHistorySourceIdKind.CellularPhoneLineId, StartTime = sender.EndTime ?? DateTimeOffset.Now, }; await App.Current.CallHistoryStore.SaveEntryAsync(missedCall); goto default; case CallState.Dialing: case CallState.OnHold: case CallState.ActiveTalking: PhoneCallHistoryEntry call = new PhoneCallHistoryEntry() { Address = new PhoneCallHistoryEntryAddress() { DisplayName = sender.Name, RawAddress = sender.Number, RawAddressKind = PhoneCallHistoryEntryRawAddressKind.PhoneNumber }, IsSeen = true, IsIncoming = sender.Direction == CallDirection.Incoming, Duration = sender.EndTime - sender.StartTime, Media = PhoneCallHistoryEntryMedia.Audio, OtherAppReadAccess = PhoneCallHistoryEntryOtherAppReadAccess.Full, //SourceId = sender.Line.Id.ToString(), //SourceIdKind = PhoneCallHistorySourceIdKind.CellularPhoneLineId, StartTime = sender.StartTime ?? DateTimeOffset.Now, }; await App.Current.CallHistoryStore.SaveEntryAsync(call); goto default; default: switch (args.StateReason) { default: sender.StateChanged -= Call_StateChanged; break; } break; } break; } }