Skip to content

Commit

Permalink
Merge branch 'master' into bardram/responsive-refactor-#212
Browse files Browse the repository at this point in the history
  • Loading branch information
bardram committed Jan 26, 2024
2 parents 5afe12b + af38871 commit b2b4b96
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 74 deletions.
49 changes: 5 additions & 44 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,50 +64,6 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />

<!-- Permissions for Health Connect API -->
<uses-permission android:name="android.permission.health.READ_STEPS"/>
<uses-permission android:name="android.permission.health.WRITE_STEPS"/>
<uses-permission android:name="android.permission.health.READ_WEIGHT"/>
<uses-permission android:name="android.permission.health.WRITE_WEIGHT"/>
<uses-permission android:name="android.permission.health.READ_HEIGHT"/>
<uses-permission android:name="android.permission.health.WRITE_HEIGHT"/>
<uses-permission android:name="android.permission.health.READ_HEART_RATE"/>
<uses-permission android:name="android.permission.health.WRITE_HEART_RATE"/>
<uses-permission android:name="android.permission.health.READ_EXERCISE"/>
<uses-permission android:name="android.permission.health.WRITE_EXERCISE"/>
<uses-permission android:name="android.permission.health.READ_SLEEP"/>
<uses-permission android:name="android.permission.health.WRITE_SLEEP"/>
<uses-permission android:name="android.permission.health.READ_SPEED"/>
<uses-permission android:name="android.permission.health.WRITE_SPEED"/>
<uses-permission android:name="android.permission.health.READ_DISTANCE"/>
<uses-permission android:name="android.permission.health.WRITE_DISTANCE"/>
<uses-permission android:name="android.permission.health.READ_TOTAL_CALORIES_BURNED"/>
<uses-permission android:name="android.permission.health.WRITE_TOTAL_CALORIES_BURNED"/>
<uses-permission android:name="android.permission.health.READ_ACTIVE_CALORIES_BURNED"/>
<uses-permission android:name="android.permission.health.WRITE_ACTIVE_CALORIES_BURNED"/>
<uses-permission android:name="android.permission.health.READ_BLOOD_GLUCOSE"/>
<uses-permission android:name="android.permission.health.WRITE_BLOOD_GLUCOSE"/>
<uses-permission android:name="android.permission.health.READ_BLOOD_PRESSURE"/>
<uses-permission android:name="android.permission.health.WRITE_BLOOD_PRESSURE"/>
<uses-permission android:name="android.permission.health.READ_BODY_FAT"/>
<uses-permission android:name="android.permission.health.WRITE_BODY_FAT"/>
<uses-permission android:name="android.permission.health.READ_BODY_TEMPERATURE"/>
<uses-permission android:name="android.permission.health.WRITE_BODY_TEMPERATURE"/>
<uses-permission android:name="android.permission.health.READ_OXYGEN_SATURATION"/>
<uses-permission android:name="android.permission.health.WRITE_OXYGEN_SATURATION"/>
<uses-permission android:name="android.permission.health.READ_HYDRATION"/>
<uses-permission android:name="android.permission.health.WRITE_HYDRATION"/>
<uses-permission android:name="android.permission.health.READ_RESTING_HEART_RATE"/>
<uses-permission android:name="android.permission.health.WRITE_RESTING_HEART_RATE"/>
<uses-permission android:name="android.permission.health.WRITE_FLOORS_CLIMBED"/>
<uses-permission android:name="android.permission.health.READ_FLOORS_CLIMBED"/>
<uses-permission android:name="android.permission.health.WRITE_BASAL_METABOLIC_RATE"/>
<uses-permission android:name="android.permission.health.READ_BASAL_METABOLIC_RATE"/>
<uses-permission android:name="android.permission.health.READ_RESPIRATORY_RATE"/>
<uses-permission android:name="android.permission.health.WRITE_RESPIRATORY_RATE"/>
<uses-permission android:name="android.permission.health.WRITE_NUTRITION"/>
<uses-permission android:name="android.permission.health.READ_NUTRITION"/>

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
Expand Down Expand Up @@ -189,6 +145,11 @@
<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
</intent-filter>

<!-- Intention to show Permissions screen for Health Connect API -->
<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
</intent-filter>
</activity>

