Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding chart to GDH #202

Open
wants to merge 115 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
025c0b3
add chart to phone
pachi81 Dec 20, 2024
bf193fa
chart as bitmap
pachi81 Jan 19, 2025
add18a2
Rename class
pachi81 Jan 20, 2025
fd5cb42
Chart time line added
pachi81 Jan 20, 2025
a8912de
Create chart data from LibreLinkUp
pachi81 Jan 21, 2025
e0609a7
Reset chart for GraphData changed
pachi81 Jan 21, 2025
b9440a2
Update gradle
pachi81 Jan 23, 2025
264f309
Chart creation asynch
pachi81 Jan 23, 2025
5b238b6
Using database
pachi81 Jan 24, 2025
6faf101
Fixes for chart
pachi81 Jan 26, 2025
feb99db
DB sync
pachi81 Jan 28, 2025
83741a4
Wear Graph
pachi81 Jan 28, 2025
b27bfd8
Refactor chart
pachi81 Jan 29, 2025
67ebf63
Chart complication
pachi81 Jan 29, 2025
cedf8c1
Fix chart exceptions
pachi81 Jan 30, 2025
cf3902e
Wear chart duration setting
pachi81 Jan 30, 2025
ae13c45
Wear chart activity
pachi81 Jan 30, 2025
1f9b5d7
Fix duplicate values
pachi81 Jan 31, 2025
e8cdd92
Complication Tap action: show graph
pachi81 Jan 31, 2025
3b9bb6c
Graph fixes
pachi81 Jan 31, 2025
f0dfa5b
Enable touch after drawing
pachi81 Feb 2, 2025
a263b6b
Wear Graph: only last 24h
pachi81 Feb 2, 2025
c2044b0
Fix x compare
pachi81 Feb 2, 2025
b82e3bc
Cleanup DB
pachi81 Feb 3, 2025
7b06d49
Mobile Layout adjust to graph
pachi81 Feb 3, 2025
e348d50
Cleanup db data
pachi81 Feb 4, 2025
33f0649
Graphdata for Nightscout and Dexcom Share
pachi81 Feb 6, 2025
7acce5b
Disable graph setting
pachi81 Feb 7, 2025
c5b6f5f
Delta and rate calculation
pachi81 Feb 8, 2025
9ccadca
Change foreground service startup
pachi81 Feb 9, 2025
99efa70
Hungarian translation
pachi81 Feb 9, 2025
a956b88
Added widget for WearOS device battery level
rwalker-bluebeck Dec 23, 2024
2b22e3e
Moved bettery level widget into it's own class. Updated BatteryReceiv…
rwalker-bluebeck Jan 8, 2025
8618594
Now using broadcaster to update widgets. Removed DeviceName field fro…
rwalker-bluebeck Jan 8, 2025
9bd7718
Only add notifiers if widgets present. Handle watch disconnection pro…
rwalker-bluebeck Jan 9, 2025
fa3ad9c
Removed init function from BatteryLevelWidgetNotifier. Added safety c…
rwalker-bluebeck Jan 9, 2025
a575b06
Use pickBestNodeId to get battery level
rwalker-bluebeck Jan 9, 2025
d1032c5
Change no value color and wear display-name
pachi81 Feb 9, 2025
ea51741
Use value colors for battery widget
pachi81 Feb 9, 2025
5c05d5c
5 degree steps for trend
pachi81 Feb 10, 2025
4d02d56
Revert "Change foreground service startup"
pachi81 Feb 11, 2025
05f2225
Graph widget
pachi81 Feb 12, 2025
238dc8b
Save and read calculated values
pachi81 Feb 12, 2025
a9a4f12
Graph in notification
pachi81 Feb 12, 2025
5f09fe7
Full alarm activity graph
pachi81 Feb 12, 2025
f665720
Fix notify graph changed
pachi81 Feb 13, 2025
747beaf
Change calculation for delta and rate
pachi81 Feb 13, 2025
04c57be
Floating widget with graph
pachi81 Feb 13, 2025
4bc484d
LockscreenWallpaper with graph
pachi81 Feb 13, 2025
c61e71d
Update Floating widget generation
pachi81 Feb 13, 2025
a5e9be7
Update strings.xml
Ginocar Feb 14, 2025
df7ba0c
Base class for Wallpaper creation
pachi81 Feb 14, 2025
1d5ce99
Merge remote-tracking branch 'origin/chart' into chart
pachi81 Feb 14, 2025
7842c56
Update strings.xml
Ginocar Feb 15, 2025
0be3a68
feat: NotificationSource to receive data from G7 and Omnipod 5 (#180)
rgodha24 Feb 16, 2025
85c9909
Move TapActionPref to SelectReceiverPref
pachi81 Feb 16, 2025
e2003aa
Settings for Notification Reader
pachi81 Feb 17, 2025
b54ea7d
5 minute interval
pachi81 Feb 17, 2025
985c545
Fix chart complication
pachi81 Feb 18, 2025
06e008c
Refactor Optimize Notification Reader
pachi81 Feb 19, 2025
ac60d41
Fix LockScreenWallpaper
pachi81 Feb 19, 2025
7bb06a7
Add Notification Dexcom Info
pachi81 Feb 19, 2025
2a12956
Tablet Landscape Layout
pachi81 Feb 20, 2025
a81df88
AOD support (#208)
RobertoW-UK Feb 20, 2025
4492ad8
Fix Dexcom Notification
pachi81 Feb 20, 2025
d740946
Merge remote-tracking branch 'origin/chart' into chart
pachi81 Feb 20, 2025
0e9e59c
Changes for AOD
pachi81 Feb 20, 2025
c5d44f0
Adjust settings for AOD, add Graph Duration
pachi81 Feb 20, 2025
96f2439
Adjust sizes
pachi81 Feb 20, 2025
ee32399
Change ScreenEventReceiver
pachi81 Feb 20, 2025
69d3bef
Disable Lockscreen while AOD
pachi81 Feb 21, 2025
78fabb8
Libre Sensor Age
pachi81 Feb 21, 2025
72b8a2b
Fix chart bitmap creation
pachi81 Feb 21, 2025
b933fba
Sensor Age resources
pachi81 Feb 21, 2025
a5cd2b6
Refactor Screen Event receiver
pachi81 Feb 21, 2025
6ab32e0
Using calculated rate for alarm calculation
pachi81 Feb 21, 2025
516b7ca
Sensor age
pachi81 Feb 21, 2025
aed13fe
Fix WP layout
pachi81 Feb 21, 2025
f43e5f5
Add device info to logcat
pachi81 Feb 21, 2025
0ec9c5f
Upgrade gradle to 8.8.1
pachi81 Feb 21, 2025
fc8a937
Short vibration pattern
pachi81 Feb 21, 2025
e5d2022
Fix permission request
pachi81 Feb 21, 2025
d9d05f9
Fix Dexcom notification reading
pachi81 Feb 21, 2025
7650734
Merge branch 'master' into chart
pachi81 Feb 21, 2025
56e6d53
Small changes
pachi81 Feb 21, 2025
c563eac
dev.6 version
pachi81 Feb 21, 2025
f99896e
Fix for Dexcom
pachi81 Feb 22, 2025
125bdb6
Adjust Lockscreen AOD size
pachi81 Feb 22, 2025
42a2a7f
New main layout
pachi81 Feb 22, 2025
243f144
Translation
pachi81 Feb 23, 2025
3166047
Fix fr
pachi81 Feb 23, 2025
7076914
Fix Dexcom notification
pachi81 Feb 24, 2025
93cc044
Update strings
pachi81 Feb 24, 2025
60d4c1b
Fix Widget/WP Layout
pachi81 Feb 25, 2025
c85a2f6
Fix Dexcom G6 notification reader
pachi81 Feb 25, 2025
c1eee7e
Fix chart widget layout
pachi81 Feb 25, 2025
94ae8c1
Increase text of battery widget
pachi81 Feb 25, 2025
5d272ba
Floating Widget: Lock position
pachi81 Feb 25, 2025
b6ae17c
Small changes
pachi81 Feb 25, 2025
8013ebd
Update strings.xml
Ginocar Feb 26, 2025
dba9f0a
Small changes
pachi81 Feb 26, 2025
a334842
Fix NotificationReader for Eversense
pachi81 Feb 26, 2025
0e8e08e
Merge remote-tracking branch 'origin/chart' into chart
pachi81 Feb 26, 2025
18f6d2f
Update strings.xml part 1 PL
froster82 Feb 27, 2025
a37c8dd
Merge remote-tracking branch 'origin/chart' into chart
pachi81 Feb 27, 2025
162449f
Update strings.xml Strings PL - final
froster82 Feb 27, 2025
a2e38ac
Show trend in main
pachi81 Feb 27, 2025
a2164e5
Fix missing strings
pachi81 Feb 27, 2025
2271ab0
Fix for notification
pachi81 Feb 27, 2025
8d40705
Merge remote-tracking branch 'origin/chart' into chart
pachi81 Feb 27, 2025
eee00bc
Fix string
pachi81 Feb 27, 2025
a9dcd8e
Fix adding old data to db
pachi81 Feb 27, 2025
bf0b34a
v2.0 (106)
pachi81 Feb 27, 2025
d90eb6d
Fix strings
pachi81 Feb 27, 2025
b789fbb
Update strings.xml One bug in PL corrected
froster82 Mar 2, 2025
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
Prev Previous commit
Next Next commit
Fixes for chart
pachi81 committed Jan 28, 2025
commit 6faf1018db28fc35cc37518f20a2d1b12640c0d6
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package de.michelinside.glucodatahandler.common.chart

import android.content.Context
import android.graphics.Bitmap
import android.os.Bundle
import android.util.Log
import com.github.mikephil.charting.data.LineData
import com.github.mikephil.charting.data.LineDataSet
import de.michelinside.glucodatahandler.common.Constants
import de.michelinside.glucodatahandler.common.database.dbAccess
import de.michelinside.glucodatahandler.common.notifier.InternalNotifier
import de.michelinside.glucodatahandler.common.notifier.NotifySource

class ChartBitmapCreator(chart: GlucoseChart, context: Context): ChartCreator(chart, context) {
private val LOG_ID = "GDH.Chart.BitmapCreator"
private var bitmap: Bitmap? = null
override val resetChart = true

override fun initXaxis() {
Log.v(LOG_ID, "initXaxis")
@@ -45,9 +52,18 @@ class ChartBitmapCreator(chart: GlucoseChart, context: Context): ChartCreator(ch
addEmptyTimeData()
chart.notifyDataSetChanged()
chart.invalidate()
chart.waitForInvalidate()
bitmap = createBitmap()
InternalNotifier.notify(context, NotifySource.GRAPH_CHANGED, Bundle().apply { putInt(Constants.GRAPH_ID, chart.id) })
}

override fun updateTimeElapsed() {
update(dbAccess.getGlucoseValues(getMinTime()))
}

fun getBitmap(): Bitmap? {
if(bitmap == null)
bitmap = createBitmap()
return bitmap
}
}
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import de.michelinside.glucodatahandler.common.notifier.InternalNotifier
import de.michelinside.glucodatahandler.common.notifier.NotifierInterface
import de.michelinside.glucodatahandler.common.notifier.NotifySource
import de.michelinside.glucodatahandler.common.utils.Utils
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@@ -33,6 +34,7 @@ import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import java.util.concurrent.TimeUnit
import kotlin.math.abs


open class ChartCreator(protected val chart: GlucoseChart, protected val context: Context): NotifierInterface,
@@ -43,8 +45,9 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
protected var init = false
protected var hasTimeNotifier = false
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
private var currentJob: Job? = null
private var createJob: Job? = null
private var dataSyncJob: Job? = null
protected open val resetChart = false

private var graphPrefList = mutableSetOf(
Constants.SHARED_PREF_LOW_GLUCOSE,
@@ -80,14 +83,18 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
}
}

fun create() {
if(currentJob?.isActive == true) {
private fun waitForCreation() {
if(createJob?.isActive == true) {
Log.d(LOG_ID, "waitForCreation - wait for current execution")
runBlocking {
Log.d(LOG_ID, "create - wait for current execution")
currentJob!!.join()
createJob!!.join()
}
}
currentJob = scope.launch {
}

fun create() {
waitForCreation()
createJob = scope.launch {
Log.d(LOG_ID, "create")
try {
init()
@@ -98,7 +105,7 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
initData()
created = true
} catch (exc: Exception) {
Log.e(LOG_ID, "create exception: " + exc.message.toString() )
Log.e(LOG_ID, "create exception: " + exc.message + " - " + exc.stackTraceToString())
}
}
}
@@ -115,12 +122,7 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
dataSyncJob!!.cancelAndJoin()
}
}
if(currentJob?.isActive == true) {
runBlocking {
Log.d(LOG_ID, "close current job - wait for current execution")
currentJob!!.join()
}
}
waitForCreation()
init = false
}
} catch (exc: Exception) {
@@ -264,6 +266,8 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
update(values)
}
Log.d(LOG_ID, "dataSync done")
} catch (exc: CancellationException) {
Log.d(LOG_ID, "dataSync cancelled")
} catch (exc: Exception) {
Log.e(LOG_ID, "dataSync exception: " + exc.message.toString() )
}
@@ -435,6 +439,14 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
return 0L
}

