Track Timer Update

main
unknown 6 months ago
parent 7287c9aa2a
commit 01d0f0ae36
  1. 1
      AppShell.xaml
  2. 7
      AppShell.xaml.cs
  3. 16
      Justice.csproj
  4. 3
      Justice.csproj.user
  5. 4
      Platforms/Android/Resources/values/colors.xml
  6. 1
      Views/DashboardPage.xaml
  7. 4
      Views/DashboardPage.xaml.cs
  8. 42
      Views/MapTimer.xaml
  9. 142
      Views/MapTimer.xaml.cs
  10. BIN
      bin/Debug/net9.0-android/Justice.dll
  11. BIN
      bin/Debug/net9.0-android/Justice.pdb
  12. 17
      bin/Debug/net9.0-android/Justice.xml
  13. BIN
      bin/Debug/net9.0-android/com.companyname.justice-Signed.apk
  14. BIN
      bin/Debug/net9.0-android/com.companyname.justice-Signed.apk.idsig
  15. BIN
      bin/Debug/net9.0-android/com.companyname.justice.apk
  16. BIN
      bin/Debug/net9.0-ios/iossimulator-x64/Justice.dll
  17. BIN
      bin/Debug/net9.0-ios/iossimulator-x64/Justice.pdb
  18. BIN
      bin/Debug/net9.0-ios/iossimulator-x64/Microsoft.Maui.Controls.Maps.dll
  19. BIN
      bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.dll
  20. BIN
      bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Justice.pdb
  21. BIN
      bin/Debug/net9.0-maccatalyst/maccatalyst-x64/Microsoft.Maui.Controls.Maps.dll
  22. 19
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.deps.json
  23. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.dll
  24. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.exe
  25. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Justice.pdb
  26. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/Microsoft.Maui.Controls.Maps.dll
  27. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/dotnet_bot.scale-100.png
  28. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/dotnet_bot.scale-125.png
  29. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/dotnet_bot.scale-150.png
  30. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/dotnet_bot.scale-200.png
  31. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/dotnet_bot.scale-400.png
  32. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/log.scale-100.png
  33. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/log.scale-125.png
  34. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/log.scale-150.png
  35. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/log.scale-200.png
  36. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/log.scale-400.png
  37. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logSplashScreen.scale-100.png
  38. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logSplashScreen.scale-125.png
  39. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logSplashScreen.scale-150.png
  40. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logSplashScreen.scale-200.png
  41. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logSplashScreen.scale-400.png
  42. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logoSplashScreen.scale-100.png
  43. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logoSplashScreen.scale-125.png
  44. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logoSplashScreen.scale-150.png
  45. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logoSplashScreen.scale-200.png
  46. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/logoSplashScreen.scale-400.png
  47. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/resources.pri
  48. 8
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/splash.svg
  49. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/splashSplashScreen.scale-100.png
  50. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/splashSplashScreen.scale-125.png
  51. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/splashSplashScreen.scale-150.png
  52. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/splashSplashScreen.scale-200.png
  53. BIN
      bin/Debug/net9.0-windows10.0.19041.0/win10-x64/splashSplashScreen.scale-400.png

@ -14,5 +14,6 @@
<ShellContent Title="My Reports" ContentTemplate="{DataTemplate views:EndUserReportsPage}" Route="EndUserReportsPage" />
<ShellContent Title="Authority Reports" ContentTemplate="{DataTemplate views:AuthorityReportsPage}" Route="AuthorityReportsPage" />
<MenuItem Text="Logout" Command="{Binding LogoutCommand}" />
</Shell>

