Skip to content

Commit

Permalink
Merge branch 'sliderchanges' of https://github.com/fat-tire/haven int…
Browse files Browse the repository at this point in the history
…o fat-tire-sliderchanges
  • Loading branch information
n8fr8 committed Dec 27, 2017
2 parents 2053600 + 0312e87 commit 0bb97af
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class AccelConfigureActivity extends AppCompatActivity implements SensorE
private SimpleWaveformExtended mWaveform;
private LinkedList<Integer> mWaveAmpList;

static final int MAX_SLIDER_VALUE = 100;

private double maxAmp = 0;

/**
Expand Down Expand Up @@ -90,9 +92,10 @@ protected void onCreate(Bundle savedInstanceState) {
mTextLevel = (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() {
@Override
public void onValueChanged(int oldValue, int newValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class MicrophoneConfigureActivity extends AppCompatActivity implements Mi
private PreferenceManager mPrefManager;
private SimpleWaveformExtended mWaveform;
private LinkedList<Integer> mWaveAmpList;
static final int MAX_SLIDER_VALUE = 120;

private double maxAmp = 0;

Expand All @@ -52,9 +53,10 @@ protected void onCreate(Bundle savedInstanceState) {
mTextLevel = (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() {
@Override
public void onValueChanged(int oldValue, int newValue) {
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/org/havenapp/main/ui/SimpleWaveformExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class SimpleWaveformExtended extends SimpleWaveform {


private int mThreshold = 0;
int lineY;
int maxVal = 100; // default max value of slider

public SimpleWaveformExtended(Context context) {
super(context);
Expand All @@ -23,6 +25,10 @@ public SimpleWaveformExtended(Context context, AttributeSet attrs) {
super(context, attrs);
}

public void setMaxVal(int max_val) {
this.maxVal = max_val;
}

public void setThreshold (int threshold)
{
mThreshold = threshold;
Expand All @@ -31,9 +37,8 @@ public void setThreshold (int threshold)
@Override
protected 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);
}
}
2 changes: 1 addition & 1 deletion src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down

0 comments on commit 0bb97af

Please sign in to comment.