private fun getEntryCount(): Int {
if(chart.data != null && chart.data.dataSetCount > 0) {
val dataSet = chart.data.getDataSetByIndex(0) as LineDataSet
return dataSet.entryCount
}
return 0
}

private fun getLastTimestamp(): Long {
if(chart.data != null && chart.data.dataSetCount > 0) {
val dataSet = chart.data.getDataSetByIndex(0) as LineDataSet
@@ -448,7 +460,7 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
protected fun update(values: List<GlucoseValue>) {
Log.d(LOG_ID, "update called for ${values.size} value")
if(values.isNotEmpty()) {
if(values.first().timestamp != getFirstTimestamp()) {
if(resetChart || values.first().timestamp != getFirstTimestamp() || (abs(values.size-getEntryCount()) > 5)) {
resetData(values)
return
}
@@ -470,6 +482,7 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
dataSet.clear()
dataSet.setColors(0)
dataSet.setCircleColor(0)
chart.data.clearValues()
chart.data.notifyDataChanged()
chart.notifyDataSetChanged()
}
@@ -478,28 +491,27 @@ open class ChartCreator(protected val chart: GlucoseChart, protected val context
}

override fun OnNotifyData(context: Context, dataSource: NotifySource, extras: Bundle?) {
if(currentJob?.isActive == true) {
runBlocking {
Log.d(LOG_ID, "OnNotifyData - wait for current execution")
currentJob!!.join()
}
Log.d(LOG_ID, "OnNotifyData: $dataSource")
if(!init) {
Log.w(LOG_ID, "Chart still not init - create!")
create()
}
currentJob = scope.launch {
try {
Log.d(LOG_ID, "OnNotifyData: $dataSource")
if(dataSource == NotifySource.TIME_VALUE) {
Log.d(LOG_ID, "time elapsed: ${ReceiveData.getElapsedTimeMinute()}")
if(ReceiveData.getElapsedTimeMinute().mod(2) == 0)
if(dataSource == NotifySource.TIME_VALUE) {
Log.d(LOG_ID, "time elapsed: ${ReceiveData.getElapsedTimeMinute()}")
if(ReceiveData.getElapsedTimeMinute().mod(2) == 0) {
waitForCreation()
createJob = scope.launch {
try {
updateTimeElapsed()
} catch (exc: Exception) {
Log.e(LOG_ID, "OnNotifyData exception: " + exc.message.toString() + " - " + exc.stackTraceToString() )
}
}
} catch (exc: Exception) {
Log.e(LOG_ID, "OnNotifyData exception: " + exc.message.toString() + " - " + exc.stackTraceToString() )
}
}
//currentJob!!.start()
}

fun getBitmap(): Bitmap? {
protected fun createBitmap(): Bitmap? {
try {
if(chart.width > 0 && chart.height > 0)
return chart.drawToBitmap()
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ class CustomBubbleMarker(context: Context) : MarkerView(context, R.layout.marker
val paint = Paint().apply {
style = Paint.Style.FILL
strokeJoin = Paint.Join.ROUND
color = if(isGlucose) ContextCompat.getColor(context, R.color.transparent_widget_background) else 0
color = if(isGlucose) ContextCompat.getColor(context, R.color.transparent_marker_background) else 0
}

val chart = chartView
Original file line number Diff line number Diff line change
@@ -2,14 +2,10 @@ package de.michelinside.glucodatahandler.common.chart

import android.content.Context
import android.graphics.Canvas
import android.os.Bundle
import android.util.AttributeSet
import android.util.Log
import android.view.View
import com.github.mikephil.charting.charts.LineChart
import de.michelinside.glucodatahandler.common.Constants
import de.michelinside.glucodatahandler.common.notifier.InternalNotifier
import de.michelinside.glucodatahandler.common.notifier.NotifySource

class GlucoseChart: LineChart {
private val LOG_ID = "GDH.Chart.GlucoseChart"
@@ -26,16 +22,17 @@ class GlucoseChart: LineChart {

private var processing = false

override fun getId(): Int {
if(super.getId() == View.NO_ID) {
id = generateViewId()
}
return super.getId()
}

override fun invalidate() {
processing = true
try {
if(id == View.NO_ID) {
id = generateViewId()
}
//Log.v(LOG_ID, "start invalidate - notify ID: $id")
super.invalidate()
//Log.i(LOG_ID, "invalidate finished - notify ID: $id")
InternalNotifier.notify(context, NotifySource.GRAPH_CHANGED, Bundle().apply { putInt(Constants.GRAPH_ID, id) })
} catch (exc: Exception) {
Log.e(LOG_ID, "invalidate exception: ${exc.message}\n${exc.stackTraceToString()}")
}
Original file line number Diff line number Diff line change
@@ -39,10 +39,18 @@ object InternalNotifier {
return notifiers.contains(notifier)
}

private fun getNotifiers(): MutableMap<NotifierInterface, MutableSet<NotifySource>?> {
Log.d(LOG_ID, "getNotifiers")
synchronized(notifiers) {
Log.d(LOG_ID, "getNotifiers synchronized")
return notifiers.toMutableMap()
}
}

fun notify(context: Context, notifySource: NotifySource, extras: Bundle?)
{
Log.d(LOG_ID, "Sending new data from " + notifySource.toString() + " to " + getNotifierCount(notifySource) + " notifier(s).")
val curNotifiers = notifiers.toMutableMap()
val curNotifiers = getNotifiers()
curNotifiers.forEach{
try {
if (it.value == null || it.value!!.contains(notifySource)) {
@@ -57,8 +65,8 @@ object InternalNotifier {

fun getNotifierCount(notifySource: NotifySource): Int {
var count = 0
val curNotifiers = notifiers.toMutableMap()
curNotifiers.forEach {
val curNotifiers = getNotifiers()
curNotifiers.forEach{
if (it.value == null || it.value!!.contains(notifySource)) {
Log.v(LOG_ID, "Notifier " + it.toString() + " has source " + notifySource.toString())
count++
@@ -92,8 +100,12 @@ object InternalNotifier {

private fun hasSource(notifier: NotifierInterface, notifySource: NotifySource): Boolean {
if(hasNotifier(notifier)) {
Log.v(LOG_ID, "Check notifier ${notifier} has source $notifySource: ${notifiers[notifier]}")
return notifiers[notifier]!!.contains(notifySource)
synchronized(notifiers) {
if(notifiers.contains(notifier) && notifiers[notifier] != null) {
Log.v(LOG_ID, "Check notifier ${notifier} has source $notifySource: ${notifiers[notifier]}")
return notifiers[notifier]!!.contains(notifySource)
}
}
}
return false
}
2 changes: 1 addition & 1 deletion common/src/main/res/layout/marker_layout.xml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/transparent_widget_background"
android:background="@color/transparent_marker_background"
android:paddingHorizontal="12dp"
android:paddingVertical="8dp">

1 change: 1 addition & 0 deletions common/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -17,4 +17,5 @@
<color name="table_row">#FF666666</color>
<color name="transparent_widget_background">#55000000</color>
<color name="transparent_widget_textcolor">@color/white</color>
<color name="transparent_marker_background">#AA000000</color>
</resources>
1 change: 1 addition & 0 deletions common/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -18,4 +18,5 @@
<color name="table_row">#FFF0F0F0</color>
<color name="transparent_widget_background">#55000000</color>
<color name="transparent_widget_textcolor">@color/white</color>
<color name="transparent_marker_background">#77000000</color>
</resources>
10 changes: 10 additions & 0 deletions mobile/src/main/res/layout-land/activity_main.xml
Original file line number Diff line number Diff line change
@@ -143,6 +143,16 @@
android:layout_marginTop="20dp"
android:text="@string/menu_sources"
/>
<de.michelinside.glucodatahandler.common.chart.GlucoseChart
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="200dp"
/>

<ImageView
android:id="@+id/graphImage"
android:layout_width="match_parent"
android:layout_height="200dp" />
</LinearLayout>
</ScrollView>