Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Paco-Server/ear/default/web/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 19 additions & 0 deletions Paco/res/drawable/seekbar_background_fill.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ### -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#bbbbbb"
android:centerColor="#bbbbbb"
android:endColor="#bbbbbb"
android:angle="90" />

<corners android:radius="5px" />

<stroke
android:width="2dp"
android:color="#50999999" />

<stroke
android:width="1dp"
android:color="#70555555" />
</shape>
10 changes: 10 additions & 0 deletions Paco/res/drawable/seekbar_progress.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ### -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"
android:drawable="@drawable/seekbar_background_fill" />

<item android:id="@android:id/progress">
<clip android:drawable="@drawable/seekbar_progress_fill" />
</item>
</layer-list>
19 changes: 19 additions & 0 deletions Paco/res/drawable/seekbar_progress_fill.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ### -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#bbbbbb"
android:centerColor="#bbbbbb"
android:endColor="#bbbbbb"
android:angle="90" />

<corners android:radius="5px" />

<stroke
android:width="2dp"
android:color="#50999999" />

<stroke
android:width="1dp"
android:color="#70555555" />
</shape>
40 changes: 40 additions & 0 deletions Paco/res/layout/va_scale.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2011 Google Inc. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
###
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="8dip"
android:weightSum="1">


<com.pacoapp.paco.ui.SeekBar_api14
android:id="@+id/va_scale_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:progressDrawable="@drawable/seekbar_progress" />
</LinearLayout>

</merge>
1 change: 1 addition & 0 deletions Paco/src/com/google/android/apps/paco/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions Paco/src/com/pacoapp/paco/ui/InputLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
74 changes: 74 additions & 0 deletions Paco/src/com/pacoapp/paco/ui/SeekBar_api14.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
1 change: 1 addition & 0 deletions Shared/src/com/pacoapp/paco/shared/model2/Input2.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion Shared/src_non_j2objc/com/pacoapp/paco/shared/model/InputDAO.java
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down