|
...
|
...
|
@@ -335,7 +335,42 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
|
|
|
|
|
|
Future<bool> requestHealthAuthorization(
|
|
|
|
{bool isFromNoPermissionPage = false}) async {
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
if (isOhos()) {
|
|
|
|
try {
|
|
|
|
await _checkHealthAuthStatus();
|
|
|
|
AppLogger.d("checkHealthAppAuthorization : $_currentStatus");
|
|
|
|
if (_currentStatus == 1) {
|
|
|
|
_refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
if (isFromNoPermissionPage) {
|
|
|
|
Get.back();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
bool success = await _hostApi.requestHealthClientAuthorization();
|
|
|
|
AppLogger.d("requestHealthClientAuthorization : $success");
|
|
|
|
if (success) {
|
|
|
|
_currentStatus = 1;
|
|
|
|
_refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
// await LoadingService.instance.run(() async {
|
|
|
|
_performCaculateAndUpload();
|
|
|
|
// });
|
|
|
|
// result.status = 1;
|
|
|
|
// AppToast.show('刷新完成');
|
|
|
|
if (isFromNoPermissionPage) {
|
|
|
|
Get.back();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// Get.to(NoHealthDataPage(
|
|
|
|
// onRefresh: _performDataUpload,
|
|
|
|
// ));
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
AppToast.show(e.toString());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
await _checkHealthAuthStatus();
|
|
|
|
AppLogger.d("checkHealthAppAuthorization : $_currentStatus");
|
|
...
|
...
|
@@ -384,40 +419,79 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
|
|
_isHandlingHealthAuthorizationTap = true;
|
|
|
|
ta.track('click_doublefeel_today_status', properties: {'ita': '授权访问健康数据'});
|
|
|
|
try {
|
|
|
|
if (_currentStatus == 1 && hrvChartData.isNotEmpty) {
|
|
|
|
return;
|
|
|
|
} else if (_currentStatus == 0) {
|
|
|
|
final success = await requestHealthAuthorization();
|
|
|
|
if (success) {
|
|
|
|
_currentStatus = 1;
|
|
|
|
_refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
if (isOhos()) {
|
|
|
|
if (_currentStatus != 1) {
|
|
|
|
final success = await requestHealthAuthorization();
|
|
|
|
if (success) {
|
|
|
|
_currentStatus = 1;
|
|
|
|
_refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (hrvChartData.isNotEmpty) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await Get.to(() => NoHealthDataPage(
|
|
|
|
onRefresh: () {
|
|
|
|
refreshTab();
|
|
|
|
Future.delayed(const Duration(milliseconds: 800), () {
|
|
|
|
AppToast.show(l10n.refreshComplete);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onHelp: () {
|
|
|
|
if (environmentConfig.region.value == AppRegion.china) {
|
|
|
|
Get.toNamed(Routes.HELP);
|
|
|
|
} else {
|
|
|
|
final userId = Get.find<UserPreferencesStorage>()
|
|
|
|
.preferences
|
|
|
|
.value
|
|
|
|
.meUserInfo
|
|
|
|
?.id ??
|
|
|
|
0;
|
|
|
|
sendFeedbackEmail(
|
|
|
|
userId: userId.toString(),
|
|
|
|
pageName: 'No heart rate data available page',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
));
|
|
|
|
checkHealthDataAuthCardVisible();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
await Get.to(() => NoHealthDataPage(
|
|
|
|
onRefresh: () {
|
|
|
|
refreshTab();
|
|
|
|
Future.delayed(const Duration(milliseconds: 800), () {
|
|
|
|
AppToast.show(l10n.refreshComplete);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onHelp: () {
|
|
|
|
if (environmentConfig.region.value == AppRegion.china) {
|
|
|
|
Get.toNamed(Routes.HELP);
|
|
|
|
} else {
|
|
|
|
final userId = Get.find<UserPreferencesStorage>()
|
|
|
|
.preferences
|
|
|
|
.value
|
|
|
|
.meUserInfo
|
|
|
|
?.id ??
|
|
|
|
0;
|
|
|
|
sendFeedbackEmail(
|
|
|
|
userId: userId.toString(),
|
|
|
|
pageName: 'No heart rate data available page',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
));
|
|
|
|
checkHealthDataAuthCardVisible();
|
|
|
|
if (_currentStatus == 1 && hrvChartData.isNotEmpty) {
|
|
|
|
return;
|
|
|
|
} else if (_currentStatus == 0) {
|
|
|
|
final success = await requestHealthAuthorization();
|
|
|
|
if (success) {
|
|
|
|
_currentStatus = 1;
|
|
|
|
_refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
await Get.to(() => NoHealthDataPage(
|
|
|
|
onRefresh: () {
|
|
|
|
refreshTab();
|
|
|
|
Future.delayed(const Duration(milliseconds: 800), () {
|
|
|
|
AppToast.show(l10n.refreshComplete);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onHelp: () {
|
|
|
|
if (environmentConfig.region.value == AppRegion.china) {
|
|
|
|
Get.toNamed(Routes.HELP);
|
|
|
|
} else {
|
|
|
|
final userId = Get.find<UserPreferencesStorage>()
|
|
|
|
.preferences
|
|
|
|
.value
|
|
|
|
.meUserInfo
|
|
|
|
?.id ??
|
|
|
|
0;
|
|
|
|
sendFeedbackEmail(
|
|
|
|
userId: userId.toString(),
|
|
|
|
pageName: 'No heart rate data available page',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
));
|
|
|
|
checkHealthDataAuthCardVisible();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
_isHandlingHealthAuthorizationTap = false;
|
...
|
...
|
|