From 51c9988b69d43febcf998090423856c465f44024 Mon Sep 17 00:00:00 2001
From: Peter De Jonckheere <peter.de-jonckheere.2014@uni.strath.ac.uk>
Date: Tue, 26 Jun 2018 14:19:32 +0100
Subject: [PATCH] Added more changes

---
 .../notification/FeedbackNotification.java    |  3 +-
 .../notification/Notification.java            |  3 +-
 .../notification/SedentaryNotification.java   | 11 ++-----
 .../sedentary/frontEnd/MainActivity.java      | 16 ++++++++++
 .../stimulusStrategy/Accelerometer.java       |  6 ++++
 .../stimulusStrategy/ProximitySensor.java     | 31 +++++++++++++++++++
 .../stimulusStrategy/SigMotionDetect.java     |  8 ++---
 src/main/res/layout/activity_main.xml         |  6 ++--
 8 files changed, 67 insertions(+), 17 deletions(-)
 create mode 100644 src/main/java/com/notificationFramework/stimulusStrategy/ProximitySensor.java

diff --git a/src/main/java/com/notificationFramework/notification/FeedbackNotification.java b/src/main/java/com/notificationFramework/notification/FeedbackNotification.java
index 693bce2..e26fa6b 100644
--- a/src/main/java/com/notificationFramework/notification/FeedbackNotification.java
+++ b/src/main/java/com/notificationFramework/notification/FeedbackNotification.java
@@ -19,7 +19,7 @@ import com.notificationFramework.sedentary.frontEnd.R;
 public class FeedbackNotification extends SedentaryNotification {
 
 
-    protected int snId = this.getResources().getInteger(R.integer.notffeedback_id);
+
     /**
      * Called when the service is started. Uses the Notification implementation of this method.
      * @param intent  the intent used to start the service
@@ -29,6 +29,7 @@ public class FeedbackNotification extends SedentaryNotification {
      */
     @Override
     public int onStartCommand(Intent intent, int flags, int startId){
+        snId = this.getResources().getInteger(R.integer.notffeedback_id);
         return super.onStartCommand(intent, flags, startId);
     }
 
diff --git a/src/main/java/com/notificationFramework/notification/Notification.java b/src/main/java/com/notificationFramework/notification/Notification.java
index 982c28b..c3d5431 100644
--- a/src/main/java/com/notificationFramework/notification/Notification.java
+++ b/src/main/java/com/notificationFramework/notification/Notification.java
@@ -38,7 +38,7 @@ public abstract class Notification extends Service {
     /**
      * Arbitrary integer for the id of the notification
      */
-    protected int snId = this.getResources().getInteger(R.integer.notf_id);
+    protected int snId;
     /**
      * Instance of SharedPreferences which allows access to information saved in
      * sedentary.FrontEnd.Settings needed to determine the properties of the notification to
@@ -59,6 +59,7 @@ public abstract class Notification extends Service {
      */
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
+        snId = this.getResources().getInteger(R.integer.notf_id);
         nm = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
         preferences = this.getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
         buildNotification();
diff --git a/src/main/java/com/notificationFramework/notification/SedentaryNotification.java b/src/main/java/com/notificationFramework/notification/SedentaryNotification.java
index 10aae50..1ba7d26 100644
--- a/src/main/java/com/notificationFramework/notification/SedentaryNotification.java
+++ b/src/main/java/com/notificationFramework/notification/SedentaryNotification.java
@@ -84,15 +84,10 @@ public class SedentaryNotification extends Notification {
             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.parseColor
-                    (preferences.getString(getString(R.string.led_colour), "RED"));
-            builder.mNotification.ledOnMS =
-                    (preferences.getInt(getString(R.string.led_period), 1)) * 1000;
-            builder.mNotification.ledOffMS =
-                    (preferences.getInt(getString(R.string.led_period), 1)) * 1000;
+            builder.setLights(Color.parseColor(preferences.getString(getString(R.string.led_colour), "RED")),
+                    (preferences.getInt(getString(R.string.led_period), 1)) * 1000,
+                    (preferences.getInt(getString(R.string.led_period), 1)) * 1000);
         }
-
         return builder;
     }
 
diff --git a/src/main/java/com/notificationFramework/sedentary/frontEnd/MainActivity.java b/src/main/java/com/notificationFramework/sedentary/frontEnd/MainActivity.java
index e3d5f57..7e81de4 100644
--- a/src/main/java/com/notificationFramework/sedentary/frontEnd/MainActivity.java
+++ b/src/main/java/com/notificationFramework/sedentary/frontEnd/MainActivity.java
@@ -13,6 +13,9 @@ import android.view.View;
 import android.widget.Button;
 import android.widget.ProgressBar;
 
+import com.jjoe64.graphview.GraphView;
+import com.jjoe64.graphview.series.DataPoint;
+import com.jjoe64.graphview.series.LineGraphSeries;
 import com.notificationFramework.stimulus.SedentaryStimulus;
 import com.notificationFramework.stimulus.Stimulus;
 import com.notificationFramework.stimulusStrategy.Accelerometer;
@@ -74,8 +77,21 @@ public class MainActivity extends AppCompatActivity {
         ProgressBar progress = findViewById(R.id.progressBar);
         progress.setMax((shared.getInt(getString(R.string.daily_goal_set), R.integer.daily_goal_minutes)));
         progress.setProgress(shared.getInt(getString(R.string.daily_progress), 0));
+        setUpGraph();
     }
 
+
+    private void setUpGraph(){
+        GraphView graph = (GraphView) findViewById(R.id.graph);
+        LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[] {
+                new DataPoint(0, 1),
+                new DataPoint(1, 5),
+                new DataPoint(2, 3),
+                new DataPoint(3, 2),
+                new DataPoint(4, 6)
+        });
+        graph.addSeries(series);
+    }
     /**
      * Creates the stimulus object which initiates the background processes of the application. Uses
      * the strategy here to begin monitoring sedentary behaviour. This strategy is currently
diff --git a/src/main/java/com/notificationFramework/stimulusStrategy/Accelerometer.java b/src/main/java/com/notificationFramework/stimulusStrategy/Accelerometer.java
index a72ccc5..dc2bf74 100644
--- a/src/main/java/com/notificationFramework/stimulusStrategy/Accelerometer.java
+++ b/src/main/java/com/notificationFramework/stimulusStrategy/Accelerometer.java
@@ -165,6 +165,7 @@ public class Accelerometer extends Service implements StimulusStrategy, SensorEv
         PendingIntent pi = PendingIntent.getBroadcast(getBaseContext(),
                 R.integer.alarm_rc, i, PendingIntent.FLAG_UPDATE_CURRENT);
         am.cancel(pi);
+        collectData();
         SaveFile.recordNotification(0, 0, 1,0, this);
         setUpClock();
     }
@@ -233,6 +234,11 @@ public class Accelerometer extends Service implements StimulusStrategy, SensorEv
         }
     }
 
+
+    private void collectData(){
+
+    }
+
     /**
      * Unused as accuracy is not a major factor when using previous values. Required by
      * SensorEventListener
diff --git a/src/main/java/com/notificationFramework/stimulusStrategy/ProximitySensor.java b/src/main/java/com/notificationFramework/stimulusStrategy/ProximitySensor.java
new file mode 100644
index 0000000..e706034
--- /dev/null
+++ b/src/main/java/com/notificationFramework/stimulusStrategy/ProximitySensor.java
@@ -0,0 +1,31 @@
+package com.notificationFramework.stimulusStrategy;
+
+import android.app.Service;
+import android.content.Intent;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.os.IBinder;
+import android.support.annotation.Nullable;
+
+/**
+ * Created by pharmacy on 26/06/2018.
+ */
+
+public class ProximitySensor extends Service implements SensorEventListener {
+    @Nullable
+    @Override
+    public IBinder onBind(Intent intent) {
+        return null;
+    }
+
+    @Override
+    public void onSensorChanged(SensorEvent sensorEvent) {
+
+    }
+
+    @Override
+    public void onAccuracyChanged(Sensor sensor, int i) {
+
+    }
+}
diff --git a/src/main/java/com/notificationFramework/stimulusStrategy/SigMotionDetect.java b/src/main/java/com/notificationFramework/stimulusStrategy/SigMotionDetect.java
index 95865b2..598246a 100644
--- a/src/main/java/com/notificationFramework/stimulusStrategy/SigMotionDetect.java
+++ b/src/main/java/com/notificationFramework/stimulusStrategy/SigMotionDetect.java
@@ -126,11 +126,11 @@ public class SigMotionDetect extends Service implements StimulusStrategy {
                 R.integer.alarm_rc, i, 0);
         SharedPreferences shared = this.getSharedPreferences(getString(
                 R.string.preference_file_key), Context.MODE_PRIVATE);
