diff --git a/Paco-Server/ear/default/web/js/services.js b/Paco-Server/ear/default/web/js/services.js
index a0aae3bf4..38440bc6d 100755
--- a/Paco-Server/ear/default/web/js/services.js
+++ b/Paco-Server/ear/default/web/js/services.js
@@ -451,6 +451,7 @@ pacoApp.service('config', function() {
this.responseTypes = {
'likert': 'Scale',
+ 'va_scale': 'Visual Analogue Scale',
'likert_smileys': '5 Point Smiley Scale',
'number': 'Number',
'open text': 'Open Text',
diff --git a/Paco/res/drawable/seekbar_background_fill.xml b/Paco/res/drawable/seekbar_background_fill.xml
new file mode 100644
index 000000000..500fe551d
--- /dev/null
+++ b/Paco/res/drawable/seekbar_background_fill.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Paco/res/drawable/seekbar_progress.xml b/Paco/res/drawable/seekbar_progress.xml
new file mode 100644
index 000000000..5334e60fe
--- /dev/null
+++ b/Paco/res/drawable/seekbar_progress.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ -
+
+
+
\ No newline at end of file
diff --git a/Paco/res/drawable/seekbar_progress_fill.xml b/Paco/res/drawable/seekbar_progress_fill.xml
new file mode 100644
index 000000000..06504f0fb
--- /dev/null
+++ b/Paco/res/drawable/seekbar_progress_fill.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Paco/res/layout/va_scale.xml b/Paco/res/layout/va_scale.xml
new file mode 100644
index 000000000..3b0d58c84
--- /dev/null
+++ b/Paco/res/layout/va_scale.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Paco/src/com/google/android/apps/paco/Input.java b/Paco/src/com/google/android/apps/paco/Input.java
index 5df81e795..f8146c229 100644
--- a/Paco/src/com/google/android/apps/paco/Input.java
+++ b/Paco/src/com/google/android/apps/paco/Input.java
@@ -34,6 +34,7 @@ public class Input {
public static final String PHOTO = "photo";
public static final String SOUND = "sound";
public static final String ACTIVITY = "activity";
+ public static final String VA_SCALE = "va_scale";
@JsonIgnore
diff --git a/Paco/src/com/pacoapp/paco/ui/InputLayout.java b/Paco/src/com/pacoapp/paco/ui/InputLayout.java
index 1f0897f74..b1873d8c0 100644
--- a/Paco/src/com/pacoapp/paco/ui/InputLayout.java
+++ b/Paco/src/com/pacoapp/paco/ui/InputLayout.java
@@ -75,6 +75,7 @@
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Spinner;
import android.widget.TextView;
+import android.widget.SeekBar;
import android.widget.Toast;
public class InputLayout extends LinearLayout implements SpeechRecognitionListener {
@@ -108,6 +109,7 @@ public class InputLayout extends LinearLayout implements SpeechRecognitionListen
private MediaPlayer audioPlayer = null;
boolean mStartRecording = true;
boolean mStartPlaying = true;
+ private boolean va_scale_hasChanged = false;
public InputLayout(ExperimentExecutor context, Input2 input2) {
@@ -221,6 +223,8 @@ public Object getValue() {
return getPhotoValue();
} else if (input.getResponseType().equals(Input2.AUDIO)) {
return getAudioValue();
+ } else if (input.getResponseType().equals(Input2.VA_SCALE)) {
+ return getVaScaleValue();
}
return null;
}
@@ -245,6 +249,8 @@ public String getValueAsString() {
return getPhotoValue();
} else if (input.getResponseType().equals(Input2.AUDIO)) {
return getAudioValue();
+ } else if (input.getResponseType().equals(Input2.VA_SCALE)) {
+ return intToString(getVaScaleValue());
}
return null;
}
@@ -286,6 +292,8 @@ public Class getResponseType() {
} else if (input.getResponseType().equals(Input2.SOUND)) {
return SoundPool.class; // TODO (bobevans): is this really a good idea as
// the storage type? probably not.
+ } else if (input.getResponseType().equals(Input2.VA_SCALE)) {
+ return Integer.class;
}
return Object.class;
}
@@ -308,6 +316,16 @@ private String getAudioValue() {
return "";
}
+ private Integer getVaScaleValue() {
+ SeekBar seekBar =(SeekBar) componentWithValue;
+// if(seekBar.getThumb().mutate().getAlpha() == 0)
+
+ if(va_scale_hasChanged)
+ return ((SeekBar) componentWithValue).getProgress();
+ else
+ return null;
+ }
+
private String getPhotoValue() {
// Load data from this.file if it is non-null
@@ -495,6 +513,8 @@ private View getInputResponseTypeView(Input2 input2) {
return renderPhotoButton(input2);
} else if (questionType.equals(Input2.AUDIO)) {
return renderAudioRecorder(input2);
+ } else if (questionType.equals(Input2.VA_SCALE)) {
+ return renderVaScale();
}
return null;
}
@@ -907,6 +927,30 @@ private int getRadioGroupLayoutId(Integer steps) {
}
+ private View renderVaScale() {
+ View view = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
+ R.layout.va_scale, this, true);
+ SeekBar_api14 seekBar = (SeekBar_api14) findViewById(R.id.va_scale_input);
+ seekBar.getThumb().mutate().setAlpha(0);
+
+ seekBar.setOnSeekBarChangeListener(new SeekBar_api14.OnSeekBarChangeListener() {
+ @Override
+ public void onStartTrackingTouch(SeekBar_api14 s) {
+ va_scale_hasChanged = true;
+ s.getThumb().setAlpha(255);
+ notifyChangeListeners();
+ }
+ @Override
+ public void onStopTrackingTouch(SeekBar_api14 seekBar) {
+ }
+ @Override
+ public void onProgressChanged(SeekBar_api14 seekBar, int progress,boolean fromUser) {
+ }
+ });
+
+ return seekBar;
+ }
+
private View renderOpenText() {
View likertView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
R.layout.open_text, this, true);
diff --git a/Paco/src/com/pacoapp/paco/ui/SeekBar_api14.java b/Paco/src/com/pacoapp/paco/ui/SeekBar_api14.java
new file mode 100644
index 000000000..4387a0fdb
--- /dev/null
+++ b/Paco/src/com/pacoapp/paco/ui/SeekBar_api14.java
@@ -0,0 +1,74 @@
+package com.pacoapp.paco.ui;
+
+import android.widget.SeekBar;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.graphics.drawable.Drawable;
+
+/**
+ * SeekBar.getThumb() is not supported prior to SDK 16 - this class adds this functionality
+ *
+ * If Paco is pushed to SDK 16 (or newer) just remove this class and replace every SeekBar_api14 in
+ * the code with the native SeekBar (behavior, code and function-names can stay the same)
+ */
+
+
+
+public class SeekBar_api14 extends SeekBar{
+ Drawable myThumb;
+
+ public interface OnSeekBarChangeListener {
+ void onProgressChanged(SeekBar_api14 seekBar, int progress, boolean fromUser);
+ void onStartTrackingTouch(SeekBar_api14 seekBar);
+ void onStopTrackingTouch(SeekBar_api14 seekBar);
+ }
+
+
+ public class OnSeekBarChangeListener_api14 implements SeekBar.OnSeekBarChangeListener {
+ SeekBar_api14 seekBar_api14;
+ SeekBar_api14.OnSeekBarChangeListener listener_fu;
+ OnSeekBarChangeListener_api14(SeekBar_api14 s, SeekBar_api14.OnSeekBarChangeListener l) {
+ seekBar_api14 = s;
+ listener_fu = l;
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
+ listener_fu.onProgressChanged(seekBar_api14, progress, fromUser);
+ }
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ listener_fu.onStartTrackingTouch(seekBar_api14);
+ }
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ listener_fu.onStopTrackingTouch(seekBar_api14);
+ }
+ }
+
+
+ public void setOnSeekBarChangeListener(SeekBar_api14.OnSeekBarChangeListener l) {
+ super.setOnSeekBarChangeListener(new OnSeekBarChangeListener_api14(this, l));
+ }
+
+ public SeekBar_api14(Context context) {
+ super(context);
+ }
+ public SeekBar_api14(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+ public SeekBar_api14(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+
+
+ @Override
+ public void setThumb(Drawable thumb) {
+ super.setThumb(thumb);
+ myThumb = thumb;
+ }
+ public Drawable getThumb() {
+ return myThumb;
+ }
+}
diff --git a/Shared/src/com/pacoapp/paco/shared/model2/Input2.java b/Shared/src/com/pacoapp/paco/shared/model2/Input2.java
old mode 100755
new mode 100644
index dbb93ae1d..197f98bde
--- a/Shared/src/com/pacoapp/paco/shared/model2/Input2.java
+++ b/Shared/src/com/pacoapp/paco/shared/model2/Input2.java
@@ -34,6 +34,7 @@ public class Input2 extends ModelBase implements Validatable, Serializable {
public static final String SOUND = "sound";
public static final String ACTIVITY = "activity";
public static final String AUDIO = "audio";
+ public static final String VA_SCALE = "va_scale";
public static String[] RESPONSE_TYPES = {LIKERT_SMILEYS, LIKERT, OPEN_TEXT, LIST, NUMBER,
LOCATION, PHOTO, SOUND, ACTIVITY, AUDIO};
diff --git a/Shared/src_non_j2objc/com/pacoapp/paco/shared/model/InputDAO.java b/Shared/src_non_j2objc/com/pacoapp/paco/shared/model/InputDAO.java
old mode 100755
new mode 100644
index a8d43e27b..4b8542d69
--- a/Shared/src_non_j2objc/com/pacoapp/paco/shared/model/InputDAO.java
+++ b/Shared/src_non_j2objc/com/pacoapp/paco/shared/model/InputDAO.java
@@ -45,9 +45,10 @@ public class InputDAO implements Serializable {
public static final String PHOTO = "photo";
public static final String SOUND = "sound";
public static final String ACTIVITY = "activity";
+ public static final String VA_SCALE = "va_scale";
public static String[] RESPONSE_TYPES = {LIKERT_SMILEYS, LIKERT, OPEN_TEXT, LIST, NUMBER,
- LOCATION, PHOTO, SOUND, ACTIVITY};
+ LOCATION, PHOTO, SOUND, ACTIVITY, VA_SCALE};
private Long id;
private String questionType;