Skip to content

Commit

Permalink
updated to .net 8
Browse files Browse the repository at this point in the history
  • Loading branch information
0xc3u committed Dec 11, 2023
1 parent 69d1789 commit 516cfb2
Show file tree
Hide file tree
Showing 5 changed files with 248 additions and 17 deletions.
Binary file modified nuget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion samples/Plugin.Maui.Health.Sample.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugin.Maui.Health.Sample", "Plugin.Maui.Health.Sample\Plugin.Maui.Health.Sample.csproj", "{490BB138-9606-4FFF-8AAD-841C5B1ED059}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugin.Maui.Health", "..\src\Plugin.Maui.Health\Plugin.Maui.Health.csproj", "{B60F3174-E978-4F2B-B117-F6F0327594C8}"

EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{31D596F2-4262-4677-8B85-87C0B1F3950A}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml
..\README.md = ..\README.md
..\.github\workflows\release-nuget.yml = ..\.github\workflows\release-nuget.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
Expand Down
244 changes: 232 additions & 12 deletions src/Plugin.Maui.Health/Health.android.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Plugin.Maui.Health.Enums;
using Android.Content.PM;
using Microsoft.Maui.ApplicationModel;
using Plugin.Maui.Health.Enums;
using Plugin.Maui.Health.Exceptions;
using Plugin.Maui.Health.Extensions;
using Plugin.Maui.Health.Models;

namespace Plugin.Maui.Health;
Expand All @@ -17,11 +21,6 @@ public Task<List<Sample>> ReadAllAsync(HealthParameter healthParameter, DateTime
throw new NotImplementedException();
}

public Task<List<Workout>> ReadAllWorkoutsAsync(WorkoutType workoutType, DateTime from, DateTime until)
{
throw new NotImplementedException();
}

