Haven is for people who need a way to protect their personal spaces and possessions without compromising their own privacy, through an Android app and on-device sensors
Slider changes to fix #108 and betterize the slider behavior generally
fattire0312e873ecb5
diff --git a/src/main/java/org/havenapp/main/ui/AccelConfigureActivity.java b/src/main/java/org/havenapp/main/ui/AccelConfigureActivity.javaindex 2d2361b..f9bd4f3 100644--- a/src/main/java/org/havenapp/main/ui/AccelConfigureActivity.java+++ b/src/main/java/org/havenapp/main/ui/AccelConfigureActivity.java@@ -44,6 +44,8 @@ public class AccelConfigureActivity extends AppCompatActivity implements SensorEprivate SimpleWaveformExtended mWaveform;private LinkedList<Integer> mWaveAmpList;+ static final int MAX_SLIDER_VALUE = 100;+private double maxAmp = 0;/**@@ -90,9 +92,10 @@ public class AccelConfigureActivity extends AppCompatActivity implements SensorEmTextLevel = (TextView)findViewById(R.id.text_display_level);mNumberTrigger = (ActualNumberPicker)findViewById(R.id.number_trigger_level);mWaveform = (SimpleWaveformExtended)findViewById(R.id.simplewaveform);+ mWaveform.setMaxVal(MAX_SLIDER_VALUE);mNumberTrigger.setMinValue(0);- mNumberTrigger.setMaxValue(100);+ mNumberTrigger.setMaxValue(MAX_SLIDER_VALUE);mNumberTrigger.setListener(new OnValueChangeListener() {@Overridepublic void onValueChanged(int oldValue, int newValue) {diff --git a/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java b/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.javaindex 0a2fc8b..c6fefc4 100644--- a/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java+++ b/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java@@ -35,6 +35,7 @@ public class MicrophoneConfigureActivity extends AppCompatActivity implements Miprivate PreferenceManager mPrefManager;private SimpleWaveformExtended mWaveform;private LinkedList<Integer> mWaveAmpList;+ static final int MAX_SLIDER_VALUE = 120;private double maxAmp = 0;@@ -52,9 +53,10 @@ public class MicrophoneConfigureActivity extends AppCompatActivity implements MimTextLevel = (TextView)findViewById(R.id.text_display_level);mNumberTrigger = (ActualNumberPicker)findViewById(R.id.number_trigger_level);mWaveform = (SimpleWaveformExtended)findViewById(R.id.simplewaveform);+ mWaveform.setMaxVal(MAX_SLIDER_VALUE);mNumberTrigger.setMinValue(0);- mNumberTrigger.setMaxValue(120);+ mNumberTrigger.setMaxValue(MAX_SLIDER_VALUE);mNumberTrigger.setListener(new OnValueChangeListener() {@Overridepublic void onValueChanged(int oldValue, int newValue) {diff --git a/src/main/java/org/havenapp/main/ui/SimpleWaveformExtended.java b/src/main/java/org/havenapp/main/ui/SimpleWaveformExtended.javaindex f1d23d7..398faaf 100644--- a/src/main/java/org/havenapp/main/ui/SimpleWaveformExtended.java+++ b/src/main/java/org/havenapp/main/ui/SimpleWaveformExtended.java@@ -14,6 +14,8 @@ public class SimpleWaveformExtended extends SimpleWaveform {private int mThreshold = 0;+ int lineY;+ int maxVal = 100; // default max value of sliderpublic SimpleWaveformExtended(Context context) {super(context);@@ -23,6 +25,10 @@ public class SimpleWaveformExtended extends SimpleWaveform {super(context, attrs);}+ public void setMaxVal(int max_val) {+ this.maxVal = max_val;+ }+public void setThreshold (int threshold){mThreshold = threshold;@@ -31,9 +37,8 @@ public class SimpleWaveformExtended extends SimpleWaveform {@Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);-- float percDb = (((float)mThreshold)/120f)*100f;- int lineY = getHeight()/2-(int)percDb*4;+ int midY = getHeight()/2;+ lineY = midY - (int) (((float) mThreshold/ maxVal) * midY);canvas.drawLine(0,lineY,getWidth(),lineY,peakPencilFirst);}}diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xmlindex 096b896..2e21a9d 100644--- a/src/main/res/values/strings.xml+++ b/src/main/res/values/strings.xml@@ -109,7 +109,7 @@<string name="current_noise_base">Current noise level is</string><string name="current_accel_base">Current motion level is</string>- <string name="configure_trigger_level">Slide wheel to change detection threshold</string>+ <string name="configure_trigger_level">Slide to set detection threshold</string><string name="tune_the_sound_detection">Make some noise!</string><string name="set_your_phone_on_the_table_and_make_noises_in_the_room_to_find_the_right_level_to_detect">Set your phone on the table, and make noises in the room to find the right level to detect</string>