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

Commit to attempt first run.

parent 25a1114d
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,10 @@ import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.example.stimulus.Stimulus;
import com.example.stimulus.SedentaryStimulus;
import com.example.stimulusStrategy.SigMotionDetect;
public class MainActivity extends AppCompatActivity {
@Override
......@@ -14,6 +18,7 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpButtons();
setUpStimulus();
}
private void setUpButtons(){
......@@ -26,4 +31,11 @@ public class MainActivity extends AppCompatActivity {
}
});
}
private void setUpStimulus(){
Stimulus stimulus = new SedentaryStimulus(this, new SigMotionDetect());
}
}
......@@ -30,20 +30,9 @@ public class Settings extends AppCompatActivity{
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Saved in shared preferences, add interger resource for default values to be used when obtaining from shared preferences.
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();//???
String message = (findViewById(R.id.notificationMessage)).toString();
SharedPreferences sharedPref = view.getContext().getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean(getString(R.string.audio), audio);
editor.putBoolean(getString(R.string.vibration), vibration);
editor.putBoolean(getString(R.string.led), led);
editor.putInt(getString(R.string.daily_goal), notifyGap);
editor.putString(getString(R.string.daily_goal_text), message);
editor.commit();
//Saved in shared preferences, add interger resource for default values to be used when obtaining from shared preferences.
saveSharedPreferenceData(view);
Intent intent = new Intent(view.getContext(), MainActivity.class);
displaySavedToast(view);
startActivity(intent);
......@@ -57,4 +46,20 @@ public class Settings extends AppCompatActivity{
saved.setDuration(Toast.LENGTH_SHORT);
saved.show();
}
private void saveSharedPreferenceData(View view){
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();//???
String message = (findViewById(R.id.notificationMessage)).toString();
SharedPreferences sharedPref = view.getContext().getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean(getString(R.string.audio), audio);
editor.putBoolean(getString(R.string.vibration), vibration);
editor.putBoolean(getString(R.string.led), led);
editor.putInt(getString(R.string.daily_goal), notifyGap);
editor.putString(getString(R.string.daily_goal_text), message);
editor.commit();
}
}
......@@ -11,7 +11,7 @@ import com.example.stimulusStrategy.StimulusStrategy;
* Created by pharmacy on 09/01/2018.
*/
class SedentaryStimulus extends BroadcastReceiver implements Stimulus {
public class SedentaryStimulus extends BroadcastReceiver implements Stimulus {
private StimulusStrategy strategy;
private Context context;
......@@ -27,12 +27,11 @@ class SedentaryStimulus extends BroadcastReceiver implements Stimulus {
}
public void chooseStrategy(StimulusStrategy s) {
private void chooseStrategy(StimulusStrategy s) {
if(s != null){
strategy = s;
} else{
strategy = defaultStrategy;
//can no longer have default strategy in interface as strategies require context
}
strategy.monitor();
Intent intent = new Intent(this.context, strategy.getClass());
......
......@@ -12,6 +12,5 @@ public interface Stimulus {
StimulusStrategy defaultStrategy = new Clock();
//Allows the Stimulus Strategy to be used with this stimlus to be chosen
void chooseStrategy(StimulusStrategy s);
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="daily_goal_minutes">75</integer>
<integer name="notify_period_minutes">60</integer>
</resources>
\ No newline at end of file
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