Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
811f57b
refactor: Removes .idea files as it's workspace specific and not reco…
subbramanil May 17, 2019
ae6dd61
fix: Addresses gradle warning about order of enabling plugins
subbramanil May 17, 2019
1e1dbb7
chore: Upgrades version number of dependencies & plugins
subbramanil May 17, 2019
1c58001
feat: Adds Column to store Task Status and adds migration strategy to…
subbramanil May 17, 2019
8eea806
feat: Updates Task UI to enable 'Done' using checkbox
subbramanil May 17, 2019
a85d1e1
chore: Updates git ignore to ignore workspace specific '.idea' files
subbramanil May 17, 2019
38bec12
fix: Changes the task status from integer to boolean and follow up th…
subbramanil May 17, 2019
45562af
feat: Delete tasks on completing the task
subbramanil May 29, 2019
fcdcc10
Merge branch 'master' of github.com:subbramanil/SimpleToDo into featu…
subbramanil May 29, 2019
c71352c
feat: Adds Testcases for TaskDao
subbramanil May 29, 2019
1c9da48
Merge branch 'master' of github.com:subbramanil/SimpleToDo into featu…
subbramanil Jan 8, 2020
4b294cc
chore: updates gradle plugin versions & libraries to the latest versions
subbramanil Jan 8, 2020
5a8779f
fix: upgrading gradle plugin breaks the build, so downgrading to 3.4.0
subbramanil Jan 8, 2020
f0dbf8f
feat: adds translated string values for completing a task
subbramanil Jan 8, 2020
037c58e
feat: adds method to get all open tasks
subbramanil Jan 8, 2020
20b3e55
feat: adds a method to complete the task
subbramanil Jan 8, 2020
5d15f36
feat: adds a screen to see the completed tasks
subbramanil Jan 9, 2020
eae8cc2
feat: updates icon for completed task
subbramanil Jan 9, 2020
e510040
fix: fixes the bug in search screen
subbramanil Jan 9, 2020
7790732
fix: updates the database version to the correct number (5 to 4)
subbramanil Jan 9, 2020
f650bd5
feat: disables editing a completed task in the edit task screen
subbramanil Jan 10, 2020
028f7a8
feat: updates swipe actions & fix a bug on 'undo'ing a completed task
subbramanil Jan 10, 2020
8f0b614
fix: updates the completed task messages to be consistent with other …
subbramanil Jan 10, 2020
c7da33f
feat: adds swipe feature to completed tasks screen
subbramanil Jan 10, 2020
a78f260
fix: removes unnecessary toasts
subbramanil Jan 10, 2020
24fcf38
fix: updates the message when task is moved back to Open & renames th…
subbramanil Jan 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.iml
.idea/
.gradle
/local.properties
/.idea/workspace.xml
Expand All @@ -7,4 +8,4 @@
/build
/captures
.externalNativeBuild
/app/google-services.json
/app/google-services.json
40 changes: 0 additions & 40 deletions .idea/assetWizardSettings.xml

This file was deleted.

Binary file removed .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 0 additions & 4 deletions .idea/encodings.xml

This file was deleted.

18 changes: 0 additions & 18 deletions .idea/gradle.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

16 changes: 13 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'