@ -1,4 +1,9 @@
using Justice.Helpers;
using Justice.Services;
using Justice.Models;
using Microsoft.Maui.Controls.Maps;
using Microsoft.Maui.Maps;
namespace Justice
{
@ -13,6 +18,8 @@ namespace Justice
Routing.RegisterRoute("DashboardPage", typeof(Views.DashboardPage));
Routing.RegisterRoute("ViewReportsPage", typeof(Views.EndUserReportsPage));
LogoutCommand = new Command(async () =>
{
AuthHelper.Logout();

@ -46,11 +46,11 @@
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!--<MauiSplashScreen Include="Resources\Raw\splash.svg" Color="#512BD4" BaseSize="128,128" />-->
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="250,185" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
@ -59,6 +59,10 @@
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Splash\log.svg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="MailKit" Version="4.9.0" />
@ -70,6 +74,7 @@
</PackageReference>
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.22" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="9.0.22" />
<PackageReference Include="Microsoft.Maui.Maps" Version="9.0.22" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
</ItemGroup>
@ -78,6 +83,10 @@
<Folder Include="ViewModels\" />
</ItemGroup>
<ItemGroup>
<MauiSplashScreen Include="Resources\Splash\log.svg" Color="#F0F0F0" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Views\AddContactPage.xaml">
<Generator>MSBuild:Compile</Generator>
@ -109,6 +118,9 @@
<MauiXaml Update="Views\LoginPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\MapTimer.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\RegistrationPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

@ -41,6 +41,9 @@
<MauiXaml Update="Views\LoginPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
<MauiXaml Update="Views\MapTimer.xaml">
<SubType>Designer</SubType>
</MauiXaml>
<MauiXaml Update="Views\RegistrationPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>

@ -3,4 +3,8 @@
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
<style name="Maui.SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/maui_splash_image</item>
</style>
</resources>

@ -141,6 +141,7 @@
</VerticalStackLayout>
</Border>
</Grid>
<Button Text="TRACK" Clicked="MaptimerClicked" BackgroundColor="#FFA726" FontAttributes="Bold"/>
</VerticalStackLayout>
</ScrollView>
</ContentPage>

@ -49,4 +49,8 @@ public partial class DashboardPage : ContentPage
}
}
private void MaptimerClicked(object sender, EventArgs e)
{
Navigation.PushAsync(new MapTimer());
}
}

@ -0,0 +1,42 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Justice.Views.MapTimer"
Title="Track Journey">
<VerticalStackLayout Padding="20" Spacing="15">
<!-- Page Title -->
<Label Text="Track Your Journey" FontSize="Large" HorizontalOptions="Center" FontAttributes="Bold" />
<!-- Current Location -->
<Label Text="Current Location (Latitude, Longitude):" FontSize="Medium" />
<Entry x:Name="SourceLatitudeEntry" IsReadOnly="True" Placeholder="Latitude" />
<Entry x:Name="SourceLongitudeEntry" IsReadOnly="True" Placeholder="Longitude" />
<Entry x:Name="SourceAddressEntry" IsReadOnly="True" Placeholder="Address" />
<!-- Destination Location -->
<Label Text="Destination Location (Latitude, Longitude):" FontSize="Medium" />
<Entry x:Name="DestinationLatitudeEntry" Placeholder="Enter Destination Latitude" />
<Entry x:Name="DestinationLongitudeEntry" Placeholder="Enter Destination Longitude" />
<!-- Timer -->
<Label Text="Set Timer (minutes):" FontSize="Medium" />
<Entry x:Name="TimerEntry" Keyboard="Numeric" Placeholder="Enter timer in minutes" />
<!-- Countdown Display -->
<Label x:Name="TimerLabel"
Text="Set your timer and start tracking."
FontSize="Medium"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
TextColor="DarkGray" />
<!-- Start Button -->
<Button Text="Start Tracking" Clicked="StartTrackingClicked" />
<!-- Activity Indicator -->
<ActivityIndicator x:Name="LoadingIndicator"
IsRunning="False"
IsVisible="False"
HorizontalOptions="Center"
VerticalOptions="Center" />
</VerticalStackLayout>
</ContentPage>

