Skip to content

Commit

Permalink
Latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Sep 27, 2019
1 parent 6750ede commit 792e03a
Show file tree
Hide file tree
Showing 32 changed files with 515 additions and 179 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CA1303: Do not pass literals as localized parameters
dotnet_diagnostic.CA1303.severity = suggestion
195 changes: 194 additions & 1 deletion App.xaml

Large diffs are not rendered by default.

27 changes: 22 additions & 5 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Windows.ApplicationModel;
using Chat.ContentDialogs;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.UI.Xaml;
using System;
using System.Globalization;

namespace Chat
{
Expand All @@ -10,6 +13,19 @@ public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
this.UnhandledException += App_UnhandledException;
}

private async void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
{
e.Handled = true;
string ExceptionDesc = e.Exception.Message + "\nHRESULT: 0x" + e.Exception.HResult.ToString("X4", new CultureInfo("en-US")) + "\n" + e.Exception.StackTrace + "\n" + e.Exception.Source;
if (e.Exception.InnerException != null)
ExceptionDesc += "\n\n" + e.Exception.InnerException.Message + "\nHRESULT: 0x" + e.Exception.InnerException.HResult.ToString("X4", new CultureInfo("en-US")) + "\n" + e.Exception.InnerException.StackTrace + "\n" + e.Exception.InnerException.Source;
else
ExceptionDesc += "\n\nNo inner exception was thrown";

await new UnhandledExceptionContentDialog(ExceptionDesc).ShowAsync();
}

protected override void OnLaunched(LaunchActivatedEventArgs e)
Expand All @@ -20,17 +36,18 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
{
rootShell = new Shell();

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
if (e != null && e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}

rootShell.HandleArguments(e);
if (e != null)
rootShell.HandleArguments(e);

Window.Current.Content = rootShell;
}

if (e.PrelaunchActivated == false)
if (e != null && e.PrelaunchActivated == false)
{
rootShell.HandleArguments(e);
Window.Current.Activate();
Expand All @@ -39,7 +56,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)