Expand Down Expand Up @@ -39,7 +39,7 @@ dependencies {
// UI
implementation "androidx.appcompat:appcompat:$rootProject.appcompatVersion"
implementation "com.google.android.material:material:$rootProject.materialVersion"
implementation "androidx.cardview:cardview:$rootProject.androidxVersion"
implementation "androidx.cardview:cardview:$rootProject.cardViewVersion"
implementation "androidx.preference:preference:$rootProject.androidxVersion"
implementation "com.github.XunMengWinter:CircularAnim:$rootProject.circularAnimVersion"
implementation "com.github.Daio-io:dresscode:$rootProject.dresscodeVersion"
Expand All @@ -66,8 +66,18 @@ dependencies {

// Lifecycle components
implementation "android.arch.lifecycle:extensions:$rootProject.lifecycleVersion"
annotationProcessor "android.arch.lifecycle:compiler:$rootProject.lifecycleVersion"
kapt "android.arch.lifecycle:compiler:$rootProject.lifecycleVersion"

// Tests
testImplementation "junit:junit:$rootProject.junitVersion"

// Core library
androidTestImplementation 'androidx.test:core:1.1.0'

// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'

// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
}
126 changes: 126 additions & 0 deletions app/src/androidTest/java/apps/jizzu/simpletodo/TaskDAOTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package apps.jizzu.simpletodo

import android.content.Context
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import apps.jizzu.simpletodo.data.database.TaskDao
import apps.jizzu.simpletodo.data.database.TasksDatabase
import apps.jizzu.simpletodo.data.models.Task
import org.junit.After
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import java.io.IOException
import java.util.*

@RunWith(AndroidJUnit4::class)
class TaskDAOTest {

private lateinit var taskDao: TaskDao
private lateinit var tasksDatabase: TasksDatabase

@Before
fun createDb() {
val context = ApplicationProvider.getApplicationContext<Context>()
tasksDatabase = Room.inMemoryDatabaseBuilder(
context, TasksDatabase::class.java
).build()
taskDao = tasksDatabase.taskDAO()
}

@Test
fun testSaveTask() {
val task = Task(1, "", "", Date().time, 1, Date().time)
taskDao.saveTask(task)

val tasks = taskDao.getAllTasks()
assertEquals(1, tasks.size)
}

@Test
fun testGetAllTasks() {
var task = Task(1, "", "", Date().time, 1, Date().time)
taskDao.saveTask(task)

var tasks = taskDao.getAllTasks()
assertEquals(1, tasks.size)

task = Task(2, "", "", Date().time, 2, Date().time, false)
taskDao.saveTask(task)

tasks = taskDao.getAllTasks()
assertEquals(2, tasks.size)

task = Task(3, "", "", Date().time, 2, Date().time, true)
taskDao.saveTask(task)

tasks = taskDao.getAllTasks()
assertEquals(3, tasks.size)
}

@Test
fun testGetAllOpenTasks() {
var task = Task(1, "", "", Date().time, 1, Date().time)
taskDao.saveTask(task)

var tasks = taskDao.getAllOpenTasks()
assertEquals(1, tasks.size)

task = Task(2, "", "", Date().time, 2, Date().time, false)
taskDao.saveTask(task)

tasks = taskDao.getAllOpenTasks()
assertEquals(2, tasks.size)

task = Task(3, "", "", Date().time, 2, Date().time, true)
taskDao.saveTask(task)

tasks = taskDao.getAllOpenTasks()
assertEquals(2, tasks.size)
}

@Test
fun testUpdateTask() {
var tasks = taskDao.getAllTasks()
assertEquals(0, tasks.size)

val task = Task(1, "", "", Date().time, 1, Date().time)
taskDao.saveTask(task)

tasks = taskDao.getAllOpenTasks()
assertEquals("", tasks[0].title)

tasks[0].title = "Test"
taskDao.updateTask(tasks[0])

tasks = taskDao.getAllTasks()
assertEquals(1, tasks.size)
assertEquals("Test", tasks[0].title)
}

@Test
fun testUpdateStatusTask() {
var tasks = taskDao.getAllTasks()
assertEquals(0, tasks.size)

val task = Task(1, "Test Me", "Task to Complete", Date().time, 1, Date().time)
taskDao.saveTask(task)

tasks = taskDao.getAllOpenTasks()
assertFalse(tasks[0].taskStatus)

tasks[0].taskStatus = tasks[0].taskStatus.not()
taskDao.updateTask(tasks[0])

tasks = taskDao.getAllOpenTasks()
assertEquals(0, tasks.size)
}

@After
@Throws(IOException::class)
fun closeDb() {
tasksDatabase.close()
}
}
8 changes: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="apps.jizzu.simpletodo">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand All @@ -12,7 +13,8 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.Light">
android:theme="@style/AppTheme.Light"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity
android:name=".ui.view.MainActivity"
android:launchMode="singleTop"
Expand Down Expand Up @@ -47,6 +49,10 @@
android:name=".ui.view.SearchActivity"
android:screenOrientation="portrait" />

<activity
android:name=".ui.view.CompletedTasksActivity"
android:screenOrientation="portrait" />

<service
android:name=".service.widget.WidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ interface TaskDao {
@Query("DELETE FROM tasks_table")
fun deleteAllTasks()

@Query("SELECT * FROM tasks_table where task_status=0 ORDER BY task_position")
fun getAllOpenTasksLiveData(): LiveData<List<Task>>

@Query("SELECT * FROM tasks_table where task_status=1 ORDER BY task_position")
fun getAllCompletedTasksLiveData(): LiveData<List<Task>>

@Query("SELECT * FROM tasks_table ORDER BY task_position")
fun getAllTasksLiveData(): LiveData<List<Task>>

@Query("SELECT * FROM tasks_table ORDER BY task_position")
fun getAllTasks(): List<Task>

@Query("SELECT * FROM tasks_table where task_status=0 ORDER BY task_position")
fun getAllOpenTasks(): List<Task>

@Query("SELECT * FROM tasks_table WHERE task_title LIKE '%' || :searchText || '%'")
fun getTasksForSearch(searchText: String): LiveData<List<Task>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import io.reactivex.schedulers.Schedulers

class TaskListRepository(app: Application) {
private val mTaskDao = TasksDatabase.getInstance(app).taskDAO()
private val mAllTasksLiveData = mTaskDao.getAllTasksLiveData()
private val mAllOpenTasksLiveData = mTaskDao.getAllOpenTasksLiveData()
private val mAllCompletedTasksLiveData = mTaskDao.getAllCompletedTasksLiveData()

fun getAllTasksLiveData() = mAllTasksLiveData
fun getAllOpenTasksLiveData() = mAllOpenTasksLiveData
fun getAllCompletedTasksLiveData() = mAllCompletedTasksLiveData

fun deleteAllTasks() = Completable.fromCallable { mTaskDao.deleteAllTasks() }.subscribeOn(Schedulers.io()).subscribe()!!

Expand All @@ -32,4 +34,12 @@ class TaskListRepository(app: Application) {
.subscribeBy(onNext = { task -> taskList.add(task) })
return taskList
}

fun getAllOpenTasks(): ArrayList<Task> {
val taskList = arrayListOf<Task>()
Observable.fromCallable { mTaskDao.getAllOpenTasks() }.subscribeOn(Schedulers.io())
.flatMap { tasks -> Observable.fromIterable(tasks) }
.subscribeBy(onNext = { task -> taskList.add(task) })
return taskList
}
}
Loading