@ -0,0 +1,142 @@
using Justice.Helpers;
using Microsoft.Maui.ApplicationModel.Communication;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Justice.Views
{
public partial class MapTimer : ContentPage
{
private bool isTrackingActive;
public MapTimer()
{
InitializeComponent();
FetchLocation();
}
private async void StartTrackingClicked(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(DestinationLatitudeEntry.Text) ||
string.IsNullOrWhiteSpace(DestinationLongitudeEntry.Text))
{
await DisplayAlert("Error", "Please enter destination coordinates.", "OK");
return;
}
if (!double.TryParse(DestinationLatitudeEntry.Text, out double destinationLatitude) ||
!double.TryParse(DestinationLongitudeEntry.Text, out double destinationLongitude))
{
await DisplayAlert("Error", "Invalid destination coordinates.", "OK");
return;
}
if (!int.TryParse(TimerEntry.Text, out int timerMinutes))
{
await DisplayAlert("Error", "Invalid timer value. Please enter a numeric value.", "OK");
return;
}
isTrackingActive = true;
// Set timer duration
var timerDuration = TimeSpan.FromMinutes(timerMinutes);
var timerEnd = DateTime.Now.Add(timerDuration);
string phoneNumber = "9860104625";
// Start countdown display
_ = UpdateCountdownDisplay(timerEnd);
while (isTrackingActive && DateTime.Now < timerEnd)
{
await Task.Delay(5000); // Check location every 5 seconds
// Fetch current location
var (currentLatitude, currentLongitude, _) = await GeolocationHelper.GetLocationAsync();
// Define tolerance for proximity
const double Tolerance = 0.0001;
// Check if user has reached the destination
if (Math.Abs(destinationLatitude - currentLatitude) < Tolerance &&
Math.Abs(destinationLongitude - currentLongitude) < Tolerance)
{
isTrackingActive = false;
// Notify user and send SMS
string reachedMessage = "User has safely reached the destination.";
await DisplayAlert("Success", "Safely reached the destination!", "OK");
await SendSmsNotification(phoneNumber, reachedMessage);
return;
}
}
// If timer expires and destination is not reached
if (isTrackingActive)
{
string notReachedMessage = "User did not reach the destination within the set time.";
await DisplayAlert("Time's Up", "You did not reach the destination within the set timer.", "OK");
await SendSmsNotification(phoneNumber, notReachedMessage);
}
}
private async Task UpdateCountdownDisplay(DateTime timerEnd)
{
while (isTrackingActive && DateTime.Now < timerEnd)
{
TimeSpan remainingTime = timerEnd - DateTime.Now;
// Update the UI with remaining time
TimerLabel.Text = $"Time Remaining: {remainingTime.Minutes:D2}:{remainingTime.Seconds:D2}";
// Wait for 1 second before updating again
await Task.Delay(1000);
}
// Clear the timer label after countdown ends
TimerLabel.Text = isTrackingActive ? "Time's Up!" : "You reached the destination!";
}
private async void FetchLocation()
{
try
{
var (latitude, longitude, address) = await GeolocationHelper.GetLocationAsync();
SourceLatitudeEntry.Text = latitude.ToString();
SourceLongitudeEntry.Text = longitude.ToString();
}
catch (Exception ex)
{
Console.WriteLine($"Error fetching location: {ex.Message}");
await DisplayAlert("Error", $"Failed to get location: {ex.Message}", "OK");
}
}
private async Task SendSmsNotification(string phoneNumber, string message)
{
try
{
if (Sms.Default.IsComposeSupported)
{
var smsMessage = new SmsMessage
{
Body = message,
Recipients = new List<string> { phoneNumber }
};
await Sms.Default.ComposeAsync(smsMessage);
}
else
{
await DisplayAlert("Error", "SMS is not supported on this device.", "OK");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error sending SMS: {ex.Message}");
await DisplayAlert("Error", "Failed to send SMS.", "OK");
}
}
}
}

@ -22,6 +22,23 @@
Sends an email with an optional attachment.
</summary>
</member>
<member name="M:Justice.Services.SmsService.SendBulkSmsAsync(System.Collections.Generic.List{System.String},System.String)">
<summary>
Sends a bulk SMS message to a list of phone numbers.
</summary>
<param name="phoneNumbers">List of phone numbers to send the SMS to.</param>
<param name="message">The message to send.</param>
</member>
<member name="M:Justice.Views.MapTimer.FetchLocation">
<summary>
Fetches the user's current location and updates the source coordinates.
</summary>
</member>
<member name="M:Justice.Views.MapTimer.SendSmsNotification(System.String,System.String)">
<summary>
Sends an SMS notification.
</summary>
</member>
<member name="T:Justice.Resource">
<summary>
Android Resource Designer class.

@ -16,6 +16,7 @@
"Microsoft.EntityFrameworkCore.Tools": "9.0.0",
"Microsoft.Extensions.Logging.Debug": "9.0.0",
"Microsoft.Maui.Controls": "9.0.22",
"Microsoft.Maui.Controls.Maps": "9.0.22",
"Microsoft.Maui.Maps": "9.0.22",
"sqlite-net-pcl": "1.9.172",
"Microsoft.Maui.Controls.HotReload.Forms": "17.0.0.0",
@ -904,6 +905,17 @@
}
}
},
"Microsoft.Maui.Controls.Maps/9.0.22": {
"dependencies": {
"Microsoft.Maui.Maps": "9.0.22"
},
"runtime": {
"lib/net9.0-windows10.0.19041/Microsoft.Maui.Controls.Maps.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "9.0.2225.5707"
}
}
},
"Microsoft.Maui.Controls.Xaml/9.0.22": {
"dependencies": {
"Microsoft.Extensions.Configuration": "9.0.0",
@ -1798,6 +1810,13 @@
"path": "microsoft.maui.controls.core/9.0.22",
"hashPath": "microsoft.maui.controls.core.9.0.22.nupkg.sha512"
},
"Microsoft.Maui.Controls.Maps/9.0.22": {
"type": "package",
"serviceable": true,
"sha512": "sha512-orF2cIa2dISDnrdIX7k8ynp+lYM6qcyhgQEw9KMhmlMFxyb1JdLMD59PrbVDfprKXxP4uapvT4O3tE0v3oodOw==",
"path": "microsoft.maui.controls.maps/9.0.22",
"hashPath": "microsoft.maui.controls.maps.9.0.22.nupkg.sha512"
},
"Microsoft.Maui.Controls.Xaml/9.0.22": {
"type": "package",
"serviceable": true,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 KiB

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="m 105.50037,281.60863 c -2.70293,0 -5.00091,-0.90042 -6.893127,-2.70209 -1.892214,-1.84778 -2.837901,-4.04181 -2.837901,-6.58209 0,-2.58722 0.945687,-4.80389 2.837901,-6.65167 1.892217,-1.84778 4.190197,-2.77167 6.893127,-2.77167 2.74819,0 5.06798,0.92389 6.96019,2.77167 1.93749,1.84778 2.90581,4.06445 2.90581,6.65167 0,2.54028 -0.96832,4.73431 -2.90581,6.58209 -1.89221,1.80167 -4.212,2.70209 -6.96019,2.70209 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 213.56111,280.08446 H 195.99044 L 149.69953,207.0544 c -1.17121,-1.84778 -2.14037,-3.76515 -2.90581,-5.75126 h -0.40578 c 0.36051,2.12528 0.54076,6.67515 0.54076,13.6496 v 65.13172 h -15.54349 v -99.36009 h 18.71925 l 44.7374,71.29798 c 1.89222,2.95695 3.1087,4.98917 3.64945,6.09751 h 0.26996 c -0.45021,-2.6325 -0.67573,-7.09015 -0.67573,-13.37293 v -64.02256 h 15.47557 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="m 289.25134,280.08446 h -54.40052 v -99.36009 h 52.23835 v 13.99669 h -36.15411 v 28.13085 h 33.31621 v 13.9271 h -33.31621 v 29.37835 h 38.31628 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 366.56466,194.72106 H 338.7222 v 85.3634 h -16.08423 v -85.3634 h -27.77455 v -13.99669 h 71.70124 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Loading…
Cancel
Save