-        int interval = shared.getInt(getString(R.string.daily_goal), getResources().getInteger(R.integer.notify_period_minutes));
-        am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
-                SystemClock.elapsedRealtime() + (1000 * 60 * interval), pi);
+       //int interval = shared.getInt(getString(R.string.daily_goal), getResources().getInteger(R.integer.notify_period_minutes));
+        //am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+        //        SystemClock.elapsedRealtime() + (1000 * 60 * interval), pi);
         //test
-        // am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 3000, pi);
+         am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 3000, pi);
     }
 
     /**
diff --git a/src/main/res/layout/activity_main.xml b/src/main/res/layout/activity_main.xml
index b82a8ff..661d006 100644
--- a/src/main/res/layout/activity_main.xml
+++ b/src/main/res/layout/activity_main.xml
@@ -50,8 +50,8 @@
         app:layout_constraintStart_toStartOf="@+id/textView3"
         app:layout_constraintTop_toBottomOf="@+id/progressBar" />
 
-    <ImageView
-        android:id="@+id/imageView"
+    <com.jjoe64.graphview.GraphView
+        android:id="@+id/graph"
         android:layout_width="278dp"
         android:layout_height="148dp"
         android:layout_marginEnd="8dp"
@@ -69,7 +69,7 @@
         android:layout_marginTop="32dp"
         android:text="@string/progress_view"
         app:layout_constraintStart_toStartOf="@+id/progressBar"
-        app:layout_constraintTop_toBottomOf="@+id/imageView" />
+        app:layout_constraintTop_toBottomOf="@+id/graph" />
 
     <TextView
         android:id="@+id/textView3"
-- 
GitLab