Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
roedll committed Mar 11, 2021
2 parents 9924fc1 + 635a40f commit 9728b0f
Show file tree
Hide file tree
Showing 41 changed files with 221 additions and 88 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p align="center">
<img src="assets/top/surveykit-logo.png" width="500">
</p>

# SurveyKit: Create beautiful surveys on Android (inspired by ResearchKit Surveys on iOS)

Do you want to display a questionnaire to get the opinion of your users? A survey for a medical trial? A series of instructions in a manual-like style? <br/>
Expand Down
Binary file added assets/top/surveykit-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions buildSrc/src/main/kotlin/ApiKeys.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.quickbirdstudios.surveykit

import java.util.*
import org.gradle.api.Project
import java.io.IOException
import java.util.*

object ApiKeys {

Expand All @@ -23,7 +24,11 @@ object ApiKeys {

private fun Project.findInLocalPropertiesFile(name: String): String? {
val properties = Properties()
properties.load(project.rootProject.file("local.properties").inputStream())
try {
properties.load(project.rootProject.file("local.properties").inputStream())
} catch (e: IOException) {
println("Error trying to load local.properties file")
}
return properties[name] as? String?
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Library.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Library {
const val groupId = "com.quickbirdstudios"
const val artifactId = "surveykit"
const val version = "1.1.0"
const val version = "2.0.0-alpha-4"

object Meta {
const val gitUrl = "https://github.com/quickbirdstudios/SurveyKit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import org.json.JSONObject
class YandexAddressSuggestionProvider(
private val apiKey: String,
private val resultsCount: Int = 5,
private val lang: String = "tr_TR",
private val lang: String = "en_GB",
override var onSuggestionListReady: (suggestions: List<AddressSuggestion>) -> Unit? = {}
) : AddressSuggestionProvider {

private val exceptionHandler = CoroutineExceptionHandler { _, exception ->
private val exceptionHandler = CoroutineExceptionHandler { _, _ ->
// ignore
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import com.quickbirdstudios.surveykit.NavigationRule
import com.quickbirdstudios.surveykit.StepIdentifier
import com.quickbirdstudios.surveykit.SurveyTheme
import com.quickbirdstudios.surveykit.TextChoice
import com.quickbirdstudios.example.YandexAddressSuggestionProvider
import com.quickbirdstudios.surveykit.backend.address.GeocoderAddressSuggestionProvider
import com.quickbirdstudios.surveykit.backend.views.main_parts.AbortDialogConfiguration
import com.quickbirdstudios.surveykit.backend.views.step.StepView
import com.quickbirdstudios.surveykit.result.QuestionResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ internal class NavigableOrderedTaskNavigator(

//region Private Helper

private fun Step?.record() {
if (this != null) {
history.push(this)
}
}

private fun Step.extractRule(): NavigationRule? = task.getRule(this.id)

private fun NavigationRule.DirectStepNavigationRule.evaluateNextStep() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ internal class OrderedTaskNavigator(

override fun finalStep(): Step? = task.steps.lastOrNull()

override fun nextStep(step: Step, stepResult: StepResult?): Step? = step.nextInList()
override fun nextStep(step: Step, stepResult: StepResult?): Step? {
step.record()
return step.nextInList()
}

override fun previousStep(step: Step): Step? = step.previousInList()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ interface TaskNavigator {
return history.peek()
}

fun hasPreviousStep() : Boolean {
val previousStep = peekHistory()
return previousStep != null
}

fun Step?.record() {
if (this != null) {
history.push(this)
}
}

companion object {
operator fun invoke(task: Task): TaskNavigator =
when (task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package com.quickbirdstudios.surveykit.backend.presenter
import android.content.Context
import android.widget.FrameLayout
import com.quickbirdstudios.surveykit.SurveyTheme
import com.quickbirdstudios.surveykit.backend.navigator.TaskNavigator
import com.quickbirdstudios.surveykit.result.StepResult
import com.quickbirdstudios.surveykit.steps.Step

interface Presenter {
val context: Context
val viewContainer: FrameLayout
val surveyTheme: SurveyTheme
val taskNavigator: TaskNavigator

suspend operator fun invoke(
transition: Transition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ import android.widget.FrameLayout
import android.widget.LinearLayout
import com.quickbirdstudios.surveykit.StepIdentifier
import com.quickbirdstudios.surveykit.SurveyTheme
import com.quickbirdstudios.surveykit.backend.navigator.TaskNavigator
import com.quickbirdstudios.surveykit.backend.presenter.animations.ViewAnimator
import com.quickbirdstudios.surveykit.backend.views.step.QuestionView
import com.quickbirdstudios.surveykit.backend.views.step.StepView
import com.quickbirdstudios.surveykit.result.StepResult
import com.quickbirdstudios.surveykit.steps.Step
import kotlinx.android.synthetic.main.layout_header.view.*
import kotlinx.android.synthetic.main.view_question.view.*
import java.util.Date
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine

internal class PresenterImpl(
override val context: Context,
override val viewContainer: FrameLayout,
override val surveyTheme: SurveyTheme
override val surveyTheme: SurveyTheme,
override val taskNavigator: TaskNavigator
) : Presenter {

//region Members
Expand Down Expand Up @@ -95,7 +100,13 @@ internal class PresenterImpl(
}

private fun showView(questionView: StepView, transition: Presenter.Transition) {

val previousQuestionView = currentQuestionView

if(!hasPreviousStep()) {
questionView.questionHeader.canBack = false
}

currentQuestionView = questionView

viewContainer.addView(questionView)
Expand All @@ -118,5 +129,9 @@ internal class PresenterImpl(
}
}

private fun hasPreviousStep() : Boolean {
return taskNavigator.hasPreviousStep()
}

//endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class Footer @JvmOverloads constructor(
buttonContinue.text = text
}

fun setSkipButtonText(text: String) {
buttonSkip.text = text
}

var onContinue: () -> Unit = {}
var onSkip: () -> Unit = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class LocationPickerPart @JvmOverloads constructor(
this.gravity = Gravity.CENTER

search = AutoCompleteTextView(context).apply {
id = R.id.locationAnswerSearchField
setHint(android.R.string.search_go)
setSingleLine(true)
setCompoundDrawables(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.os.Build
import android.util.AttributeSet
import android.view.Gravity
import android.view.MotionEvent
import android.widget.LinearLayout
import android.widget.TimePicker
import com.quickbirdstudios.surveykit.R
Expand Down Expand Up @@ -74,6 +75,12 @@ internal class TimePickerPart @JvmOverloads constructor(

//endregion

override fun onInterceptTouchEvent(motionEvent: MotionEvent?): Boolean {
if (motionEvent?.actionMasked == MotionEvent.ACTION_DOWN)
parent?.requestDisallowInterceptTouchEvent(true)
return false
}

init {
this.gravity = Gravity.CENTER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ internal class BooleanQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.BooleanAnswerFormat,
private var preselected: AnswerFormat.BooleanAnswerFormat.Result?
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ internal class DatePickerQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.DateAnswerFormat,
private val preselected: AnswerFormat.DateAnswerFormat.Date?
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ internal class DateTimePickerQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.DateTimeAnswerFormat,
private val preselected: AnswerFormat.DateTimeAnswerFormat.DateTime?
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

private lateinit var dateTimePickerPart: DateTimePickerPart

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ internal class EmailQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.EmailAnswerFormat,
private val preselected: String? = null
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class FinishQuestionView(
finishButtonText: String,
private val lottieAnimation: CompletionStep.LottieAnimation?,
private val repeatCount: Int?
) : QuestionView(context, id, false, title, text, finishButtonText) {
) : QuestionView(context, id, false, title, text, finishButtonText, "") {

//region Overrides

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ internal class ImageSelectorQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.ImageSelectorFormat,
private var preselected: List<Int>?
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ internal class IntegerQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
@StringRes private val hintText: Int = R.string.empty,
private val answerFormat: AnswerFormat.IntegerAnswerFormat,
private val preselected: Int? = null
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class IntroQuestionView(
title: String?,
text: String?,
startButtonText: String
) : QuestionView(context, id, isOptional, title, text, startButtonText) {
) : QuestionView(context, id, isOptional, title, text, startButtonText, "") {

//region Overrides

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ internal class LocationPickerQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val lifecycle: Lifecycle?,
private val addressProvider: AddressSuggestionProvider?,
private val answerFormat: AnswerFormat.LocationAnswerFormat,
private val preselected: AnswerFormat.LocationAnswerFormat.Location?
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ internal class MultipleChoiceQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.MultipleChoiceAnswerFormat,
private val preselected: List<TextChoice>?
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ internal class ScaleQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.ScaleAnswerFormat,
private val preselected: Float? = null
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ internal class SingleChoiceQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.SingleChoiceAnswerFormat,
private val preselected: TextChoice? = null
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ internal class TextQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.TextAnswerFormat,
private val preselected: String? = null
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ internal class TimePickerQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.TimeAnswerFormat,
private val preselected: AnswerFormat.TimeAnswerFormat.Time?
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ internal class ValuePickerQuestionView(
title: String?,
text: String?,
nextButtonText: String,
skipButtonText: String,
private val answerFormat: AnswerFormat.ValuePickerAnswerFormat,
private val preselected: String?
) : QuestionView(context, id, isOptional, title, text, nextButtonText) {
) : QuestionView(context, id, isOptional, title, text, nextButtonText, skipButtonText) {

//region Members

Expand Down
Loading

0 comments on commit 9728b0f

Please sign in to comment.