protected override void OnActivated(IActivatedEventArgs e)
{
if (e.Kind == ActivationKind.Protocol || e.Kind == ActivationKind.ToastNotification)
if (e != null && e.Kind == ActivationKind.Protocol || e != null && e.Kind == ActivationKind.ToastNotification)
{
Shell rootShell = Window.Current.Content as Shell;
if (rootShell == null)
Expand Down
4 changes: 2 additions & 2 deletions Chat.BackgroundTasks/Chat.BackgroundTasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.8</Version>
<Version>6.2.9</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
<Version>5.0.0-preview.gb86cb1c4cb</Version>
<Version>5.1.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ private async Task<string> SaveFile(IRandomAccessStreamReference stream, string
private async Task DisplayToast(ChatMessage message)
{
var information = await ContactUtils.FindContactInformationFromSender(message.From);
string extra = "";
string thumbnailpath = "";
string text = "";

Expand Down
8 changes: 5 additions & 3 deletions Chat.BackgroundTasks/SmsBackgroundTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private async Task DisplayToast(IBackgroundTaskInstance taskInstance)
information = await ContactUtils.FindContactInformationFromSmsMessage(smsTextMessage);
break;
}
case SmsMessageType.Wap:
/*case SmsMessageType.Wap:
{
SmsWapMessage smsWapMessage = smsDetails.WapMessage;
body = "[DEBUG - Report if seen] " + smsWapMessage.ContentType + " - " + "Wap";
Expand All @@ -53,7 +53,7 @@ private async Task DisplayToast(IBackgroundTaskInstance taskInstance)
case SmsMessageType.App:
{
SmsAppMessage smsAppMessage = smsDetails.AppMessage;
body = "[DEBUG - Report if seen] " + smsAppMessage.Body + " - " + "App";
body = "[DEBUG - Report if seen] " + smsAppMessage.Body + " - RAW: " + BitConverter.ToString(smsAppMessage.BinaryBody.ToArray()) + " - " + "App";
deviceid = smsAppMessage.DeviceId;
from = smsAppMessage.From;
information = await ContactUtils.FindContactInformationFromSmsMessage(smsAppMessage);
Expand All @@ -67,7 +67,9 @@ private async Task DisplayToast(IBackgroundTaskInstance taskInstance)
from = smsStatusMessage.From;
information = await ContactUtils.FindContactInformationFromSmsMessage(smsStatusMessage);
break;
}
}*/
default:
return;
}

var toastContent = new ToastContent()
Expand Down
14 changes: 8 additions & 6 deletions Chat.Common/BadgeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public class BadgeHandler
{
public static void IncreaseBadgeNumber()
{
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
return;
/*ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
if (!localSettings.Values.ContainsKey("UnreadCount"))
{
Expand All @@ -26,12 +27,13 @@ public static void IncreaseBadgeNumber()
count++;
localSettings.Values["UnreadCount"] = count;
setBadgeNumber(count);
setBadgeNumber(count);*/
}

public static void DecreaseBadgeNumber()
{
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
return;
/*ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
if (!localSettings.Values.ContainsKey("UnreadCount"))
{
Expand All @@ -53,10 +55,10 @@ public static void DecreaseBadgeNumber()
localSettings.Values["UnreadCount"] = count;
setBadgeNumber(count);
setBadgeNumber(count);*/
}

private static void setBadgeNumber(int num)
/*private static void setBadgeNumber(int num)
{
XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
Expand All @@ -68,6 +70,6 @@ private static void setBadgeNumber(int num)
BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
badgeUpdater.Update(badge);
}
}*/
}
}
2 changes: 1 addition & 1 deletion Chat.Common/Chat.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.8</Version>
<Version>6.2.9</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
Expand Down
23 changes: 15 additions & 8 deletions Chat.Common/ContactUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,27 @@ public static bool ArePhoneNumbersMostLikelyTheSame(string num1, string num2)

public static async Task<Contact> BindPhoneNumberToGlobalContact(string phonenumber)
{
var store = await ContactManager.RequestStoreAsync();
if (store != null)
try
{
var contacts = await store.FindContactsAsync();

foreach (var contact in contacts)
var store = await ContactManager.RequestStoreAsync();
if (store != null)
{
foreach (var num in contact.Phones)
var contacts = await store.FindContactsAsync();

foreach (var contact in contacts)
{
if (ArePhoneNumbersMostLikelyTheSame(phonenumber, num.Number))
return contact;
foreach (var num in contact.Phones)
{
if (ArePhoneNumbersMostLikelyTheSame(phonenumber, num.Number))
return contact;
}
}
}
}
catch
{

}

Contact blankcontact = new Contact();
blankcontact.Phones.Add(new ContactPhone() { Number = phonenumber, Kind = ContactPhoneKind.Other });
Expand Down
27 changes: 21 additions & 6 deletions Chat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>arm64</AppxBundlePlatforms>
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -64,6 +65,9 @@
<Compile Include="ContentDialogs\CellularUnavailableContentDialog.xaml.cs">
<DependentUpon>CellularUnavailableContentDialog.xaml</DependentUpon>
</Compile>
<Compile Include="ContentDialogs\UnhandledExceptionContentDialog.xaml.cs">
<DependentUpon>UnhandledExceptionContentDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\CellularLineControl.xaml.cs">
<DependentUpon>CellularLineControl.xaml</DependentUpon>
</Compile>
Expand All @@ -79,7 +83,6 @@
<Compile Include="Controls\TitlebarControl.xaml.cs">
<DependentUpon>TitlebarControl.xaml</DependentUpon>
</Compile>
<Compile Include="Helpers\DateTimeExtensions.cs" />
<Compile Include="Helpers\Observable.cs" />
<Compile Include="Pages\ComposePage.xaml.cs">
<DependentUpon>ComposePage.xaml</DependentUpon>
Expand Down Expand Up @@ -175,6 +178,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ContentDialogs\UnhandledExceptionContentDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\CellularLineControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -210,16 +217,21 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluiFramework.UWP">
<Version>0.0.28-alpha</Version>
<Version>0.0.29</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<Version>2.9.5-beta1.final</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.8</Version>
<Version>6.2.9</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>5.0.0-preview.gb86cb1c4cb</Version>
<Version>5.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.2.190731001-prerelease</Version>
<Version>2.3.190909001-prerelease</Version>
</PackageReference>
<PackageReference Include="MvvmLightLibs">
<Version>5.4.1.1</Version>
Expand All @@ -235,6 +247,9 @@
<Name>Chat.BackgroundTasks</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include=".editorconfig" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
12 changes: 0 additions & 12 deletions Chat.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chat.BackgroundTasks", "Cha
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chat.Common", "Chat.Common\Chat.Common.csproj", "{D7B4A4F2-501E-4498-A857-00A0E73D078B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibPhoneNumber.Contrib", "LibPhoneNumber.Contrib\LibPhoneNumber.Contrib.csproj", "{76E62544-DFBA-4AEC-8309-A441176ABF2D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -93,16 +91,6 @@ Global
{D7B4A4F2-501E-4498-A857-00A0E73D078B}.Release|x64.Build.0 = Release|x64
{D7B4A4F2-501E-4498-A857-00A0E73D078B}.Release|x86.ActiveCfg = Release|x86
{D7B4A4F2-501E-4498-A857-00A0E73D078B}.Release|x86.Build.0 = Release|x86
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Debug|ARM.ActiveCfg = Debug|ARM
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Debug|ARM64.ActiveCfg = Debug|ARM64
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Debug|x64.ActiveCfg = Debug|x64
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Debug|x86.ActiveCfg = Debug|x86
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Release|ARM.ActiveCfg = Release|ARM
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Release|ARM64.ActiveCfg = Release|ARM64
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Release|x64.ActiveCfg = Release|x64
{76E62544-DFBA-4AEC-8309-A441176ABF2D}.Release|x86.ActiveCfg = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions ContentDialogs/CellularUnavailableContentDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<TextBlock Grid.Column="1"
Grid.Row="0"
Text="Cellular is currently unavailable"
TextWrapping="Wrap"
Style="{ThemeResource FluentTitleTextStyle}"
FontWeight="SemiBold"/>
<!-- Version number -->
Expand Down
Loading

0 comments on commit 792e03a

Please sign in to comment.