Skip to content

Commit 162234f

Browse files
Merge branch 'andy_tandem_dev' into andy_tandem
2 parents e51f2b1 + 110d590 commit 162234f

1,844 files changed

Lines changed: 26905 additions & 22533 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Use the latest 2.1 version of CircleCI pipeline process engine.
1+
# Use the latest 2.1 version of CircleCI pipeline process engine.
22
# See: https://circleci.com/docs/2.0/configuration-reference
33
version: 2.1
44

@@ -19,21 +19,21 @@ jobs:
1919
- run:
2020
name: Create avd
2121
command: |
22-
echo "no" | /opt/android-sdk/cmdline-tools/latest/bin/avdmanager --verbose create avd -n citest -k "system-images;android-30;google_apis_playstore;x86" --force
22+
echo "no" | /usr/lib/android-sdk/cmdline-tools/13.0/bin/avdmanager --verbose create avd -n citest -k "system-images;android-31;google_apis_playstore;x86_64" --force
2323
2424
- run:
2525
name: Launch emulator
2626
command: |
27-
export ANDROID_SDK_ROOT=/opt/android-sdk
28-
export ANDROID_HOME=/opt/android-sdk
27+
export ANDROID_SDK_ROOT=/usr/lib/android-sdk
28+
export ANDROID_HOME=/usr/lib/android-sdk
2929
emulator -avd citest -delay-adb -verbose -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
3030
background: true
3131

3232
- run:
3333
name: Run connectedFullDebugAndroidTest
3434
command: |
35-
export ANDROID_SDK_ROOT=/opt/android-sdk
36-
export ANDROID_HOME=/opt/android-sdk
35+
export ANDROID_SDK_ROOT=/usr/lib/android-sdk
36+
export ANDROID_HOME=/usr/lib/android-sdk
3737
env
3838
./gradlew -Dorg.gradle.jvmargs=-Xmx6g connectedFullDebugAndroidTest
3939
@@ -46,15 +46,15 @@ jobs:
4646
- run:
4747
name: Run testFullDebugUnitTest
4848
command: |
49-
export ANDROID_SDK_ROOT=/opt/android-sdk
50-
export ANDROID_HOME=/opt/android-sdk
49+
export ANDROID_SDK_ROOT=/usr/lib/android-sdk
50+
export ANDROID_HOME=/usr/lib/android-sdk
5151
./gradlew -Dorg.gradle.jvmargs=-Xmx6g testFullDebugUnitTest
5252
5353
- run:
5454
run: Run jacocoAllDebugReport
5555
command: |
56-
export ANDROID_SDK_ROOT=/opt/android-sdk
57-
export ANDROID_HOME=/opt/android-sdk
56+
export ANDROID_SDK_ROOT=/usr/lib/android-sdk
57+
export ANDROID_HOME=/usr/lib/android-sdk
5858
./gradlew --stacktrace jacocoAllDebugReport
5959
6060
- run:
@@ -73,6 +73,12 @@ jobs:
7373
- codecov/upload:
7474
file: './build/reports/jacoco/jacocoAllDebugReport/jacocoAllDebugReport.xml'
7575

76+
- run:
77+
name: Kill java processes
78+
command: |
79+
killall java
80+
when: always
81+
7682
workflows:
7783
# Below is the definition of your workflow.
7884
# Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the build-and-test job above.

.kotlin/errors/errors-1730369688333.log