public Task<double?> ReadAverageAsync(HealthParameter healthParameter, DateTime from, DateTime until, string unit)
{
throw new NotImplementedException();
Expand All @@ -37,11 +36,6 @@ public Task<double> ReadCountAsync(HealthParameter healthParameter, DateTime fro
throw new NotImplementedException();
}

public Task<Workout?> ReadLatestWorkoutAsync(WorkoutType workoutType, DateTime from, DateTime until)
{
throw new NotImplementedException();
}

public Task<double?> ReadMaxAsync(HealthParameter healthParameter, DateTime from, DateTime until, string unit)
{
throw new NotImplementedException();
Expand All @@ -56,4 +50,230 @@ public Task<bool> WriteAsync(HealthParameter healthParameter, DateTime? date, do
{
throw new NotImplementedException();
}
}
}

//partial class HealthDataProviderImplementation : IHealth
//{

// // Set of static methods for working with POSIX time
// public static class TimeUtility
// {
// const string tag = "TimeUtility";

// // Start of POSIX time
// static readonly DateTime unixEpoch =
// new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

// // A week in milliseconds
// const long weekInMillis = 1000 * 60 * 60 * 24 * 7;

// // 48 hours in milliseconds
// const long twoDaysInMillis = 1000 * 60 * 60 * 24 * 2;

// // Current POSIX time
// public static long CurrentMillis()
// {
// return (long)(DateTime.UtcNow - unixEpoch).TotalMilliseconds;
// }

// // A week ago in POSIX time
// public static long WeekAgoMillis()
// {
// return (long)(DateTime.UtcNow - unixEpoch).TotalMilliseconds - weekInMillis;
// }

// // 48 hours ago in POSIX time
// public static long TwoDaysAgoMillis()
// {
// // We add a 1 to ensure only two buckets of 24 hours apiece are created
// return (long)(DateTime.UtcNow - unixEpoch).TotalMilliseconds - twoDaysInMillis + 1;
// }

// // Converts POSIX time to DateTime
// public static DateTime FromMillis(long millis)
// {
// return unixEpoch.AddMilliseconds(millis);
// }

// // Calculate how many days in the past a day is from today
// public static uint DaysInPast(DateTime dateTime)
// {
// return (uint)(DateTime.Now.Date - dateTime.Date).Days;
// }

// }

// readonly Dictionary<HealthParameter, Android.Gms.Fitness.Data.DataType> healthParameterMapping = new()
// {
// {HealthParameter.ActiveEnergyBurned, Android.Gms.Fitness.Data.DataType.TypeCaloriesExpended},
// //{HealthParameter.AtrialFibrillationBurden, /*not supported*/}
// //{HealthParameter.BasalBodyTemperature, /*not supported*/},
// {HealthParameter.BasalEnergyBurned, Android.Gms.Fitness.Data.DataType.TypeBasalMetabolicRate},
// //{HealthParameter.BloodAlcoholContent, /*not supported*/},
// //{HealthParameter.BloodGlucose, /*not supported*/},
// //{HealthParameter.BloodPressureDiastolic, /*not supported*/},
// //{HealthParameter.BloodPressureSystolic, /*not supported*/},
// {HealthParameter.BodyFatPercentage, Android.Gms.Fitness.Data.DataType.TypeBodyFatPercentage},
// {HealthParameter.BodyMass, Android.Gms.Fitness.Data.DataType.TypeWeight},
// //{HealthParameter.BodyMassIndex, /*not supported*/},
// //{HealthParameter.BodyTemperature, /*not supported*/},
// {HealthParameter.DietaryBiotin, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryCaffeine, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryCalcium, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryCarbohydrates, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryChloride, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryCholesterol, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryChromium, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryCopper, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryEnergyConsumed, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryFatMonounsaturated, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryFatPolyunsaturated, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryFatSaturated, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryFatTotal, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryFiber, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryFolate, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryIodine, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryIron, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryMagnesium, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryManganese, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryMolybdenum, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryNiacin, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryPantothenicAcid, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryPhosphorus, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryPotassium, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryProtein, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryRiboflavin, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietarySelenium, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietarySodium, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietarySugar, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryThiamin, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryVitaminA, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryVitaminB12, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryVitaminB6, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryVitaminC, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryVitaminD, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryVitaminE, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryVitaminK, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryWater, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.DietaryZinc, Android.Gms.Fitness.Data.DataType.TypeNutrition},
// {HealthParameter.HeartRate, Android.Gms.Fitness.Data.DataType.TypeHeartRateBpm},
// {HealthParameter.Height, Android.Gms.Fitness.Data.DataType.TypeHeight},
// {HealthParameter.LeanBodyMass, Android.Gms.Fitness.Data.DataType.TypeWeight},
// {HealthParameter.DistanceCycling, Android.Gms.Fitness.Data.DataType.AggregateDistanceDelta},
// {HealthParameter.DistanceWalkingRunning, Android.Gms.Fitness.Data.DataType.AggregateDistanceDelta},
// {HealthParameter.DistanceWheelchair, Android.Gms.Fitness.Data.DataType.AggregateDistanceDelta},
// // {HealthParameter.ElectrodermalActivity, /*not supported*/ },
// // {HealthParameter.EnvironmentalAudioExposure, /*not supported*/ },
// {HealthParameter.ExerciseTime, Android.Gms.Fitness.Data.DataType.TypeMoveMinutes},
// {HealthParameter.FlightsClimbed, Android.Gms.Fitness.Data.DataType.TypeHeight},
// //{HealthParameter.ForcedExpiratoryVolume1, /*not supported*/ }
// {HealthParameter.StepCount, Android.Gms.Fitness.Data.DataType.TypeStepCountDelta},
// };

// readonly SemaphoreSlim semaphore = new(1, 1);

// readonly PackageManager? packageManager = Application.Context.PackageManager;

// public bool IsSupported => true;
// void CreateGoogleApiClient()
// {



// //GoogleApiClient mClient = new GoogleApiClient.Builder(Application.Context)
// // .AddApi(FitnessClass.HISTORY_API)
// // .AddScope(new Scope(Scopes.FitnessActivityRead))
// // .AddConnectionCallbacks(this)
// // .AddOnConnectionFailedListener(this)
// // .Build();

// }


// public Task<bool> CheckPermissionAsync(HealthParameter healthParameter, PermissionType permissionType)
// {
// var activity = Platform.CurrentActivity;
// //Android.Gms.Fitness.Data.DataType.TypeStepCountDelta

// throw new NotImplementedException();
// }

// public Task<List<Sample>> ReadAllAsync(HealthParameter healthParameter, DateTime from, DateTime until, string unit)
// {
// throw new NotImplementedException();
// }

// public Task<List<Workout>> ReadAllWorkoutsAsync(WorkoutType workoutType, DateTime from, DateTime until)
// {
// throw new NotImplementedException();
// }

// public Task<double?> ReadAverageAsync(HealthParameter healthParameter, DateTime from, DateTime until, string unit)
// {
// throw new NotImplementedException();
// }

// public Task<double> ReadCountAsync(HealthParameter healthParameter, DateTime from, DateTime until)
// {
// throw new NotImplementedException();
// }

// public async Task<double?> ReadLatestAsync(HealthParameter healthParameter, DateTime from, DateTime until, string unit)
// {

// await semaphore.WaitAsync();
// var tcs = new TaskCompletionSource<double?>();

// try
// {
// if (!healthParameterMapping.TryGetValue(healthParameter, out var requestedHealthParameter))
// {
// throw new HealthException($"{healthParameter} not available");
// }

// // Prepare the time range
// var startTime = from.ToUnixTimeMilliseconds();
// var endTime = until.ToUnixTimeMilliseconds();

// // Build the data request
// var readRequest = new DataReadRequest.Builder()
// .Aggregate(requestedHealthParameter)
// .BucketByTime(1, Java.Util.Concurrent.TimeUnit.Microseconds)
// .SetTimeRange(startTime, endTime, Java.Util.Concurrent.TimeUnit.Microseconds)
// .Build();


// }
// catch (Exception ex)
// {
// tcs.SetException(new HealthException(ex.Message, ex));
// }
// finally
// {
// semaphore.Release();
// }

// return await tcs.Task;
// }

// public Task<Workout?> ReadLatestWorkoutAsync(WorkoutType workoutType, DateTime from, DateTime until)
// {
// throw new NotImplementedException();
// }

// public Task<double?> ReadMaxAsync(HealthParameter healthParameter, DateTime from, DateTime until, string unit)
// {
// throw new NotImplementedException();
// }

// public Task<double?> ReadMinAsync(HealthParameter healthParameter, DateTime from, DateTime until, string unit)
// {
// throw new NotImplementedException();
// }

// public Task<bool> WriteAsync(HealthParameter healthParameter, DateTime? date, double valueToStore, string unit)
// {
// throw new NotImplementedException();
// }

//}
11 changes: 8 additions & 3 deletions src/Plugin.Maui.Health/Plugin.Maui.Health.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst;</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst;</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<SingleProject>true</SingleProject>
Expand Down Expand Up @@ -60,8 +60,13 @@
<ItemGroup>
<None Include="..\..\nuget.png" PackagePath="icon.png" Pack="true" />
</ItemGroup>
<ItemGroup>
<Folder Include="Extensions\" />
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0-android'">
<PackageReference Include="Xamarin.GooglePlayServices.Base">
<Version>118.2.0.2</Version>
</PackageReference>
<PackageReference Include="Xamarin.GooglePlayServices.Fitness">
<Version>121.1.0.4</Version>
</PackageReference>
</ItemGroup>

</Project>

0 comments on commit 516cfb2

Please sign in to comment.