Skip to content
Snippets Groups Projects
Commit d15545f6 authored by Peter Joseph De Jonckheere CESM2014's avatar Peter Joseph De Jonckheere CESM2014
Browse files

Graph alterations

parent 9d26c1e7
No related branches found
No related tags found
No related merge requests found
...@@ -121,11 +121,13 @@ public class DataAnalysis { ...@@ -121,11 +121,13 @@ public class DataAnalysis {
int ackDays = sharedPref.getInt(context.getString(R.string.ack_days), 1); int ackDays = sharedPref.getInt(context.getString(R.string.ack_days), 1);
float avgAck = 0; float avgAck = 0;
int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_YEAR); int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
SharedPreferences.Editor editor = sharedPref.edit();; SharedPreferences.Editor editor = sharedPref.edit();
if (currentDay != sharedPref.getInt(context.getString(R.string.progress_day), 0)) { if (currentDay != sharedPref.getInt(context.getString(R.string.progress_day), 0)) {
avgAck = totalAck / ackDays; avgAck = totalAck / ackDays;
ackDays++; ackDays++;
editor.putInt(context.getString(R.string.progress_day), currentDay); editor.putInt(context.getString(R.string.progress_day), currentDay);
editor.putInt(context.getString(R.string.prev_ack_total),totalAck);
SaveFile.weeklyAcks(context);
} }
totalAck++; totalAck++;
editor.putInt(context.getString(R.string.ack_total), totalAck); editor.putInt(context.getString(R.string.ack_total), totalAck);
......
...@@ -574,6 +574,49 @@ public class SaveFile { ...@@ -574,6 +574,49 @@ public class SaveFile {
return popular; return popular;
} }
static void weeklyAcks(Context context) {
String line = "";
List<String> contents = new ArrayList<>();
SharedPreferences shared = context.getSharedPreferences(context.getString(R.string.preference_file_key), Context.MODE_PRIVATE);
int totalAck = shared.getInt(context.getString(R.string.ack_total), 0);
int prevAck = shared.getInt(context.getString(R.string.prev_ack_total), 0);
int ackDays = shared.getInt(context.getString(R.string.ack_days), 1);
if (isExternalStorageMounted()) {
File dir = getDirectory(context);
File file = new File(dir, "ACKLOG.txt");
//Creates a new file if one doesn't already exist
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
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));
while ((line = br.readLine()) != null) {
contents.add(line + '\n');
}
if (file.isFile() & file.canWrite()) {
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
if (contents.size() > 6) {
contents.remove(0);
}
for (String ts : contents) {
bw.write(ts);
}
bw.write(ackDays + " " + (totalAck - prevAck));
bw.close();
}
}
} catch (IOException e) {
}
}
}
/** /**
* Checks if external storage is available on the device. * Checks if external storage is available on the device.
* *
......
...@@ -57,4 +57,6 @@ ...@@ -57,4 +57,6 @@
<string name="store_mcp">Most Common Place</string> <string name="store_mcp">Most Common Place</string>
<string name="store_last_ack">Last Acknowledgement</string> <string name="store_last_ack">Last Acknowledgement</string>
<string name="place_ack_total">Last Place Acknowledgement Total</string> <string name="place_ack_total">Last Place Acknowledgement Total</string>
<string name="current_week">Current Week</string>
<string name="prev_ack_total">Previous Acknowledgement Count</string>
</resources> </resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment