|
@@ -335,7 +335,42 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
@@ -335,7 +335,42 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
335
|
|
335
|
|
|
336
|
Future<bool> requestHealthAuthorization(
|
336
|
Future<bool> requestHealthAuthorization(
|
|
337
|
{bool isFromNoPermissionPage = false}) async {
|
337
|
{bool isFromNoPermissionPage = false}) async {
|
|
338
|
- if (Platform.isIOS) {
|
338
|
+ if (isOhos()) {
|
|
|
|
339
|
+ try {
|
|
|
|
340
|
+ await _checkHealthAuthStatus();
|
|
|
|
341
|
+ AppLogger.d("checkHealthAppAuthorization : $_currentStatus");
|
|
|
|
342
|
+ if (_currentStatus == 1) {
|
|
|
|
343
|
+ _refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
344
|
+ if (isFromNoPermissionPage) {
|
|
|
|
345
|
+ Get.back();
|
|
|
|
346
|
+ }
|
|
|
|
347
|
+ return true;
|
|
|
|
348
|
+ } else {
|
|
|
|
349
|
+ bool success = await _hostApi.requestHealthClientAuthorization();
|
|
|
|
350
|
+ AppLogger.d("requestHealthClientAuthorization : $success");
|
|
|
|
351
|
+ if (success) {
|
|
|
|
352
|
+ _currentStatus = 1;
|
|
|
|
353
|
+ _refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
354
|
+ // await LoadingService.instance.run(() async {
|
|
|
|
355
|
+ _performCaculateAndUpload();
|
|
|
|
356
|
+ // });
|
|
|
|
357
|
+ // result.status = 1;
|
|
|
|
358
|
+ // AppToast.show('刷新完成');
|
|
|
|
359
|
+ if (isFromNoPermissionPage) {
|
|
|
|
360
|
+ Get.back();
|
|
|
|
361
|
+ }
|
|
|
|
362
|
+ return true;
|
|
|
|
363
|
+ } else {
|
|
|
|
364
|
+ // Get.to(NoHealthDataPage(
|
|
|
|
365
|
+ // onRefresh: _performDataUpload,
|
|
|
|
366
|
+ // ));
|
|
|
|
367
|
+ }
|
|
|
|
368
|
+ return false;
|
|
|
|
369
|
+ }
|
|
|
|
370
|
+ } catch (e) {
|
|
|
|
371
|
+ AppToast.show(e.toString());
|
|
|
|
372
|
+ }
|
|
|
|
373
|
+ } else {
|
|
339
|
try {
|
374
|
try {
|
|
340
|
await _checkHealthAuthStatus();
|
375
|
await _checkHealthAuthStatus();
|
|
341
|
AppLogger.d("checkHealthAppAuthorization : $_currentStatus");
|
376
|
AppLogger.d("checkHealthAppAuthorization : $_currentStatus");
|
|
@@ -384,40 +419,79 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
@@ -384,40 +419,79 @@ class TodayController extends GetxController with WidgetsBindingObserver { |
|
384
|
_isHandlingHealthAuthorizationTap = true;
|
419
|
_isHandlingHealthAuthorizationTap = true;
|
|
385
|
ta.track('click_doublefeel_today_status', properties: {'ita': '授权访问健康数据'});
|
420
|
ta.track('click_doublefeel_today_status', properties: {'ita': '授权访问健康数据'});
|
|
386
|
try {
|
421
|
try {
|
|
387
|
- if (_currentStatus == 1 && hrvChartData.isNotEmpty) {
|
|
|
|
388
|
- return;
|
|
|
|
389
|
- } else if (_currentStatus == 0) {
|
|
|
|
390
|
- final success = await requestHealthAuthorization();
|
|
|
|
391
|
- if (success) {
|
|
|
|
392
|
- _currentStatus = 1;
|
|
|
|
393
|
- _refreshHealthDataAuthCardStatus(status: 1);
|
422
|
+ if (isOhos()) {
|
|
|
|
423
|
+ if (_currentStatus != 1) {
|
|
|
|
424
|
+ final success = await requestHealthAuthorization();
|
|
|
|
425
|
+ if (success) {
|
|
|
|
426
|
+ _currentStatus = 1;
|
|
|
|
427
|
+ _refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
428
|
+ }
|
|
|
|
429
|
+ } else {
|
|
|
|
430
|
+ if (hrvChartData.isNotEmpty) {
|
|
|
|
431
|
+ return;
|
|
|
|
432
|
+ }
|
|
|
|
433
|
+ await Get.to(() => NoHealthDataPage(
|
|
|
|
434
|
+ onRefresh: () {
|
|
|
|
435
|
+ refreshTab();
|
|
|
|
436
|
+ Future.delayed(const Duration(milliseconds: 800), () {
|
|
|
|
437
|
+ AppToast.show(l10n.refreshComplete);
|
|
|
|
438
|
+ });
|
|
|
|
439
|
+ },
|
|
|
|
440
|
+ onHelp: () {
|
|
|
|
441
|
+ if (environmentConfig.region.value == AppRegion.china) {
|
|
|
|
442
|
+ Get.toNamed(Routes.HELP);
|
|
|
|
443
|
+ } else {
|
|
|
|
444
|
+ final userId = Get.find<UserPreferencesStorage>()
|
|
|
|
445
|
+ .preferences
|
|
|
|
446
|
+ .value
|
|
|
|
447
|
+ .meUserInfo
|
|
|
|
448
|
+ ?.id ??
|
|
|
|
449
|
+ 0;
|
|
|
|
450
|
+ sendFeedbackEmail(
|
|
|
|
451
|
+ userId: userId.toString(),
|
|
|
|
452
|
+ pageName: 'No heart rate data available page',
|
|
|
|
453
|
+ );
|
|
|
|
454
|
+ }
|
|
|
|
455
|
+ },
|
|
|
|
456
|
+ ));
|
|
|
|
457
|
+ checkHealthDataAuthCardVisible();
|
|
394
|
}
|
458
|
}
|
|
395
|
} else {
|
459
|
} else {
|
|
396
|
- await Get.to(() => NoHealthDataPage(
|
|
|
|
397
|
- onRefresh: () {
|
|
|
|
398
|
- refreshTab();
|
|
|
|
399
|
- Future.delayed(const Duration(milliseconds: 800), () {
|
|
|
|
400
|
- AppToast.show(l10n.refreshComplete);
|
|
|
|
401
|
- });
|
|
|
|
402
|
- },
|
|
|
|
403
|
- onHelp: () {
|
|
|
|
404
|
- if (environmentConfig.region.value == AppRegion.china) {
|
|
|
|
405
|
- Get.toNamed(Routes.HELP);
|
|
|
|
406
|
- } else {
|
|
|
|
407
|
- final userId = Get.find<UserPreferencesStorage>()
|
|
|
|
408
|
- .preferences
|
|
|
|
409
|
- .value
|
|
|
|
410
|
- .meUserInfo
|
|
|
|
411
|
- ?.id ??
|
|
|
|
412
|
- 0;
|
|
|
|
413
|
- sendFeedbackEmail(
|
|
|
|
414
|
- userId: userId.toString(),
|
|
|
|
415
|
- pageName: 'No heart rate data available page',
|
|
|
|
416
|
- );
|
|
|
|
417
|
- }
|
|
|
|
418
|
- },
|
|
|
|
419
|
- ));
|
|
|
|
420
|
- checkHealthDataAuthCardVisible();
|
460
|
+ if (_currentStatus == 1 && hrvChartData.isNotEmpty) {
|
|
|
|
461
|
+ return;
|
|
|
|
462
|
+ } else if (_currentStatus == 0) {
|
|
|
|
463
|
+ final success = await requestHealthAuthorization();
|
|
|
|
464
|
+ if (success) {
|
|
|
|
465
|
+ _currentStatus = 1;
|
|
|
|
466
|
+ _refreshHealthDataAuthCardStatus(status: 1);
|
|
|
|
467
|
+ }
|
|
|
|
468
|
+ } else {
|
|
|
|
469
|
+ await Get.to(() => NoHealthDataPage(
|
|
|
|
470
|
+ onRefresh: () {
|
|
|
|
471
|
+ refreshTab();
|
|
|
|
472
|
+ Future.delayed(const Duration(milliseconds: 800), () {
|
|
|
|
473
|
+ AppToast.show(l10n.refreshComplete);
|
|
|
|
474
|
+ });
|
|
|
|
475
|
+ },
|
|
|
|
476
|
+ onHelp: () {
|
|
|
|
477
|
+ if (environmentConfig.region.value == AppRegion.china) {
|
|
|
|
478
|
+ Get.toNamed(Routes.HELP);
|
|
|
|
479
|
+ } else {
|
|
|
|
480
|
+ final userId = Get.find<UserPreferencesStorage>()
|
|
|
|
481
|
+ .preferences
|
|
|
|
482
|
+ .value
|
|
|
|
483
|
+ .meUserInfo
|
|
|
|
484
|
+ ?.id ??
|
|
|
|
485
|
+ 0;
|
|
|
|
486
|
+ sendFeedbackEmail(
|
|
|
|
487
|
+ userId: userId.toString(),
|
|
|
|
488
|
+ pageName: 'No heart rate data available page',
|
|
|
|
489
|
+ );
|
|
|
|
490
|
+ }
|
|
|
|
491
|
+ },
|
|
|
|
492
|
+ ));
|
|
|
|
493
|
+ checkHealthDataAuthCardVisible();
|
|
|
|
494
|
+ }
|
|
421
|
}
|
495
|
}
|
|
422
|
} finally {
|
496
|
} finally {
|
|
423
|
_isHandlingHealthAuthorizationTap = false;
|
497
|
_isHandlingHealthAuthorizationTap = false;
|