3 Methodology » History » Version 38
André Fernandes Gonçalves, 13/01/2024 18:30
1 | 2 | Ana Sofia Sousa | h1. 3 Methodology |
---|---|---|---|
2 | 3 | André Fernandes Gonçalves | |
3 | 6 | Ana Sofia Sousa | h2. 3.1. App Structure |
4 | 1 | Ana Sofia Sousa | |
5 | 8 | Ana Sofia Sousa | h3. 3.1.1. Use Cases Diagram |
6 | 6 | Ana Sofia Sousa | |
7 | 6 | Ana Sofia Sousa | In the Figure bellow is the developed Use Cases Diagram that represents the possible interactions of different actors (User, Vital Jacket, Data System and Doctor) within the system. This diagram shows the requirements for the development of the app. |
8 | 6 | Ana Sofia Sousa | |
9 | 33 | Ana Sofia Sousa | p=. !{width:600px}UseCasesDiagram.png! |
10 | 10 | Ana Sofia Sousa | Figure 3.1.1.1. Use Cases Diagram. |
11 | 6 | Ana Sofia Sousa | |
12 | 14 | André Fernandes Gonçalves | h3. 3.1.2. Activity Workflow Diagram |
13 | 1 | Ana Sofia Sousa | |
14 | 36 | Ana Sofia Sousa | The activity diagram shows the relationshop between the different pages and actions that these perform. |
15 | 1 | Ana Sofia Sousa | |
16 | 33 | Ana Sofia Sousa | p=. !{width:400px}ActivityDiagram.png! |
17 | 26 | Ana Sofia Sousa | Figure 3.1.1.2. Activity Diagram. |
18 | 25 | Ana Sofia Sousa | |
19 | 37 | André Fernandes Gonçalves | h2. 3.2 Algorithms |
20 | 37 | André Fernandes Gonçalves | |
21 | 18 | Ana Sofia Sousa | h3. 3.2.1. Step Counting |
22 | 9 | Ana Sofia Sousa | |
23 | 15 | André Fernandes Gonçalves | The steps are counted based on changes in the accelerometer data, specifically, the magnitude of acceleration. Here's how the step counting logic works: |
24 | 16 | André Fernandes Gonçalves | |
25 | 22 | Ana Sofia Sousa | The magnitude of the current accelerometer data (x, y and z axis) is calculated using the Euclidean norm: Magnitude = sqrt(x^2 + y^2 + z^2). Then, the difference between the current magnitude and the previous magnitude is calculated: MagnitudeDelta = Magnitude - MagnitudePrevious. |
26 | 21 | Ana Sofia Sousa | |
27 | 21 | Ana Sofia Sousa | If MagnitudeDelta is between 15 and 90, it is considered a potential step, and the stepCount is incremented. Also, if MagnitudeDelta is greater than 90, it is considered a potential step, and the stepCount is incremented. However, if MagnitudeDelta is not in the specified ranges, it indicates no movement, and the notMovingCounter is incremented. |
28 | 20 | Ana Sofia Sousa | |
29 | 20 | Ana Sofia Sousa | The notMovingCounter keeps track of consecutive accelerometer readings indicating no movement. If this counter exceeds a threshold (15 in this case), it sets the status to 0, indicating no movement. |
30 | 20 | Ana Sofia Sousa | In summary, steps are counted when there is a significant change in the accelerometer data's magnitude, and consecutive readings indicating no movement trigger a reset of the status. The stepCount variable holds the cumulative count of steps. |
31 | 1 | Ana Sofia Sousa | |
32 | 24 | Ana Sofia Sousa | h3. 3.2.2. Distance Calculation |
33 | 1 | Ana Sofia Sousa | |
34 | 24 | Ana Sofia Sousa | The distance walked was calculated using the following formula: |
35 | 24 | Ana Sofia Sousa | |
36 | 24 | Ana Sofia Sousa | distance = (0.415 * Height/100) * steps; for males |
37 | 24 | Ana Sofia Sousa | distance = (0.413 * Height/100) * steps; for females |
38 | 24 | Ana Sofia Sousa | |
39 | 24 | Ana Sofia Sousa | where, the Height is a parameter inserted by the user, and steps is the number of steps gathered by the App. |
40 | 24 | Ana Sofia Sousa | |
41 | 24 | Ana Sofia Sousa | h3. 3.2.3. Burnt Calories Calculation |
42 | 24 | Ana Sofia Sousa | |
43 | 24 | Ana Sofia Sousa | The burnt calories were calculated using the following formulas: |
44 | 24 | Ana Sofia Sousa | |
45 | 24 | Ana Sofia Sousa | Calories Burnt = (BMR/24) * MET * T |
46 | 24 | Ana Sofia Sousa | |
47 | 24 | Ana Sofia Sousa | Where: BMR=Basal Metabolic Rate, MET=Metabolic Equivalent (fixed value = 3,80) and T=Time duration of Activity (in hours). |
48 | 24 | Ana Sofia Sousa | |
49 | 24 | Ana Sofia Sousa | For males: BMR=(13.75 x WKG) + (5 x HCm) - (6.76 x age)+66 |
50 | 24 | Ana Sofia Sousa | |
51 | 24 | Ana Sofia Sousa | For females: BMR=(9.56 x WKG) + (1.85 x HC) - (4.68 x age)+655 |
52 | 24 | Ana Sofia Sousa | |
53 | 24 | Ana Sofia Sousa | Where, HCm=Height (in centimeters) and WKG=Weight (in kilograms). |
54 | 24 | Ana Sofia Sousa | |
55 | 24 | Ana Sofia Sousa | The time of activity, T, was calculated using the distance walked and the velocity (value assumed as 4000 m/h): |
56 | 24 | Ana Sofia Sousa | |
57 | 24 | Ana Sofia Sousa | T = distance / velocity; |
58 | 24 | Ana Sofia Sousa | |
59 | 24 | Ana Sofia Sousa | |
60 | 23 | Ana Sofia Sousa | h2. 3.3. App Design |
61 | 9 | Ana Sofia Sousa | |
62 | 28 | Ana Sofia Sousa | A dark theme with orange and red details was used throughout the app to capture the user's attention. |
63 | 9 | Ana Sofia Sousa | |
64 | 9 | Ana Sofia Sousa | |
65 | 23 | Ana Sofia Sousa | h3. Login and Sign Up Pages |
66 | 1 | Ana Sofia Sousa | |
67 | 23 | Ana Sofia Sousa | When the user opens the app, he encounters the Login Page. Here, the user can fill in his username and password to enter the app or, if they don't have an account yet, click on the sign up button to register. If the user types in credentials that do not exist, the message "User not found!" is shown. |
68 | 23 | Ana Sofia Sousa | When the user clicks on the button to sign up in the Login Page, he is sent to the Sign Up Page. Here, the user can create an account by choosing an username and a password. When the user clicks on the sign up button, he is sent to the Login Page. There is also the possibility of clicking on the login button to go back if the user is already registered. When a new user is added, an user ID is created that is used in the following activities. |
69 | 9 | Ana Sofia Sousa | |
70 | 30 | Ana Sofia Sousa | p=. !{width:200px}login.jpg! |
71 | 29 | Ana Sofia Sousa | Figure 3.3.1. Log In Page. |
72 | 1 | Ana Sofia Sousa | |
73 | 31 | Ana Sofia Sousa | p=. !{width:200px}signup.jpg! |
74 | 29 | Ana Sofia Sousa | Figure 3.3.2. Sign Up Page. |
75 | 1 | Ana Sofia Sousa | |
76 | 9 | Ana Sofia Sousa | |
77 | 29 | Ana Sofia Sousa | |
78 | 23 | Ana Sofia Sousa | h3. How to Use Page |
79 | 1 | Ana Sofia Sousa | |
80 | 1 | Ana Sofia Sousa | After logging in or signing up, the user enters the app, where first the How to Use Page, a scrollable page, is shown. Here, there is an explanation of the app usage, where the main features are described. First, the bluetooth connection to the Vital Jacket can be performed, where the user is aided with pop-ups. Once this connection is completed, by clicking the button to continue. If the user has already used the app, when clicking the button to continue, the Home Page will appear. |
81 | 1 | Ana Sofia Sousa | |
82 | 31 | Ana Sofia Sousa | p=. !{width:200px}intermediate.jpg! |
83 | 29 | Ana Sofia Sousa | Figure 3.3.3. How to Use Page. |
84 | 29 | Ana Sofia Sousa | |
85 | 34 | Ana Sofia Sousa | p=. !{width:200px}bluetoothText.jpg! |
86 | 29 | Ana Sofia Sousa | Figure 3.3.4. Bluetooth enabled pop-up. |
87 | 29 | Ana Sofia Sousa | |
88 | 34 | Ana Sofia Sousa | p=. !{width:200px}connectedText.jpg! |
89 | 29 | Ana Sofia Sousa | Figure 3.3.5. Bluetooth Conection to Vital Jacket pop-up. |
90 | 29 | Ana Sofia Sousa | |
91 | 23 | Ana Sofia Sousa | h3. Home Page |
92 | 9 | Ana Sofia Sousa | |
93 | 23 | Ana Sofia Sousa | In the Home Page, data obtained from the present day is shown. Here, the walked distance, burnt calories and a progress bar are displayed. The progress bar shows a percentage of the steps taken, being the previously set step goal the maximum value where the bar is full (100%): progress bar value = (taken steps x 100) / step goal. If the user takes more steps than the defined step goal, the progress bar remains at 100%. |
94 | 1 | Ana Sofia Sousa | In this page, a bottom navigation bar can be seen. This allows the user to travel to the other four pages, Statistics, Profile, Calendar and Settings by clicking on the desired icon. This bar is also present in those pages. |
95 | 1 | Ana Sofia Sousa | Also, when the user achieves the step goal, a celebrative animation appears on the screen of the app. |
96 | 1 | Ana Sofia Sousa | |
97 | 31 | Ana Sofia Sousa | p=. !{width:200px}home.jpg! |
98 | 29 | Ana Sofia Sousa | Figure 3.3.6. Home Page. |
99 | 1 | Ana Sofia Sousa | |
100 | 31 | Ana Sofia Sousa | p=. !{width:200px}confetti.jpg! |
101 | 29 | Ana Sofia Sousa | Figure 3.3.7. Home Page with Celebration Animation. |
102 | 9 | Ana Sofia Sousa | |
103 | 29 | Ana Sofia Sousa | |
104 | 9 | Ana Sofia Sousa | h3. Statistics Page |
105 | 23 | Ana Sofia Sousa | |
106 | 1 | Ana Sofia Sousa | The app's Statistics Page displays a dynamic graph illustrating the user's step count over the past week, offering a clear visual representation of their physical activity progression. |
107 | 1 | Ana Sofia Sousa | |
108 | 31 | Ana Sofia Sousa | p=. !{width:200px}Statistics.jpg! |
109 | 29 | Ana Sofia Sousa | Figure 3.3.8. Statistics Page. |
110 | 9 | Ana Sofia Sousa | |
111 | 1 | Ana Sofia Sousa | h3. Profile Page |
112 | 9 | Ana Sofia Sousa | |
113 | 1 | Ana Sofia Sousa | In the Profile Page, the user can choose the goals he wants to accomplish by choosing the desired steps, calories burnt, walked distance or spent time through the number pickers. By clicking on the save button, the user's data is stored in the database under the user ID. If the user leaves this page before saving the desired goals, these values will not be stored, and won't appear once the Profile Page is opened again. While this page is not filled in, the app assumes default values for the goals. |
114 | 1 | Ana Sofia Sousa | |
115 | 31 | Ana Sofia Sousa | p=. !{width:200px}profile.jpg! |
116 | 29 | Ana Sofia Sousa | Figure 3.3.9. Profile Page. |
117 | 23 | Ana Sofia Sousa | |
118 | 1 | Ana Sofia Sousa | h3. Calendar Page |
119 | 1 | Ana Sofia Sousa | |
120 | 1 | Ana Sofia Sousa | In the Calendar Page, a monthly calendar is shown. The progress bar, walked distance and burnt calories from the present day are presented. The user has the possibility of choosing a different month or day, where the same information is displayed. |
121 | 1 | Ana Sofia Sousa | |
122 | 31 | Ana Sofia Sousa | p=. !{width:200px}calendar.jpg! |
123 | 29 | Ana Sofia Sousa | Figure 3.3.10. Example 1 of Calendar Page. |
124 | 9 | Ana Sofia Sousa | |
125 | 31 | Ana Sofia Sousa | p=. !{width:200px}calendar1.jpg! |
126 | 29 | Ana Sofia Sousa | Figure 3.3.11. Example 2 of Calendar Page. |
127 | 1 | Ana Sofia Sousa | |
128 | 31 | Ana Sofia Sousa | p=. !{width:200px}calendar2.jpg! |
129 | 29 | Ana Sofia Sousa | Figure 3.3.12. Example 3 of Calendar Page. |
130 | 29 | Ana Sofia Sousa | |
131 | 29 | Ana Sofia Sousa | |
132 | 9 | Ana Sofia Sousa | h3. Settings Page |
133 | 9 | Ana Sofia Sousa | |
134 | 1 | Ana Sofia Sousa | The first time the user opens the app, after the How to Use Page, the user is sent to Settings Page, where he can fill in his information, so that the calculations performed later regarding the walked distance, for example, can be adequate to the user's characteristics. Here, the user can choose their weight, age and height through the displayed number pickers and the gender through the radio buttons. When the user clicks on the save button, this data is stored in the database under the user's ID. If the information required on this page is not filled in, the app assumes default values for the user's settings. Also, if the user decides to leave this page before saving the desired settings, these values will not be stored, and won't appear once the Settings Page is opened again. After this, the user can click on the bar in the bottom to travel to any activity they desire. |
135 | 1 | Ana Sofia Sousa | |
136 | 1 | Ana Sofia Sousa | |
137 | 31 | Ana Sofia Sousa | p=. !{width:200px}settings.jpg! |
138 | 29 | Ana Sofia Sousa | Figure 3.3.13. Settings Page. |
139 | 29 | Ana Sofia Sousa | |
140 | 1 | Ana Sofia Sousa | h3. Notifications |
141 | 1 | Ana Sofia Sousa | |
142 | 1 | Ana Sofia Sousa | When a user reaches the number of steps, distance walked or calories burned they define as their goal, a notification is sent to the mobile phone congratulating the user on the achievement. The NotificationCompat.Builder was used. |
143 | 29 | Ana Sofia Sousa | |
144 | 32 | Ana Sofia Sousa | p=. !{width:300px}Notification1.jpg! |
145 | 38 | André Fernandes Gonçalves | Figure 3.3.14. Steps Goal Reached Notification. |
146 | 29 | Ana Sofia Sousa | |
147 | 32 | Ana Sofia Sousa | p=. !{width:300px}Notification2.jpg! |
148 | 38 | André Fernandes Gonçalves | Figure 3.3.15. Distance Goal Reached Notification. |
149 | 32 | Ana Sofia Sousa | |
150 | 29 | Ana Sofia Sousa | p=. !{width:300px}Notification3.jpg! |
151 | 38 | André Fernandes Gonçalves | Figure 3.3.16. Calories Goal Reached Notification. |
152 | 9 | Ana Sofia Sousa | |
153 | 24 | Ana Sofia Sousa | h2. 3.4. Implementation |
154 | 1 | Ana Sofia Sousa | |
155 | 1 | Ana Sofia Sousa | |
156 | 9 | Ana Sofia Sousa | h3. BluetoothService |
157 | 9 | Ana Sofia Sousa | |
158 | 24 | Ana Sofia Sousa | BluetoothService handles the bluetooth connection to the Vital Jacket. The onCreate method initializes the Bluetooth using BioLib. The Connect method attempts to connect the Vital Jacket device specified by the MAC address. In this class, the accelerometer data is obtained and sent to the database. |
159 | 24 | Ana Sofia Sousa | |
160 | 1 | Ana Sofia Sousa | h3. MyContentProvider |
161 | 1 | Ana Sofia Sousa | |
162 | 35 | Ana Sofia Sousa | This activity allows the app to gather the acceleration data previously saved in the database and then sends it to the StepCounterService, to be used in the future calculations. |
163 | 35 | Ana Sofia Sousa | |
164 | 23 | Ana Sofia Sousa | h3. StepCounterService |
165 | 9 | Ana Sofia Sousa | |
166 | 24 | Ana Sofia Sousa | The StepCounterService is responsible for counting steps, calculating calories, distance, and time based on the accelerometer data. It also interacts with the database to store and retrieve relevant information. The service runs in the background and is designed to constantly handle changes in accelerometer data, updating step count and related metrics in the databases. Additionally, it includes a functionality for goal notifications and broadcasts updates to the UI. |
167 | 24 | Ana Sofia Sousa | |
168 | 23 | Ana Sofia Sousa | h3. MainActivity |
169 | 9 | Ana Sofia Sousa | |
170 | 23 | Ana Sofia Sousa | The MainActivity activity not only starts the StepCounterService but also allows the user to navigate between pages using the navigation bar on the bottom of every page. |
171 | 9 | Ana Sofia Sousa | |
172 | 9 | Ana Sofia Sousa | h3. DatabaseHelper |
173 | 9 | Ana Sofia Sousa | |
174 | 23 | Ana Sofia Sousa | To allow storing and retrieving the necessary data in the app, a database helper was used to manage and interact with a SQLite database by providing methods for tasks such as initializing the database, inserting data, updating records, and retrieving information. |
175 | 9 | Ana Sofia Sousa | |
176 | 23 | Ana Sofia Sousa | In the DatabaseHelper.java file, the database is initialized, three tables 'users', 'Data', and 'ACCDataTable' are created and some default data is inserted. |
177 | 23 | Ana Sofia Sousa | The users table consists of the information from the Login/Sign Up, Settings and Profile, more precisely: the user ID, username, password, gender, height, age, weight, step goal, burnt calories goal, time spent goal and walked distance goal. |
178 | 1 | Ana Sofia Sousa | The AccDataTable table stores the accelerometer data, more precisely the x, y and z values, and the respective timestamp. |
179 | 1 | Ana Sofia Sousa | The Data table stores the information of the taken steps, calories burnt, walked distance, time spent and the respective date. |
180 | 1 | Ana Sofia Sousa | |
181 | 1 | Ana Sofia Sousa | The database is upgraded when there is a change in the database version, dropping the existing tables and recreating them with the updated structure. Regarding the user related operations: The insertUser method inserts a new user into the users table, checking for the availability of the username. Regarding the operations of the data obtained from the vital jacket: The insert method inserts data into the Data table, including steps, calories, distance, time, and date. The getAll method retrieves data from the Data table, grouping it by date. Regarding the profile and settings updates: The updateSettings and updateProfile methods update user settings and profiles, respectively, in the users table based on the provided user ID. Accelerometer Data Operations: The addACCData method inserts accelerometer data into the ACCDataTable table. It also uses a ContentResolver to insert data into a content provider (MyContentProvider). User ID Retrieval: The getUserIdByUsername method retrieves the user ID based on the given username from the users table. |
182 | 24 | Ana Sofia Sousa | |
183 | 24 | Ana Sofia Sousa | h3. Confetti Animation |
184 | 24 | Ana Sofia Sousa | |
185 | 24 | Ana Sofia Sousa | To be able to perform the celebration animation, the Konfetti-Compose library, version 2.0.4 was used by adding the following dependency to the Android project: |
186 | 24 | Ana Sofia Sousa | |
187 | 24 | Ana Sofia Sousa | implementation("nl.dionsegijn:konfetti-xml:2.0.4") |
188 | 24 | Ana Sofia Sousa | |
189 | 24 | Ana Sofia Sousa | Using the library’s features, the celebration effect was altered to suit specific requirements, and design elements of the app. |
190 | 24 | Ana Sofia Sousa | |
191 | 24 | Ana Sofia Sousa | h3. Widgets used |
192 | 24 | Ana Sofia Sousa | |
193 | 24 | Ana Sofia Sousa | With the goal of creating a more interactive and user-friendly app, the ProgressBar and CalendarView android widgets were used. |