-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Support for the following question types: Dichotomic choice (e.g. example YES/NO), Single choice, Multiple choose; - Presentation page; - Question blocked until response is obtained; - Bug fixes and improvements.
- Loading branch information
1 parent
db4c026
commit c3e1336
Showing
20 changed files
with
539 additions
and
128 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
# SimpleSurvey | ||
Library for simple survey creation | ||
# Simple Survey | ||
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT) | ||
|
||
Library for simple survey creation. | ||
This library has as main dependency the library [AppIntro](https://github.com/AppIntro/AppIntro) _(An excellent library for you to create introductions to your application)_. | ||
|
||
**Simple Survey**, only provides an easy way to create forms with pre-defined question types. | ||
|
||
## Features | ||
- Support for the following question types: | ||
- Dichotomic choice (e.g. example YES/NO) | ||
- Single choice | ||
- Multiple choose | ||
- Presentation page | ||
- Question blocked until response is obtained. | ||
|
||
## Installation | ||
``` | ||
allprojects { | ||
repositories { | ||
... | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
|
||
``` | ||
dependencies { | ||
implementation 'com.github.nutes-uepb:simple-survey:v1.0.0' | ||
} | ||
``` | ||
|
||
## Using | ||
|
||
#### [See example of use](https://github.com/nutes-uepb/simple-survey/blob/master/app/src/main/java/br/edu/uepb/nutes/simplesurvey/SimpleSurvey1.java) | ||
|
||
`More examples coming soon...` | ||
|
||
|
131 changes: 105 additions & 26 deletions
131
app/src/main/java/br/edu/uepb/nutes/simplesurvey/SimpleSurvey1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,155 @@ | ||
package br.edu.uepb.nutes.simplesurvey; | ||
|
||
import android.app.AlertDialog; | ||
import android.content.DialogInterface; | ||
import android.graphics.Color; | ||
import android.support.v4.content.ContextCompat; | ||
import android.util.Log; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import br.edu.uepb.nutes.simplesurvey.base.SimpleSurvey; | ||
import br.edu.uepb.nutes.simplesurvey.pages.DichotomicChoice; | ||
import br.edu.uepb.nutes.simplesurvey.pages.Infor; | ||
import br.edu.uepb.nutes.simplesurvey.pages.MultipleChoice; | ||
import br.edu.uepb.nutes.simplesurvey.pages.SingleChoice; | ||
|
||
public class SimpleSurvey1 extends SimpleSurvey implements DichotomicChoice.OnRadioListener, | ||
Infor.OnButtonListener { | ||
public class SimpleSurvey1 extends SimpleSurvey implements Infor.OnInfoListener, | ||
DichotomicChoice.OnDichotomicListener, SingleChoice.OnSingleListener, | ||
MultipleChoice.OnMultipleListener { | ||
private final String LOG_TAG = SimpleSurvey1.class.getSimpleName(); | ||
|
||
@Override | ||
protected void initView() { | ||
addPages(); | ||
} | ||
|
||
private void addPages() { | ||
setMessageBlocked("Ops! responda para poder ir para próxima perguta..."); | ||
setMessageBlocked("Oops! answer so i can go to the next question..."); | ||
/** | ||
* Available animations: | ||
* - setFadeAnimation() | ||
* - setZoomAnimation() | ||
* - setFlowAnimation() | ||
* - setSlideOverAnimation() | ||
* - setDepthAnimation() | ||
* More details: {https://github.com/AppIntro/AppIntro#animations} | ||
*/ | ||
setFadeAnimation(); | ||
|
||
addQuestion(new Infor.Config() | ||
.layout(R.layout.welcome) | ||
.nextQuestionAuto() | ||
.pageNumber(0) | ||
.build()); | ||
|
||
// page 1 | ||
addQuestion(new DichotomicChoice.Config() | ||
.title("Title of the question") | ||
.description("Lorem Ipsum is simply dummy text of the printing and typesetting industry?") | ||
.title("Title of the question 1", Color.WHITE) | ||
.description("Lorem Ipsum is simply dummy text of the printing and typesetting industry?", | ||
Color.WHITE) | ||
.colorBackground(ContextCompat.getColor(this, R.color.colorGreen)) | ||
.radioStyle(R.drawable.radio_sample1_lef, R.drawable.radio_sample1_right, Color.WHITE, Color.WHITE) | ||
.radioLeftText(R.string.masc) | ||
.radioRightText(R.string.femi) | ||
.nextQuestionAuto() | ||
.image(R.drawable.placeholder) | ||
.buttonClose(R.drawable.ic_action_close_dark) | ||
.enableZoomImage() | ||
.pageNumber(1) | ||
.build()); | ||
|
||
addQuestion(new DichotomicChoice.Config() | ||
.title("Simple Survey 1") | ||
.description("Simple survey from @NUTES") | ||
addQuestion(new SingleChoice.Config() | ||
.title("Title of the question 2", Color.WHITE) | ||
.description("Lorem Ipsum is simply dummy text of the printing and typesetting industry?", | ||
Color.WHITE) | ||
.colorBackground(ContextCompat.getColor(this, R.color.colorCyan)) | ||
.colorBackgroundTint(Color.WHITE) | ||
.colorSelectedText(Color.WHITE) | ||
.items(new ArrayList<String>() {{ | ||
add("Item 1"); | ||
add("Item 2"); | ||
add("Item 3"); | ||
add("Item 4"); | ||
}}) | ||
.image(R.drawable.placeholder) | ||
.buttonClose(R.drawable.ic_action_close_dark) | ||
.disableAddNewItem() | ||
.nextQuestionAuto() | ||
.pageNumber(2) | ||
.build()); | ||
|
||
addQuestion(new DichotomicChoice.Config() | ||
.title("Simple Survey 2") | ||
.description("Simple survey from @NUTES") | ||
.pageNumber(3) | ||
.title("Title of the question 3") | ||
.description("Lorem Ipsum is simply dummy text of the printing and typesetting industry?") | ||
.nextQuestionAuto() | ||
.pageNumber(3) | ||
.build()); | ||
|
||
addQuestion(new DichotomicChoice.Config() | ||
.title("Simple Survey 3") | ||
.description("Simple survey from @NUTES") | ||
.colorBackground(ContextCompat.getColor(this, R.color.colorBlueGrey)) | ||
addQuestion(new MultipleChoice.Config() | ||
.title("Simple Survey 3", Color.WHITE) | ||
.description("Simple survey from @NUTES", Color.WHITE) | ||
.colorBackground(ContextCompat.getColor(this, R.color.colorDeepPurple)) | ||
.items(new ArrayList<String>() {{ | ||
add("Item 1"); | ||
add("Item 2"); | ||
add("Item 3"); | ||
add("Item 4"); | ||
}}) | ||
.buttonClose(R.drawable.ic_action_close_dark) | ||
.nextQuestionAuto() | ||
.colorBackgroundTint(Color.WHITE) | ||
.colorSelectedText(Color.WHITE) | ||
.pageNumber(4) | ||
.build()); | ||
|
||
|
||
addQuestion(new Infor.Config() | ||
.title("Lorem Ipsum") | ||
.description("Lorem Ipsum is simply dummy text of the printing and typesetting industry." + | ||
" Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,") | ||
.pageNumber(4) | ||
.title("Thank you for the answers :)") | ||
.pageNumber(-1) | ||
.build()); | ||
} | ||
|
||
@Override | ||
public void onAnswerButton(int page) { | ||
|
||
public void onClosePage() { | ||
new AlertDialog | ||
.Builder(this) | ||
.setMessage("Do you want to cancel the survey??") | ||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() { | ||
@Override | ||
public void onClick(DialogInterface dialog, int which) { | ||
finish(); | ||
} | ||
}) | ||
.setNegativeButton("No", null) | ||
.show(); | ||
} | ||
|
||
@Override | ||
public void onAnswerRadio(int page, boolean value) { | ||
public void onAnswerInfo(int page) { | ||
Log.w(LOG_TAG, "onAnswerInfo() | PAGE: " + page); | ||
if (page == 0) { // first page | ||
nextQuestion(); | ||
} else if (page == -1) { // end page | ||
finish(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onAnswerDichotomic(int page, boolean value) { | ||
Log.w(LOG_TAG, "onAnswerDichotomic() | PAGE: " + page + " | ANSWER: " + value); | ||
} | ||
|
||
@Override | ||
public void onClosePage() { | ||
public void onAnswerSingle(int page, String value, int indexValue) { | ||
Log.w(LOG_TAG, "onAnswerMultiple() | PAGE: " + page | ||
+ " | ANSWER (value): " + value | ||
+ " | ANSWER (index): " + indexValue); | ||
} | ||
|
||
@Override | ||
public void onAnswerMultiple(int page, List<String> values, List<Integer> indexValues) { | ||
Log.w(LOG_TAG, "onAnswerMultiple() | PAGE: " + page | ||
+ " | ANSWER (values): " + Arrays.toString(values.toArray()) | ||
+ " | ANSWER (indexes): " + Arrays.toString(indexValues.toArray())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="#FFFFFF"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> | ||
</vector> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_checked="true"> | ||
<shape> | ||
<corners android:bottomLeftRadius="25dp" android:topLeftRadius="60dp" /> | ||
<solid android:color="#286572" /> | ||
<padding android:bottom="15dp" android:left="40dp" android:right="40dp" android:top="15dp" /> | ||
</shape> | ||
</item> | ||
|
||
<item android:state_pressed="true"> | ||
<shape> | ||
<corners android:bottomLeftRadius="25dp" android:topLeftRadius="60dp" /> | ||
<stroke android:width="2dp" android:color="#286572" /> | ||
<padding android:bottom="15dp" android:left="40dp" android:right="40dp" android:top="15dp" /> | ||
</shape> | ||
</item> | ||
|
||
<item> | ||
<shape> | ||
<corners android:bottomLeftRadius="25dp" android:topLeftRadius="60dp" /> | ||
<stroke android:width="2dp" android:color="#286572" /> | ||
<padding android:bottom="15dp" android:left="40dp" android:right="40dp" android:top="15dp" /> | ||
</shape> | ||
</item> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_checked="true"> | ||
<shape> | ||
<corners android:bottomRightRadius="60dp" android:topRightRadius="25dp" /> | ||
<solid android:color="#286572" /> | ||
<padding android:bottom="15dp" android:left="40dp" android:right="40dp" android:top="15dp" /> | ||
</shape> | ||
</item> | ||
|
||
<item android:state_pressed="true"> | ||
<shape> | ||
<corners android:bottomRightRadius="60dp" android:topRightRadius="25dp" /> | ||
<stroke android:width="2dp" android:color="#286572" /> | ||
<padding android:bottom="15dp" android:left="40dp" android:right="40dp" android:top="15dp" /> | ||
</shape> | ||
</item> | ||
|
||
<item> | ||
<shape> | ||
<corners android:bottomRightRadius="60dp" android:topRightRadius="25dp" /> | ||
<stroke android:width="2dp" android:color="#286572" /> | ||
<padding android:bottom="15dp" android:left="40dp" android:right="40dp" android:top="15dp" /> | ||
</shape> | ||
</item> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:paddingLeft="30dp" | ||
android:paddingRight="30dp" | ||
android:layout_marginTop="80dp"> | ||
|
||
<TextView | ||
android:id="@+id/question_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:text="Welcome to Simple Survey" | ||
android:textSize="50sp" /> | ||
|
||
<TextView | ||
android:id="@+id/question_description" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="40dp" | ||
android:gravity="center" | ||
android:text="Sample 1" | ||
android:textSize="25sp" /> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:layout_marginTop="40dp" | ||
android:gravity="center" | ||
android:text=":-)" | ||
android:textSize="50sp" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="0dip" | ||
android:layout_weight="1" | ||
android:gravity="center|bottom" | ||
android:orientation="vertical" | ||
android:padding="100dp"> | ||
|
||
<Button | ||
android:id="@+id/answer_button" | ||
style="@style/Widget.AppCompat.Button.Colored" | ||
android:layout_width="match_parent" | ||
android:layout_height="60dp" | ||
android:text="Lets go >>" | ||
android:textSize="16sp" /> | ||
</LinearLayout> | ||
</LinearLayout> | ||
|
||
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<resources> | ||
<string name="app_name">Simple Survey</string> | ||
<string name="masc">Masculino</string> | ||
<string name="femi">Feminino</string> | ||
<string name="masc">Male</string> | ||
<string name="femi">Female</string> | ||
</resources> |
Oops, something went wrong.