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

Changes to notifcations.

parent f92c83e7
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import android.app.NotificationChannel;
import android.content.Intent;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
......@@ -39,9 +40,21 @@ public class SedentaryNotification extends Notification {
builder.setCategory(NotificationCompat.CATEGORY_ALARM);
builder.mNotification.flags |= android.app.Notification.FLAG_AUTO_CANCEL;
//SET VIBRATION PATTERN AND SOUND HERE
builder.setVibrate(new long[] {0, 500});
//builder.setSound();
builder.setColor(256);
if(preferences.getBoolean(getString(R.string.vibration), false)) {
builder.setVibrate(new long[]{0, 500});
} else {
}
if(preferences.getBoolean(getString(R.string.audio), false)){
builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_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.ledOffMS = 100;
}
return builder;
}
......@@ -49,9 +62,15 @@ public class SedentaryNotification extends Notification {
@TargetApi(26)
protected NotificationChannel setChannelParameters(NotificationChannel nc) {
nc.setDescription(this.getClass().getName());
nc.enableLights(preferences.getBoolean(getString(R.string.led), false));
nc.enableVibration(preferences.getBoolean(getString(R.string.vibration), false));
//Play empty sound for sound??
if(preferences.getBoolean(getString(R.string.vibration), false)) {
nc.enableVibration(preferences.getBoolean(getString(R.string.vibration), false));
}
if(preferences.getBoolean(getString(R.string.led), false)) {
nc.enableLights(preferences.getBoolean(getString(R.string.led), false));
}
if(preferences.getBoolean(getString(R.string.audio), false)) {
//Play empty sound for sound??
}
return nc;
}
}
......@@ -72,8 +72,9 @@ public class SedentaryStimulus extends BroadcastReceiver implements Stimulus {
context.getApplicationContext().startService(i);
}
//Stops previous service
//Crashes here when app is killed and strategy is therefore null.
Log.d("STRATEGY",strategy.toString());
if(strategy == null){
strategy = defaultStrategy;
}
Intent intent1 = new Intent(context, strategy.getClass());
context.stopService(intent1);
//Restarts the chosen strategy process.
......
......@@ -46,7 +46,7 @@ public class Accelerometer extends Service implements StimulusStrategy, SensorEv
//Sampling period is still far too often here.
//Parameters to be set here such as delay etc.
//Does data streaming/listening need to be set up? If so here
//Slightly better when app is not in foreground
am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
setUpClock();
return START_STICKY;
......@@ -86,7 +86,11 @@ public class Accelerometer extends Service implements StimulusStrategy, SensorEv
@Override
public void onSensorChanged(SensorEvent event) {
//Needs major tuning currently vibration triggers motion
//Need to work out the maths on this
//Google API Activity Detection client??
//Maybe work maths out and use this as 3rd option
//2 Manual options and an existing option
float[] gravity = new float[3];
float[] linearAcc = new float[3];
int moved = 0;
......
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