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

Bug fixes following testing

parent f73aa687
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ public class SedentaryNotification extends Notification {
if(preferences.getBoolean(getString(R.string.led), false)){
builder.mNotification.flags |= android.app.Notification.FLAG_SHOW_LIGHTS;
builder.mNotification.ledARGB = Color.RED;
builder.mNotification.ledOnMS = 100;
builder.mNotification.ledOnMS = 1000;
builder.mNotification.ledOffMS = 100;
}
......
......@@ -14,6 +14,10 @@ import android.widget.Toast;
import com.example.pharmacy.frontEnd.R;
import com.example.stimulusStrategy.StimulusStrategy;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Created by pharmacy on 09/01/2018.
......@@ -65,7 +69,9 @@ public class SedentaryStimulus extends BroadcastReceiver implements Stimulus {
Log.d("CALLBACK", "SERVICE STARTED");
//possibly check here for android notification settings
if(shared.getBoolean(context.getString(R.string.notf_switch), true)) {
Calendar cal = Calendar.getInstance();
if(shared.getBoolean(context.getString(R.string.notf_switch), true) &&
cal.getTime().before()) {
Log.d("CALLBACK", "NOTIFICATION");
Intent i = new Intent(context.getApplicationContext(), com.example.notification.SedentaryNotification.class);
......
......@@ -54,13 +54,27 @@ public class Accelerometer extends Service implements StimulusStrategy, SensorEv
//Parameters to be set here such as delay etc.
//Slightly better when app is not in foreground
am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
minutes = sharedPref.getInt(getString(R.string.daily_progress), 0);
prevMinutes = minutes;
setUpDailyProgress();
setUpClock();
return START_STICKY;
}
private void setUpDailyProgress(){
SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
if(currentDay == sharedPref.getInt(getString(R.string.progress_day), 0)) {
minutes = sharedPref.getInt(getString(R.string.daily_progress), 0);
} else {
minutes = 0;
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt(getString(R.string.progress_day), currentDay);
editor.putInt(getString(R.string.daily_progress), minutes);
editor.commit();
}
prevMinutes = minutes;
}
private void setUpClock() {
SharedPreferences shared = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
Intent i = new Intent(getBaseContext(), com.example.stimulus.SedentaryStimulus.class);
......
......@@ -14,6 +14,8 @@ import android.widget.Toast;
import com.example.pharmacy.frontEnd.R;
import java.util.Calendar;
/**
* Created by pharmacy on 13/02/2018.
*/
......@@ -32,11 +34,26 @@ public class StepCounter extends Service implements SensorEventListener {
stepCounter = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
mSensorManager.registerListener(this, stepCounter, 60000000);
SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
minutes = sharedPref.getInt(getString(R.string.daily_progress), 0);
setUpDailyProgress();
return START_STICKY;
}
private void setUpDailyProgress(){
SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
if(currentDay == sharedPref.getInt(getString(R.string.progress_day), 0)) {
minutes = sharedPref.getInt(getString(R.string.daily_progress), 0);
} else {
minutes = 0;
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt(getString(R.string.progress_day), currentDay);
editor.putInt(getString(R.string.daily_progress), minutes);
editor.commit();
}
}
@Override
public void onSensorChanged(SensorEvent event) {
if (prevStepCount == 0) {
......
......@@ -20,4 +20,5 @@
<string name="motion">Motion Detected</string>
<string name="minute_progress">One Minute of Progress Made</string>
<string name="serviceID">com.example.sedbeh.serv</string>
<string name="progress_day">Current Day</string>
</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