<!-- service for using the Android activity recognition API
Expand Down
2 changes: 1 addition & 1 deletion ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#include? "../Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
#include? "Generated.xcconfig"
4 changes: 2 additions & 2 deletions ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#include "../Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
#include? "../Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include? "Generated.xcconfig"
32 changes: 16 additions & 16 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ PODS:
- Flutter
- polar (0.0.1):
- Flutter
- PolarBleSdk (~> 5.4.0)
- PolarBleSdk (5.4.0):
- PolarBleSdk (~> 5.5.0)
- PolarBleSdk (5.5.0):
- RxSwift (~> 6.5.0)
- SwiftProtobuf (~> 1.0)
- ReachabilitySwift (5.0.0)
Expand Down Expand Up @@ -211,17 +211,17 @@ SPEC CHECKSUMS:
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
audio_streamer: af49e73eb66f71c4eeabb4bbcb05f122d03a6709
audiofileplayer: 4aaff759a721ec3a850a682e0d9ec554e5f9e86f
battery_plus: 091633b7f01cb33dfc4aeedb450816f4d33818fa
camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb
connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
battery_plus: 3b68b6e7710fe49c022999753d22760e6dbbc471
camera_avfoundation: 759172d1a77ae7be0de08fc104cfb79738b8a59e
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
ESense: cbe103ad16c435424f2fd6f8b274f2468af84173
esense_flutter: 8bfadfdefe7b51d6f78366e43b2b64ec9b6144b6
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_activity_recognition: 5c3b026997742b01e82424ef257db9640822ad77
flutter_appauth: cf9b928962105b2a64a9802585d1c8adaf3e0f46
flutter_appauth: 0863b1f33110b410213e736aead4a6727303f509
flutter_blue_plus: 4837da7d00cf5d441fdd6635b3a57f936778ea96
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
flutter_sound: c60effa2a350fb977885f0db2fbc4c1ad5160900
flutter_sound_core: 26c10e5832e76aaacfae252d8925232281c486ae
flutter_timezone: ffb07bdad3c6276af8dada0f11978d8a1f8a20bb
Expand All @@ -233,20 +233,20 @@ SPEC CHECKSUMS:
network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f
open_settings: 9628e736cb2738fd1dc84159565755c214478158
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
pedometer: 381969883680ade42559782cc41a3bbd453d8234
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
polar: 3df98f4edaae7ff57d39fa6af2bd01b5b857e79d
PolarBleSdk: 980933f58cb2856c3627f40a54c91b9351a07736
polar: 8efdf64c1b4e0034e8fa3b1d12b64e5b27a877f1
PolarBleSdk: 2551160f3dcba0207723fc466a275e2d3aeda01f
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8
screen_state: a7ae251997e97f3f001839df09b57313b0ddef18
sensors_plus: 4ee32bc7d61a055f27f88d3215ad6b6fb96a2b8e
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
sensors_plus: 42b9de1b8237675fa8d8121e4bb93be0f79fa61d
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 50a33e1d72bd59ee092a519a35d107502757ebed
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
url_launcher_ios: 68d46cc9766d0c41dbdc884310529557e3cd7a86
video_player_avfoundation: 8563f13d8fc8b2c29dc2d09e60b660e4e8128837
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579

PODFILE CHECKSUM: cf73571b196c8b5799c2f2111e13846fa4ef168b

