Skip to content

Commit 736081c

Browse files
committed
Somewhat ready for new release
1 parent d58d13a commit 736081c

File tree

6 files changed

+44
-32
lines changed

6 files changed

+44
-32
lines changed

Dialer/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private async Task InitializateSystems()
7171
ResourceLoader = ResourceLoader.GetForViewIndependentUse();
7272
NotificationSystem.Initializate();
7373
await CallSystem.Initializate();
74-
await ContactSystem.LoadContacts();
74+
ContactSystem.LoadContacts();
7575
}
7676

7777
protected override void OnActivated(IActivatedEventArgs args)

Dialer/Systems/ContactSystem.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ public static ObservableCollection<ContactControl> ContactControls
3838
}
3939
}
4040

41-
public static async Task LoadContacts()
41+
public static async void LoadContacts()
4242
{
4343
if(_contacts == null && ContactsLoading == false)
4444
{
4545
ContactsLoading = true;
4646
_contactStore = await ContactManager.RequestStoreAsync();
47-
_contacts = new ObservableCollection<Contact>(await _contactStore.FindContactsAsync());
47+
ObservableCollection<Contact> t_contacts = new ObservableCollection<Contact>(await _contactStore.FindContactsAsync());
4848

49-
Debug.WriteLine("Found " + _contacts.Count + " contacts");
49+
Debug.WriteLine("Found " + t_contacts.Count + " contacts");
5050

51-
_contactControls = new ObservableCollection<ContactControl>();
51+
ObservableCollection<ContactControl> t_contactControls = new ObservableCollection<ContactControl>();
5252

53-
foreach (Contact contact in _contacts)
53+
foreach (Contact contact in t_contacts)
5454
{
5555
ContactControl cc = new ContactControl();
5656
cc.AssociatedContact = contact;
@@ -66,11 +66,15 @@ public static async Task LoadContacts()
6666
if (contact.SmallDisplayPicture != null)
6767
//TODO: Fix wrong cast
6868
cc.ContactPicture = contact.SmallDisplayPicture;
69-
_contactControls.Add(cc);
69+
t_contactControls.Add(cc);
7070
}
71-
}
71+
_contacts = t_contacts;
72+
_contactControls = t_contactControls;
73+
74+
ContactsLoading = false;
7275

73-
ContactsLoaded?.Invoke(null, EventArgs.Empty);
76+
ContactsLoaded?.Invoke(null, EventArgs.Empty);
77+
}
7478
}
7579

7680
public static async Task DeleteContact(Contact contact)

Dialer/UI/Controls/AdditionalPhoneContactPresenter.xaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010
d:DesignWidth="400">
1111

1212
<Grid>
13-
<Grid.ContextFlyout>
14-
<MenuFlyout>
15-
<MenuFlyoutItem Text="Call" Icon="Phone"></MenuFlyoutItem>
16-
<MenuFlyoutItem Text="Copy" Icon="Copy"></MenuFlyoutItem>
17-
</MenuFlyout>
18-
</Grid.ContextFlyout>
1913
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Center">
2014
<TextBlock x:Name="PhoneTypeTB" Style="{StaticResource CaptionTextBlockStyle}" Margin="0, 0, 0, 5"><Run Text="[PhoneType]"/></TextBlock>
2115
<TextBlock x:Name="PhoneNumberTB"><Run Text="[+99 999 999999]"/></TextBlock>

