├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── ic_add.xml
│ │ │ │ ├── ic_remove.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── layout
│ │ │ │ ├── item_todo.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── content_main.xml
│ │ │ │ └── fragment_new_todo.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── cotel
│ │ │ │ └── comonadic_ui
│ │ │ │ ├── ServiceLocator.kt
│ │ │ │ ├── datatypes
│ │ │ │ ├── Component.kt
│ │ │ │ ├── Moore.kt
│ │ │ │ └── Store.kt
│ │ │ │ ├── Model.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── TodosAdapter.kt
│ │ │ │ ├── NewTodoFragment.kt
│ │ │ │ └── TodosListFragment.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── cotel
│ │ │ └── comonadic_ui
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── cotel
│ │ └── comonadic_ui
│ │ ├── matchers.kt
│ │ ├── TodosListFragmentTest.kt
│ │ └── NewTodoRecordedTest.kt
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── .travis.yml
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cotel/Android-Comonadic-UI/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/ServiceLocator.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | object ServiceLocator {
4 |
5 | var todosState = TodosState(emptyList())
6 |
7 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea/
4 | /local.properties
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Oct 12 16:48:04 CEST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Comonadic-Ui
3 | Settings
4 |
5 |
6 | Hello blank fragment
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/datatypes/Component.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui.datatypes
2 |
3 | import arrow.data.State
4 |
5 | data class Component(val model: T, val render: (T) -> State) {
6 | fun extract(): State = render(model)
7 |
8 | fun move(newModel: T): Component = Component(newModel, render)
9 | }
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_remove.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/cotel/comonadic_ui/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/datatypes/Moore.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui.datatypes
2 |
3 | class Moore(val state: S, val handle: (E) -> Moore) {
4 |
5 | fun extract(): S = state
6 |
7 | fun extend(f: (Moore) -> A): Moore =
8 | Moore(f(Moore(state, handle))) { update ->
9 | handle(update).extend(f)
10 | }
11 |
12 | fun map(f: (S) -> A): Moore =
13 | Moore(f(state)) { update -> handle(update).map(f) }
14 |
15 | fun duplicate(): Moore> = extend { it }
16 |
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/datatypes/Store.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui.datatypes
2 |
3 | class Store(val state: S, val render: (S) -> V) {
4 |
5 | fun extract(): V = render(state)
6 |
7 | fun extend(f: (Store) -> A): Store =
8 | Store(state) { next -> f(Store(next, render)) }
9 |
10 | fun map(f: (V) -> A): Store =
11 | Store(state) { next -> f(render(next)) }
12 |
13 | fun duplicate(): Store> = extend { it }
14 |
15 | fun move(newState: S): Store = Store(newState, render)
16 |
17 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/Model.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import java.util.*
4 |
5 | data class Todo(
6 | val title: String,
7 | val id: UUID = UUID.randomUUID(),
8 | val isCompleted: Boolean = false
9 | )
10 |
11 | data class TodosState(val todos: List) {
12 | fun addTodo(todo: Todo): TodosState = copy(todos = todos + todo)
13 |
14 | fun updateTodo(todo: Todo): TodosState = copy(todos = todos.map {
15 | if (todo.id == it.id) todo else it
16 | })
17 |
18 | fun removeTodo(todo: Todo): TodosState = copy(todos = todos.filterNot { it.id == todo.id })
19 | }
20 |
21 | sealed class TodoInputs
22 | class AddTodo(val todo: Todo) : TodoInputs()
23 | class UpdateTodo(val todo: Todo) : TodoInputs()
24 | class RemoveTodo(val todo: Todo) : TodoInputs()
25 |
26 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | android:
3 | components:
4 | - tools
5 | - platform-tools
6 | - build-tools-28.0.3
7 | - android-22
8 | - android-27
9 | - android-28
10 | - extra-android-support
11 | - extra-google-m2repository
12 | - extra-android-m2repository
13 | - sys-img-armeabi-v7a-android-22
14 |
15 | before_script:
16 | - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
17 | - emulator -avd test -no-audio -no-window &
18 | - android-wait-for-emulator
19 | - adb shell settings put global window_animation_scale 0 &
20 | - adb shell settings put global transition_animation_scale 0 &
21 | - adb shell settings put global animator_duration_scale 0 &
22 | - adb shell input keyevent 82 &
23 |
24 | script: ./gradlew connectedAndroidTest
25 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cotel/comonadic_ui/matchers.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import android.support.test.espresso.assertion.ViewAssertions
4 | import android.support.test.espresso.matcher.BoundedMatcher
5 | import android.view.View
6 | import android.widget.TextView
7 | import com.agoda.kakao.TextViewAssertions
8 | import org.hamcrest.Description
9 | import org.hamcrest.Matcher
10 |
11 | fun withPaintFlag(paintFlags: Int): Matcher =
12 | object : BoundedMatcher(TextView::class.java) {
13 | override fun describeTo(description: Description) {
14 | description.appendText("with paint flag: ")
15 | }
16 |
17 | override fun matchesSafely(item: TextView): Boolean =
18 | (item.paintFlags and paintFlags) == paintFlags
19 | }
20 |
21 | fun TextViewAssertions.withPaintFlag(paintFlags: Int) {
22 | view.check(ViewAssertions.matches(cotel.comonadic_ui.withPaintFlag(paintFlags)))
23 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import kotlinx.android.synthetic.main.activity_main.*
6 |
7 | class MainActivity : AppCompatActivity(),
8 | TodosListFragment.TodosListDelegate,
9 | NewTodoFragment.NewTodoDelegate {
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | setContentView(R.layout.activity_main)
14 | setSupportActionBar(toolbar)
15 |
16 | supportFragmentManager.beginTransaction()
17 | .replace(R.id.fragment_container, TodosListFragment.newInstance())
18 | .commit()
19 | }
20 |
21 | override fun onTodosListAttached() {
22 | toolbar.title = getString(R.string.app_name)
23 | supportActionBar!!.setDisplayHomeAsUpEnabled(false)
24 | }
25 |
26 | override fun onNewTodoAttached() {
27 | supportActionBar!!.setDisplayHomeAsUpEnabled(true)
28 | toolbar.setNavigationOnClickListener {
29 | supportFragmentManager!!.popBackStack()
30 | }
31 | toolbar.title = "New Todo"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_todo.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
24 |
25 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/TodosAdapter.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import android.graphics.Paint
4 | import android.support.v7.widget.RecyclerView
5 | import android.view.LayoutInflater
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import kotlinx.android.synthetic.main.item_todo.view.*
9 |
10 | class TodosAdapter(
11 | private val onItemClick: (Todo) -> Unit,
12 | private val onRemoveClick: (Todo) -> Unit
13 | ) :
14 | RecyclerView.Adapter() {
15 |
16 | private var todos: List = emptyList()
17 |
18 | fun setTodos(todos: List) {
19 | this.todos = todos
20 | notifyDataSetChanged()
21 | }
22 |
23 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder =
24 | ViewHolder(
25 | LayoutInflater.from(parent.context)
26 | .inflate(R.layout.item_todo, parent, false)
27 | )
28 |
29 | override fun getItemCount(): Int = todos.size
30 |
31 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
32 | holder.bind(todos[position], onItemClick, onRemoveClick)
33 | }
34 |
35 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
36 | fun bind(todo: Todo, onItemClick: (Todo) -> Unit, onRemoveClick: (Todo) -> Unit) {
37 | with(itemView) {
38 | todo_title.text = todo.title
39 |
40 | if (todo.isCompleted) {
41 | todo_title.paintFlags = todo_title.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
42 | } else {
43 | todo_title.paintFlags = 0
44 | }
45 |
46 | setOnClickListener { onItemClick(todo) }
47 | todo_remove_button.setOnClickListener { onRemoveClick(todo) }
48 | }
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/NewTodoFragment.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import android.content.Context
4 | import android.os.Bundle
5 | import android.support.v4.app.DialogFragment
6 | import android.support.v4.app.Fragment
7 | import android.support.v7.app.AppCompatActivity
8 | import android.support.v7.widget.Toolbar
9 | import android.view.LayoutInflater
10 | import android.view.View
11 | import android.view.ViewGroup
12 | import kotlinx.android.synthetic.main.activity_main.*
13 | import kotlinx.android.synthetic.main.fragment_new_todo.*
14 |
15 | class NewTodoFragment : Fragment() {
16 |
17 | companion object {
18 | fun newInstance(): NewTodoFragment = NewTodoFragment()
19 | }
20 |
21 | interface NewTodoDelegate {
22 | fun onNewTodoAttached()
23 | }
24 |
25 | override fun onCreateView(
26 | inflater: LayoutInflater, container: ViewGroup?,
27 | savedInstanceState: Bundle?
28 | ): View? = inflater.inflate(R.layout.fragment_new_todo, container, false)
29 |
30 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
31 | super.onViewCreated(view, savedInstanceState)
32 |
33 | submit_todo_button.setOnClickListener { handleSubmitPressed() }
34 | }
35 |
36 | override fun onResume() {
37 | super.onResume()
38 |
39 | (activity as NewTodoDelegate).onNewTodoAttached()
40 | }
41 |
42 | private fun handleSubmitPressed() {
43 | val todoTitle = todo_title_input.text.toString()
44 |
45 | if (todoTitle.isNotBlank()) {
46 | val currentState = ServiceLocator.todosState
47 | ServiceLocator.todosState = currentState
48 | .copy(todos = currentState.todos + Todo(todoTitle))
49 |
50 | fragmentManager!!.popBackStack()
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 |
7 | android {
8 | compileSdkVersion 27
9 | defaultConfig {
10 | applicationId "cotel.comonadic_ui"
11 | minSdkVersion 21
12 | targetSdkVersion 27
13 | versionCode 1
14 | versionName "1.0"
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: 'libs', include: ['*.jar'])
27 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
28 | implementation 'com.android.support:appcompat-v7:27.1.1'
29 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
30 | implementation 'com.android.support:design:27.1.1'
31 | implementation 'com.android.support:support-v4:27.1.1'
32 |
33 | testImplementation 'junit:junit:4.12'
34 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
35 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
36 | androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
37 | androidTestImplementation 'com.agoda.kakao:kakao:1.4.0'
38 | androidTestImplementation "io.mockk:mockk-android:1.8.9"
39 |
40 |
41 | implementation "io.arrow-kt:arrow-core:0.7.3"
42 | implementation "io.arrow-kt:arrow-data:0.7.3"
43 | implementation "io.arrow-kt:arrow-instances-core:0.7.3"
44 | implementation "io.arrow-kt:arrow-instances-data:0.7.3"
45 | implementation "io.arrow-kt:arrow-syntax:0.7.3"
46 | implementation "io.arrow-kt:arrow-typeclasses:0.7.3"
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
21 |
22 |
33 |
34 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_new_todo.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
31 |
36 |
37 |
38 |
47 |
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Android Comonadic UI
2 |
3 | An Android application implemented in a declarative way bringing some concepts from [Comonadic Declarative UIs](https://functorial.com/the-future-is-comonadic/main.pdf) using [Λrrow](http://arrow-kt.io).
4 |
5 |
6 | ### What is a Comonad?
7 |
8 | Comonads are the dual of [Monads](https://arrow-kt.io/docs/patterns/monads/).
9 |
10 | > A Comonad represents a Space of points. We can consider a UI as a Space of states. So we can build a UI with a Comonad as it is a Space of all possible points, and user actions are movements inside this Space. [Source](https://speakerdeck.com/wuct/from-declarative-uis-to-comonadic-uis)
11 |
12 | For example, [`Store`](app/src/main/java/cotel/comonadic_ui/datatypes/Store.kt) is a comonadic datatype which holds a state and a render function (lambda) for giving a visual representation of its state. We can `extract()` the Comonad which means giving a representation of the current point in the Space. We can also `move(newState)` the Comonad inside the Space.
13 |
14 | ```kotlin
15 | class MainActivity : Activity() {
16 |
17 | var greetingComponent: Store by observable(Store(initialState = "John Doe") { state ->
18 | user_name_textview.text = state
19 | }) { _, _, new -> new.extract() }
20 |
21 | override fun onCreate(savedInstanceState: Bundle?) {
22 | super.onCreate(savedInstanceState)
23 | setContentView(R.layout.activity_main)
24 |
25 | greetingComponent.extract() // The textview should show "John Doe"
26 | greetingComponent = greetingComponent.move("A new name") // The textview should show "A new name"
27 | }
28 | }
29 | ```
30 |
31 | This declarative approach is similar to other libraries and languages for frontend applications like React, Elm, Halogen, etc.
32 |
33 | :medal_sports: The Future is Comonadic :medal_sports:
34 |
35 |
36 | ### Scope
37 |
38 | This app is a classical TODOs manager example. The core features are:
39 |
40 | * Showing a list of TODOs. If there are no tasks then an empty case should be shown.
41 | * Marking a TODO as completed. It's title should be struck through.
42 | * Deleting a TODO.
43 | * Creating new TODOs.
44 |
45 | In the future we will add more features for showing how we can interact with the Android framework with a declarative approach.
46 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cotel/comonadic_ui/TodosListFragmentTest.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import android.graphics.Paint
4 | import android.support.test.espresso.Espresso.onView
5 | import android.support.test.espresso.matcher.ViewMatchers.withId
6 | import android.support.test.rule.ActivityTestRule
7 | import android.support.test.runner.AndroidJUnit4
8 | import android.view.View
9 | import com.agoda.kakao.KButton
10 | import com.agoda.kakao.KRecyclerItem
11 | import com.agoda.kakao.KRecyclerView
12 | import com.agoda.kakao.KTextView
13 | import com.agoda.kakao.Screen
14 | import org.hamcrest.Matcher
15 | import org.junit.Assert.assertTrue
16 | import org.junit.Rule
17 | import org.junit.Test
18 | import org.junit.runner.RunWith
19 |
20 | @RunWith(AndroidJUnit4::class)
21 | class TodosListFragmentTest {
22 |
23 | @Rule
24 | @JvmField
25 | val rule = ActivityTestRule(MainActivity::class.java, true, false)
26 |
27 | val todosListScreen = TodosListScreen()
28 |
29 |
30 | @Test
31 | fun should_show_empty_case_if_there_are_no_todos() {
32 | givenNoTodos()
33 |
34 | rule.launchActivity(null)
35 |
36 | todosListScreen {
37 | emptyCase {
38 | isVisible()
39 | }
40 | }
41 | }
42 |
43 | @Test
44 | fun should_show_two_items_if_there_are_two_todos() {
45 | givenTwoTodos()
46 |
47 | rule.launchActivity(null)
48 |
49 | todosListScreen {
50 | emptyCase { isNotDisplayed() }
51 |
52 | todosList {
53 | lastChild {
54 | title { hasText("Another todo") }
55 | }
56 | }
57 | }
58 | }
59 |
60 | @Test
61 | fun should_mark_one_item_with_stroken_title_when_clicking_todo() {
62 | givenTwoTodos()
63 |
64 | rule.launchActivity(null)
65 |
66 | todosListScreen {
67 | todosList {
68 | firstChild {
69 | click()
70 |
71 | title {
72 | hasText("One todo")
73 |
74 | withPaintFlag(Paint.STRIKE_THRU_TEXT_FLAG)
75 | }
76 | }
77 | }
78 | }
79 | }
80 |
81 | @Test
82 | fun should_remove_one_item_if_todo_remove_button_is_pressed() {
83 | givenTwoTodos()
84 |
85 | rule.launchActivity(null)
86 |
87 | todosListScreen {
88 | todosList {
89 | firstChild {
90 | removeBtn { click() }
91 | }
92 |
93 | hasSize(1)
94 | }
95 | }
96 | }
97 |
98 | private fun givenNoTodos() {
99 | ServiceLocator.todosState = TodosState(emptyList())
100 | }
101 |
102 | private fun givenTwoTodos() {
103 | ServiceLocator.todosState = TodosState(listOf(
104 | Todo("One todo"),
105 | Todo("Another todo")
106 | ))
107 | }
108 |
109 | class TodosListScreen : Screen() {
110 | val emptyCase: KTextView = KTextView { withId(R.id.todos_empty_case) }
111 | val todosList: KRecyclerView = KRecyclerView(
112 | { withId(R.id.todos_list) },
113 | itemTypeBuilder = {
114 | itemType(::TodoItem)
115 | }
116 | )
117 |
118 | class TodoItem(parent: Matcher) : KRecyclerItem(parent) {
119 | val title: KTextView = KTextView(parent) { withId(R.id.todo_title) }
120 | val removeBtn: KButton = KButton(parent) { withId(R.id.todo_remove_button) }
121 | }
122 | }
123 |
124 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/cotel/comonadic_ui/NewTodoRecordedTest.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import android.support.test.espresso.Espresso.onView
4 | import android.support.test.espresso.action.ViewActions.click
5 | import android.support.test.espresso.action.ViewActions.closeSoftKeyboard
6 | import android.support.test.espresso.action.ViewActions.replaceText
7 | import android.support.test.espresso.assertion.ViewAssertions.matches
8 | import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
9 | import android.support.test.espresso.matcher.ViewMatchers.withId
10 | import android.support.test.espresso.matcher.ViewMatchers.withText
11 | import android.support.test.filters.LargeTest
12 | import android.support.test.rule.ActivityTestRule
13 | import android.support.test.runner.AndroidJUnit4
14 | import android.view.View
15 | import android.view.ViewGroup
16 | import org.hamcrest.Description
17 | import org.hamcrest.Matcher
18 | import org.hamcrest.Matchers.allOf
19 | import org.hamcrest.TypeSafeMatcher
20 | import org.junit.Rule
21 | import org.junit.Test
22 | import org.junit.runner.RunWith
23 |
24 | @LargeTest
25 | @RunWith(AndroidJUnit4::class)
26 | class NewTodoRecordedTest {
27 |
28 | @Rule
29 | @JvmField
30 | var mActivityTestRule = ActivityTestRule(MainActivity::class.java)
31 |
32 | @Test
33 | fun should_add_a_new_todo_to_the_list_after_navigating_to_creation_screen() {
34 | val floatingActionButton = onView(
35 | allOf(withId(R.id.fab),
36 | childAtPosition(
37 | childAtPosition(
38 | withId(R.id.fragment_container),
39 | 0),
40 | 2),
41 | isDisplayed()))
42 | floatingActionButton.perform(click())
43 |
44 | val textInputEditText = onView(
45 | allOf(withId(R.id.todo_title_input),
46 | childAtPosition(
47 | childAtPosition(
48 | withId(R.id.todo_title_input_layout),
49 | 0),
50 | 0),
51 | isDisplayed()))
52 | textInputEditText.perform(replaceText("test todo"), closeSoftKeyboard())
53 |
54 | val appCompatButton = onView(
55 | allOf(withId(R.id.submit_todo_button), withText("Create todo"),
56 | childAtPosition(
57 | childAtPosition(
58 | withId(R.id.fragment_container),
59 | 0),
60 | 2),
61 | isDisplayed()))
62 | appCompatButton.perform(click())
63 |
64 | val recyclerView = onView(
65 | allOf(withId(R.id.todos_list),
66 | childAtPosition(
67 | childAtPosition(
68 | withId(R.id.fragment_container),
69 | 0),
70 | 0),
71 | isDisplayed()))
72 | recyclerView.check(matches(isDisplayed()))
73 |
74 | val textView = onView(
75 | allOf(withId(R.id.todo_title), withText("test todo"),
76 | childAtPosition(
77 | childAtPosition(
78 | withId(R.id.todos_list),
79 | 0),
80 | 0),
81 | isDisplayed()))
82 | textView.check(matches(withText("test todo")))
83 | }
84 |
85 | private fun childAtPosition(
86 | parentMatcher: Matcher, position: Int): Matcher {
87 |
88 | return object : TypeSafeMatcher() {
89 | override fun describeTo(description: Description) {
90 | description.appendText("Child at position $position in parent ")
91 | parentMatcher.describeTo(description)
92 | }
93 |
94 | public override fun matchesSafely(view: View): Boolean {
95 | val parent = view.parent
96 | return parent is ViewGroup && parentMatcher.matches(parent)
97 | && view == parent.getChildAt(position)
98 | }
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/cotel/comonadic_ui/TodosListFragment.kt:
--------------------------------------------------------------------------------
1 | package cotel.comonadic_ui
2 |
3 | import android.os.Bundle
4 | import android.support.v4.app.Fragment
5 | import android.support.v7.widget.LinearLayoutManager
6 | import android.view.LayoutInflater
7 | import android.view.View
8 | import android.view.ViewGroup
9 | import cotel.comonadic_ui.datatypes.Moore
10 | import cotel.comonadic_ui.datatypes.Store
11 | import kotlinx.android.synthetic.main.content_main.*
12 |
13 | class TodosListFragment : Fragment() {
14 |
15 | companion object {
16 | fun newInstance(): TodosListFragment = TodosListFragment()
17 | }
18 |
19 | interface TodosListDelegate {
20 | fun onTodosListAttached()
21 | }
22 |
23 | private fun handleUpdate(input: TodoInputs): Moore> =
24 | when (input) {
25 | is AddTodo -> {
26 | ServiceLocator.todosState = ServiceLocator.todosState
27 | .copy(todos = ServiceLocator.todosState.todos + input.todo)
28 | Moore(
29 | todosMoore.state.move(todosMoore.state.state.addTodo(input.todo)),
30 | ::handleUpdate
31 | )
32 | }
33 |
34 | is UpdateTodo -> {
35 | ServiceLocator.todosState = ServiceLocator.todosState
36 | .copy(todos = ServiceLocator.todosState.todos.map { todo ->
37 | if (todo.id == input.todo.id) input.todo else todo
38 | })
39 | Moore(
40 | todosMoore.state.move(todosMoore.state.state.updateTodo(input.todo)),
41 | ::handleUpdate
42 | )
43 | }
44 |
45 | is RemoveTodo -> {
46 | ServiceLocator.todosState = ServiceLocator.todosState
47 | .copy(todos = ServiceLocator.todosState.todos.filterNot { todo ->
48 | todo.id == input.todo.id
49 | })
50 | Moore(
51 | todosMoore.state.move(todosMoore.state.state.removeTodo(input.todo)),
52 | ::handleUpdate
53 | )
54 | }
55 | }
56 |
57 | private var todosMoore = Moore(Store(ServiceLocator.todosState) {
58 | adapter.setTodos(it.todos)
59 | if (it.todos.isNotEmpty()) {
60 | todos_empty_case.visibility = View.GONE
61 | } else {
62 | todos_empty_case.visibility = View.VISIBLE
63 | }
64 | }, ::handleUpdate)
65 |
66 | private val adapter = TodosAdapter(::handleTodoClicked, ::handleTodoRemoveClicked)
67 |
68 | override fun onCreateView(
69 | inflater: LayoutInflater,
70 | container: ViewGroup?,
71 | savedInstanceState: Bundle?
72 | ): View? = inflater.inflate(R.layout.content_main, container, false)
73 |
74 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
75 | super.onViewCreated(view, savedInstanceState)
76 |
77 | todos_list.let {
78 | it.adapter = adapter
79 | it.layoutManager = LinearLayoutManager(context)
80 | it.adapter.notifyDataSetChanged()
81 | }
82 |
83 | fab.setOnClickListener {
84 | fragmentManager!!.beginTransaction()
85 | .addToBackStack(null)
86 | .replace(R.id.fragment_container, NewTodoFragment.newInstance())
87 | .commit()
88 | }
89 | }
90 |
91 | override fun onResume() {
92 | super.onResume()
93 |
94 | (activity!! as TodosListDelegate).onTodosListAttached()
95 | (ServiceLocator.todosState.todos - todosMoore.state.state.todos).forEach {
96 | dispatch(AddTodo(it))
97 | }
98 | render()
99 | }
100 |
101 | private fun render() {
102 | todosMoore.extract().extract()
103 | }
104 |
105 | private fun dispatch(event: TodoInputs) {
106 | todosMoore = todosMoore.handle(event)
107 | }
108 |
109 | private fun handleTodoClicked(todo: Todo) {
110 | val newTodo = todo.copy(isCompleted = !todo.isCompleted)
111 | dispatch(UpdateTodo(newTodo))
112 |
113 | render()
114 | }
115 |
116 | private fun handleTodoRemoveClicked(todo: Todo) {
117 | dispatch(RemoveTodo(todo))
118 |
119 | render()
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------