diff --git a/src/main/java/com/notificationFramework/notification/FeedbackNotification.java b/src/main/java/com/notificationFramework/notification/FeedbackNotification.java index bf7c1872568aa76ff259cff5af23314bebd133d1..747ede18279dbad6cc90f959d538054f8d26cd9e 100644 --- a/src/main/java/com/notificationFramework/notification/FeedbackNotification.java +++ b/src/main/java/com/notificationFramework/notification/FeedbackNotification.java @@ -51,7 +51,6 @@ public class FeedbackNotification extends SedentaryNotification { builder.setVibrate(new long[]{0, 500, 0, 500}); } setCancellingAlarm(); - Log.d("Feedback", "Should be"); return builder; } diff --git a/src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java b/src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java index ef74e3898d146f50a8f4b8a70ed6aa0b573d1577..bf23906f804f83d1861042f13a13fc348bd34ae3 100644 --- a/src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java +++ b/src/main/java/com/notificationFramework/sedentary/frontEnd/SaveFile.java @@ -194,6 +194,9 @@ public class SaveFile { } recordTimeStamp(sent, clicked, movement, acknowledged, context); getExtraData(context); + if(sent == 1 || acknowledged == 1){ + DataAnalysis.placeAnalysis(context); + } } /** @@ -362,7 +365,6 @@ public class SaveFile { } } - DataAnalysis.placeAnalysis(context); } diff --git a/src/main/java/com/notificationFramework/stimulusStrategy/Accelerometer.java b/src/main/java/com/notificationFramework/stimulusStrategy/Accelerometer.java index 20408620d8904bc3eed6196026c53e3551fec86b..12d4ac78933418d8437a3bb965fb59dba3928452 100644 --- a/src/main/java/com/notificationFramework/stimulusStrategy/Accelerometer.java +++ b/src/main/java/com/notificationFramework/stimulusStrategy/Accelerometer.java @@ -269,7 +269,7 @@ public class Accelerometer extends Service implements StimulusStrategy, SensorEv history[i] = event.values[i]; } //If all 3 planes had movement - if (moved >= 3) { + if (moved >= 3) {/* //Update seconds and cancel the alarm if the time is greater than the last seconds //value if (((event.timestamp - historyTime) / 1000000000) > (seconds + 15)) { @@ -277,9 +277,10 @@ public class Accelerometer extends Service implements StimulusStrategy, SensorEv monitor(); } //Update minutes if the time is greater than a minute or seconds has reached 60 - if ((((event.timestamp - historyTime) / 1000000000) > 60) || (seconds > 60)) { + if ((((event.timestamp - historyTime) / 1000000000) > 60) || (seconds > 60)) {*/ + if(((event.timestamp - historyTime) / 1000000000) > 60){ historyTime = event.timestamp; - seconds = 0; + // seconds = 0; minutes++; } } @@ -289,6 +290,7 @@ public class Accelerometer extends Service implements StimulusStrategy, SensorEv editor.putInt(getString(R.string.daily_progress), minutes); editor.commit(); prevMinutes = minutes; + monitor(); } } diff --git a/src/main/java/com/notificationFramework/stimulusStrategy/SigMotionDetect.java b/src/main/java/com/notificationFramework/stimulusStrategy/SigMotionDetect.java index 2efb2bb972d8f50ee4127d601570d23a553b4e8a..219df50edceb343b15196ac0edd10ad667ec0cea 100644 --- a/src/main/java/com/notificationFramework/stimulusStrategy/SigMotionDetect.java +++ b/src/main/java/com/notificationFramework/stimulusStrategy/SigMotionDetect.java @@ -158,7 +158,7 @@ public class SigMotionDetect extends Service implements StimulusStrategy { stepCalc(); //If a small movement has occurred cancel the alarm, record a movement and set up a new //alarm - if (seconds > prevSeconds) { + /* if (seconds > prevSeconds) { Intent i = new Intent(this, com.notificationFramework.stimulus.SedentaryStimulus.class); PendingIntent pi = PendingIntent.getBroadcast(this, @@ -167,10 +167,17 @@ public class SigMotionDetect extends Service implements StimulusStrategy { SaveFile.recordNotification(0, 0, 1, 0, this); setUpClock(); prevSeconds = seconds; - } + }*/ //If a longer movement has occurred add a minute to the daily progress and sets new history //values if (minutes > prevMinutes) { + Intent i = new Intent(this, + com.notificationFramework.stimulus.SedentaryStimulus.class); + PendingIntent pi = PendingIntent.getBroadcast(this, + R.integer.alarm_rc, i, 0); + am.cancel(pi); + SaveFile.recordNotification(0, 0, 1, 0, this); + setUpClock(); storeData(); prevStepCount = StepCounter.stepCount; prevTimeStamp = StepCounter.timestamp; @@ -186,7 +193,7 @@ public class SigMotionDetect extends Service implements StimulusStrategy { * calculation. The average time of these two metrics is used to determine the length of * movement time. */ - private void stepCalc() { + /* private void stepCalc() { float stepDifference = 0; long timeDifference = 0; if (prevStepCount != 0) { @@ -208,6 +215,24 @@ public class SigMotionDetect extends Service implements StimulusStrategy { seconds = 0; prevSeconds = 0; } + }*/ + private void stepCalc() { + float stepDifference = 0; + long timeDifference = 0; + if(prevStepCount != 0) { + stepDifference = StepCounter.stepCount - prevStepCount; + } else { + prevStepCount = StepCounter.stepCount; + } + if(prevTimeStamp != 0) { + timeDifference = StepCounter.timestamp - prevTimeStamp; + } else{ + prevTimeStamp = StepCounter.timestamp; + } + float averageTime = ((timeDifference / 3600) + (stepDifference / 60)) / 2; + if(averageTime > 1) { + minutes = minutes + Math.round(averageTime); + } } /**