diff --git a/src/WorkFlowCheck.MAUI/AppShell.xaml b/src/WorkFlowCheck.MAUI/AppShell.xaml
index 9ffbddd..69c3246 100644
--- a/src/WorkFlowCheck.MAUI/AppShell.xaml
+++ b/src/WorkFlowCheck.MAUI/AppShell.xaml
@@ -16,6 +16,7 @@
+
diff --git a/src/WorkFlowCheck.MAUI/MainPage.xaml b/src/WorkFlowCheck.MAUI/MainPage.xaml
index fd3f6af..4475319 100644
--- a/src/WorkFlowCheck.MAUI/MainPage.xaml
+++ b/src/WorkFlowCheck.MAUI/MainPage.xaml
@@ -5,6 +5,14 @@
Title="Főmenü"
BackgroundColor="#f0f0f0">
+
+
+
+
+
+
-
+
+
+
diff --git a/src/WorkFlowCheck.MAUI/MainPage.xaml.cs b/src/WorkFlowCheck.MAUI/MainPage.xaml.cs
index 4e37a64..6674dd4 100644
--- a/src/WorkFlowCheck.MAUI/MainPage.xaml.cs
+++ b/src/WorkFlowCheck.MAUI/MainPage.xaml.cs
@@ -13,37 +13,38 @@ namespace WorkFlowCheck.MAUI
InitializeComponent();
_userService = userService;
}
- //public void Initialize(IUserService userService)
- //{
- // _userService = userService;
- //}
- //private void OnCounterClicked(object sender, EventArgs e)
- //{
- // count++;
- // if (count == 1)
- // CounterBtn.Text = $"Clicked {count} time";
- // else
- // CounterBtn.Text = $"Clicked {count} times";
+ override protected async void OnAppearing()
+ {
+ base.OnAppearing();
+ var currentUser = _userService.GetCurrentUser();
+ DeviceId.Text = DeviceInfo.Current.Idiom.ToString();
+ if (currentUser != null)
+ {
+ foreach (var role in currentUser.RoleDTO)
+ {
+ if (role.RoleName == "Admin")
+ {
- // SemanticScreenReader.Announce(CounterBtn.Text);
- //}
+ }
+ else
+ {
+
+ }
+ }
+ }
+
+
+ }
+ private async void OnButtonAction(object sender, EventArgs e)
+ {
+ }
+ private void OnButtonDownloadAPK(object sender, EventArgs e)
+ {
+ Shell.Current.GoToAsync("//DownloadAPKPage");
+ }
private async void OnButtonGetUser(object sender, EventArgs e)
{
- //var response = await _userService.GetUserAsync();
- //if (response != null)
- //{
- // try
- // {
- // WelcomeLabel.Text = response.Data.FirstName;
- // }
- // catch (Exception ex)
- // {
-
- // WelcomeLabel.Text = ex.Message;
- // }
-
- //}
await Navigation.PushAsync(new CaptureImagePage());
}
private async void OnButtonNFCTest(object sender, EventArgs e)
@@ -67,7 +68,7 @@ namespace WorkFlowCheck.MAUI
private async void OnButtonCheckList(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//CheckListPage");
- }
+ }
}
}
diff --git a/src/WorkFlowCheck.MAUI/Pages/NFC/NFCWaiter.xaml b/src/WorkFlowCheck.MAUI/Pages/NFC/NFCWaiter.xaml
index 2ba565f..c2c6f1b 100644
--- a/src/WorkFlowCheck.MAUI/Pages/NFC/NFCWaiter.xaml
+++ b/src/WorkFlowCheck.MAUI/Pages/NFC/NFCWaiter.xaml
@@ -24,7 +24,7 @@
Text="Mégse"
FontSize="18"
TextColor="White"
- HorizontalOptions="Center"
+ HorizontalOptions="Fill"
Clicked="OnCancelButtonClicked" />
diff --git a/src/WorkFlowCheck.MAUI/Pages/System/DownloadAPKPage.xaml b/src/WorkFlowCheck.MAUI/Pages/System/DownloadAPKPage.xaml
new file mode 100644
index 0000000..7126969
--- /dev/null
+++ b/src/WorkFlowCheck.MAUI/Pages/System/DownloadAPKPage.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/WorkFlowCheck.MAUI/Pages/System/DownloadAPKPage.xaml.cs b/src/WorkFlowCheck.MAUI/Pages/System/DownloadAPKPage.xaml.cs
new file mode 100644
index 0000000..35b844e
--- /dev/null
+++ b/src/WorkFlowCheck.MAUI/Pages/System/DownloadAPKPage.xaml.cs
@@ -0,0 +1,54 @@
+using WorkFlowCheck.MAUI.Services.Interfaces;
+
+namespace WorkFlowCheck.MAUI.Pages.System;
+
+public partial class DownloadAPKPage : ContentPage
+{
+ private ISyncService _syncService;
+ public DownloadAPKPage()
+ {
+ InitializeComponent();
+ _syncService = MauiProgram.ServiceProvider.GetRequiredService();
+ }
+ private async void OnSyncClicked(object sender, EventArgs e)
+ {
+ SyncBtn.IsEnabled = false;
+ LoadingIndicator.IsRunning = true;
+ LoadingIndicator.IsVisible = true;
+ progressLabel.Text = "Letöltés indítása...";
+ progressBar.Progress = 0;
+
+ try
+ {
+ await Task.Run(async () =>
+ {
+ await _syncService.DownloadAPK((percentage, infostring) =>
+ {
+ MainThread.BeginInvokeOnMainThread(() =>
+ {
+ progressBar.Progress = percentage / 100;
+ progressLabel.Text = $"{infostring}: {percentage:0.00}%";
+ });
+ });
+ });
+
+ progressLabel.Text = "Letöltés kész!";
+ await Shell.Current.GoToAsync("//MainPage");
+ }
+ catch (Exception ex)
+ {
+ progressLabel.Text = $"Hiba történt: {ex.Message}";
+ }
+ finally
+ {
+ SyncBtn.IsEnabled = true;
+ LoadingIndicator.IsVisible = false;
+ LoadingIndicator.IsRunning = false;
+ }
+ }
+ protected override bool OnBackButtonPressed()
+ {
+ Shell.Current.GoToAsync("//MainPage");
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/WorkFlowCheck.MAUI/Platforms/Android/AndroidManifest.xml b/src/WorkFlowCheck.MAUI/Platforms/Android/AndroidManifest.xml
index c2ad4f0..1e83531 100644
--- a/src/WorkFlowCheck.MAUI/Platforms/Android/AndroidManifest.xml
+++ b/src/WorkFlowCheck.MAUI/Platforms/Android/AndroidManifest.xml
@@ -4,8 +4,17 @@
-
+
+
+
diff --git a/src/WorkFlowCheck.MAUI/Platforms/Android/Resources/xml/file_paths.xml b/src/WorkFlowCheck.MAUI/Platforms/Android/Resources/xml/file_paths.xml
new file mode 100644
index 0000000..538ba60
--- /dev/null
+++ b/src/WorkFlowCheck.MAUI/Platforms/Android/Resources/xml/file_paths.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/src/WorkFlowCheck.MAUI/Services/Interfaces/ISyncService.cs b/src/WorkFlowCheck.MAUI/Services/Interfaces/ISyncService.cs
index 8e16cfe..1d4895e 100644
--- a/src/WorkFlowCheck.MAUI/Services/Interfaces/ISyncService.cs
+++ b/src/WorkFlowCheck.MAUI/Services/Interfaces/ISyncService.cs
@@ -10,6 +10,7 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
public interface ISyncService
{
Task SyncDatas(Action reportProgress);
+ Task DownloadAPK(Action reportProgress);
Task SyncCheckPoints_Down(Action reportProgress);
Task> SyncCheckPoints_Up(Action reportProgress);
Task SyncLocations_Down(Action reportProgress);
diff --git a/src/WorkFlowCheck.MAUI/Services/SyncService.cs b/src/WorkFlowCheck.MAUI/Services/SyncService.cs
index b4fa2d1..06403fb 100644
--- a/src/WorkFlowCheck.MAUI/Services/SyncService.cs
+++ b/src/WorkFlowCheck.MAUI/Services/SyncService.cs
@@ -1,4 +1,5 @@
-using AutoMapper;
+using Android.Content;
+using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
@@ -27,6 +28,84 @@ namespace WorkFlowCheck.MAUI.Services
await SyncCheckListTemplates_Down(reportProgress);
await SyncCheckListHeader_Down(reportProgress);
}
+ public async Task DownloadAPK(Action reportProgress)
+ {
+ try
+ {
+ await PrepareAuthenticatedRequestAsync();
+ string endpoint = $"{_httpClient.BaseAddress}api/Sync/Download";
+
+ string fileName = "com.nuvolar.wfcapp-Signed.apk";
+
+ // Az Androidon lévő privát letöltési mappa
+ string downloadFolder = Path.Combine(Android.App.Application.Context.GetExternalFilesDir(null)?.AbsolutePath, "APK");
+
+ // Ellenőrizd, hogy a mappa létezik-e, ha nem, hozd létre
+ if (!Directory.Exists(downloadFolder))
+ {
+ Directory.CreateDirectory(downloadFolder);
+ }
+
+ string filePath = Path.Combine(downloadFolder, fileName);
+
+ using (_httpClient)
+ {
+ var response = await _httpClient.GetAsync(endpoint, HttpCompletionOption.ResponseHeadersRead);
+ if (response.IsSuccessStatusCode)
+ {
+ var totalBytes = response.Content.Headers.ContentLength ?? -1L;
+ long receivedBytes = 0;
+
+ using (var stream = await response.Content.ReadAsStreamAsync())
+ using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
+ {
+ byte[] buffer = new byte[1024 * 1024]
+;
+ int bytesRead;
+
+ while ((bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length)) > 0)
+ {
+ await fileStream.WriteAsync(buffer, 0, bytesRead);
+ receivedBytes += bytesRead;
+
+ if (totalBytes != -1)
+ {
+ double progress = (double)receivedBytes / totalBytes * 100;
+ reportProgress(progress, $"APK letöltés...");
+ }
+ else
+ {
+ reportProgress(-1, $"APK letöltés...");
+ }
+ }
+ }
+
+ // TelepÃtés indÃtása a FileProvider segÃtségével
+ var apkUri = FileProvider.GetUriForFile(Android.App.Application.Context,
+ $"{Android.App.Application.Context.PackageName}.fileprovider",
+ new Java.IO.File(filePath));
+
+ var installIntent = new Intent(Intent.ActionView);
+ installIntent.SetDataAndType(apkUri, "application/vnd.android.package-archive");
+ installIntent.AddFlags(ActivityFlags.NewTask);
+ installIntent.AddFlags(ActivityFlags.GrantReadUriPermission);
+
+ Android.App.Application.Context.StartActivity(installIntent);
+ }
+ else
+ {
+ reportProgress(0, $"Letöltési hiba: {response.StatusCode}");
+ Console.WriteLine($"Letöltési hiba: {response.StatusCode}");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ reportProgress(0, $"Hiba történt: {ex.Message}");
+ Console.WriteLine($"Hiba történt: {ex.Message}");
+ }
+ }
+
public async Task SyncCheckPoints_Down(Action reportProgress)
{
try
diff --git a/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj b/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj
index 6ddaf10..70f579b 100644
--- a/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj
+++ b/src/WorkFlowCheck.MAUI/WorkFlowCheck.MAUI.csproj
@@ -55,6 +55,10 @@
+
+
+
+
@@ -134,6 +138,9 @@
MSBuild:Compile
+
+ MSBuild:Compile
+
MSBuild:Compile