1
0
mirror of https://github.com/dzeiocom/OpenHealth.git synced 2025-06-07 07:19:54 +00:00

feat: Integrate the Custom Lib

This commit is contained in:
Florian Bouillon 2022-07-20 00:25:48 +02:00
parent 1f72b68a13
commit 04911dcd23
Signed by: Florian Bouillon
GPG Key ID: 0A288052C94BD2C8
5 changed files with 32 additions and 56 deletions

View File

@ -97,6 +97,9 @@ android {
}
dependencies {
// Dzeio Charts
implementation project(path: ":charts")
// Core dependencies
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
@ -135,6 +138,9 @@ dependencies {
// Graph
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
// Graphs test 2
implementation 'com.github.HackPlan:AndroidCharts:1.0.4'
// Hilt
implementation 'com.google.dagger:hilt-android:2.42'
kapt 'com.google.dagger:hilt-compiler:2.42'

View File

@ -41,7 +41,6 @@ class OpenHealthService : Service() {
)
private var mNM: NotificationManager? = null
private lateinit var notification: Notification
/**
* Displayed steps in the notification panel
@ -63,9 +62,7 @@ class OpenHealthService : Service() {
mNM = getSystemService(NOTIFICATION_SERVICE) as NotificationManager?
}
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
Log.i("LocalService", "Received start id $startId: $intent")
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
scope.launch {
val source = StepSource(this@OpenHealthService)
source.events.receiveAsFlow().collectLatest {
@ -130,7 +127,7 @@ class OpenHealthService : Service() {
.getPendingIntent(0, flag)
// Set the info for the views that show in the notification panel.
this.notification = NotificationCompat.Builder(
val notification = NotificationCompat.Builder(
this,
NotificationChannels.SERVICE.id
)

View File

@ -8,11 +8,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.dzeio.openhealth.adapters.StepsAdapter
import com.dzeio.openhealth.core.BaseFragment
import com.dzeio.openhealth.databinding.FragmentStepsHomeBinding
import com.dzeio.openhealth.utils.GraphUtils
import com.github.mikephil.charting.data.BarData
import com.github.mikephil.charting.data.BarDataSet
import com.github.mikephil.charting.data.BarEntry
import com.google.android.material.color.MaterialColors
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
@ -44,35 +39,21 @@ class StepsHomeFragment :
val chart = binding.chart
GraphUtils.barChartSetup(
chart,
MaterialColors.getColor(
requireView(),
com.google.android.material.R.attr.colorPrimary
),
MaterialColors.getColor(
requireView(),
com.google.android.material.R.attr.colorOnBackground
)
)
chart.xAxis.valueFormatter = GraphUtils.DateTimeValueFormatter()
viewModel.items.observe(viewLifecycleOwner) { list ->
adapter.set(list)
val dataset = BarDataSet(
list.map {
return@map BarEntry(
(it.timestamp).toFloat(),
it.value.toFloat()
)
},
""
)
val strings = ArrayList<String>()
val values = ArrayList<Int>()
chart.data = BarData(dataset)
chart.invalidate()
list.forEach {
strings.add(it.formatTimestamp())
values.add(it.value)
}
chart.setBottomTextList(strings)
chart.setDataList(
values
)
}
}
}

View File

@ -18,11 +18,11 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical">
<com.github.mikephil.charting.charts.BarChart
<view
class="com.dzeio.charts.BarView"
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="200dp"

View File

@ -1,26 +1,18 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# Default value: -Xmx1024m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
#Tue Jul 19 18:42:00 CEST 2022
android.nonTransitiveRClass=true
android.enableJetifier=false
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
org.gradle.unsafe.configuration-cache=true