mirror of
https://github.com/dzeiocom/OpenHealth.git
synced 2025-06-12 17:19:18 +00:00
feat: Continue work on Chart
This commit is contained in:
@ -142,8 +142,8 @@ dependencies {
|
||||
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'
|
||||
implementation 'com.google.dagger:hilt-android:2.43'
|
||||
kapt 'com.google.dagger:hilt-compiler:2.43'
|
||||
|
||||
// Google Fit
|
||||
implementation "com.google.android.gms:play-services-fitness:21.1.0"
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
<!-- Activity for error handling -->
|
||||
<activity android:name=".ui.ErrorActivity"
|
||||
android:theme="@style/Theme.OpenHealth.NoActionBar"
|
||||
android:theme="@style/Theme.OpenHealth"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
|
@ -5,12 +5,14 @@ import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
@ -25,6 +27,7 @@ import com.dzeio.openhealth.databinding.ActivityMainBinding
|
||||
import com.dzeio.openhealth.interfaces.NotificationChannels
|
||||
import com.dzeio.openhealth.services.OpenHealthService
|
||||
import com.dzeio.openhealth.workers.WaterReminderWorker
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
@ -52,6 +55,30 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
|
||||
setSupportActionBar(binding.toolbar)
|
||||
|
||||
window.navigationBarColor = MaterialColors.getColor(
|
||||
window.decorView,
|
||||
com.google.android.material.R.attr.colorSecondaryContainer
|
||||
)
|
||||
window.statusBarColor = MaterialColors.getColor(
|
||||
window.decorView,
|
||||
com.google.android.material.R.attr.colorSecondaryContainer
|
||||
)
|
||||
|
||||
when (this.resources.configuration.uiMode.and(Configuration.UI_MODE_NIGHT_MASK)) {
|
||||
Configuration.UI_MODE_NIGHT_YES -> {
|
||||
WindowCompat.getInsetsController(window, window.decorView).apply {
|
||||
isAppearanceLightNavigationBars = true
|
||||
isAppearanceLightStatusBars = false
|
||||
}
|
||||
}
|
||||
Configuration.UI_MODE_NIGHT_NO, Configuration.UI_MODE_NIGHT_UNDEFINED -> {
|
||||
WindowCompat.getInsetsController(window, window.decorView).apply {
|
||||
isAppearanceLightNavigationBars = false
|
||||
isAppearanceLightStatusBars = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val navHostFragment =
|
||||
supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
|
||||
|
||||
|
@ -4,12 +4,10 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.dzeio.charts.Entry
|
||||
import com.dzeio.charts.series.BarSerie
|
||||
import com.dzeio.openhealth.Application
|
||||
import com.dzeio.openhealth.R
|
||||
import com.dzeio.openhealth.adapters.StepsAdapter
|
||||
import com.dzeio.openhealth.core.BaseFragment
|
||||
import com.dzeio.openhealth.databinding.FragmentStepsHomeBinding
|
||||
@ -59,24 +57,44 @@ class StepsHomeFragment :
|
||||
viewModel.items.observe(viewLifecycleOwner) { list ->
|
||||
adapter.set(list)
|
||||
|
||||
chart.debug = true
|
||||
// chart.debug = true
|
||||
|
||||
chart.xAxis.entriesDisplayed = 10
|
||||
// chart.numberOfLabels = 2
|
||||
|
||||
// chart.animation.enabled = false
|
||||
chart.animation.refreshRate = 60
|
||||
chart.animation.duration = 500
|
||||
chart.animation.duration = 300
|
||||
|
||||
chart.scroller.zoomEnabled = false
|
||||
|
||||
chart.xAxis.labels.color = MaterialColors.getColor(
|
||||
requireView(),
|
||||
com.google.android.material.R.attr.colorOnBackground
|
||||
)
|
||||
|
||||
chart.xAxis.labels.size = 32f
|
||||
chart.yAxis.color = MaterialColors.getColor(
|
||||
requireView(),
|
||||
com.google.android.material.R.attr.colorPrimary
|
||||
)
|
||||
chart.yAxis.apply {
|
||||
color = MaterialColors.getColor(
|
||||
requireView(),
|
||||
com.google.android.material.R.attr.colorPrimary
|
||||
)
|
||||
textPaint.color = MaterialColors.getColor(
|
||||
requireView(),
|
||||
com.google.android.material.R.attr.colorOnBackground
|
||||
)
|
||||
linePaint.color = MaterialColors.getColor(
|
||||
requireView(),
|
||||
com.google.android.material.R.attr.colorOutline
|
||||
)
|
||||
onValueFormat = onValueFormat@{ value, short ->
|
||||
if (short) {
|
||||
return@onValueFormat value.toInt().toString()
|
||||
} else {
|
||||
return@onValueFormat "${value.toInt()} steps"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serie.datas = list.reversed().map {
|
||||
return@map Entry(it.timestamp.toDouble(), it.value.toFloat())
|
||||
@ -95,5 +113,21 @@ class StepsHomeFragment :
|
||||
|
||||
chart.refresh()
|
||||
}
|
||||
|
||||
// val scrollView = requireActivity().findViewById<NestedScrollView>(R.id.scrollView)
|
||||
// var scrollEnabled = false
|
||||
// scrollView.setOnTouchListener { view, _ ->
|
||||
// view.performClick()
|
||||
// if (scrollEnabled) {
|
||||
// } else {
|
||||
// return@setOnTouchListener !scrollEnabled
|
||||
// }
|
||||
// return@setOnTouchListener true
|
||||
// }
|
||||
|
||||
// binding.chart.setOnToggleScroll {
|
||||
// Log.d(TAG, it.toString())
|
||||
// scrollEnabled = it
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
|
||||
<!-- <item android:drawable="?colorPrimary" />-->
|
||||
<item android:drawable="?attr/backgroundColor" />
|
||||
<item
|
||||
android:width="133dp"
|
||||
android:gravity="center">
|
||||
|
@ -4,8 +4,8 @@
|
||||
android:height="512dp"
|
||||
android:viewportWidth="512"
|
||||
android:viewportHeight="512"
|
||||
android:tint="#FFFFFF">
|
||||
android:tint="?attr/backgroundColor">
|
||||
<path
|
||||
android:pathData="M0,0h512v512h-512z"
|
||||
android:fillColor="#FF000000"/>
|
||||
android:tint="#FF000000"/>
|
||||
</vector>
|
||||
|
@ -65,12 +65,4 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:menu="@menu/bottom_menu" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_begin="20dp" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
@ -1,17 +1,3 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.OpenHealth" parent="Theme.Material3.DynamicColors.DayNight">
|
||||
<!-- <!– Primary brand color. –>-->
|
||||
<!-- <item name="colorPrimary">@color/purple_200</item>-->
|
||||
<!-- <item name="colorPrimaryVariant">@color/purple_700</item>-->
|
||||
<!-- <item name="colorOnPrimary">@color/black</item>-->
|
||||
<!-- <!– Secondary brand color. –>-->
|
||||
<!-- <item name="colorSecondary">@color/teal_200</item>-->
|
||||
<!-- <item name="colorSecondaryVariant">@color/teal_200</item>-->
|
||||
<!-- <item name="colorOnSecondary">@color/black</item>-->
|
||||
<!-- <!– Status bar color. –>-->
|
||||
<!-- <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>-->
|
||||
<!-- <!– Customize your theme here. –>-->
|
||||
|
||||
</style>
|
||||
<resources>
|
||||
<style name="Theme.OpenHealth" parent="Theme.Material3.DynamicColors.DayNight" />
|
||||
</resources>
|
@ -1,10 +1,13 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<resources>
|
||||
|
||||
<style name="Theme.OpenHealth" parent="Theme.Material3.DayNight.NoActionBar" />
|
||||
<style name="Theme.OpenHealth" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.OpenHealth.NoActionBar" parent="Theme.OpenHealth">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="ShapeAppearance.OpenHealth.Corner.Medium" parent="">
|
||||
|
Reference in New Issue
Block a user