From c3e13366bdca328773e59f7ab0a86c774cd11e67 Mon Sep 17 00:00:00 2001 From: Douglas Rafael Date: Tue, 12 Mar 2019 18:30:14 -0300 Subject: [PATCH] Version 1.0 finalized. - 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. --- ..gitignore.swp | Bin 1024 -> 0 bytes README.md | 41 +++++- .../nutes/simplesurvey/SimpleSurvey1.java | 131 ++++++++++++++---- .../drawable-anydpi/ic_action_close_dark.xml | 10 ++ .../drawable-hdpi/ic_action_close_dark.png | Bin 0 -> 202 bytes .../drawable-mdpi/ic_action_close_dark.png | Bin 0 -> 156 bytes .../drawable-xhdpi/ic_action_close_dark.png | Bin 0 -> 232 bytes .../drawable-xxhdpi/ic_action_close_dark.png | Bin 0 -> 314 bytes .../main/res/drawable/radio_sample1_lef.xml | 26 ++++ .../main/res/drawable/radio_sample1_right.xml | 26 ++++ app/src/main/res/layout/activity_main.xml | 7 +- app/src/main/res/layout/welcome.xml | 58 ++++++++ app/src/main/res/values/strings.xml | 4 +- .../simplesurvey/base/BaseConfigQuestion.java | 18 ++- .../nutes/simplesurvey/base/BaseQuestion.java | 1 - .../nutes/simplesurvey/base/SimpleSurvey.java | 46 ++++-- .../simplesurvey/pages/DichotomicChoice.java | 70 +++++++--- .../uepb/nutes/simplesurvey/pages/Infor.java | 56 ++++++-- .../simplesurvey/pages/MultipleChoice.java | 103 +++++++++----- .../simplesurvey/pages/SingleChoice.java | 70 +++++++--- 20 files changed, 539 insertions(+), 128 deletions(-) delete mode 100644 ..gitignore.swp create mode 100644 app/src/main/res/drawable-anydpi/ic_action_close_dark.xml create mode 100644 app/src/main/res/drawable-hdpi/ic_action_close_dark.png create mode 100644 app/src/main/res/drawable-mdpi/ic_action_close_dark.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_action_close_dark.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_action_close_dark.png create mode 100644 app/src/main/res/drawable/radio_sample1_lef.xml create mode 100644 app/src/main/res/drawable/radio_sample1_right.xml create mode 100644 app/src/main/res/layout/welcome.xml diff --git a/..gitignore.swp b/..gitignore.swp deleted file mode 100644 index 65dcfacd5d3fe8403aa9a2f2b85fbfe9cb2a9a83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{7E)H7y40t@XJ7*g^}({mDwkwmdG^GZuni*-HoiVHG}^7C}fP0b9j cD%4BQEXhpI%P&gBDm^MV8UmvsK<5wu0P;5x$^ZZW diff --git a/README.md b/README.md index ffe4889..82af6a0 100644 --- a/README.md +++ b/README.md @@ -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...` + + diff --git a/app/src/main/java/br/edu/uepb/nutes/simplesurvey/SimpleSurvey1.java b/app/src/main/java/br/edu/uepb/nutes/simplesurvey/SimpleSurvey1.java index f615b31..3d1cc8a 100644 --- a/app/src/main/java/br/edu/uepb/nutes/simplesurvey/SimpleSurvey1.java +++ b/app/src/main/java/br/edu/uepb/nutes/simplesurvey/SimpleSurvey1.java @@ -1,13 +1,25 @@ 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() { @@ -15,62 +27,129 @@ protected void initView() { } 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() {{ + 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() {{ + 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 values, List indexValues) { + Log.w(LOG_TAG, "onAnswerMultiple() | PAGE: " + page + + " | ANSWER (values): " + Arrays.toString(values.toArray()) + + " | ANSWER (indexes): " + Arrays.toString(indexValues.toArray())); } } diff --git a/app/src/main/res/drawable-anydpi/ic_action_close_dark.xml b/app/src/main/res/drawable-anydpi/ic_action_close_dark.xml new file mode 100644 index 0000000..914246e --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_action_close_dark.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable-hdpi/ic_action_close_dark.png b/app/src/main/res/drawable-hdpi/ic_action_close_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..681c88c4b358a4244f21b0cf910674cdcdfc54ce GIT binary patch literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbBCVIL!hE&{oJMALp0RI`q{E{Ej7uW&YnMcX6A<2v?UW~_AFVrv&Z37+%wl#(vpo+_VUaTxT4FVdQ&MBb@ E0IVM~&;S4c literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_action_close_dark.png b/app/src/main/res/drawable-xhdpi/ic_action_close_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..66e67f6cefd21e41f523010fa7dbba716b26bc52 GIT binary patch literal 232 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUt^`0({Ar-gY&hX|spupq8dj5qd z5Fg_5U04!)TWyx+=L5Mlm-CZ2S_GUp7#D68`+cfbwfUB3mb>@QOJ%FlI3}(S+C8IX z!s=o-)g!L|6xbI>$Cx@tT$!`&VM*oL-svZ^IdrD~S9;|3uXlp=PxYj{r|v9wPxH5Y z(61L}a;{TosjvLOaG_t|i#N|-$<}`p9k&ZzI4e_P&1-wXp?}H;=fCoOp&R(OJ?IzX eRBRDQI>7eSomq!F+3^<8=?tE(elF{r5}E){Yh087 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_close_dark.png b/app/src/main/res/drawable-xxhdpi/ic_action_close_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..5a4d51cd881c972d65091e4eada6993726f21c8c GIT binary patch literal 314 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@Zgyv2U}W@kaSW-r^>&swUyFhOYiy6bo1+Wx_okFWKNW&DVLxAbKgMoA}_AplYMp00i_>zopr E0CWI)BLDyZ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/radio_sample1_lef.xml b/app/src/main/res/drawable/radio_sample1_lef.xml new file mode 100644 index 0000000..1572fcf --- /dev/null +++ b/app/src/main/res/drawable/radio_sample1_lef.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/radio_sample1_right.xml b/app/src/main/res/drawable/radio_sample1_right.xml new file mode 100644 index 0000000..1ab0ce5 --- /dev/null +++ b/app/src/main/res/drawable/radio_sample1_right.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 9e86107..fac269b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,5 @@ + android:padding="60dp">