Expand Down
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objectVersion = 56;
objects = {

/* Begin PBXBuildFile section */
Expand Down
6 changes: 3 additions & 3 deletions ios/ci_scripts/ci_post_clone.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

# The default execution directory of this script is the ci_scripts directory.
cd $CI_WORKSPACE # change working directory to the root of your cloned repo.
# Change working directory to the root of your cloned repo.
cd $CI_PRIMARY_REPOSITORY_PATH

# Install Flutter using git.
git clone https://github.com/flutter/flutter.git --depth 1 -b stable $HOME/flutter
Expand All @@ -18,6 +18,6 @@ HOMEBREW_NO_AUTO_UPDATE=1 # disable homebrew's automatic updates.
brew install cocoapods

# Install CocoaPods dependencies.
cd ios && pod install # run `pod install` in the `ios` directory.
cd ios && pod install

exit 0
61 changes: 61 additions & 0 deletions lib/blocs/common.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
part of carp_study_app;

/// Enumeration of different types of deployments on the CARP Web Service (CAWS).
enum DeploymentMode {
/// Use the CARP production server to get the study deployment and store data.
production,

/// Use the CARP staging server to get the study deployment and store data.
staging,

/// Use the CARP testing server to get the study deployment and store data.
test,

/// Use the CARP development server to get the study deployment and store data.
dev,
}

/// Enumeration of of different user authentication states.
enum LoginStatus {
/// No invitation selected (tap outside the invitation box).
/// Navigate to login screen.
noSelection,

/// Informed Consent not accepted.
/// Navigate to message screen or login.
noConsent,

/// User registered but no current ongoing studies.
/// Navigate to message screen.
noInvitation,

/// User temporary blocked based on 3 wrongly login credentials.
/// Navigate to message screen.
temporaryBlock,

/// Successful login.
/// Navigate to home page.
successful,
}

enum ProcessStatus {
done,
error,
other,
}

/// Enumeration of different app states.
enum StudiesAppState {
initialized,
authenticating,
accessTokenRetrieved,
configuring,
loading,
loaded,
error,
}

extension StringExtension on String {
String truncateTo(int maxLength) =>
(length <= maxLength) ? this : '${substring(0, maxLength)}...';
}
21 changes: 14 additions & 7 deletions lib/blocs/sensing.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
part of carp_study_app;
/*
* Copyright 2021 Copenhagen Center for Health Technology (CACHET) at the
* Technical University of Denmark (DTU).
* Use of this source code is governed by a MIT-style license that can be
* found in the LICENSE file.
*/

part of '../main.dart';

/// This class implements the sensing layer.
///
Expand All @@ -10,7 +17,7 @@ part of carp_study_app;
/// Note that this class is a singleton and only one sensing layer is used.
/// Hence, the current assumption at the moment is that this Study App only
/// runs one study at a time, even though CAMS supports that several studies
/// can be added to the [client].
/// added to the [client].
class Sensing {
static final Sensing _instance = Sensing._();
StudyDeploymentStatus? _status;
Expand All @@ -30,7 +37,7 @@ class Sensing {
StudyDeploymentStatus? get status => _status;

/// The role name of this device in the deployed study.
String? get deviceRoleName => _study?.deviceRoleName;
String? get deviceRolename => _study?.deviceRoleName;

/// The study deployment id of the deployment running on this phone.
String? get studyDeploymentId => _study?.studyDeploymentId;
Expand All @@ -51,7 +58,7 @@ class Sensing {
List<DeviceManager>? get runningDevices =>
SmartPhoneClientManager().deviceController.connectedDevices;

/// The singleton sensing instance.
/// The singleton sensing instance
factory Sensing() => _instance;

Sensing._() {
Expand All @@ -61,9 +68,9 @@ class Sensing {
//SamplingPackageRegistry.register(CommunicationSamplingPackage());
SamplingPackageRegistry().register(MediaSamplingPackage());
SamplingPackageRegistry().register(SurveySamplingPackage());
//SamplingPackageRegistry.register(HealthSamplingPackage());
SamplingPackageRegistry().register(ESenseSamplingPackage());
SamplingPackageRegistry().register(PolarSamplingPackage());
SamplingPackageRegistry().register(HealthSamplingPackage());

// create and register external data managers
DataManagerRegistry().register(CarpDataManagerFactory());
Expand All @@ -74,7 +81,7 @@ class Sensing {

/// Initialize and set up sensing.
Future<void> initialize() async {
info('Initializing $runtimeType');
info('Initializing $runtimeType}');

// set up the devices available on this phone
DeviceController().registerAllAvailableDevices();
Expand Down Expand Up @@ -108,7 +115,7 @@ class Sensing {
// Define the study and add it to the client.
_study = await SmartPhoneClientManager().addStudy(
bloc.studyDeploymentId!,
bloc.deviceRoleName!,
bloc.deviceRolename!,
);

// Get the study controller and try to deploy the study.
Expand Down
94 changes: 94 additions & 0 deletions lib/ui/pages/cans_login.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
part of carp_study_app;

class LoginPage extends StatefulWidget {
const LoginPage({super.key});

@override
State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
final GlobalKey webViewKey = GlobalKey();

@override
Widget build(BuildContext context) {
RPLocalizations locale = RPLocalizations.of(context)!;
return Scaffold(
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
margin:
const EdgeInsets.symmetric(vertical: 32, horizontal: 56),
child: Image.asset(
'assets/carp_logo.png',
fit: BoxFit.contain,
),
),
),
Container(
margin:
const EdgeInsets.symmetric(vertical: 16, horizontal: 64),
width: MediaQuery.of(context).size.width,
height: 56,
decoration: BoxDecoration(
color: const Color(
0xff006398,
),
borderRadius: BorderRadius.circular(
100,
),
),
child: TextButton(
onPressed: () async {
await bloc.backend.authenticate();
if (bloc.backend.isAuthenticated) {
if (context.mounted) {
context.push('/invitations').then((value) {
setState(() {});
});
}
}
},
child: Text(
locale.translate("pages.login.login"),
style: const TextStyle(
color: Color(
0xffffffff,
),
fontSize: 22,
),
textAlign: TextAlign.center,
),
),
),
if (CarpService().authenticated)
TextButton(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return const LogoutMessage();
},
).then((value) async {
if (value == true) {
await bloc.backend.signOut();
setState(() {});
}
});
},
child: Text(
locale.translate('pages.login.endsession'),
),
)
],
),
),
),
);
}
}

0 comments on commit b2b4b96

Please sign in to comment.