Skip to content

Commit 599fb7a

Browse files
committed
adds a Seekbar component (app side, no preview available server side), taken
from google#1536 but modified, bumping Android version to API level 16
1 parent d8e37c2 commit 599fb7a

File tree

9 files changed

+129
-10
lines changed

9 files changed

+129
-10
lines changed

Paco-Server/ear/default/web/js/services.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,15 +475,16 @@ pacoApp.service('config', function() {
475475
'Fifth'
476476
];
477477

478-
this.responseTypes =[
479-
{"id" : 'likert', "name" : 'Scale'},
480-
{"id" : 'likert_smileys', "name" : '5 Point Smiley Scale'},
481-
{"id" : 'number', "name" : 'Number'},
482-
{"id" : 'open text', "name" : 'Open Text'},
483-
{"id" : 'list', "name" : 'List'},
484-
{"id" : 'photo', "name" : 'Photo'},
485-
{"id" : 'location', "name" : 'Location'},
486-
{"id" : 'audio', "name" : 'Audio'}];
478+
this.responseTypes =[
479+
{"id" : 'likert', "name" : 'Scale'},
480+
{"id" : 'likert_smileys', "name" : '5 Point Smiley Scale'},
481+
{"id" : 'number', "name" : 'Number'},
482+
{"id" : 'open text', "name" : 'Open Text'},
483+
{"id" : 'list', "name" : 'List'},
484+
{"id" : 'photo', "name" : 'Photo'},
485+
{"id" : 'location', "name" : 'Location'},
486+
{"id" : 'audio', "name" : 'Audio'},
487+
{"id" : "va_scale", "name" : 'Visual Analogue Scale'}];
487488

488489
this.feedbackTypes = [
489490
'Static Message',

Paco/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,5 +362,5 @@
362362
<uses-permission android:name="android.permission.READ_CALENDAR" />
363363

364364
<uses-feature android:name="android.hardware.camera" android:required="false"/>
365-
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22"></uses-sdk>
365+
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22"></uses-sdk>
366366
</manifest>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:startColor="#bbbbbb"
5+
android:centerColor="#bbbbbb"
6+
android:endColor="#bbbbbb"
7+
android:angle="90" />
8+
9+
<corners android:radius="5px" />
10+
11+
<stroke
12+
android:width="2dp"
13+
android:color="#50999999" />
14+
15+
<stroke
16+
android:width="1dp"
17+
android:color="#70555555" />
18+
</shape>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:id="@android:id/background"
4+
android:drawable="@drawable/seekbar_background_fill" />
5+
6+
<item android:id="@android:id/progress">
7+
<clip android:drawable="@drawable/seekbar_progress_fill" />
8+
</item>
9+
</layer-list>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:startColor="#bbbbbb"
5+
android:centerColor="#bbbbbb"
6+
android:endColor="#bbbbbb"
7+
android:angle="90" />
8+
9+
<corners android:radius="5px" />
10+
11+
<stroke
12+
android:width="2dp"
13+
android:color="#50999999" />
14+
15+
<stroke
16+
android:width="1dp"
17+
android:color="#70555555" />
18+
</shape>

Paco/res/layout/va_scale.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2011 Google Inc. All Rights Reserved.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing,
12+
~ software distributed under the License is distributed on an
13+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
~ KIND, either express or implied. See the License for the
15+
~ specific language governing permissions and limitations
16+
~ under the License.
17+
###
18+
-->
19+
<merge xmlns:android="http://schemas.android.com/apk/res/android"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content" >
22+
23+
<LinearLayout
24+
android:layout_width="match_parent"
25+
android:layout_height="match_parent"
26+
android:orientation="horizontal"
27+
android:paddingBottom="8dip"
28+
android:weightSum="1">
29+
30+
31+
<SeekBar
32+
android:id="@+id/va_scale_input"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:layout_gravity="center_vertical"
36+
android:layout_weight="1"
37+
android:max="100"
38+
android:min="0"
39+
android:progress="20"
40+
android:progressDrawable="@drawable/seekbar_progress" />
41+
</LinearLayout>
42+
</merge>

Paco/src/com/google/android/apps/paco/Input.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Input {
3434
public static final String PHOTO = "photo";
3535
public static final String SOUND = "sound";
3636
public static final String ACTIVITY = "activity";
37+
public static final String VA_SCALE = "va_scale";
3738

3839

3940
@JsonIgnore

Paco/src/com/pacoapp/paco/ui/InputLayout.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Date;
2828
import java.util.List;
2929

30+
import android.widget.SeekBar;
3031
import org.slf4j.Logger;
3132
import org.slf4j.LoggerFactory;
3233

@@ -221,6 +222,8 @@ public Object getValue() {
221222
return getPhotoValue();
222223
} else if (input.getResponseType().equals(Input2.AUDIO)) {
223224
return getAudioValue();
225+
} else if (input.getResponseType().equals(Input2.VA_SCALE)) {
226+
return intToString(getVaScaleValue());
224227
}
225228
return null;
226229
}
@@ -245,6 +248,8 @@ public String getValueAsString() {
245248
return getPhotoValue();
246249
} else if (input.getResponseType().equals(Input2.AUDIO)) {
247250
return getAudioValue();
251+
} else if (input.getResponseType().equals(Input2.VA_SCALE)) {
252+
return intToString(getVaScaleValue());
248253
}
249254
return null;
250255
}
@@ -326,6 +331,10 @@ private String getPhotoValue() {
326331
return "";
327332
}
328333

334+
private Integer getVaScaleValue() {
335+
return ((SeekBar) componentWithValue).getProgress();
336+
}
337+
329338
private Bitmap decodeFile(File f) {
330339
Bitmap b = null;
331340
try {
@@ -495,10 +504,30 @@ private View getInputResponseTypeView(Input2 input2) {
495504
return renderPhotoButton(input2);
496505
} else if (questionType.equals(Input2.AUDIO)) {
497506
return renderAudioRecorder(input2);
507+
} else if (questionType.equals(Input2.VA_SCALE)) {
508+
return renderVaScale();
498509
}
499510
return null;
500511
}
501512

513+
private View renderVaScale() {
514+
((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE))
515+
.inflate(R.layout.va_scale, this, true);
516+
SeekBar seekBar = (SeekBar) findViewById(R.id.va_scale_input);
517+
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
518+
@Override
519+
public void onStartTrackingTouch(SeekBar s) {
520+
notifyChangeListeners();
521+
}
522+
@Override
523+
public void onStopTrackingTouch(SeekBar seekBar) {}
524+
@Override
525+
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {}
526+
});
527+
528+
return seekBar;
529+
}
530+
502531
private View renderPhotoButton(Input2 input2) {
503532
View photoInputView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
504533
R.layout.photo_input, this, true);

Shared/src/com/pacoapp/paco/shared/model2/Input2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Input2 extends ModelBase implements Validatable, Serializable {
3434
public static final String SOUND = "sound";
3535
public static final String ACTIVITY = "activity";
3636
public static final String AUDIO = "audio";
37+
public static final String VA_SCALE = "va_scale";
3738

3839
public static String[] RESPONSE_TYPES = {LIKERT_SMILEYS, LIKERT, OPEN_TEXT, LIST, NUMBER,
3940
LOCATION, PHOTO, SOUND, ACTIVITY, AUDIO};

0 commit comments

Comments
 (0)