Commit b2247e7f authored by Joey's avatar Joey

data, ui: create modules out of core

* core will host generic util / base classes only
* data will host db and entities management
* ui will host app style configs, common resources and widgets
Signed-off-by: Joey's avatarJoey <bevilacquajoey@gmail.com>
parent f11ce8c8
Pipeline #59256436 passed with stages
in 17 minutes and 5 seconds
......@@ -21,13 +21,16 @@ jobs:
- run:
name: Assemble, lint and unit tests
command: ./gradlew check -PisCiBuild
# Store results
# Store report results
- store_artifacts:
path: app/build/reports
destination: app-reports
- store_artifacts:
path: core/build/reports
destination: core-reports
- store_artifacts:
path: data/build/reports
destination: data-reports
- store_artifacts:
path: export/build/reports
destination: export-reports
......@@ -40,10 +43,16 @@ jobs:
- store_artifacts:
path: settings/build/reports
destination: settings-reports
- store_artifacts:
path: ui/build/reports
destination: ui-reports
# Store test results
- store_test_results:
path: app/build/test-results
- store_test_results:
path: core/build/test-results
- store_test_results:
path: data/build/test-results
- store_test_results:
path: glucose/build/test-results
# Save build dir
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -52,6 +52,8 @@ android {
dependencies {
implementation project(':core')
implementation project(':data')
implementation project(':ui')
implementation project(':glucose')
implementation project(':insulin')
implementation project(':settings')
......
......@@ -11,10 +11,10 @@ package it.diab.viewmodels.glucose
import android.content.Context
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.test.core.app.ApplicationProvider
import it.diab.core.data.AppDatabase
import it.diab.core.data.repositories.GlucoseRepository
import it.diab.core.data.repositories.InsulinRepository
import it.diab.core.util.extensions.insulin
import it.diab.data.AppDatabase
import it.diab.data.repositories.GlucoseRepository
import it.diab.data.repositories.InsulinRepository
import it.diab.data.extensions.insulin
import it.diab.util.extensions.get
import it.diab.util.extensions.getWeekDay
import org.junit.Assert.assertEquals
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -11,10 +11,10 @@ package it.diab.viewmodels.glucose
import android.content.Context
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.test.core.app.ApplicationProvider
import it.diab.core.data.AppDatabase
import it.diab.core.data.entities.TimeFrame
import it.diab.core.data.repositories.GlucoseRepository
import it.diab.core.util.extensions.glucose
import it.diab.data.AppDatabase
import it.diab.data.entities.TimeFrame
import it.diab.data.repositories.GlucoseRepository
import it.diab.data.extensions.glucose
import it.diab.viewmodels.overview.OverviewViewModel
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
......
<!--
Copyright (c) 2018 Bevilacqua Joey
Copyright (c) 2019 Bevilacqua Joey
Licensed under the GNU GPLv3 license
......@@ -11,7 +11,7 @@
package="it.diab">
<application
android:name=".core.DiabApplication"
android:name=".DiabApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@mipmap/ic_launcher"
......
......@@ -6,13 +6,13 @@
* The text of the license can be found in the LICENSE file
* or at https://www.gnu.org/licenses/gpl.txt
*/
package it.diab.core
package it.diab
import android.app.Application
import android.preference.PreferenceManager
import it.diab.core.util.Activities.Settings.PREF_UI_STYLE
import it.diab.core.util.UIUtils
import it.diab.core.util.extensions.get
import it.diab.ui.util.UIUtils
@Suppress("unused")
class DiabApplication : Application() {
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -19,7 +19,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import it.diab.R
import it.diab.core.data.entities.Glucose
import it.diab.data.entities.Glucose
import it.diab.core.util.PreferencesUtil
import it.diab.core.util.event.Event
import it.diab.holders.GlucoseHolder
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -15,7 +15,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.paging.PagedListAdapter
import androidx.recyclerview.widget.DiffUtil
import it.diab.R
import it.diab.core.data.entities.Insulin
import it.diab.data.entities.Insulin
import it.diab.core.util.event.Event
import it.diab.holders.InsulinHolderCallbacks
import it.diab.holders.InsulinHolder
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -21,9 +21,9 @@ import androidx.paging.PagedList
import androidx.recyclerview.widget.RecyclerView
import it.diab.R
import it.diab.adapters.GlucoseListAdapter
import it.diab.core.data.entities.Glucose
import it.diab.core.data.repositories.GlucoseRepository
import it.diab.core.data.repositories.InsulinRepository
import it.diab.data.entities.Glucose
import it.diab.data.repositories.GlucoseRepository
import it.diab.data.repositories.InsulinRepository
import it.diab.core.util.event.Event
import it.diab.core.util.event.EventObserver
import it.diab.ui.TimeHeaderDecoration
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -18,8 +18,8 @@ import androidx.paging.PagedList
import androidx.recyclerview.widget.RecyclerView
import it.diab.R
import it.diab.adapters.InsulinAdapter
import it.diab.core.data.entities.Insulin
import it.diab.core.data.repositories.InsulinRepository
import it.diab.data.entities.Insulin
import it.diab.data.repositories.InsulinRepository
import it.diab.core.util.Activities
import it.diab.core.util.event.EventObserver
import it.diab.core.util.intentTo
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -29,8 +29,8 @@ import com.github.mikephil.charting.data.LineDataSet
import com.github.mikephil.charting.formatter.IValueFormatter
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet
import it.diab.R
import it.diab.core.data.entities.Glucose
import it.diab.core.data.repositories.GlucoseRepository
import it.diab.data.entities.Glucose
import it.diab.data.repositories.GlucoseRepository
import it.diab.core.override.BaseFitHandler
import it.diab.core.util.Activities
import it.diab.core.util.SystemUtil
......
......@@ -13,7 +13,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import it.diab.R
import it.diab.core.data.entities.Glucose
import it.diab.data.entities.Glucose
import it.diab.core.util.extensions.setPrecomputedText
class GlucoseHolder(
......
......@@ -13,7 +13,7 @@ import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import it.diab.R
import it.diab.core.data.entities.Insulin
import it.diab.data.entities.Insulin
class InsulinHolder(
view: View,
......
......@@ -29,8 +29,8 @@ import android.text.style.AbsoluteSizeSpan
import android.text.style.StyleSpan
import androidx.recyclerview.widget.RecyclerView
import it.diab.R
import it.diab.core.data.entities.Glucose
import it.diab.core.util.extensions.getCalendar
import it.diab.data.entities.Glucose
import it.diab.util.extensions.inSpans
import it.diab.util.extensions.withTranslation
import java.text.SimpleDateFormat
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -10,9 +10,9 @@ package it.diab.viewmodels.glucose
import androidx.annotation.VisibleForTesting
import androidx.paging.LivePagedListBuilder
import it.diab.core.data.entities.Insulin
import it.diab.core.data.repositories.GlucoseRepository
import it.diab.core.data.repositories.InsulinRepository
import it.diab.data.entities.Insulin
import it.diab.data.repositories.GlucoseRepository
import it.diab.data.repositories.InsulinRepository
import it.diab.core.viewmodels.ScopedViewModel
import it.diab.util.extensions.diff
import it.diab.util.extensions.getWeekDay
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -10,8 +10,8 @@ package it.diab.viewmodels.glucose
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import it.diab.core.data.repositories.GlucoseRepository
import it.diab.core.data.repositories.InsulinRepository
import it.diab.data.repositories.GlucoseRepository
import it.diab.data.repositories.InsulinRepository
class GlucoseListViewModelFactory(
private val glucoseRepository: GlucoseRepository,
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -9,7 +9,7 @@
package it.diab.viewmodels.insulin
import androidx.paging.LivePagedListBuilder
import it.diab.core.data.repositories.InsulinRepository
import it.diab.data.repositories.InsulinRepository
import it.diab.core.viewmodels.ScopedViewModel
class InsulinViewModel internal constructor(
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -10,7 +10,7 @@ package it.diab.viewmodels.insulin
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import it.diab.core.data.repositories.InsulinRepository
import it.diab.data.repositories.InsulinRepository
class InsulinViewModelFactory(
private val insulinRepository: InsulinRepository
......
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -11,12 +11,12 @@ package it.diab.viewmodels.overview
import android.annotation.SuppressLint
import androidx.annotation.VisibleForTesting
import com.github.mikephil.charting.data.Entry
import it.diab.core.data.entities.Glucose
import it.diab.core.data.entities.TimeFrame
import it.diab.core.data.repositories.GlucoseRepository
import it.diab.data.entities.Glucose
import it.diab.data.entities.TimeFrame
import it.diab.data.repositories.GlucoseRepository
import it.diab.core.override.BaseFitHandler
import it.diab.core.util.DateUtils
import it.diab.core.util.extensions.toTimeFrame
import it.diab.data.extensions.toTimeFrame
import it.diab.core.viewmodels.ScopedViewModel
import it.diab.util.extensions.getAsMinutes
import it.diab.util.extensions.isToday
......
......@@ -10,7 +10,7 @@ package it.diab.viewmodels.overview
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import it.diab.core.data.repositories.GlucoseRepository
import it.diab.data.repositories.GlucoseRepository
class OverviewViewModelFactory(
private val glucoseRepository: GlucoseRepository
......
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2018 Bevilacqua Joey
Copyright (c) 2019 Bevilacqua Joey
Licensed under the GNU GPLv3 license
The text of the license can be found in the LICENSE file
or at https://www.gnu.org/licenses/gpl.txt
-->
<it.diab.core.ui.RecyclerViewExt xmlns:android="http://schemas.android.com/apk/res/android"
<it.diab.ui.widgets.RecyclerViewExt xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/glucose_recyclerview"
android:layout_width="match_parent"
......
<!--
Copyright (c) 2018 Bevilacqua Joey
Copyright (c) 2019 Bevilacqua Joey
Licensed under the GNU GPLv3 license
The text of the license can be found in the LICENSE file
or at https://www.gnu.org/licenses/gpl.txt
-->
<it.diab.core.ui.RecyclerViewExt xmlns:android="http://schemas.android.com/apk/res/android"
<it.diab.ui.widgets.RecyclerViewExt xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/insulin_list"
......
......@@ -20,10 +20,6 @@ android {
targetSdkVersion 28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
kapt.arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}
compileOptions {
......@@ -42,24 +38,7 @@ dependencies {
// Architecture
api "androidx.lifecycle:lifecycle-extensions:2.0.0"
kapt "androidx.lifecycle:lifecycle-compiler:2.0.0"
api "androidx.room:room-runtime:2.0.0"
kapt "androidx.room:room-compiler:2.0.0"
api "androidx.paging:paging-runtime:2.1.0"
// AppCompat
api "androidx.appcompat:appcompat:1.0.2"
// UI
api "com.google.android.material:material:1.0.0"
api "androidx.constraintlayout:constraintlayout:2.0.0-alpha5"
}
// Testing dependencies
apply from: "../deps_test.gradle"
repositories {
google()
mavenCentral()
}
\ No newline at end of file
......@@ -6,13 +6,4 @@
The text of the license can be found in the LICENSE file
or at https://www.gnu.org/licenses/gpl.txt
-->
<manifest package="it.diab.core"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:name=".DiabApplication"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning" />
</manifest>
<manifest package="it.diab.core" />
/*
* Copyright (c) 2018 Bevilacqua Joey
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
......@@ -9,7 +9,6 @@
package it.diab.core.override
import android.content.Context
import it.diab.core.data.entities.Glucose
/**
* Base class for Fitness services integration.
......@@ -41,7 +40,7 @@ open class BaseFitHandler {
*/
open fun upload(
context: Context,
glucose: Glucose,
item: Any,
isNew: Boolean,
onSuccess: () -> Unit,
onFailure: (Exception) -> Unit
......
......@@ -8,21 +8,11 @@
*/
package it.diab.core.util.extensions
import it.diab.core.data.entities.TimeFrame
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
import java.util.Locale
fun Date.asTimeFrame() = when (getHour()) {
in 6..9 -> TimeFrame.MORNING
in 10..11 -> TimeFrame.LATE_MORNING
in 12..13 -> TimeFrame.LUNCH
in 14..18 -> TimeFrame.AFTERNOON
in 19..20 -> TimeFrame.DINNER
else -> TimeFrame.NIGHT
}
fun Date.format(format: String): String =
SimpleDateFormat(format, Locale.getDefault()).format(this)
......
......@@ -16,13 +16,4 @@
<!-- Time -->
<string name="time_today">आज</string>
<string name="time_yesterday">कल</string>
<!-- Time frame -->
<string name="time_extra">अतिरिक्त</string>
<string name="time_morning">सुबह</string>
<string name="time_late_morning">देर सुबह</string>
<string name="time_lunch">दोपहर का भोजन</string>
<string name="time_afternoon">दोपहर</string>
<string name="time_dinner">रात का खाना</string>
<string name="time_night">रात</string>
</resources>
......@@ -15,13 +15,4 @@
<!-- Time -->
<string name="time_today">Oggi</string>
<string name="time_yesterday">Ieri</string>
<!-- Time zone -->
<string name="time_extra">Extra</string>
<string name="time_morning">Mattina</string>
<string name="time_late_morning">Tarda mattinata</string>
<string name="time_lunch">Pranzo</string>
<string name="time_afternoon">Pomeriggio</string>
<string name="time_dinner">Cena</string>
<string name="time_night">Notte</string>
</resources>
\ No newline at end of file
......@@ -15,13 +15,4 @@
<!-- Time -->
<string name="time_today">Today</string>
<string name="time_yesterday">Yesterday</string>
<!-- Time frame -->
<string name="time_extra">Extra</string>
<string name="time_morning">Morning</string>
<string name="time_late_morning">Late morning</string>
<string name="time_lunch">Lunch</string>
<string name="time_afternoon">Afternoon</string>
<string name="time_dinner">Dinner</string>
<string name="time_night">Night</string>
</resources>
......@@ -8,8 +8,6 @@
*/
package it.diab.core.util
import it.diab.core.data.entities.TimeFrame
import it.diab.core.util.extensions.asTimeFrame
import it.diab.core.util.extensions.format
import it.diab.core.util.extensions.getCalendar
import it.diab.core.util.extensions.getHour
......@@ -19,20 +17,6 @@ import java.util.Calendar
class DateExtTest {
@Test
fun asTimeFrame() {
val calendar = Calendar.getInstance()
calendar[Calendar.HOUR_OF_DAY] = 8
assertEquals(TimeFrame.MORNING, calendar.time.asTimeFrame())
calendar[Calendar.HOUR_OF_DAY] = 18
assertEquals(TimeFrame.AFTERNOON, calendar.time.asTimeFrame())
calendar[Calendar.HOUR_OF_DAY] = 0
assertEquals(TimeFrame.NIGHT, calendar.time.asTimeFrame())
}
@Test
fun format() {
val calendar = Calendar.getInstance().apply {
......
/*
* Copyright (c) 2019 Bevilacqua Joey
*
* Licensed under the GNU GPLv3 license
*
* The text of the license can be found in the LICENSE file
* or at https://www.gnu.org/licenses/gpl.txt
*/
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
kapt.arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':core')
api "androidx.room:room-runtime:2.0.0"
kapt "androidx.room:room-compiler:2.0.0"
api "androidx.paging:paging-runtime:2.1.0"
}
// Testing dependencies
apply from: "../deps_test.gradle"
......@@ -6,16 +6,16 @@
* The text of the license can be found in the LICENSE file
* or at https://www.gnu.org/licenses/gpl.txt
*/
package it.diab.core.data
package it.diab.data
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import it.diab.core.data.dao.GlucoseDao
import it.diab.core.data.dao.InsulinDao
import it.diab.core.data.entities.Glucose
import it.diab.core.data.entities.TimeFrame
import it.diab.core.util.extensions.glucose
import it.diab.core.util.extensions.insulin
import it.diab.data.dao.GlucoseDao
import it.diab.data.dao.InsulinDao
import it.diab.data.entities.Glucose
import it.diab.data.entities.TimeFrame
import it.diab.data.extensions.glucose
import it.diab.data.extensions.insulin
import junit.framework.Assert.assertEquals
import org.junit.Before
import org.junit.Test
......
......@@ -6,12 +6,12 @@
* The text of the license can be found in the LICENSE file
* or at https://www.gnu.org/licenses/gpl.txt
*/
package it.diab.core.data.repositories
package it.diab.data.repositories
import androidx.test.platform.app.InstrumentationRegistry
import it.diab.core.data.AppDatabase
import it.diab.data.AppDatabase
import it.diab.core.util.DateUtils
import it.diab.core.util.extensions.glucose
import it.diab.data.extensions.glucose
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
......
......@@ -6,11 +6,11 @@
* The text of the license can be found in the LICENSE file
* or at https://www.gnu.org/licenses/gpl.txt
*/
package it.diab.core.data.repositories
package it.diab.data.repositories
import androidx.test.platform.app.InstrumentationRegistry
import it.diab.core.data.AppDatabase
import it.diab.core.util.extensions.hba1c
import it.diab.data.AppDatabase
import it.diab.data.extensions.hba1c
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
......
......@@ -6,11 +6,11 @@
* The text of the license can be found in the LICENSE file
* or at https://www.gnu.org/licenses/gpl.txt
*/
package it.diab.core.data.repositories
package it.diab.data.repositories
import androidx.test.platform.app.InstrumentationRegistry
import it.diab.core.data.AppDatabase
import it.diab.core.util.extensions.insulin
import it.diab.data.AppDatabase
import it.diab.data.extensions.insulin
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
......
<!--
Copyright (c) 2019 Bevilacqua Joey
Licensed under the GNU GPLv3 license