Repository for the HealthTool which enables Apple users to analyse their health data from the Apple health app and prepares the data for contributing it for future studies on wearable data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

144 lines
5.6 KiB

package application.helpers;
import java.text.SimpleDateFormat;
import application.res.Colors;
import application.res.Text;
import javafx.scene.layout.Border;
import javafx.scene.layout.BorderStroke;
import javafx.scene.layout.BorderStrokeStyle;
import javafx.scene.layout.BorderWidths;
/**
* Gathers some of the data structures an methods more widely used.
*
* @author Bianca
*
*/
public class Utils
{
/**
* Attributes of an activity summary row (10 in total)
*/
public static final String[] ACTIV_SUMM_ATTR = new String[]
{ "dateComponents", "activeEnergyBurned", "activeEnergyBurnedGoal", "activeEnergyBurnedUnit", "appleExerciseTime",
"appleExerciseTimeGoal", "appleStandHours", "appleStandHoursGoal", "appleMoveMinutes",
"appleMoveMinutesGoal"
// appleMoveMinutes /-Goal couldn't be tested due to missing test data
};
/**
* Attributes of a workout row (12 attributes +WorkoutEvents) Important: nested attributes need to be at the end of the array!
*/
public static final String[] workoutAttributes = new String[]
{ "workoutActivityType", "duration", "durationUnit", "totalDistance", "totalDistanceUnit", "totalEnergyBurned",
"totalEnergyBurnedUnit", //"sourceName", left out because of privacy
"sourceVersion", "creationDate", "startDate", "endDate", "device",
Text.TAG_NAME_WORKOUT_EVENT //, Text.TAG_NAME_META_DATA_ENTRY, Text.TAG_NAME_WORKOUT_ROUTE left out because of privacy
};
/**
* Attributes of a record row (8 attributes + HRMetaList(+IBperMinute)
* +MetaData) Important: nested attributes need to be at the end of the array!
*/
public static final String[] recordAttributes = new String[]
{ "type", "unit", "value", // "sourceName", left out because of privacy
"sourceVersion", "device", "creationDate", "startDate", "endDate",// Text.TAG_NAME_META_DATA_ENTRY, left out due to privacy
Text.TAG_NAME_HR_LIST };
/**
* Attributes of a meta data entry (2 attributes in total)
*/
public static String[] META_DATA_ATTR = new String[]
{ "key", "value" };
/**
* Attributes of a workout event entry (4 attributes in total)
*/
public static String[] WORKOUT_EVENT_ATTR = new String[]
{ "type", "date", "duration", "durationUnit" };
/**
* Attributes of a workout route entry (6 attributes + MetaData)
* (Currently excluded due to privacy)
*/
public static String[] WORKOUT_ROUTE_ATTR = new String[]
{ "sourceName", "sourceVersion", "device", "creationDate", "startDate", "endDate", Text.TAG_NAME_META_DATA_ENTRY };
/**
* Attributes of a hr_list entry (only ib_per_minutes entries)
*/
public static String[] HR_LIST_ATTR = new String[]
{ Text.TAG_NAME_IB_PER_MINUTES };
/**
* Attributes of a ib per mintes entry (2 attributes in total)
*/
public static String[] IB_PER_MINUTES_ATTR = new String[]
{ "bpm", "time" };
/**
* This format is according to the format the date of birth is saved in the
* health data
*/
public static final SimpleDateFormat formatDateOfBirth = new SimpleDateFormat("yyyy-MM-dd");
/**
* Especially sub workouts / records start with something like 'HK...' and
* aren't very readable for the user. This method tries to remove the
* unnecessary parts to make it more readable. Based on https://developer.apple.com/documentation/healthkit/data_types
*
* @param input The string to shorten
* @return the shortened result
*/
public static String shortenHKStrings(String input)
{
// Subclasses
// class HKCharacteristicType
// A type that represents data that does not typically change over time.
String res = input.replace("HKCharacteristicType", "");
// class HKQuantityType
// A type that identifies samples that store numerical values.
res = res.replace("HKQuantityType", "");
// class HKCategoryType
// A type that identifies samples that contain a value from a small set of possible values.
res = res.replace("HKCategoryType", "");
// class HKCorrelationType
// A type that identifies samples that group multiple subsamples.
res = res.replace("HKCorrelationType", "");
// class HKActivitySummaryType
// A type that identifies activity summary objects.
res = res.replace("HKActivitySummaryType", "");
// class HKAudiogramSampleType
// A type that identifies samples that contain audiogram data.
res = res.replace("HKAudiogramSampleType", "");
// class HKElectrocardiogramType
// A type that identifies samples containing electrocardiogram data.
res = res.replace("HKElectrocardiogramType", "");
// class HKSeriesType
// A type that indicates the data stored in a series sample.
res = res.replace("HKSeriesType", "");
// class HKClinicalType
// A type that identifies samples that contain clinical record data.
res = res.replace("HKClinicalType", "");
// class HKWorkoutType
// A type that identifies samples that store information about a workout.
res = res.replace("HKWorkoutType", "");
res = res.replace("HKWorkoutActivityType", "");
res = res.replace("Identifier", "");
return res;
}
public static Border darkBlueBorder = new Border(new BorderStroke(Colors.darkBlue, Colors.darkBlue, Colors.darkBlue,
Colors.darkBlue, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID,
BorderStrokeStyle.SOLID, null, new BorderWidths(2), null));
public static Border redBorder = new Border(new BorderStroke(Colors.red, Colors.red, Colors.red, Colors.red,
BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, null,
new BorderWidths(2), null));
public static Border darkGreyBorderBR = new Border(new BorderStroke(null, Colors.darkGrey, Colors.darkGrey, null,
BorderStrokeStyle.NONE, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.NONE, null,
new BorderWidths(1), null));
}