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

Pre-meeting commit. Changes mainly to java files associated with activties - buttons, clicks etc.

parent 3a54cdbd
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 69 deletions
......@@ -16,6 +16,16 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Settings">
</activity>
<activity android:name=".NotificationClicked">
</activity>
<service android:name="com.example.notification.SedentaryNotification">
</service>
<service android:name="com.example.stimulusStrategy.SigMotionDetect">
</service>
<service android:name="com.example.stimulusStrategy.Clock">
</service>
</application>
</manifest>
\ No newline at end of file
......@@ -11,7 +11,6 @@ import android.content.Intent;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import com.example.pharmacy.frontEnd.MainActivity;
import com.example.pharmacy.frontEnd.NotificationClicked;
/**
......@@ -33,10 +32,10 @@ public abstract class Notification extends Service{
NotificationCompat.Builder mBuilder;
if(Build.VERSION.SDK_INT >= 26){
NotificationChannel nc = createNotificationChannel();
mBuilder = new NotificationCompat.Builder(this, "sednc");
mBuilder = new NotificationCompat.Builder(this, nc.getId());
} else {
mBuilder = new NotificationCompat.Builder(this, "sednc");
setParameters(mBuilder);
mBuilder = setParameters(mBuilder);
}
......@@ -66,7 +65,7 @@ public abstract class Notification extends Service{
@TargetApi(26)
private NotificationChannel createNotificationChannel(){
NotificationChannel nc = new NotificationChannel("sednc", "sedentaryNotification", NotificationManager.IMPORTANCE_DEFAULT);
setChannelParameters(nc);
nc = setChannelParameters(nc);
return nc;
}
......
......@@ -2,22 +2,13 @@ package com.example.notification;
import android.annotation.TargetApi;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import com.example.pharmacy.frontEnd.MainActivity;
import com.example.pharmacy.frontEnd.R;
/**
* Created by pharmacy on 09/01/2018.
......
package com.example.pharmacy.frontEnd;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
......@@ -12,6 +13,17 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpButtons();
}
private void setUpButtons(){
Button settings = (Button)findViewById(R.id.settings);
settings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), Settings.class);
startActivity(intent);
}
});
}
}
package com.example.pharmacy.frontEnd;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
......@@ -9,7 +8,6 @@ import android.util.Log;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
......@@ -60,19 +58,14 @@ public class NotificationClicked extends AppCompatActivity {
}
/* Checks if external storage is available */
public boolean isExternalStorageMounted() {
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
return true;
}
return false;
return (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()));
}
/* Checks if external storage is available to at least read */
public boolean isExternalStorageReadable() {
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(Environment.getExternalStorageState())) {
return true;
}
return false;
return (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(Environment.getExternalStorageState()));
}
public File getDirectory(){
......
package com.example.pharmacy.frontEnd;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.Toast;
/**
* Created by pharmacy on 21/11/2017.
*/
public class Settings {
public class Settings extends AppCompatActivity{
public Settings(){
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
setUpButtons();
}
private void setUpButtons(){
ImageButton back = (ImageButton)findViewById(R.id.back);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Get values and store them in a static? location
boolean audio = findViewById(R.id.Audio).isActivated();
boolean vibration = findViewById(R.id.Vibration).isActivated();
boolean led = findViewById(R.id.LEDFlash).isActivated();
int notifyGap = findViewById(R.id.spinner).getTop();//???
Intent intent = new Intent(view.getContext(), MainActivity.class);
displaySavedToast(view);
startActivity(intent);
}
});
}
private void displaySavedToast(View view){
Toast saved = new Toast(view.getContext());
saved.setText(R.string.settings_saved);
saved.setDuration(Toast.LENGTH_SHORT);
saved.show();
}
}
......@@ -4,11 +4,8 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.example.notification.Notification;
import com.example.notification.SedentaryNotification;
import com.example.stimulusStrategy.StimulusStrategy;
import java.util.Observable;
/**
* Created by pharmacy on 09/01/2018.
......@@ -50,9 +47,8 @@ class SedentaryStimulus extends BroadcastReceiver implements Stimulus {
//If a condition - such as time elapsed since last notification or not night time
//Intent data used here to configure notification?? Intent would need to be configured properly for this.
context.startService(intent);
//For clock-based detection/alarm setting needs to be restarted here.
//chooseStrategy(context.);
//Restarts the chosen strategy process.
chooseStrategy(strategy);
}
......
package com.example.stimulus;
import android.content.BroadcastReceiver;
import com.example.notification.Notification;
import com.example.stimulusStrategy.Accelerometer;
import com.example.stimulusStrategy.Clock;
import com.example.stimulusStrategy.StimulusStrategy;
import java.util.Observer;
/**
* Created by pharmacy on 09/01/2018.
......
package com.example.stimulusStrategy;
import android.app.Activity;
import android.app.Notification;
import android.app.Service;
import android.content.Context;
......@@ -12,10 +11,7 @@ import android.hardware.SensorManager;
import android.os.IBinder;
import android.support.annotation.Nullable;
import com.example.stimulus.Stimulus;
import java.util.Observable;
import java.util.Observer;
/**
* Created by pharmacy on 09/01/2018.
......
......@@ -9,10 +9,6 @@ import android.os.IBinder;
import android.support.annotation.Nullable;
import com.example.notification.Notification;
import com.example.stimulus.Stimulus;
import java.util.Observable;
import java.util.Observer;
/**
* Created by pharmacy on 09/01/2018.
......
......@@ -6,8 +6,6 @@ import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.hardware.TriggerEvent;
import android.hardware.TriggerEventListener;
......@@ -36,7 +34,9 @@ public class SigMotionDetect extends Service implements StimulusStrategy {
am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
setUpClock();
mSensorManager = (SensorManager) this.getSystemService(Context.SENSOR_SERVICE);
md = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
//Need to test if this produces null to avoid NULLPOINTEREXCEPTION
md = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
tel = new TriggerEventListener() {
@Override
public void onTrigger(TriggerEvent triggerEvent) {
......
package com.example.stimulusStrategy;
import android.app.Activity;
import com.example.stimulus.Stimulus;
import java.util.Observable;
import java.util.Observer;
/**
* Created by pharmacy on 09/01/2018.
......
......@@ -7,7 +7,7 @@
tools:context="com.example.pharmacy.frontEnd.MainActivity">
<Button
android:id="@+id/button"
android:id="@+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
......@@ -60,7 +60,7 @@
android:layout_marginTop="32dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button"
app:layout_constraintTop_toBottomOf="@+id/settings"
app:srcCompat="@mipmap/ic_launcher" />
<TextView
......
......@@ -7,7 +7,7 @@
android:layout_height="match_parent">
<ImageButton
android:id="@+id/imageButton"
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
......@@ -60,7 +60,7 @@
app:layout_constraintTop_toBottomOf="@+id/textView5" />
<Switch
android:id="@+id/switch1"
android:id="@+id/NotSwitch"
android:layout_width="63dp"
android:layout_height="38dp"
android:layout_marginStart="32dp"
......@@ -89,7 +89,7 @@
android:entries="@string/spinner_opt"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView7"
app:layout_constraintTop_toBottomOf="@+id/switch1" />
app:layout_constraintTop_toBottomOf="@+id/NotSwitch" />
<TextView
android:id="@+id/textView8"
......@@ -102,7 +102,7 @@
app:layout_constraintTop_toBottomOf="@+id/textView7" />
<RadioButton
android:id="@+id/radioButton"
android:id="@+id/Audio"
android:layout_width="162dp"
android:layout_height="38dp"
android:layout_marginEnd="8dp"
......@@ -115,7 +115,7 @@
app:layout_constraintTop_toBottomOf="@+id/spinner" />
<RadioButton
android:id="@+id/radioButton2"
android:id="@+id/Vibration"
android:layout_width="162dp"
android:layout_height="38dp"
android:layout_marginEnd="8dp"
......@@ -124,10 +124,10 @@
android:text="@string/vibration"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView8"
app:layout_constraintTop_toBottomOf="@+id/radioButton" />
app:layout_constraintTop_toBottomOf="@+id/Audio" />
<RadioButton
android:id="@+id/radioButton3"
android:id="@+id/LEDFlash"
android:layout_width="162dp"
android:layout_height="38dp"
android:layout_marginEnd="8dp"
......@@ -136,7 +136,7 @@
android:text="@string/led"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView8"
app:layout_constraintTop_toBottomOf="@+id/radioButton2" />
app:layout_constraintTop_toBottomOf="@+id/Vibration" />
<EditText
android:id="@+id/editText"
......@@ -152,7 +152,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/radioButton3" />
app:layout_constraintTop_toBottomOf="@+id/LEDFlash" />
<TextView
android:id="@+id/textView9"
......@@ -165,7 +165,7 @@
android:textAlignment="textStart"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageButton"
app:layout_constraintStart_toEndOf="@+id/back"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -14,4 +14,5 @@
<string name="led">LED Flash</string>
<string name="notf_text">Your personalised notification message here</string>
<string name="spinner_opt">Every 15 Minutes</string>
<string name="settings_saved">Settings saved!</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