Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@
"permission_health_read_description": "Zum Lesen deiner Aktivitäten und Fitness-Daten",
"permission_health_write_title": "Gesundheitsdaten Schreiben",
"permission_health_write_description": "Zum Speichern deiner Aktivitäten in der Health-Datenbank",
"permission_health_read_missing": "Bitte erteile zuerst die Leseberechtigung für Gesundheitsdaten",
"permission_health_historical_title": "Historische Gesundheitsdaten",
"permission_health_historical_description": "Für den Zugriff auf Gesundheitsdaten, die älter als 30 Tage sind, für Langzeitanalysen",
"permission_allow": "Erlauben",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@
"permission_health_read_description": "To read your activities and fitness data",
"permission_health_write_title": "Health Data Write",
"permission_health_write_description": "To save your activities to the health database",
"permission_health_read_missing": "Please first allow access to read your health data",
"permission_health_historical_title": "Historical Health Data",
"permission_health_historical_description": "To access your health data older than 30 days for long-term analysis",
"permission_allow": "Allow",
Expand Down
25 changes: 24 additions & 1 deletion lib/presentation/onboarding/providers/permissions_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class PermissionsState {
final bool healthWritePermissionStatus;
final bool healthHistoricalPermissionStatus;

/*
* Determine if historical health functionality is available
* Only relevant for Android, on iOS this is always false
* */
final bool isHealthHistoricalAvailable;

bool get hasRequiredPermissions => healthPermissionStatus;

PermissionsState({
Expand All @@ -28,6 +34,7 @@ class PermissionsState {
this.healthPermissionStatus = false,
this.healthWritePermissionStatus = false,
this.healthHistoricalPermissionStatus = false,
this.isHealthHistoricalAvailable = false,
});

PermissionsState copyWith({
Expand All @@ -37,6 +44,7 @@ class PermissionsState {
bool? healthPermissionStatus,
bool? healthWritePermissionStatus,
bool? healthHistoricalPermissionStatus,
bool? isHealthHistoricalAvailable,
}) {
return PermissionsState(
locationPermissionStatus:
Expand All @@ -51,6 +59,8 @@ class PermissionsState {
healthWritePermissionStatus ?? this.healthWritePermissionStatus,
healthHistoricalPermissionStatus: healthHistoricalPermissionStatus ??
this.healthHistoricalPermissionStatus,
isHealthHistoricalAvailable:
isHealthHistoricalAvailable ?? this.isHealthHistoricalAvailable,
);
}

Expand Down Expand Up @@ -284,7 +294,20 @@ class PermissionsNotifier extends StateNotifier<PermissionsState> {
}

try {
// Verwende die direkte API-Methode, um zu prüfen, ob historische Berechtigungen gewährt wurden
// Check the availability of historical permissions
// This is only relevant for Android, on iOS this is not available

bool isHistoricalAvailable =
await _health.isHealthDataHistoryAvailable();
state =
state.copyWith(isHealthHistoricalAvailable: isHistoricalAvailable);
if (!isHistoricalAvailable) {
log.warning("Historical Health feature is not available");
return;
}

// Verwende die direkte API-Methode, um zu prüfen, ob historische Berechtigungen gewährt wurde

bool hasHistoricalPermissions =
await _health.isHealthDataHistoryAuthorized();

Expand Down
10 changes: 4 additions & 6 deletions lib/presentation/onboarding/widgets/permissions_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ class PermissionsPage extends ConsumerWidget {
if (!permissionsState.healthPermissionStatus) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Bitte erteile zuerst die Leseberechtigung für Gesundheitsdaten'),
content: Text(l10n.permission_health_read_missing),
backgroundColor: theme.colorScheme.error,
duration: const Duration(seconds: 2),
),
Expand Down Expand Up @@ -200,8 +199,8 @@ class PermissionsPage extends ConsumerWidget {

const SizedBox(height: 16),

// Historical Health Data permission - only for Android
if (Theme.of(context).platform == TargetPlatform.android)
// Historical Health Data permission - only if available
if (permissionsState.isHealthHistoricalAvailable)
Column(
children: [
PermissionCard(
Expand All @@ -216,8 +215,7 @@ class PermissionsPage extends ConsumerWidget {
if (!permissionsState.healthPermissionStatus) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text(
'Bitte erteile zuerst die Leseberechtigung für Gesundheitsdaten'),
content: Text(l10n.permission_health_read_missing),
backgroundColor: theme.colorScheme.error,
duration: const Duration(seconds: 2),
),
Expand Down
10 changes: 4 additions & 6 deletions lib/presentation/profile/screen/permissions_settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ class PermissionsSettingsScreen extends HookConsumerWidget {
if (!permissionsState.healthPermissionStatus) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Bitte erteile zuerst die Leseberechtigung für Gesundheitsdaten'),
content: Text(l10n.permission_health_read_missing),
backgroundColor: theme.colorScheme.error,
duration: const Duration(seconds: 2),
),
Expand Down Expand Up @@ -193,8 +192,8 @@ class PermissionsSettingsScreen extends HookConsumerWidget {

const SizedBox(height: 16),

// Historical Health Data permission - only for Android
if (Theme.of(context).platform == TargetPlatform.android)
// Historical Health Data permission - only if available
if (permissionsState.isHealthHistoricalAvailable)
PermissionCard(
icon: Icons.history,
title: l10n.permission_health_historical_title,
Expand All @@ -207,8 +206,7 @@ class PermissionsSettingsScreen extends HookConsumerWidget {
if (!permissionsState.healthPermissionStatus) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Bitte erteile zuerst die Leseberechtigung für Gesundheitsdaten'),
content: Text(l10n.permission_health_read_missing),
backgroundColor: theme.colorScheme.error,
duration: const Duration(seconds: 2),
),
Expand Down
Loading