Lines changed: 0 additions & 4 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,129 @@ Hints
4646
* For new features, make sure there is Issue to track progress and have on-topic discussion
4747
* Reach out to community, discuss idea on Discord (https://discord.gg/4fQUWHZ4Mw)
4848
* Speak with other developers to minimize merge conflicts. Find out who worked, working or plan to work on specific issue or part of app
49+
50+
51+
New Jetpack Compose UI
52+
========================
53+
54+
Integrating with Dagger
55+
------------------------
56+
When using new Compose API, you need to use ComponentActivity in which you put your content. This wouldn't really be
57+
problem by itself, but together with Dagger you get a little bit of mess, since you will need at least few
58+
classes injected.
59+
60+
Solution is done with dagger.Subcompoents and bindings (everything is done only on module level).
61+
62+
Solution requires to create 1 new class in your module, something like this:
63+
64+
@Subcomponent
65+
interface TandemComposeUiComponent : ComposeUi {
66+
fun inject(activity: ActionsActivity)
67+
fun inject(activity: DataActivity)
68+
fun inject(activity: PairingActivity)
69+
70+
71+
@Subcomponent.Factory
72+
interface FactoryCompose : ComposeUiFactory {
73+
override fun create(): TandemComposeUiComponent
74+
}
75+
}
76+
77+
78+
For your solution you just need to change the name and insert "fun inject()" for each activity. So in this module we
79+
have 3 specific "main" activities. The way Compose works is that you need just the starting point and all sub-windows
80+
are just Compose elements, so you just need "entry" activity.
81+
82+
Next change that is required is entry in your Dagger Module file:
83+
84+
85+
@Binds
86+
@IntoMap
87+
@ComposeUiModule("tandem")
88+
abstract fun bindTandemComposeUiFactory(factory: TandemComposeUiComponent.FactoryCompose): ComposeUiFactory
89+
90+
ComposeUiModule name needs to be unique across whole app, so using driver name (in case of pump driver) is a
91+
good solution.
92+
93+
Also on main Module file you need to specify subComponent you created
94+
95+
@Module(subcomponents = [TandemComposeUiComponent::class])
96+
97+
98+
99+
Now in every ComposeActivity, you need to do following:
100+
101+
1. you activity needs to extend DaggerComponentActivity (DaggerComponentActivity is just marker class that tells dagger
102+
what to inject, it is just abstract class that extends ComponentActivity), and next step is of course to add all
103+
your injects...
104+
105+
So something like:
106+
107+
@Inject lateinit var aapsLogger: AAPSLogger
108+
109+
110+
2. final change is to add following code onCreate:
111+
112+
override fun onCreate(savedInstanceState: Bundle?) {
113+
super.onCreate(savedInstanceState)
114+
115+
val composeUiComponent = (application as ComposeUiProvider)
116+
.getComposeUiModule("tandem") as TandemComposeUiComponent
117+
118+
composeUiComponent.inject(this)
119+
120+
// .... other code
121+
122+
enableEdgeToEdge()
123+
setContent {
124+
125+
// ... Compose Ui Code (elements with @Composable attribute)
126+
127+
}
128+
}
129+
130+
131+
Basic setup in module
132+
------------------------
133+
134+
1.) Other config
135+
136+
android {
137+
138+
buildFeatures {
139+
compose=true
140+
}
141+
}
142+
143+
2.) Plugins
144+
145+
plugins {
146+
alias(libs.plugins.compose.compiler)
147+
}
148+
149+
3.) Dependencies
150+
151+
Mostly depends what you need:
152+
153+
Required:
154+
155+
implementation(libs.androidx.activity.compose)
156+
implementation(platform(libs.androidx.compose.bom))
157+
158+
Preview: (last 2 needed for preview, first two might be needed always)
159+
160+
implementation(libs.androidx.ui)
161+
implementation(libs.androidx.ui.graphics)
162+
implementation(libs.androidx.ui.tooling)
163+
implementation(libs.androidx.ui.tooling.preview)
164+
165+
Others:
166+
167+
implementation(libs.androidx.compose.material3) // Material 3 interface
168+
implementation(libs.androidx.compose.material) // Material interface (both interfaces shouldn't be mixed, at least not in same screen)
169+
implementation(libs.androidx.compose.foundation) // base classes
170+
171+
implementation(libs.androidx.lifecycle.runtime.compose) // if you will use livedata and lifecyles
172+
implementation(libs.androidx.compose.runtime.livedata)
173+
174+
implementation(libs.androidx.compose.navigation) // if you use navigation models

_docs/icons/expand.svg

Lines changed: 9 additions & 0 deletions
Loading

app/build.gradle.kts

Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,29 @@ repositories {
1919
}
2020

2121
fun generateGitBuild(): String {
22-
val stringBuilder: StringBuilder = StringBuilder()
2322
try {
24-
val stdout = ByteArrayOutputStream()
25-
exec {
26-
commandLine("git", "describe", "--always")
27-
standardOutput = stdout
28-
}
29-
val commitObject = stdout.toString().trim()
30-
stringBuilder.append(commitObject)
23+
val processBuilder = ProcessBuilder("git", "describe", "--always")
24+
val output = File.createTempFile("git-build", "")
25+
processBuilder.redirectOutput(output)
26+
val process = processBuilder.start()
27+
process.waitFor()
28+
return output.readText().trim()
3129
} catch (_: Exception) {
32-
stringBuilder.append("NoGitSystemAvailable")
30+
return "NoGitSystemAvailable"
3331
}
34-
return stringBuilder.toString()
3532
}
3633

