Révision 7b67ff55
INRAETemplate/INRAETemplate.csproj | ||
---|---|---|
32 | 32 |
|
33 | 33 |
<ItemGroup> |
34 | 34 |
<!-- App Icon --> |
35 |
<MauiIcon Include="Resources\AppIcon\ae.svg" Color="#FFFFFF"/> |
|
35 |
<MauiIcon Include="Resources\AppIcon\ae.svg" Color="#FFFFFF" />
|
|
36 | 36 |
|
37 | 37 |
<!-- Splash Screen --> |
38 | 38 |
<MauiSplashScreen Include="Resources\Images\logo_inrae.svg" Color="White" BaseSize="128,128" /> |
... | ... | |
68 | 68 |
<MauiXaml Update="View\SettingsView.xaml"> |
69 | 69 |
<Generator>MSBuild:Compile</Generator> |
70 | 70 |
</MauiXaml> |
71 |
<MauiXaml Update="View\Tools\ConnectionIndicatorView.xaml"> |
|
72 |
<Generator>MSBuild:Compile</Generator> |
|
73 |
</MauiXaml> |
|
71 | 74 |
<MauiXaml Update="View\VivantEditionView.xaml"> |
72 | 75 |
<Generator>MSBuild:Compile</Generator> |
73 | 76 |
</MauiXaml> |
INRAETemplate/INRAETemplate.csproj.user | ||
---|---|---|
3 | 3 |
<PropertyGroup> |
4 | 4 |
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen> |
5 | 5 |
<ActiveDebugFramework>net7.0-android</ActiveDebugFramework> |
6 |
<ActiveDebugProfile>Samsung SM-G736B (Android 14.0 - API 34)</ActiveDebugProfile>
|
|
6 |
<ActiveDebugProfile>Coppernic C-One (Android 7.1 - API 25)</ActiveDebugProfile>
|
|
7 | 7 |
<SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup> |
8 | 8 |
<DefaultDevice>pixel_5_-_api_26</DefaultDevice> |
9 | 9 |
</PropertyGroup> |
... | ... | |
17 | 17 |
<MauiXaml Update="View\SettingsView.xaml"> |
18 | 18 |
<SubType>Designer</SubType> |
19 | 19 |
</MauiXaml> |
20 |
<MauiXaml Update="View\Tools\ConnectionIndicatorView.xaml"> |
|
21 |
<SubType>Designer</SubType> |
|
22 |
</MauiXaml> |
|
20 | 23 |
<MauiXaml Update="View\VivantEditionView.xaml"> |
21 | 24 |
<SubType>Designer</SubType> |
22 | 25 |
</MauiXaml> |
INRAETemplate/MauiProgram.cs | ||
---|---|---|
1 | 1 |
using CommunityToolkit.Maui; |
2 |
using INRAETemplate.Services; |
|
3 |
using INRAETemplate.View; |
|
4 |
using INRAETemplate.ViewModel; |
|
2 | 5 |
using Microsoft.Extensions.Logging; |
3 | 6 |
|
4 | 7 |
namespace INRAETemplate; |
... | ... | |
20 | 23 |
fonts.AddFont("fa-solid.ttf", "FASolid"); |
21 | 24 |
}); |
22 | 25 |
|
26 |
// Services |
|
27 |
builder.Services.AddSingleton<ConnexionService>(); |
|
28 |
|
|
29 |
// Views |
|
30 |
builder.Services.AddSingleton<AboutView>(); |
|
31 |
builder.Services.AddSingleton<SettingsView>(); |
|
32 |
builder.Services.AddSingleton<VivantEditionView>(); |
|
33 |
builder.Services.AddSingleton<VivantView>(); |
|
34 |
|
|
35 |
// ViewModels |
|
36 |
builder.Services.AddSingleton<AboutViewModel>(); |
|
37 |
builder.Services.AddSingleton<SettingsViewModel>(); |
|
38 |
builder.Services.AddSingleton<VivantEditionViewModel>(); |
|
39 |
builder.Services.AddSingleton<VivantViewModel>(); |
|
40 |
|
|
41 |
|
|
23 | 42 |
#if DEBUG |
24 |
builder.Logging.AddDebug();
|
|
43 |
builder.Logging.AddDebug();
|
|
25 | 44 |
#endif |
26 | 45 |
|
27 | 46 |
return builder.Build(); |
INRAETemplate/Platforms/Android/AndroidManifest.xml | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="utf-8"?> |
2 |
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> |
|
2 |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="120" android:versionName="1.2.0">
|
|
3 | 3 |
<application android:allowBackup="true" android:supportsRtl="true" android:icon="@mipmap/ae"></application> |
4 | 4 |
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
5 | 5 |
<uses-permission android:name="android.permission.INTERNET" /> |
6 |
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="34" /> |
|
7 | 6 |
</manifest> |
INRAETemplate/Services/ConnexionService.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.ComponentModel; |
|
4 |
using System.Linq; |
|
5 |
using System.Net.NetworkInformation; |
|
6 |
using System.Runtime.CompilerServices; |
|
7 |
using System.Text; |
|
8 |
using System.Threading.Tasks; |
|
9 |
|
|
10 |
namespace INRAETemplate.Services |
|
11 |
{ |
|
12 |
public class ConnexionService : INotifyPropertyChanged |
|
13 |
{ |
|
14 |
private bool isINRAE; |
|
15 |
public bool IsINRAE |
|
16 |
{ |
|
17 |
get => isINRAE; |
|
18 |
set => SetProperty(ref isINRAE, value); |
|
19 |
} |
|
20 |
|
|
21 |
// e est null à l'init |
|
22 |
public async Task SetIsConnected(ConnectivityChangedEventArgs e = null) |
|
23 |
{ |
|
24 |
bool internetAccess = e is null ? Connectivity.NetworkAccess == NetworkAccess.Internet : e.NetworkAccess == NetworkAccess.Internet; |
|
25 |
// Test de l'accès au serveur |
|
26 |
try |
|
27 |
{ |
|
28 |
await Task.Run(() => |
|
29 |
{ |
|
30 |
IsINRAE = new Ping().Send("138.102.166.28").Status == IPStatus.Success || new Ping().Send("147.100.200.52").Status == IPStatus.Success; |
|
31 |
}); |
|
32 |
IsINRAE = internetAccess && IsINRAE; |
|
33 |
} |
|
34 |
catch (Exception) |
|
35 |
{ |
|
36 |
IsINRAE = false; |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
public ConnexionService() |
|
41 |
{ |
|
42 |
Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged; |
|
43 |
Task.Run(() => this.SetIsConnected()).Wait(); |
|
44 |
// ou : new Action(async () => await SetIsConnected())(); |
|
45 |
} |
|
46 |
|
|
47 |
~ConnexionService() |
|
48 |
{ |
|
49 |
Connectivity.ConnectivityChanged -= Connectivity_ConnectivityChanged; |
|
50 |
} |
|
51 |
|
|
52 |
public void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e) |
|
53 |
{ |
|
54 |
Task.Run(() => this.SetIsConnected(e)).Wait(); |
|
55 |
} |
|
56 |
|
|
57 |
#region INPC |
|
58 |
public event PropertyChangedEventHandler PropertyChanged; |
|
59 |
|
|
60 |
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyname = null) |
|
61 |
{ |
|
62 |
if (Equals(storage, value)) return false; |
|
63 |
|
|
64 |
storage = value; |
|
65 |
OnPropertyChanged(propertyname); |
|
66 |
return true; |
|
67 |
} |
|
68 |
|
|
69 |
private void OnPropertyChanged([CallerMemberName] string propertyName = null) |
|
70 |
{ |
|
71 |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
|
72 |
} |
|
73 |
#endregion |
|
74 |
} |
|
75 |
} |
INRAETemplate/View/AboutView.xaml | ||
---|---|---|
2 | 2 |
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
3 | 3 |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
4 | 4 |
x:Class="INRAETemplate.View.AboutView" |
5 |
xmlns:tools="clr-namespace:INRAETemplate.View.Tools" |
|
5 | 6 |
Title="About"> |
6 | 7 |
<StackLayout BackgroundColor="{StaticResource InraePrimary}" Spacing="0"> |
8 |
<tools:ConnectionIndicatorView /> |
|
7 | 9 |
<ScrollView> |
8 | 10 |
<StackLayout Spacing="0"> |
9 | 11 |
<StackLayout |
... | ... | |
16 | 18 |
<StackLayout> |
17 | 19 |
<Frame BorderColor="{StaticResource InraePrimary}" Margin="0,0,0,20"> |
18 | 20 |
<Label |
19 |
Text="About..."
|
|
21 |
Text="A propos"
|
|
20 | 22 |
VerticalOptions="Center" |
21 | 23 |
HorizontalOptions="Center" |
22 | 24 |
Style="{StaticResource textTitre}"/> |
23 | 25 |
</Frame> |
26 |
<Grid ColumnDefinitions="70*,30*" RowDefinitions="auto"> |
|
27 |
<Label |
|
28 |
Grid.Row="0" |
|
29 |
Grid.Column="0" |
|
30 |
Text="Version Templace :" |
|
31 |
Style="{StaticResource textLabel}"/> |
|
32 |
<Label |
|
33 |
Grid.Row="0" |
|
34 |
Grid.Column="1" |
|
35 |
Text="{Binding VersionTemplate}" |
|
36 |
Style="{StaticResource textLabel}"/> |
|
37 |
</Grid> |
|
24 | 38 |
</StackLayout> |
25 | 39 |
</Frame> |
26 | 40 |
</StackLayout> |
INRAETemplate/View/AboutView.xaml.cs | ||
---|---|---|
1 |
using INRAETemplate.ViewModel; |
|
2 |
|
|
1 | 3 |
namespace INRAETemplate.View; |
2 | 4 |
|
3 | 5 |
public partial class AboutView : ContentPage |
... | ... | |
5 | 7 |
public AboutView() |
6 | 8 |
{ |
7 | 9 |
InitializeComponent(); |
8 |
} |
|
10 |
this.BindingContext = new AboutViewModel(); |
|
11 |
} |
|
9 | 12 |
} |
INRAETemplate/View/SettingsView.xaml | ||
---|---|---|
2 | 2 |
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
3 | 3 |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
4 | 4 |
x:Class="INRAETemplate.View.SettingsView" |
5 |
xmlns:tools="clr-namespace:INRAETemplate.View.Tools" |
|
5 | 6 |
Title="Settings"> |
6 | 7 |
|
7 | 8 |
<StackLayout BackgroundColor="{StaticResource InraePrimary}" Spacing="0"> |
9 |
<tools:ConnectionIndicatorView /> |
|
8 | 10 |
<ScrollView> |
9 | 11 |
<StackLayout Spacing="0"> |
10 | 12 |
<StackLayout |
INRAETemplate/View/Tools/ConnectionIndicatorView.xaml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8" ?> |
|
2 |
<StackLayout |
|
3 |
x:Class="INRAETemplate.View.Tools.ConnectionIndicatorView" |
|
4 |
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
|
5 |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
|
6 |
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" |
|
7 |
xmlns:vm="clr-namespace:INRAETemplate.Services" |
|
8 |
x:DataType="vm:ConnexionService"> |
|
9 |
|
|
10 |
<StackLayout.Resources> |
|
11 |
<ResourceDictionary> |
|
12 |
<toolkit:InvertedBoolConverter x:Key="NOTConverter" /> |
|
13 |
</ResourceDictionary> |
|
14 |
</StackLayout.Resources> |
|
15 |
|
|
16 |
<StackLayout> |
|
17 |
<!-- connecté --> |
|
18 |
<StackLayout |
|
19 |
BackgroundColor="Green" |
|
20 |
HorizontalOptions="FillAndExpand" |
|
21 |
IsVisible="{Binding IsINRAE}"> |
|
22 |
<Label |
|
23 |
FontAttributes="Bold" |
|
24 |
FontSize="Small" |
|
25 |
HorizontalOptions="Center" |
|
26 |
Text="Connecté" |
|
27 |
TextColor="White" /> |
|
28 |
</StackLayout> |
|
29 |
|
|
30 |
<!-- non connecté --> |
|
31 |
<StackLayout |
|
32 |
BackgroundColor="Black" |
|
33 |
HorizontalOptions="FillAndExpand" |
|
34 |
IsVisible="{Binding IsINRAE, Converter={StaticResource NOTConverter}}"> |
|
35 |
<Label |
|
36 |
FontAttributes="Bold" |
|
37 |
FontSize="Small" |
|
38 |
HorizontalOptions="Center" |
|
39 |
Text="Non connecté" |
|
40 |
TextColor="White" /> |
|
41 |
</StackLayout> |
|
42 |
|
|
43 |
</StackLayout> |
|
44 |
</StackLayout> |
INRAETemplate/View/Tools/ConnectionIndicatorView.xaml.cs | ||
---|---|---|
1 |
using INRAETemplate.Services; |
|
2 |
|
|
3 |
namespace INRAETemplate.View.Tools; |
|
4 |
|
|
5 |
public partial class ConnectionIndicatorView : StackLayout |
|
6 |
{ |
|
7 |
public ConnectionIndicatorView() |
|
8 |
{ |
|
9 |
InitializeComponent(); |
|
10 |
ConnexionService connexionStatus = App.Current.Handler.MauiContext.Services.GetService<ConnexionService>(); |
|
11 |
BindingContext = connexionStatus; |
|
12 |
} |
|
13 |
} |
INRAETemplate/View/VivantEditionView.xaml | ||
---|---|---|
2 | 2 |
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
3 | 3 |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
4 | 4 |
x:Class="INRAETemplate.View.VivantEditionView" |
5 |
xmlns:tools="clr-namespace:INRAETemplate.View.Tools" |
|
5 | 6 |
Title="Edition Vivant"> |
6 | 7 |
<Grid> |
7 | 8 |
<StackLayout BackgroundColor="{StaticResource InraePrimary}" Spacing="0"> |
9 |
<tools:ConnectionIndicatorView /> |
|
8 | 10 |
<ScrollView> |
9 | 11 |
<StackLayout Spacing="0"> |
10 | 12 |
<StackLayout |
INRAETemplate/View/VivantView.xaml | ||
---|---|---|
2 | 2 |
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
3 | 3 |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
4 | 4 |
x:Class="INRAETemplate.View.VivantView" |
5 |
xmlns:tools="clr-namespace:INRAETemplate.View.Tools" |
|
5 | 6 |
Title="Formulaire Vivant"> |
6 | 7 |
<Grid> |
7 | 8 |
<StackLayout BackgroundColor="{StaticResource InraePrimary}" Spacing="0"> |
9 |
<tools:ConnectionIndicatorView /> |
|
8 | 10 |
<ScrollView> |
9 | 11 |
<StackLayout Spacing="0"> |
10 | 12 |
<StackLayout |
... | ... | |
27 | 29 |
ItemsSource="{Binding Vivants}" |
28 | 30 |
SelectedItem="{Binding VivantSelectionne}" |
29 | 31 |
ItemDisplayBinding="{Binding VivantNom}"/> |
30 |
<Grid ColumnDefinitions="20*,80*" RowDefinitions="auto,auto">
|
|
32 |
<Grid ColumnDefinitions="25*,75*" RowDefinitions="auto,auto">
|
|
31 | 33 |
<Label Grid.Column="0" |
32 | 34 |
Grid.Row="0" |
33 | 35 |
Text="Id : " |
INRAETemplate/View/VivantView.xaml.cs | ||
---|---|---|
4 | 4 |
[XamlCompilation(XamlCompilationOptions.Skip)] |
5 | 5 |
public partial class VivantView : ContentPage |
6 | 6 |
{ |
7 |
public VivantView()
|
|
8 |
{
|
|
9 |
InitializeComponent();
|
|
10 |
this.BindingContext = new VivantViewModel();
|
|
11 |
}
|
|
7 |
public VivantView(VivantViewModel vm)
|
|
8 |
{
|
|
9 |
InitializeComponent();
|
|
10 |
this.BindingContext = vm;
|
|
11 |
}
|
|
12 | 12 |
} |
INRAETemplate/ViewModel/AboutViewModel.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Reflection; |
|
5 |
using System.Text; |
|
6 |
using System.Threading.Tasks; |
|
7 |
using INRAETemplate.ViewModel.Base; |
|
8 |
|
|
9 |
namespace INRAETemplate.ViewModel |
|
10 |
{ |
|
11 |
public class AboutViewModel : BaseViewModel |
|
12 |
{ |
|
13 |
#region Attributs |
|
14 |
private string versionTemplate; |
|
15 |
|
|
16 |
#endregion |
|
17 |
|
|
18 |
#region Propriétés |
|
19 |
|
|
20 |
public string VersionTemplate |
|
21 |
{ |
|
22 |
get { return versionTemplate; } |
|
23 |
set |
|
24 |
{ |
|
25 |
if (versionTemplate != value) |
|
26 |
{ |
|
27 |
versionTemplate = value; |
|
28 |
OnPropertyChanged(nameof(VersionTemplate)); |
|
29 |
} |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
#endregion |
|
34 |
|
|
35 |
#region Constructeurs |
|
36 |
public AboutViewModel() |
|
37 |
{ |
|
38 |
VersionTemplate = AppInfo.Current.VersionString; |
|
39 |
} |
|
40 |
#endregion |
|
41 |
} |
|
42 |
} |
INRAETemplate/ViewModel/SettingsViewModel.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
|
|
7 |
namespace INRAETemplate.ViewModel |
|
8 |
{ |
|
9 |
public class SettingsViewModel |
|
10 |
{ |
|
11 |
} |
|
12 |
} |
INRAETemplate/ViewModel/VivantViewModel.cs | ||
---|---|---|
1 | 1 |
using INRAETemplate.DAO; |
2 | 2 |
using INRAETemplate.Model; |
3 |
using INRAETemplate.Services; |
|
3 | 4 |
using INRAETemplate.View; |
4 | 5 |
using INRAETemplate.ViewModel.Base; |
5 | 6 |
using System; |
... | ... | |
14 | 15 |
{ |
15 | 16 |
public class VivantViewModel : BaseViewModel |
16 | 17 |
{ |
18 |
#region Services |
|
19 |
|
|
20 |
private readonly ConnexionService connService; |
|
21 |
|
|
22 |
#endregion |
|
23 |
|
|
17 | 24 |
#region Attributs |
18 | 25 |
private int vivantId; |
19 | 26 |
private string vivantNom; |
... | ... | |
83 | 90 |
#endregion |
84 | 91 |
|
85 | 92 |
#region Constructeurs |
86 |
public VivantViewModel() |
|
93 |
|
|
94 |
public VivantViewModel(ConnexionService connService) |
|
87 | 95 |
{ |
96 |
this.connService = connService; |
|
88 | 97 |
//Alimentation du Picker à partir de VivantDAO |
89 | 98 |
Vivants = new ObservableCollection<Vivant>(VivantDAO.GetVivants()); |
90 | 99 |
EditionCommand = new Command(async () => await Edition()); |
91 | 100 |
} |
101 |
|
|
92 | 102 |
#endregion |
93 | 103 |
|
94 | 104 |
#region Méthodes |
Formats disponibles : Unified diff