-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from WOA-Project/contacts-wip
Contacts wip
- Loading branch information
Showing
90 changed files
with
639 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Dialer/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Dialer/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png
Oops, something went wrong.
Binary file modified
BIN
+3.32 KB
(120%)
Dialer/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Dialer/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Dialer/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Dialer/Assets/Square44x44Logo.altform-unplated_targetsize-16.png
Oops, something went wrong.
Binary file modified
BIN
+3.32 KB
(120%)
Dialer/Assets/Square44x44Logo.altform-unplated_targetsize-256.png
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Dialer/Assets/Square44x44Logo.altform-unplated_targetsize-32.png
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Dialer/Assets/Square44x44Logo.altform-unplated_targetsize-48.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+0 Bytes
(100%)
Dialer/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using Dialer.UI.Controls; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.ApplicationModel.Contacts; | ||
|
||
namespace Dialer.Systems | ||
{ | ||
class ContactSystem | ||
{ | ||
private static ContactStore _contactStore; | ||
private static ObservableCollection<Contact> _contacts; | ||
private static ObservableCollection<ContactControl> _contactControls; | ||
|
||
public static event EventHandler ContactsLoaded; | ||
|
||
public static bool ContactsLoading = false; | ||
|
||
public static ObservableCollection<Contact> Contacts | ||
{ | ||
get | ||
{ | ||
if (_contacts != null) return _contacts; | ||
else return null; | ||
} | ||
} | ||
|
||
public static ObservableCollection<ContactControl> ContactControls | ||
{ | ||
get | ||
{ | ||
if (_contactControls != null) return _contactControls; | ||
else return null; | ||
} | ||
} | ||
|
||
public static async void LoadContacts() | ||
{ | ||
if(_contacts == null && ContactsLoading == false) | ||
{ | ||
ContactsLoading = true; | ||
_contactStore = await ContactManager.RequestStoreAsync(); | ||
ObservableCollection<Contact> t_contacts = new ObservableCollection<Contact>(await _contactStore.FindContactsAsync()); | ||
|
||
Debug.WriteLine("Found " + t_contacts.Count + " contacts"); | ||
|
||
ObservableCollection<ContactControl> t_contactControls = new ObservableCollection<ContactControl>(); | ||
|
||
foreach (Contact contact in t_contacts) | ||
{ | ||
ContactControl cc = new ContactControl(); | ||
cc.AssociatedContact = contact; | ||
cc.ContactName = contact.DisplayName; | ||
if (contact.Phones.Count == 0) continue; | ||
cc.ContactMainPhone = contact.Phones[0].Number; | ||
List<Tuple<string, string>> additionalPhones = new List<Tuple<string, string>>(); | ||
foreach (ContactPhone contactPhone in contact.Phones) | ||
{ | ||
additionalPhones.Add(new Tuple<string, string>(contactPhone.Kind.ToString(), contactPhone.Number)); | ||
} | ||
cc.AdditionalContactPhones = additionalPhones; | ||
if (contact.SmallDisplayPicture != null) | ||
//TODO: Fix wrong cast | ||
cc.ContactPicture = contact.SmallDisplayPicture; | ||
t_contactControls.Add(cc); | ||
} | ||
_contacts = t_contacts; | ||
_contactControls = t_contactControls; | ||
|
||
ContactsLoading = false; | ||
|
||
ContactsLoaded?.Invoke(null, EventArgs.Empty); | ||
} | ||
} | ||
|
||
public static async Task DeleteContact(Contact contact) | ||
{ | ||
ContactStore cs = await ContactManager.RequestStoreAsync(); | ||
ContactList cl = null; | ||
try | ||
{ | ||
cl = await cs.GetContactListAsync(contact.ContactListId); | ||
} | ||
catch | ||
{ | ||
IReadOnlyList<ContactList> contactlists = await cs.FindContactListsAsync(); | ||
foreach (ContactList _cl in contactlists) | ||
{ | ||
try | ||
{ | ||
if (_cl.GetContactAsync(contact.Id) != null) cl = _cl; | ||
} | ||
catch { } | ||
} | ||
} | ||
if (cl == null) return; //For some reason the correct contact list can't be retrieved. It should be in Contact.ContactListId, but... | ||
await cl.DeleteContactAsync(contact); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<UserControl | ||
x:Class="Dialer.UI.Controls.AdditionalPhoneContactPresenter" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Dialer.UI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400"> | ||
|
||
<Grid> | ||
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Center"> | ||
<TextBlock x:Name="PhoneTypeTB" Style="{StaticResource CaptionTextBlockStyle}" Margin="0, 0, 0, 5"><Run Text="[PhoneType]"/></TextBlock> | ||
<TextBlock x:Name="PhoneNumberTB"><Run Text="[+99 999 999999]"/></TextBlock> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Right"> | ||
<Button Style="{StaticResource TextBlockButtonStyle}"> | ||
<FontIcon Foreground="{StaticResource ApplicationForegroundThemeBrush}" FontSize="18" Glyph=""></FontIcon> | ||
</Button> | ||
<Button HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0, 0, 0, 0"> | ||
<StackPanel Orientation="Horizontal" Spacing="10"> | ||
<FontIcon FontFamily="Segoe Fluent Icons" Glyph="" /> | ||
<TextBlock Text="Call"></TextBlock> | ||
</StackPanel> | ||
</Button> | ||
</StackPanel> | ||
</Grid> | ||
</UserControl> |
38 changes: 38 additions & 0 deletions
38
Dialer/UI/Controls/AdditionalPhoneContactPresenter.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
|
||
namespace Dialer.UI.Controls | ||
{ | ||
public sealed partial class AdditionalPhoneContactPresenter : UserControl | ||
{ | ||
public string PhoneType | ||
{ | ||
get => PhoneTypeTB.Text; | ||
set => PhoneTypeTB.Text = value; | ||
} | ||
|
||
public string PhoneNumber | ||
{ | ||
get => PhoneNumberTB.Text; | ||
set => PhoneNumberTB.Text = value; | ||
} | ||
|
||
public AdditionalPhoneContactPresenter() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<UserControl | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Dialer.UI.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:Custom="using:System.Numerics" | ||
xmlns:Windows10version1809="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 7)" | ||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | ||
x:Class="Dialer.UI.Controls.ContactControl" | ||
mc:Ignorable="d" | ||
d:DesignHeight="80" | ||
d:DesignWidth="600"> | ||
|
||
<muxc:Expander x:Name="ContactExpander" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch"> | ||
<muxc:Expander.ContextFlyout> | ||
<MenuFlyout> | ||
<MenuFlyoutItem Text="Call" Icon="Phone" Click="FlyoutCallContact_Click"></MenuFlyoutItem> | ||
<MenuFlyoutSeparator></MenuFlyoutSeparator> | ||
<MenuFlyoutItem Text="Copy" Icon="Copy" IsEnabled="False"></MenuFlyoutItem> | ||
<MenuFlyoutItem Text="Share Contact" Icon="Share" IsEnabled="False"></MenuFlyoutItem> | ||
<MenuFlyoutSeparator></MenuFlyoutSeparator> | ||
<MenuFlyoutItem Text="Delete Contact" Icon="Delete" Click="FlyoutDeleteContact_Click" IsEnabled="False"></MenuFlyoutItem> | ||
</MenuFlyout> | ||
</muxc:Expander.ContextFlyout> | ||
<muxc:Expander.Header> | ||
<Grid x:Name="PrimaryPanel" MinHeight="80" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> | ||
<Ellipse HorizontalAlignment="Left" VerticalAlignment="Center" Margin="30, 0, 0, 0" Width="40" Height="40"> | ||
<Ellipse.Fill> | ||
<ImageBrush x:Name="ContactImage" ImageSource="/Assets/NoContactIcon.png"/> | ||
</Ellipse.Fill> | ||
</Ellipse> | ||
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="90, 0, 0, 0"> | ||
<TextBlock x:Name="ContactNameTB"><Run Text="[ContactName]"/></TextBlock> | ||
<TextBlock x:Name="ContactMainPhoneTB" Style="{StaticResource CaptionTextBlockStyle}"><Run Text="[+99 999 999999]"/></TextBlock> | ||
</StackPanel> | ||
<Button x:Name="MainCallButton" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0, 0, 0, 0" Tapped="MainCallButton_Tapped"> | ||
<StackPanel Orientation="Horizontal" Spacing="10"> | ||
<FontIcon FontFamily="Segoe Fluent Icons" Glyph="" /> | ||
<TextBlock Text="Call"></TextBlock> | ||
</StackPanel> | ||
</Button> | ||
</Grid> | ||
</muxc:Expander.Header> | ||
<Grid x:Name="MoreDataPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> | ||
<ItemsControl x:Name="ContactsItemsControl" ItemsSource="{x:Bind additionalPhoneContactPresenters}"> | ||
<ItemsControl.ItemsPanel> | ||
<ItemsPanelTemplate> | ||
<StackPanel Spacing="10"> | ||
</StackPanel> | ||
</ItemsPanelTemplate> | ||
</ItemsControl.ItemsPanel> | ||
</ItemsControl> | ||
</Grid> | ||
</muxc:Expander> | ||
</UserControl> |
Oops, something went wrong.