Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Jan 8, 2025
1 parent 3ec135e commit bd8912c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 10 deletions.
5 changes: 0 additions & 5 deletions samples/Sample.Maui/Sample.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@

<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
<SupportedOSPlatformVersion>15.0</SupportedOSPlatformVersion>
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<!--
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
-->
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<CI Condition="'$(GITHUB_ACTIONS)' == 'true'">true</CI>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
<MicrosoftExtensionsVersion>9.0.0</MicrosoftExtensionsVersion>
<MauiVersion>9.0.11</MauiVersion>
<MauiVersion>9.0.21</MauiVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
67 changes: 66 additions & 1 deletion src/Shiny.Health/Platforms/Android/HealthService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,69 @@
// using System;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Android.App;
using Android.Health.Connect;
using AndroidX.Health.Connect.Client;
using AndroidX.Health.Connect.Client.Impl.Converters.Time;
using AndroidX.Health.Connect.Client.Time;
using AndroidX.Health.Connect.Client.Records;
using AndroidX.Health.Connect.Client.Request;
using AndroidX.Health.Connect.Client.Response;
using Java.Time;
using Kotlin.Jvm;
using Kotlin.Reflect;
using DataOrigin = AndroidX.Health.Connect.Client.Records.Metadata.DataOrigin;
using ReadRecordsRequest = AndroidX.Health.Connect.Client.Request.ReadRecordsRequest;
using StepsRecord = Android.Health.Connect.DataTypes.StepsRecord;

namespace Shiny.Health;


public class HealthService : IHealthService
{
public Task<IEnumerable<(DataType Type, bool Success)>> RequestPermissions(params DataType[] dataTypes)
{
var client = HealthConnectClient.GetOrCreate(Application.Context);
var stepCountRecordClass = JvmClassMappingKt.GetKotlinClass(
Java.Lang.Class.FromType(typeof(StepsRecord))
);
var trf = TimeRangeFilter.Between(
Instant.OfEpochMilli(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds())!,
Instant.OfEpochMilli(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds())!
);
// new ReadRecordsRequest.Builder<StepsRecord>()
//new ReadRecordsRequest.Builder<StepsRecord>();
var request = new ReadRecordsRequest(
stepCountRecordClass,
trf,
new List<DataOrigin>(),
true,
10,
"page token"
);
//new TimeRangeFilterConverterKt()
//client.ReadRecords(request)
// var i = HealthServices.GetClient(Application.Context);
// var healthClient = HealthServices.GetClient(Application.Context);
//new HealthDataStore(null);
// var dataStore = new HealthDatastore(null);
return null;
}

public Task<IList<NumericHealthResult>> GetCalories(DateTimeOffset start, DateTimeOffset end, Interval interval, CancellationToken cancelToken = default) => throw new NotImplementedException();

public Task<IList<NumericHealthResult>> GetDistances(DateTimeOffset start, DateTimeOffset end, Interval interval, CancellationToken cancelToken = default) => throw new NotImplementedException();

public Task<IList<NumericHealthResult>> GetStepCounts(DateTimeOffset start, DateTimeOffset end, Interval interval,
CancellationToken cancelToken = default) =>
throw new NotImplementedException();

public Task<IList<NumericHealthResult>> GetAverageHeartRate(DateTimeOffset start, DateTimeOffset end, Interval interval,
CancellationToken cancelToken = default) =>
throw new NotImplementedException();
}
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Threading;
Expand Down
10 changes: 7 additions & 3 deletions src/Shiny.Health/Shiny.Health.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
<TargetFrameworks>$(DefaultTargetFrameworks);</TargetFrameworks>
<Description>Cross Platform health data - Apple Health and Google Fit Integrations</Description>
<Nullable>enable</Nullable>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">35.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup Condition="$(TargetFramework.Contains('android'))">
<PackageReference Include="Xamarin.AndroidX.Collection.Jvm" Version="1.3.0.2" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.3.0.2" />
<PackageReference Include="Xamarin.GooglePlayServices.Auth" Version="120.7.0.1" />
<PackageReference Include="Xamarin.Androidx.Health" Version="1.0.0-pre1" />
<!--<PackageReference Include="Xamarin.GooglePlayServices.Auth" Version="120.7.0.1" />-->
<!-- <PackageReference Include="Xamarin.AndroidX.Health.ServicesClient" Version="1.1.0-alpha03" />-->
<PackageReference Include="Xamarin.Androidx.Health.Connect.ConnectClient" Version="1.1.0-alpha07" />
</ItemGroup>
</Project>

0 comments on commit bd8912c

Please sign in to comment.