Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SedentaryBehaviourApplication
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Joseph De Jonckheere CESM2014
SedentaryBehaviourApplication
Commits
8ee2dacc
Commit
8ee2dacc
authored
6 years ago
by
Peter Joseph De Jonckheere CESM2014
Browse files
Options
Downloads
Patches
Plain Diff
Some more.
parent
b2121f6c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java
+33
-2
33 additions, 2 deletions
...om/notificationFramework/sedentary/frontEnd/SaveFile.java
with
33 additions
and
2 deletions
src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java
+
33
−
2
View file @
8ee2dacc
...
...
@@ -21,17 +21,38 @@ import java.util.zip.ZipOutputStream;
/**
* Created by Peter De Jonckheere on 12/02/2018.
*
* Contains the static methods which record various information about the notifications in the log
* files stored in the external storage of the device.
*/
public
class
SaveFile
{
/**
* Saves a general timestamp which logs that a notification was either sent, clicked or
* acknowledged. The timestamp is saved in standard Android calendar format with 2 bits after.
* "00" - acknowledged
* "01" - clicked
* "10" - sent
* "11" - goal notification
*
* @param sent 1 if a notification has been sent, 1 if a goal notification has been sent,
* 0 otherwise
* @param clicked 1 if a notification has been clicked on, 1 if a goal notification has been
* sent, 0 otherwise
* @param acknowledged 1 if a movement has been registered, 0 otherwise
* @param context the application context which the method has been called from and which will
* be used to access and write to the external storage of the device
*/
private
static
void
recordTimeStamp
(
int
sent
,
int
clicked
,
int
acknowledged
,
Context
context
)
{
Calendar
cal
=
Calendar
.
getInstance
();
ArrayList
<
String
>
contents
=
new
ArrayList
<
String
>();
String
line
=
""
;
String
line
;
//Checks for external storage
if
(
isExternalStorageMounted
())
{
File
dir
=
getDirectory
(
context
);
File
file
=
new
File
(
dir
,
"TIMESTAMPLOG.txt"
);
//Creates a new file if one doesn't already exist
if
(!
file
.
exists
())
{
try
{
file
.
createNewFile
();
...
...
@@ -39,6 +60,7 @@ public class SaveFile {
Log
.
e
(
"FILE_ERROR"
,
"COULDN'T CREATE NEW FILE"
);
}
}
//Reads the current contents of the log file
try
{
if
(
file
.
isFile
()
&&
file
.
canRead
())
{
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
file
));
...
...
@@ -46,6 +68,7 @@ public class SaveFile {
contents
.
add
(
line
+
'\n'
);
}
}
//Adds the new log to the file up to 1000 items. At 1000 items the oldest is removed
if
(
file
.
isFile
()
&
file
.
canWrite
())
{
BufferedWriter
bw
=
new
BufferedWriter
(
new
FileWriter
(
file
));
if
(
contents
.
size
()
>
999
)
{
...
...
@@ -64,6 +87,14 @@ public class SaveFile {
}
}
/**
* Keeps track of the number of each type of record stored in a file. Three integers only are
* written to the file used in this method. The first is
* @param sent
* @param clicked
* @param acknowledged
* @param context
*/
public
static
void
recordNotification
(
int
sent
,
int
clicked
,
int
acknowledged
,
Context
context
)
{
int
ns
=
0
;
int
nc
=
0
;
...
...
@@ -83,7 +114,7 @@ public class SaveFile {
nc
=
Integer
.
parseInt
(
br
.
readLine
());
na
=
Integer
.
parseInt
(
br
.
readLine
());
}
catch
(
NumberFormatException
e
){
Log
.
e
(
"FILEERROR"
,
"COULD NOT READ FILE"
);
}
if
(
file
.
isFile
()
&
file
.
canWrite
())
{
BufferedWriter
bw
=
new
BufferedWriter
(
new
FileWriter
(
file
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment