Skip to content

Commit

Permalink
Merge branch 'diyaps:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rikwei0817 authored Jul 10, 2024
2 parents 3f21ede + 70b3ac6 commit a5a1486
Show file tree
Hide file tree
Showing 129 changed files with 2,887 additions and 275 deletions.
22 changes: 15 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 2.1
# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
orbs:
android: circleci/[email protected]
codecov: codecov/codecov@3.2.4
codecov: codecov/codecov@3.3.0

jobs:
# Below is the definition of your job to build and test your app, you can rename and customize it as you want.
Expand All @@ -14,7 +14,7 @@ jobs:
executor:
name: android/android-machine
resource-class: large
tag: 2023.07.1
tag: 2023.11.1

steps:
- checkout
Expand All @@ -34,11 +34,19 @@ jobs:
- android/run-tests:
test-command: ./gradlew --stacktrace jacocoAllDebugReport

# And finally run the release build
# - run:
# name: Assemble release build
# command: |
# ./gradlew assembleRelease
- run:
name: Save test results
command: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/build/outputs/androidTest-results/.*xml" -exec cp {} ~/test-results/junit/ \;
when: always

- store_test_results:
path: ~/test-results

- store_artifacts:
path: ~/test-results/junit

- codecov/upload:
file: './build/reports/jacoco/jacocoAllDebugReport/jacocoAllDebugReport.xml'

Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ android {
//Deleting it causes a binding error
buildFeatures {
dataBinding = true
buildConfig = true
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
<action android:name="com.fanqies.tomatofn.BgEstimate" />
<!-- Receiver from GlucoRx Aidex -->
<action android:name="com.microtechmd.cgms.aidex.action.BgEstimate" />
<!-- Receiver from patched Ottai app -->
<action android:name="cn.diyaps.sharing.OT_APP" />
<!-- Receiver from patched SI app -->
<action android:name="cn.diyaps.sharing.SI_APP" />
<!-- Receiver from patched Sino app -->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/app/aaps/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class MainActivity : DaggerAppCompatActivityWithResult() {
})
// Setup views on 2nd and next activity start
// On 1st start app is still initializing, start() is delayed and run from EventAppInitialized
if (config.appInitialized) start()
if (config.appInitialized) setupViews()
}

