Skip to content

Commit

Permalink
Some fixes, first implementation of notifications and check for uniqu…
Browse files Browse the repository at this point in the history
…e address public key combination
  • Loading branch information
Noc2 committed Apr 7, 2018
1 parent 1311bff commit cf999fa
Show file tree
Hide file tree
Showing 55 changed files with 1,123 additions and 470 deletions.
62 changes: 62 additions & 0 deletions Chiota.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chiota.UWP", "Chiota\Chiota
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NTRUEngine", "Chiota\NTRU-NET-master\NTRUEngine.csproj", "{A25C6AB8-531E-4A7E-9968-305003D56332}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPRuntimeComponent", "UWPRuntimeComponent\UWPRuntimeComponent.csproj", "{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -339,6 +341,66 @@ Global
{A25C6AB8-531E-4A7E-9968-305003D56332}.Release|x64.Build.0 = Release|Any CPU
{A25C6AB8-531E-4A7E-9968-305003D56332}.Release|x86.ActiveCfg = Release|x86
{A25C6AB8-531E-4A7E-9968-305003D56332}.Release|x86.Build.0 = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|ARM.ActiveCfg = Debug|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|ARM.Build.0 = Debug|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|ARM64.Build.0 = Debug|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|x64.ActiveCfg = Debug|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|x64.Build.0 = Debug|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|x86.ActiveCfg = Debug|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Debug|x86.Build.0 = Debug|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|Any CPU.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|Any CPU.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|ARM.ActiveCfg = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|ARM.Build.0 = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|ARM64.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|ARM64.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|x64.ActiveCfg = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|x64.Build.0 = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|x86.ActiveCfg = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Fast|x86.Build.0 = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|Any CPU.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|Any CPU.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|ARM.ActiveCfg = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|ARM.Build.0 = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|ARM64.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|ARM64.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|x64.ActiveCfg = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|x64.Build.0 = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|x86.ActiveCfg = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Generic|x86.Build.0 = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|Any CPU.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|Any CPU.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|ARM.ActiveCfg = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|ARM.Build.0 = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|ARM64.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|ARM64.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|x64.ActiveCfg = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|x64.Build.0 = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|x86.ActiveCfg = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-fast|x86.Build.0 = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|Any CPU.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|Any CPU.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|ARM.ActiveCfg = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|ARM.Build.0 = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|ARM64.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|ARM64.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|x64.ActiveCfg = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|x64.Build.0 = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|x86.ActiveCfg = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Optimized-generic|x86.Build.0 = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|Any CPU.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|ARM.ActiveCfg = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|ARM.Build.0 = Release|ARM
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|ARM64.ActiveCfg = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|ARM64.Build.0 = Release|Any CPU
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|x64.ActiveCfg = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|x64.Build.0 = Release|x64
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|x86.ActiveCfg = Release|x86
{A7FCA39F-0FEE-4213-B0D8-EA6B7B228E50}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
22 changes: 17 additions & 5 deletions Chiota/Chiota.Android/Chiota.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="ZXingNetMobile">
<HintPath>..\..\..\..\..\.nuget\packages\zxing.net.mobile\2.4.1\lib\MonoAndroid71\ZXingNetMobile.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime">
Expand All @@ -80,7 +83,7 @@
<Version>0.6.0</Version>
</PackageReference>
<PackageReference Include="WindowsAzure.Storage">
<Version>9.1.0</Version>
<Version>9.1.1</Version>
</PackageReference>
<PackageReference Include="Xam.Plugin.Media">
<Version>3.1.3</Version>
Expand All @@ -94,7 +97,7 @@
<PackageReference Include="Xam.Plugins.Notifier">
<Version>3.0.0-beta14</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="2.5.0.280555" />
<PackageReference Include="Xamarin.Forms" Version="2.5.1.444934" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="26.1.0.1" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="26.1.0.1" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="26.1.0.1" />
Expand All @@ -105,12 +108,14 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="ClipboardService.cs" />
<Compile Include="FlatButtonRenderer.cs" />
<Compile Include="Services\ClipboardService.cs" />
<Compile Include="Renderer\FlatButtonRenderer.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scrollbardisabledrenderer.cs" />
<Compile Include="Renderer\Scrollbardisabledrenderer.cs" />
<Compile Include="Services\BackgroundReceiver.cs" />
<Compile Include="Services\PeriodicTaskService.cs" />
<Compile Include="SplashActivity.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -160,6 +165,10 @@
<Project>{a569a7a8-467d-45bd-8848-00f6a0dc34bc}</Project>
<Name>Chiota</Name>
</ProjectReference>
<ProjectReference Include="..\NTRU-NET-master\NTRUEngine.csproj">
<Project>{a25c6ab8-531e-4a7e-9968-305003d56332}</Project>
<Name>NTRUEngine</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\iota.png" />
Expand All @@ -176,5 +185,8 @@
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxhdpi\plus.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\reminder.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
30 changes: 28 additions & 2 deletions Chiota/Chiota.Android/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
namespace Chiota.Droid
{
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;

using Chiota;

using Chiota.Droid.Services;
using Chiota.Messages;
using ImageCircle.Forms.Plugin.Droid;

using Plugin.LocalNotifications;

using Plugin.Permissions;

using Xamarin.Forms;

[Activity(Label = "FlorenceApp", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
Expand All @@ -30,9 +34,10 @@ protected override void OnCreate(Bundle bundle)
ImageCircleRenderer.Init();

// Changes the notification icon
LocalNotificationsImplementation.NotificationIconId = Resource.Drawable.icon;
LocalNotificationsImplementation.NotificationIconId = Resource.Drawable.reminder;

this.LoadApplication(new App());
this.WireUpLongRunningTask();
}

// https://github.com/jamesmontemagno/MediaPlugin#important-permission-information
Expand All @@ -41,5 +46,26 @@ public override void OnRequestPermissionsResult(int requestCode, string[] permis
ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

public void WireUpLongRunningTask()
{
MessagingCenter.Subscribe<StartLongRunningTaskMessage>(
this,
"StartLongRunningTaskMessage",
message =>
{
var intent = new Intent(this, typeof(PeriodicTaskService));
this.StartService(intent);
});

MessagingCenter.Subscribe<StopLongRunningTaskMessage>(
this,
"StopLongRunningTaskMessage",
message =>
{
var intent = new Intent(this, typeof(PeriodicTaskService));
this.StopService(intent);
});
}
}
}
1 change: 1 addition & 0 deletions Chiota/Chiota.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application android:label="Chiota" android:icon="@drawable/icon"></application>
</manifest>
File renamed without changes.
59 changes: 38 additions & 21 deletions Chiota/Chiota.Android/Resources/Resource.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Chiota/Chiota.Android/Resources/drawable/iota.png
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.
46 changes: 46 additions & 0 deletions Chiota/Chiota.Android/Services/BackgroundReceiver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace Chiota.Droid.Services
{
using System.Linq;

using Android.Content;
using Android.OS;

using Chiota.Models;
using Chiota.Services;

using Plugin.LocalNotifications;

[BroadcastReceiver]
public class BackgroundReceiver : BroadcastReceiver
{
public override async void OnReceive(Context context, Intent intent)
{
var pm = (PowerManager)context.GetSystemService(Context.PowerService);
var wakeLock = pm.NewWakeLock(WakeLockFlags.Partial, "BackgroundReceiver");
wakeLock.Acquire();

// seed needs to be stored on device!!
var secureStorage = new SecureStorage();
if (secureStorage.CheckUserStored())
{
var user = await secureStorage.GetUser();
if (user != null)
{
var contactApprovedList = await user.TangleMessenger.GetJsonMessageAsync<SentDataWrapper<Contact>>(user.ApprovedAddress);

// Todo also message for a new contact request
foreach (var contact in contactApprovedList.Where(c => !c.Data.Rejected))
{
var encryptedMessages = await user.TangleMessenger.GetMessagesAsync(contact.Data.ChatAdress);
foreach (var unused in encryptedMessages.Where(c => !c.Stored))
{
CrossLocalNotifications.Current.Show(contact.Data.Name, "New Message from " + contact.Data.Name);
}
}
}
}

wakeLock.Release();
}
}
}
File renamed without changes.
Loading

0 comments on commit cf999fa

Please sign in to comment.