3734
fun generateGitRemote(): String {
38-
val stringBuilder: StringBuilder = StringBuilder()
3935
try {
40-
val stdout = ByteArrayOutputStream()
41-
exec {
42-
commandLine("git", "remote", "get-url", "origin")
43-
standardOutput = stdout
44-
}
45-
val commitObject: String = stdout.toString().trim()
46-
stringBuilder.append(commitObject)
36+
val processBuilder = ProcessBuilder("git", "remote", "get-url", "origin")
37+
val output = File.createTempFile("git-remote", "")
38+
processBuilder.redirectOutput(output)
39+
val process = processBuilder.start()
40+
process.waitFor()
41+
return output.readText().trim()
4742
} catch (_: Exception) {
48-
stringBuilder.append("NoGitSystemAvailable")
43+
return "NoGitSystemAvailable"
4944
}
50-
return stringBuilder.toString()
5145
}
5246

5347
fun generateDate(): String {
@@ -60,39 +54,31 @@ fun generateDate(): String {
6054
fun isMaster(): Boolean = !Versions.appVersion.contains("-")
6155

6256
fun gitAvailable(): Boolean {
63-
val stringBuilder: StringBuilder = StringBuilder()
6457
try {
65-
val stdout = ByteArrayOutputStream()
66-
exec {
67-
commandLine("git", "--version")
68-
standardOutput = stdout
69-
}
70-
val commitObject = stdout.toString().trim()
71-
stringBuilder.append(commitObject)
58+
val processBuilder = ProcessBuilder("git", "--version")
59+
val output = File.createTempFile("git-version", "")
60+
processBuilder.redirectOutput(output)
61+
val process = processBuilder.start()
62+
process.waitFor()
63+
return output.readText().isNotEmpty()
7264
} catch (_: Exception) {
73-
return false // NoGitSystemAvailable
65+
return false
7466
}
75-
return stringBuilder.toString().isNotEmpty()
76-
7767
}
7868

7969
fun allCommitted(): Boolean {
80-
val stringBuilder: StringBuilder = StringBuilder()
8170
try {
82-
val stdout = ByteArrayOutputStream()
83-
exec {
84-
commandLine("git", "status", "-s")
85-
standardOutput = stdout
86-
}
87-
// ignore all changes done in .idea/codeStyles
88-
val cleanedList: String = stdout.toString().replace(Regex("""(?m)^\s*(M|A|D|\?\?)\s*.*?\.idea\/codeStyles\/.*?\s*$"""), "")
71+
val processBuilder = ProcessBuilder("git", "status", "-s")
72+
val output = File.createTempFile("git-comited", "")
73+
processBuilder.redirectOutput(output)
74+
val process = processBuilder.start()
75+
process.waitFor()
76+
return output.readText().replace(Regex("""(?m)^\s*(M|A|D|\?\?)\s*.*?\.idea\/codeStyles\/.*?\s*$"""), "")
8977
// ignore all files added to project dir but not staged/known to GIT
90-
.replace(Regex("""(?m)^\s*(\?\?)\s*.*?\s*$"""), "")
91-
stringBuilder.append(cleanedList.trim())
78+
.replace(Regex("""(?m)^\s*(\?\?)\s*.*?\s*$"""), "").trim().isEmpty()
9279
} catch (_: Exception) {
93-
return false // NoGitSystemAvailable
80+
return false
9481
}
95-
return stringBuilder.toString().isEmpty()
9682
}
9783

9884
android {
@@ -205,10 +191,10 @@ dependencies {
205191
implementation(project(":pump:equil"))
206192
implementation(project(":pump:insight"))
207193
implementation(project(":pump:medtronic"))
208-
implementation(project(":pump:pump-common"))
209-
implementation(project(":pump:omnipod-common"))
210-
implementation(project(":pump:omnipod-eros"))
211-
implementation(project(":pump:omnipod-dash"))
194+
implementation(project(":pump:common"))
195+
implementation(project(":pump:omnipod:common"))
196+
implementation(project(":pump:omnipod:eros"))
197+
implementation(project(":pump:omnipod:dash"))
212198
implementation(project(":pump:rileylink"))
213199
implementation(project(":pump:tandem"))
214200
implementation(project(":pump:virtual"))
@@ -239,7 +225,7 @@ println("isMaster: ${isMaster()}")
239225
println("gitAvailable: ${gitAvailable()}")
240226
println("allCommitted: ${allCommitted()}")
241227
println("-------------------")
242-
if (isMaster() && !gitAvailable()) {
228+
if (!gitAvailable()) {
243229
throw GradleException("GIT system is not available. On Windows try to run Android Studio as an Administrator. Check if GIT is installed and Studio have permissions to use it")
244230
}
245231
if (isMaster() && !allCommitted()) {

app/src/androidTest/kotlin/app/aaps/CompatDbHelperTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import app.aaps.core.data.model.EB
77
import app.aaps.core.data.model.FD
88
import app.aaps.core.data.model.GlucoseUnit
99
import app.aaps.core.data.model.IDs
10-
import app.aaps.core.data.model.OE
10+
import app.aaps.core.data.model.RM
1111
import app.aaps.core.data.model.TB
1212
import app.aaps.core.data.model.TE
1313
import app.aaps.core.data.model.TT
@@ -31,8 +31,8 @@ import app.aaps.core.interfaces.rx.events.EventExtendedBolusChange
3131
import app.aaps.core.interfaces.rx.events.EventFoodDatabaseChanged
3232
import app.aaps.core.interfaces.rx.events.EventNewBG
3333
import app.aaps.core.interfaces.rx.events.EventNewHistoryData
34-
import app.aaps.core.interfaces.rx.events.EventOfflineChange
3534
import app.aaps.core.interfaces.rx.events.EventProfileSwitchChanged
35+
import app.aaps.core.interfaces.rx.events.EventRunningModeChange
3636
import app.aaps.core.interfaces.rx.events.EventTempBasalChange
3737
import app.aaps.core.interfaces.rx.events.EventTempTargetChange
3838
import app.aaps.core.interfaces.rx.events.EventTherapyEventChange
@@ -96,7 +96,7 @@ class CompatDbHelperTest @Inject constructor() {
9696
rxHelper.listen(EventTempTargetChange::class.java)
9797
rxHelper.listen(EventTherapyEventChange::class.java)
9898
rxHelper.listen(EventFoodDatabaseChanged::class.java)
99-
rxHelper.listen(EventOfflineChange::class.java)
99+
rxHelper.listen(EventRunningModeChange::class.java)
100100
rxHelper.listen(EventDeviceStatusChange::class.java)
101101

102102
// Enable event logging
@@ -266,16 +266,16 @@ class CompatDbHelperTest @Inject constructor() {
266266
// EventFoodDatabaseChanged should be triggered
267267
assertThat(rxHelper.waitFor(EventFoodDatabaseChanged::class.java, comment = "step13").first).isTrue()
268268

269-
// OE
270-
rxHelper.resetState(EventOfflineChange::class.java)
271-
val oe = OE(
269+
// RM
270+
rxHelper.resetState(EventRunningModeChange::class.java)
271+
val rm = RM(
272272
timestamp = dateUtil.now(),
273-
reason = OE.Reason.OTHER,
273+
mode = RM.Mode.DISCONNECTED_PUMP,
274274
duration = T.hours(1).msecs()
275275
)
276-
persistenceLayer.insertAndCancelCurrentOfflineEvent(oe, Action.DISCONNECT, Sources.Aaps, null, listOf()).blockingGet()
276+
persistenceLayer.insertOrUpdateRunningMode(rm, Action.DISCONNECT, Sources.Aaps, null, listOf()).blockingGet()
277277
// EventOfflineChange should be triggered
278-
assertThat(rxHelper.waitFor(EventOfflineChange::class.java, comment = "step13").first).isTrue()
278+
assertThat(rxHelper.waitFor(EventRunningModeChange::class.java, comment = "step13").first).isTrue()
279279

280280
// DS
281281
rxHelper.resetState(EventDeviceStatusChange::class.java)

0 commit comments

Comments
 (0)