Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github actions for this project #42

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
25 changes: 25 additions & 0 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Android Build

on: pull_request

jobs:
build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Build Project
run: ./gradlew assemble

- name: Run Tests
run: ./gradlew test

- name: Ktlint
run: ./gradlew ktlintFormat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try to add the ./gradlew publish here? What would be necessary to get it to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we publish from gitlab 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea... but It would be really nice to have everything here, right? Maybe I can find some time to figure out how to do that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KlausNie @coroutineDispatcher We need to discuss this. Please create an issue out of it and assign it to me

2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ buildscript {
mavenCentral()
google()
maven { url = uri("https://repository.quickbirdstudios.com/repository/public") }
maven { url = uri("https://plugins.gradle.org/m2/") }
}

dependencies {
classpath(Deps.Plugins.kotlin)
classpath(Deps.Plugins.ktlint)
}
}

Expand Down
4 changes: 3 additions & 1 deletion buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
object Versions {

const val kotlin = "1.3.50"
const val kotlin = "1.3.70"
const val coroutines = "1.3.0"
const val test = "1.1.1"
const val jUnit = "5.5.2"
const val jUnitPlatform = "1.5.2"
const val lottie = "3.0.7"
const val espresso = "3.1.0"
const val ktlint = "9.4.1"

object AndroidSupport {
const val appCompat = "1.0.0"
Expand All @@ -24,6 +25,7 @@ object Deps {

object Plugins {
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
const val ktlint = "org.jlleitschuh.gradle:ktlint-gradle:${Versions.ktlint}"
}

object Kotlin {
Expand Down
8 changes: 8 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Aug 27 11:22:30 CEST 2021
sdk.dir=/Users/stavroxhardha/Library/Android/sdk
3 changes: 2 additions & 1 deletion survey/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
kotlin("android")
id("org.jetbrains.kotlin.android.extensions")
id("gradle-publishing")
id("org.jlleitschuh.gradle.ktlint")
}

androidExtensions { isExperimental = true }
Expand Down Expand Up @@ -36,4 +37,4 @@ dependencies {

testImplementation(Deps.Test.jUnitJupiter)
testImplementation(Deps.Test.jUnitPlatform)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import androidx.annotation.DrawableRes
import androidx.annotation.IntRange
import androidx.lifecycle.Lifecycle
import com.quickbirdstudios.surveykit.backend.address.AddressSuggestionProvider
import kotlinx.android.parcel.Parcelize
import java.util.Calendar
import java.util.Date as JavaDate
import java.util.regex.Pattern
import kotlinx.android.parcel.Parcelize
import java.util.Date as JavaDate

sealed class AnswerFormat {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.quickbirdstudios.surveykit

import android.os.Parcelable
import java.util.UUID
import kotlinx.android.parcel.Parcelize
import java.util.UUID

@Parcelize
open class Identifier(open val id: String) : Parcelable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import android.text.TextWatcher
import android.widget.EditText

fun EditText.afterTextChanged(listener: (String) -> Unit) {
addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable) = listener(s.toString())
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = Unit
})
addTextChangedListener(
object : TextWatcher {
override fun afterTextChanged(s: Editable) = listener(s.toString())
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = Unit
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ fun View.hideKeyboard() {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(windowToken, 0)
}

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

fun hasPreviousStep() : Boolean {
fun hasPreviousStep(): Boolean {
val previousStep = peekHistory()
return previousStep != null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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
Expand Down Expand Up @@ -103,7 +102,7 @@ internal class PresenterImpl(

val previousQuestionView = currentQuestionView

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

Expand All @@ -120,16 +119,18 @@ internal class PresenterImpl(

when (transition) {
Presenter.Transition.SlideFromRight -> viewAnimator.rightToLeft(
viewContainer, ViewAnimator.PageSwipe(previousQuestionView, questionView)
viewContainer,
ViewAnimator.PageSwipe(previousQuestionView, questionView)
)
Presenter.Transition.SlideFromLeft -> viewAnimator.leftToRight(
viewContainer, ViewAnimator.PageSwipe(previousQuestionView, questionView)
viewContainer,
ViewAnimator.PageSwipe(previousQuestionView, questionView)
)
Presenter.Transition.None -> Unit
}
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,32 @@ import android.view.ViewGroup
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import com.quickbirdstudios.surveykit.R
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlin.coroutines.CoroutineContext

internal class ViewAnimator(val context: Context) {

//region Member

private val enterFromRightAnimation = AnimationUtils.loadAnimation(
context, R.anim.enter_from_right
context,
R.anim.enter_from_right
)!!
private val enterFromLeftAnimation = AnimationUtils.loadAnimation(
context, R.anim.enter_from_left
context,
R.anim.enter_from_left
)!!
private val exitToRightAnimation = AnimationUtils.loadAnimation(
context, R.anim.exit_to_right
context,
R.anim.exit_to_right
)!!
private val exitToLeftAnimation = AnimationUtils.loadAnimation(
context, R.anim.exit_to_left
context,
R.anim.exit_to_left
)!!

//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import android.content.Context
import android.os.Parcelable
import android.util.AttributeSet
import android.view.Gravity
import android.widget.*
import android.widget.Button
import android.widget.DatePicker
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.TimePicker
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.ContextCompat
import com.quickbirdstudios.surveykit.R
import com.quickbirdstudios.surveykit.SurveyTheme
import com.quickbirdstudios.surveykit.backend.views.main_parts.StyleablePart
import java.util.*
import kotlinx.android.parcel.Parcelize
import java.util.Calendar

internal class DateTimePickerPart @JvmOverloads constructor(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import android.view.Gravity
import android.view.MotionEvent
import android.view.View
import android.view.animation.BounceInterpolator
import android.widget.*
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.quickbirdstudios.surveykit.backend.views.question_parts

import android.content.Context
import android.graphics.Color
import android.os.Handler
import android.util.AttributeSet
import android.view.Gravity
Expand Down Expand Up @@ -162,7 +161,9 @@ internal class MultipleChoicePart @JvmOverloads constructor(

Handler().post {
checkBox.background = checkBox.createSelectableThemedBackground(
context, Both, themeColor
context,
Both,
themeColor
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.quickbirdstudios.surveykit.backend.views.question_parts

import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.util.TypedValue
import android.view.View
Expand Down Expand Up @@ -58,7 +57,6 @@ internal class ScalePart @JvmOverloads constructor(
private var currentValueDescriptionField: TextView
private var seekBar: AppCompatSeekBar


//endregion

//region Overrides
Expand Down Expand Up @@ -166,19 +164,19 @@ internal class ScalePart @JvmOverloads constructor(
minimumValueDescriptionField = TextView(context).setRandomViewId().apply {
this.textAlignment = View.TEXT_ALIGNMENT_CENTER
this.setTextSize(TypedValue.COMPLEX_UNIT_PX, descriptionTextSize)
this.setTextColor(ContextCompat.getColor(context, R.color.survey_text));
this.setTextColor(ContextCompat.getColor(context, R.color.survey_text))
this.setPadding(textPadding, textPadding, textPadding, 0)
}
maximumValueDescriptionField = TextView(context).setRandomViewId().apply {
this.textAlignment = View.TEXT_ALIGNMENT_CENTER
this.setTextSize(TypedValue.COMPLEX_UNIT_PX, descriptionTextSize)
this.setTextColor(ContextCompat.getColor(context, R.color.survey_text));
this.setTextColor(ContextCompat.getColor(context, R.color.survey_text))
this.setPadding(textPadding, textPadding, textPadding, 0)
}
currentValueDescriptionField = TextView(context).setRandomViewId().apply {
this.textAlignment = View.TEXT_ALIGNMENT_CENTER
this.setTextSize(TypedValue.COMPLEX_UNIT_PX, selectedTextSize)
this.setTextColor(ContextCompat.getColor(context, R.color.survey_text));
this.setTextColor(ContextCompat.getColor(context, R.color.survey_text))
this.setPadding(textPadding, textPadding, textPadding, 0)
}
seekBar = AppCompatSeekBar(context).apply {
Expand All @@ -197,13 +195,15 @@ internal class ScalePart @JvmOverloads constructor(
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
}

seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
currentValueDescription = progress.convert().toInt().toString()
}
seekBar.setOnSeekBarChangeListener(
object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
currentValueDescription = progress.convert().toInt().toString()
}

override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
})
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
}
)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.quickbirdstudios.surveykit.backend.views.question_parts

import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.Gravity
import android.view.View
Expand Down Expand Up @@ -45,10 +44,10 @@ internal class SingleChoicePart @JvmOverloads constructor(

@ColorInt
var defaultColor: Int = ContextCompat.getColor(context, R.color.survey_text)
set(color) {
update(options)
field = color
}
set(color) {
update(options)
field = color
}
var options: List<TextChoice> = emptyList()
set(value) {
update(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ internal fun Checkable.createSelectableThemedBackground(
border: BackgroundDrawable.Border,
themeColor: Int
): Drawable = BackgroundCreationHelper().createSelectableBackground(
context, border, themeColor
context,
border,
themeColor
)

private class BackgroundCreationHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ internal class BooleanQuestionView(
//region Overrides

override fun createResults(): QuestionResult {
val stringIdentifier: String = (answerFormat.textChoices
.find { it.text == booleanAnswerPart.selected?.text }
?.value
?: "")
val stringIdentifier: String = (
answerFormat.textChoices
.find { it.text == booleanAnswerPart.selected?.text }
?.value
?: ""
)

return BooleanQuestionResult(
id = id,
Expand Down
Loading