Dialer/UI/Controls/ContactControl.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
<muxc:Expander x:Name="ContactExpander" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch">
1616
<muxc:Expander.ContextFlyout>
1717
<MenuFlyout>
18-
<MenuFlyoutItem Text="Call" Icon="Phone"></MenuFlyoutItem>
18+
<MenuFlyoutItem Text="Call" Icon="Phone" Click="FlyoutCallContact_Click"></MenuFlyoutItem>
1919
<MenuFlyoutSeparator></MenuFlyoutSeparator>
20-
<MenuFlyoutItem Text="Copy" Icon="Copy"></MenuFlyoutItem>
21-
<MenuFlyoutItem Text="Share Contact" Icon="Share"></MenuFlyoutItem>
20+
<MenuFlyoutItem Text="Copy" Icon="Copy" IsEnabled="False"></MenuFlyoutItem>
21+
<MenuFlyoutItem Text="Share Contact" Icon="Share" IsEnabled="False"></MenuFlyoutItem>
2222
<MenuFlyoutSeparator></MenuFlyoutSeparator>
23-
<MenuFlyoutItem Text="Delete Contact" Icon="Delete" Click="FlyoutDeleteContact_Click"></MenuFlyoutItem>
23+
<MenuFlyoutItem Text="Delete Contact" Icon="Delete" Click="FlyoutDeleteContact_Click" IsEnabled="False"></MenuFlyoutItem>
2424
</MenuFlyout>
2525
</muxc:Expander.ContextFlyout>
2626
<muxc:Expander.Header>

Dialer/UI/Controls/ContactControl.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,14 @@ private async void FlyoutDeleteContact_Click(object sender, RoutedEventArgs e)
8484
await ContactSystem.DeleteContact(AssociatedContact);
8585
ContactsPage.CurrentInstance.RemoveContactControl(this);
8686
}
87+
88+
private void FlyoutCallContact_Click(object sender, RoutedEventArgs e)
89+
{
90+
try
91+
{
92+
App.Current.CallSystem.DefaultLine?.DialWithOptions(new PhoneDialOptions() { Number = ContactMainPhone.ToString() });
93+
}
94+
catch { }
95+
}
8796
}
8897
}

Dialer/UI/Pages/ContactsPage.xaml.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,37 @@ public ContactsPage()
2727
CurrentInstance = this;
2828
}
2929

30-
protected async override void OnNavigatedTo(NavigationEventArgs e)
30+
protected override void OnNavigatedTo(NavigationEventArgs e)
3131
{
3232
base.OnNavigatedTo(e);
3333
SizeChanged += ContactsPage_SizeChanged;
3434

35-
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
36-
{
37-
LoadingGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
38-
});
35+
LoadingGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
3936

40-
Aaa(); //Todo: This needs to be run in background, currently it blocks the UI (??)
37+
Task.Run(() =>
38+
{
39+
Aaa();
40+
}); //TODO: This still hangs the UI in some cases 🥲
4141
}
4242

43-
private Task Aaa()
43+
private void Aaa()
4444
{
4545
if (ContactSystem.ContactControls == null)
4646
{
4747
ContactSystem.ContactsLoaded += (object sender, EventArgs e) => LoadDataCompleted();
4848
}
4949
else LoadDataCompleted();
50-
return Task.CompletedTask;
5150
}
5251

53-
private void LoadDataCompleted()
52+
private async void LoadDataCompleted()
5453
{
55-
_contactControls = ContactSystem.ContactControls;
56-
LoadingGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
54+
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
55+
{
56+
ContactsItemsControl.ItemsSource = null;
57+
_contactControls = ContactSystem.ContactControls;
58+
ContactsItemsControl.ItemsSource = _contactControls;
59+
LoadingGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
60+
});
5761
}
5862

5963
private void ContactsPage_SizeChanged(object sender, Windows.UI.Xaml.SizeChangedEventArgs e)
@@ -89,11 +93,12 @@ await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
8993

9094
IEnumerable<ContactControl> ContactsWithLetter = from contact in _contactControls where contact.ContactName.ToUpper().StartsWith(letter) select contact;
9195

92-
//TODO: Fix for missing letter -> move to previous/next letter
9396
try
9497
{
9598
ContactsWithLetter.First().StartBringIntoView();
96-
} catch { }
99+
} catch {
100+
//TODO: Fix for missing letter -> move to previous/next letter
101+
}
97102

98103
_hideHintTimer.Start();
99104

0 commit comments

Comments
 (0)