private fun start() {
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/kotlin/app/aaps/di/PluginsListModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ import app.aaps.plugins.source.GlunovoPlugin
import app.aaps.plugins.source.IntelligoPlugin
import app.aaps.plugins.source.MM640gPlugin
import app.aaps.plugins.source.NSClientSourcePlugin
import app.aaps.plugins.source.PathedOTAppPlugin
import app.aaps.plugins.source.PathedSIAppPlugin
import app.aaps.plugins.source.PathedSinoAppPlugin
import app.aaps.plugins.source.PoctechPlugin
import app.aaps.plugins.source.RandomBgPlugin
import app.aaps.plugins.source.TomatoPlugin
import app.aaps.plugins.source.XdripSourcePlugin
import app.aaps.plugins.sync.dataBroadcaster.DataBroadcastPlugin
import app.aaps.plugins.sync.tizen.TizenPlugin
import app.aaps.plugins.sync.nsclient.NSClientPlugin
import app.aaps.plugins.sync.nsclientV3.NSClientV3Plugin
import app.aaps.plugins.sync.openhumans.OpenHumansUploaderPlugin
Expand Down Expand Up @@ -352,7 +353,7 @@ abstract class PluginsListModule {
@AllConfigs
@IntoMap
@IntKey(368)
abstract fun bindDataBroadcastPlugin(plugin: DataBroadcastPlugin): PluginBase
abstract fun bindDataBroadcastPlugin(plugin: TizenPlugin): PluginBase

@Binds
@AllConfigs
Expand Down Expand Up @@ -432,6 +433,12 @@ abstract class PluginsListModule {
@IntKey(470)
abstract fun bindGlunovoPlugin(plugin: GlunovoPlugin): PluginBase

@Binds
@AllConfigs
@IntoMap
@IntKey(666)
abstract fun bindPatchedOTAppPlugin(plugin: PathedOTAppPlugin): PluginBase

@Binds
@AllConfigs
@IntoMap
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/kotlin/app/aaps/receivers/DataReceiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import app.aaps.plugins.source.DexcomPlugin
import app.aaps.plugins.source.EversensePlugin
import app.aaps.plugins.source.GlimpPlugin
import app.aaps.plugins.source.MM640gPlugin
import app.aaps.plugins.source.PathedOTAppPlugin
import app.aaps.plugins.source.PathedSIAppPlugin
import app.aaps.plugins.source.PathedSinoAppPlugin
import app.aaps.plugins.source.PoctechPlugin
Expand Down Expand Up @@ -69,6 +70,12 @@ open class DataReceiver : DaggerBroadcastReceiver() {
it.copyString("collection", bundle)
it.copyString("data", bundle)
}.build()).build()
Intents.OTAPP_BG ->
OneTimeWorkRequest.Builder(PathedOTAppPlugin.PathedOTAppWorker::class.java)
.setInputData(Data.Builder().also {
it.copyString("collection", bundle)
it.copyString("data", bundle)
}.build()).build()
Intents.SIAPP_BG ->
OneTimeWorkRequest.Builder(PathedSIAppPlugin.PathedSIAppWorker::class.java)
.setInputData(Data.Builder().also {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
maven("https://mirrors.cloud.tencent.com/nexus/repository/maven-public/")
}
dependencies {
classpath("com.android.tools.build:gradle:8.1.3")
classpath("com.android.tools.build:gradle:8.2.1")
classpath("com.google.gms:google-services:4.4.0")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.9")

Expand All @@ -22,7 +22,7 @@ buildscript {
}

plugins {
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
id("org.jlleitschuh.gradle.ktlint") version "12.0.3"
}

allprojects {
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object KtsBuildVersions {

const val gradle = "8.1.3"
const val kotlin = "1.9.0"
const val gradle = "8.2.0"
const val kotlin = "1.9.10"
}

plugins {
Expand Down
21 changes: 5 additions & 16 deletions buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ object Libs {
}

object Mockito {
private const val mockitoVersion = "5.6.0"

const val jupiter = "org.mockito:mockito-junit-jupiter:5.6.0"
const val android = "org.mockito:mockito-android:$mockitoVersion"
const val core = "org.mockito:mockito-core:$mockitoVersion"
const val jupiter = "org.mockito:mockito-junit-jupiter:$mockitoVersion"
const val kotlin = "org.mockito.kotlin:mockito-kotlin:5.1.0"
}

Expand Down Expand Up @@ -197,19 +200,5 @@ object Libs {
const val commonCodecs = "commons-codec:commons-codec:1.16.0"
const val kulid = "com.github.guepardoapps:kulid:2.0.0.0"
const val xstream = "com.thoughtworks.xstream:xstream:1.4.20"

const val ormLite = "4.46"

const val junit = "4.13.2"
const val mockito = "5.6.0"
const val dexmaker = "1.2"
const val byteBuddy = "1.12.8"

const val androidx_junit = "1.1.5"
const val androidx_rules = "1.5.0"

const val kotlinx_datetime = "0.4.1"
const val kotlinx_serialization = "1.6.0"

const val caverock_androidsvg = "1.4"
const val connectiqSdk = "com.garmin.connectiq:ciq-companion-app-sdk:2.0.3@aar"
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.gradle.api.JavaVersion

object Versions {

const val appVersion = "3.2.0.2"
const val appVersion = "3.2.0.4"
const val versionCode = 1500

const val ndkVersion = "21.1.6352462"
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/test-module-dependencies.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ dependencies {
androidTestImplementation(Libs.AndroidX.Test.rules)
androidTestImplementation(Libs.Google.truth)
androidTestImplementation(Libs.AndroidX.Test.uiAutomator)
androidTestImplementation(Libs.Mockito.core)
androidTestImplementation(Libs.Mockito.android)
androidTestImplementation(Libs.Mockito.kotlin)
}

tasks.withType<Test> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.aaps.core.interfaces.pump

import app.aaps.core.interfaces.db.GlucoseUnit
import app.aaps.core.interfaces.profile.Profile
import app.aaps.core.interfaces.pump.defs.PumpType
import app.aaps.core.interfaces.utils.DateUtil
Expand Down Expand Up @@ -257,6 +258,26 @@ interface PumpSync {
**/
fun insertTherapyEventIfNewWithTimestamp(timestamp: Long, type: DetailedBolusInfo.EventType, note: String? = null, pumpId: Long? = null, pumpType: PumpType, pumpSerial: String): Boolean

/**
* Synchronization of FINGER_STICK_BG_VALUE events
*
* Assuming there will be no clash on timestamp from different pumps
* only timestamp and type is compared
*
* If db record doesn't exist, new record is created.
* If exists, data is ignored
*
* @param timestamp timestamp of event from pump history
* @param glucose glucose value
* @param glucoseUnit glucose unit
* @param note note
* @param pumpId pump id from history if available
* @param pumpType pump type like PumpType.ACCU_CHEK_COMBO
* @param pumpSerial pump serial number
* @return true if new record is created
**/
fun insertFingerBgIfNewWithTimestamp(timestamp: Long, glucose: Double, glucoseUnit: GlucoseUnit, note: String? = null, pumpId: Long? = null, pumpType: PumpType, pumpSerial: String): Boolean

/**
* Create an announcement
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface Intents {
const val EXTRA_BG_SLOPE = "com.eveningoutpost.dexdrip.Extras.BgSlope"
const val EXTRA_BG_SLOPE_NAME = "com.eveningoutpost.dexdrip.Extras.BgSlopeName"
const val EXTRA_SENSOR_BATTERY = "com.eveningoutpost.dexdrip.Extras.SensorBattery"
const val EXTRA_SENSOR_STARTED_AT = "com.eveningoutpost.dexdrip.Extras.SensorStartedAt"
const val EXTRA_TIMESTAMP = "com.eveningoutpost.dexdrip.Extras.Time"
const val EXTRA_RAW = "com.eveningoutpost.dexdrip.Extras.Raw"
const val XDRIP_DATA_SOURCE_DESCRIPTION = "com.eveningoutpost.dexdrip.Extras.SourceDesc"
Expand All @@ -47,6 +48,9 @@ interface Intents {
var AIDEX_TRANSMITTER_SN = "com.microtechmd.cgms.aidex.TransmitterSerialNumber"
var AIDEX_SENSOR_ID = "com.microtechmd.cgms.aidex.SensorId"

// Patched Ottai App -> AAPS
const val OTAPP_BG = "cn.diyaps.sharing.OT_APP"

// Patched SI App -> AAPS
const val SIAPP_BG = "cn.diyaps.sharing.SI_APP"

Expand Down
4 changes: 2 additions & 2 deletions core/ui/src/main/res/drawable/ic_user_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
android:viewportHeight="24">
<path
android:pathData="M13.351,12.926c-0.137,-0.003 -0.283,0.012 -0.337,-0.17c-0.046,-0.155 0.002,-0.266 0.122,-0.366c0.628,-0.523 0.741,-1.232 0.711,-2.042c0,-0.148 0.013,-0.348 -0.002,-0.546c-0.071,-0.91 -0.785,-1.606 -1.718,-1.686c-0.845,-0.073 -1.71,0.485 -1.862,1.344c-0.184,1.039 -0.278,2.111 0.636,2.933c0.115,0.104 0.172,0.206 0.12,0.363c-0.059,0.177 -0.201,0.171 -0.34,0.169c-0.347,-0.005 -0.668,0.083 -0.97,0.249c-0.973,0.535 -1.043,1.404 -0.165,2.061c1.299,0.974 3.949,0.841 5.144,-0.257c0.471,-0.433 0.508,-0.927 0.084,-1.408C14.4,13.146 13.918,12.937 13.351,12.926zM13.572,14.889c-1.202,0.486 -2.407,0.499 -3.555,-0.158c-0.579,-0.331 -0.548,-0.663 0.046,-0.976c0.248,-0.131 0.517,-0.214 0.801,-0.195c0.348,0.024 0.636,-0.047 0.765,-0.414c0.14,-0.399 0.306,-0.823 -0.105,-1.149c-0.661,-0.524 -0.705,-1.225 -0.666,-1.98c0.039,-0.729 0.51,-1.259 1.159,-1.248c0.662,0.011 1.13,0.529 1.146,1.269c0.003,0.119 0,0.239 0,0.456c0.097,0.503 -0.086,0.988 -0.564,1.377c-0.395,0.321 -0.385,0.738 -0.235,1.187c0.15,0.448 0.477,0.542 0.89,0.506c0.039,-0.003 0.08,0.004 0.118,0.014c0.389,0.093 0.879,0.167 0.948,0.599C14.392,14.615 13.901,14.756 13.572,14.889z"
android:fillColor="?attr/userOptionColor"/>
android:fillColor="@color/userOption"/>
<path
android:pathData="M19.107,10.662H17.78c-0.15,-0.648 -0.406,-1.253 -0.749,-1.801l0.941,-0.941c0.239,-0.239 0.239,-0.626 0,-0.864l-1.027,-1.027c-0.239,-0.239 -0.626,-0.239 -0.864,0l-0.941,0.941c-0.548,-0.343 -1.154,-0.599 -1.801,-0.749V4.893c0,-0.338 -0.274,-0.611 -0.611,-0.611h-1.453c-0.338,0 -0.611,0.274 -0.611,0.611V6.22c-0.648,0.15 -1.253,0.406 -1.801,0.749L7.92,6.028c-0.239,-0.239 -0.626,-0.239 -0.864,0L6.028,7.056c-0.239,0.239 -0.239,0.626 0,0.864l0.941,0.941C6.626,9.409 6.37,10.015 6.22,10.662H4.893c-0.338,0 -0.611,0.274 -0.611,0.611v1.453c0,0.338 0.274,0.611 0.611,0.611H6.22c0.15,0.648 0.406,1.253 0.749,1.801L6.028,16.08c-0.239,0.239 -0.239,0.626 0,0.864l1.027,1.027c0.239,0.239 0.626,0.239 0.864,0l0.941,-0.941c0.548,0.343 1.154,0.599 1.801,0.749v1.328c0,0.338 0.274,0.611 0.611,0.611h1.453c0.338,0 0.611,-0.274 0.611,-0.611V17.78c0.648,-0.15 1.254,-0.406 1.801,-0.749l0.941,0.941c0.239,0.239 0.626,0.239 0.864,0l1.027,-1.027c0.239,-0.239 0.239,-0.626 0,-0.864l-0.941,-0.941c0.343,-0.548 0.599,-1.154 0.749,-1.801h1.328c0.338,0 0.611,-0.274 0.611,-0.611v-1.453C19.719,10.936 19.445,10.662 19.107,10.662zM12,16.938c-2.723,0 -4.938,-2.215 -4.938,-4.938S9.277,7.063 12,7.063S16.938,9.277 16.938,12S14.723,16.938 12,16.938z"
android:fillColor="?attr/userOptionColor"/>
android:fillColor="@color/userOption"/>
</vector>
Binary file added core/ui/src/main/res/mipmap-xhdpi/ottai_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 44 additions & 10 deletions core/utils/src/main/kotlin/app/aaps/core/utils/MidnightUtils.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
package app.aaps.core.utils

import org.joda.time.DateTime
import java.time.Duration
import java.time.Instant
import java.time.ZoneId
import java.time.ZonedDateTime

object MidnightUtils {
/*
/**
* Midnight time conversion
*/
object MidnightUtils {

/**
* Actual passed seconds from midnight ignoring DST change
* (thus always having 24 hours in a day, not 23 or 25 in days where DST changes)
*
* @return seconds
*/
fun secondsFromMidnight(): Int {
val passed = DateTime().millisOfDay.toLong()
return (passed / 1000).toInt()
val nowZoned = ZonedDateTime.now()
val localTime = nowZoned.toLocalTime()
val midnight = nowZoned.toLocalDate().atStartOfDay(nowZoned.zone).toLocalTime()
val duration = Duration.between(midnight, localTime)
return duration.seconds.toInt()
}

fun secondsFromMidnight(date: Long): Int {
val passed = DateTime(date).millisOfDay.toLong()
return (passed / 1000).toInt()
/**
* Passed seconds from midnight for specified time ignoring DST change
* (thus always having 24 hours in a day, not 23 or 25 in days where DST changes)
*
* @param timestamp time
* @return seconds
*/
fun secondsFromMidnight(timestamp: Long): Int {
val timeZoned = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault())
val localTime = timeZoned.toLocalTime()
val midnight = timeZoned.toLocalDate().atStartOfDay(timeZoned.zone).toLocalTime()
val duration: Duration = Duration.between(midnight, localTime)
return duration.seconds.toInt()
}

fun milliSecFromMidnight(date: Long): Long {
return DateTime(date).millisOfDay.toLong()
/**
* Passed milliseconds from midnight for specified time ignoring DST change
* (thus always having 24 hours in a day, not 23 or 25 in days where DST changes)
*
* @param timestamp time
* @return milliseconds
*/
fun milliSecFromMidnight(timestamp: Long): Long {
val timeZoned = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault())
val localTime = timeZoned.toLocalTime()
val midnight = timeZoned.toLocalDate().atStartOfDay(timeZoned.zone).toLocalTime()
val duration = Duration.between(midnight, localTime)
return duration.toMillis()
}
}
Loading

0 comments on commit a5a1486

Please sign in to comment.