Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions app/src/main/kotlin/app/aaps/di/PluginsListModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import app.aaps.plugins.main.general.actions.ActionsPlugin
import app.aaps.plugins.main.general.food.FoodPlugin
import app.aaps.plugins.main.general.overview.OverviewPlugin
import app.aaps.plugins.main.general.persistentNotification.PersistentNotificationPlugin
import app.aaps.plugins.main.general.remora.RemoraPlugin
import app.aaps.plugins.main.general.smsCommunicator.SmsCommunicatorPlugin
import app.aaps.plugins.main.general.themes.ThemeSwitcherPlugin
import app.aaps.plugins.main.iob.iobCobCalculator.IobCobCalculatorPlugin
Expand Down Expand Up @@ -288,6 +289,12 @@ abstract class PluginsListModule {
@IntKey(280)
abstract fun bindSmsCommunicatorPlugin(plugin: SmsCommunicatorPlugin): PluginBase

@Binds
@NotNSClient
@IntoMap
@IntKey(285)
abstract fun bindRemoraPlugin(plugin: RemoraPlugin): PluginBase

@Binds
@APS
@IntoMap
Expand Down
3 changes: 2 additions & 1 deletion core/data/src/main/kotlin/app/aaps/core/data/ue/Sources.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ enum class Sources {
Garmin,
Database, // for PersistenceLayer
Unknown, //if necessary
SyaiTag
SyaiTag,
Remora
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ interface PersistenceLayer {
*/
fun getCarbsFromTimeToTimeExpanded(startTime: Long, endTime: Long, ascending: Boolean): List<CA>

/**
* Get carbs in time interval (eCarbs as single records)
*
* @param startTime from
* @param endTime to
* @param ascending sort order
* @return List of carbs
*/
fun getCarbsFromTimeToTimeNotExpanded(startTime: Long, endTime: Long, ascending: Boolean): List<CA>

/**
* Get next changed record after id
*
Expand Down Expand Up @@ -1054,6 +1064,7 @@ interface PersistenceLayer {
fun getTemporaryTargetByNSId(nsId: String): TT?

fun getTemporaryTargetDataFromTime(timestamp: Long, ascending: Boolean): Single<List<TT>>
fun getTemporaryTargetDataFromTimeToTime(start: Long, end: Long, ascending: Boolean): Single<List<TT>>
fun getTemporaryTargetDataIncludingInvalidFromTime(timestamp: Long, ascending: Boolean): Single<List<TT>>

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ interface SmsCommunicator {
fun sendNotificationToAllNumbers(text: String): Boolean
fun sendSMS(sms: Sms): Boolean
fun isEnabled(): Boolean
fun invalidateMessage()
}
21 changes: 21 additions & 0 deletions core/objects/src/main/res/drawable/ic_remora.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M5.6,15.49c-1.46,-3.05 0.63,-8.06 4.01,-8.89h0.05s0.08,0.05 0.06,0.09c-0.01,0.03 -0.02,0.05 -0.03,0.08 -0.22,0.45 -0.95,1.52 -1.06,1.85 -0.02,0.05 0.02,0.08 0.05,0.11 0.07,0.06 1.38,-0.44 2.35,-1.4 0.1,-0.1 0.39,-0.4 0.86,-0.58 0,0 0.15,-0.06 0.3,-0.1 1.09,-0.26 4.15,0.51 5.81,-0.57 1.5,-0.97 -1.3,-2.63 -2.59,-3.26h-0.01c-3.21,-1.48 -6.97,-0.57 -9.8,1.51 -0.04,0.03 -0.09,0.05 -0.14,0.05 -1.54,0.1 -2.47,0.58 -2.98,0.93 -0.07,0.05 -0.77,0.54 -0.68,0.75 0.08,0.18 0.74,0.1 1,0.1 0.22,0 0.58,0.04 0.83,0.06 0.1,0.01 0.15,0.12 0.1,0.2 -1.82,2.86 -2.4,7.04 -0.51,10 0.05,0.07 0.07,0.14 0.07,0.22 -0.04,0.91 0.12,1.91 0.59,2.72 0.17,0.26 0.67,1.21 0.99,1.02 0.11,-0.08 0.23,-0.25 0.27,-0.73 0.02,-0.33 0.02,-0.63 -0.03,-1 -0.1,-0.75 -0.49,-1.22 -0.09,-1.2 0.13,0 0.45,0.11 0.63,0.17 0.21,0.08 0.47,0.18 0.8,0.3 1.02,0.3 1.43,0.52 1.66,0.19s-2.11,-1.85 -2.49,-2.65h0ZM15.59,4.41h0.01c0.38,0.39 0,1.08 -0.59,0.85 -0.14,-0.05 -0.27,-0.16 -0.31,-0.29 -0.15,-0.51 0.48,-0.99 0.89,-0.55h0Z"
android:fillColor="?attr/colorControlNormal"/>
<path
android:pathData="M6.55,18.07c-0.03,0.05 -0.06,0.1 -0.08,0.15 -0.36,1.05 1.14,1.94 1.91,2.42 2.91,1.7 6.76,1.36 9.44,-0.64h0c0.18,-0.11 0.23,-0.15 0.42,-0.19 1.44,-0.26 2.16,-0.08 3.26,-1.2 0.56,-0.56 -0.19,-0.52 -0.87,-0.52s-0.31,0 -0.45,-0.02 -0.08,-0.06 -0.05,-0.1c0.1,-0.14 0.27,-0.4 0.38,-0.55 1.8,-2.83 2,-6.21 0.13,-9.22 -0.03,-0.05 -0.04,-0.1 -0.03,-0.15 0.15,-1.25 0.17,-3.41 -0.22,-3.86 -0.24,-0.33 -0.62,0.38 -0.84,0.98 -0.15,0.43 -0.43,1.12 -0.45,1.68 -0.01,0.19 -0.02,0.36 0,0.5s-0.04,0.07 -0.08,0.06c-0.2,-0.07 -0.7,-0.25 -1,-0.3 -0.45,-0.07 -0.91,-0.07 -1.19,0.07 -0.3,0.21 0.21,0.38 0.37,0.48 3.97,2.16 2.22,7.55 -1.51,8.89 -0.04,0.02 -0.07,-0.02 -0.06,-0.06 0.12,-0.37 0.79,-1.37 0.82,-1.6 0,-0.07 -0.11,-0.04 -0.19,-0.05s0,0 0,0c-1.14,0.1 -2.42,1.38 -3.22,2.05 -0.16,0.14 -0.32,0.08 -0.55,0.07 -0.5,-0.05 -1.05,-0.18 -1.55,-0.22 -1.1,-0.09 -2.57,0.25 -3.42,0.63 -0.75,0.34 -0.87,0.57 -0.95,0.7h-0.02,0ZM8.73,19.5h0c-0.47,-0.56 0.54,-1.08 0.76,-0.4 0.1,0.42 -0.47,0.74 -0.76,0.4h0Z"
android:fillColor="?attr/colorControlNormal"/>
<path
android:pathData="M16.44,14.88c0,-0.07 -0.11,-0.04 -0.19,-0.05"
android:fillColor="?attr/colorControlNormal"/>
<path
android:pathData="M16.86,1.5c0.1,-0.1 0.25,-0.2 0.25,-0.36 0.05,-0.36 -0.25,-0.56 -0.56,-0.61 -0.2,0 -0.25,0.15 -0.36,0.25 -0.15,0.2 -0.05,0.41 0.05,0.61 0.15,0.2 0.41,0.25 0.61,0.1Z"
android:fillColor="?attr/colorControlNormal"/>
<path
android:pathData="M19.03,3.2c0.3,-0.05 0.56,-0.25 0.61,-0.56 0.05,-0.2 0.15,-0.51 -0.05,-0.66 -0.25,-0.46 -0.76,-0.46 -1.12,-0.2 -0.1,0.05 -0.25,0.2 -0.3,0.36 -0.1,0.3 0,0.66 0.2,0.86 0.2,0.15 0.41,0.2 0.66,0.2Z"
android:fillColor="?attr/colorControlNormal"/>
</vector>
11 changes: 11 additions & 0 deletions database/impl/src/main/kotlin/app/aaps/database/AppRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ class AppRepository @Inject internal constructor(
.map { if (!ascending) it.reversed() else it }
.subscribeOn(Schedulers.io())

fun getTemporaryTargetDataFromTimeToTime(start: Long, end: Long, ascending: Boolean): Single<List<TemporaryTarget>> =
database.temporaryTargetDao.getTemporaryTargetDataFromTimeToTime(start, end)
.map { if (!ascending) it.reversed() else it }
.subscribeOn(Schedulers.io())

fun getTemporaryTargetDataIncludingInvalidFromTime(timestamp: Long, ascending: Boolean): Single<List<TemporaryTarget>> =
database.temporaryTargetDao.getTemporaryTargetDataIncludingInvalidFromTime(timestamp)
.map { if (!ascending) it.reversed() else it }
Expand Down Expand Up @@ -591,6 +596,12 @@ class AppRepository @Inject internal constructor(
.sort()
.map { if (!ascending) it.reversed() else it }
.subscribeOn(Schedulers.io())
.subscribeOn(Schedulers.io())

fun getCarbsDataFromTimeToTimeNotExpanded(from: Long, to: Long, ascending: Boolean): Single<List<Carbs>> =
database.carbsDao.getCarbsFromTimeToTimeExpandable(from, to)
.map { if (!ascending) it.reversed() else it }
.subscribeOn(Schedulers.io())

fun getCarbsIncludingInvalidFromTime(timestamp: Long, ascending: Boolean): Single<List<Carbs>> =
database.carbsDao.getCarbsIncludingInvalidFromTime(timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ internal interface TemporaryTargetDao : TraceableDao<TemporaryTarget> {
@Query("SELECT * FROM $TABLE_TEMPORARY_TARGETS WHERE unlikely(timestamp >= :timestamp) AND likely(isValid = 1) AND likely(referenceId IS NULL) ORDER BY timestamp ASC")
fun getTemporaryTargetDataFromTime(timestamp: Long): Single<List<TemporaryTarget>>

@Query("SELECT * FROM $TABLE_TEMPORARY_TARGETS WHERE unlikely(timestamp + duration >= :start) AND unlikely(timestamp <= :end) AND likely(isValid = 1) AND likely(referenceId IS NULL) ORDER BY timestamp ASC")
fun getTemporaryTargetDataFromTimeToTime(start: Long, end: Long): Single<List<TemporaryTarget>>

@Query("SELECT * FROM $TABLE_TEMPORARY_TARGETS WHERE unlikely(timestamp >= :timestamp) AND likely(referenceId IS NULL) ORDER BY timestamp ASC")
fun getTemporaryTargetDataIncludingInvalidFromTime(timestamp: Long): Single<List<TemporaryTarget>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ data class UserEntry(
Garmin,
Database, //for PersistenceLayer
Unknown, //if necessary
Remora
;

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ class PersistenceLayerImpl @Inject constructor(
.map { list -> list.asSequence().map { it.fromDb() }.toList() }
.blockingGet()

override fun getCarbsFromTimeToTimeNotExpanded(startTime: Long, endTime: Long, ascending: Boolean): List<CA> =
repository.getCarbsDataFromTimeToTimeNotExpanded(startTime, endTime, ascending)
.map { list -> list.asSequence().map { it.fromDb() }.toList() }
.blockingGet()

override fun getNextSyncElementCarbs(id: Long): Maybe<Pair<CA, CA>> =
repository.getNextSyncElementCarbs(id)
.map { pair -> Pair(pair.first.fromDb(), pair.second.fromDb()) }
Expand Down Expand Up @@ -1400,6 +1405,9 @@ class PersistenceLayerImpl @Inject constructor(
override fun getTemporaryTargetDataFromTime(timestamp: Long, ascending: Boolean): Single<List<TT>> =
repository.getTemporaryTargetDataFromTime(timestamp, ascending).map { list -> list.asSequence().map { it.fromDb() }.toList() }

override fun getTemporaryTargetDataFromTimeToTime(start: Long, end: Long, ascending: Boolean): Single<List<TT>> =
repository.getTemporaryTargetDataFromTimeToTime(start, end, ascending).map { list -> list.asSequence().map { it.fromDb() }.toList() }

override fun getTemporaryTargetDataIncludingInvalidFromTime(timestamp: Long, ascending: Boolean): Single<List<TT>> =
repository.getTemporaryTargetDataIncludingInvalidFromTime(timestamp, ascending).map { list -> list.asSequence().map { it.fromDb() }.toList() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ fun UserEntry.Sources.fromDb(): Sources =
UserEntry.Sources.Unknown -> Sources.Unknown
UserEntry.Sources.Ottai -> Sources.Ottai
UserEntry.Sources.SyaiTag -> Sources.SyaiTag
UserEntry.Sources.Remora -> Sources.Remora
}

fun Sources.toDb(): UserEntry.Sources =
Expand Down Expand Up @@ -159,5 +160,6 @@ fun Sources.toDb(): UserEntry.Sources =
Sources.Unknown -> UserEntry.Sources.Unknown
Sources.Ottai -> UserEntry.Sources.Ottai
Sources.SyaiTag -> UserEntry.Sources.SyaiTag
Sources.Remora -> UserEntry.Sources.Remora
}

Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class CommandQueueImplementation @Inject constructor(
private val decimalFormatter: DecimalFormatter,
private val instantiator: Instantiator,
private val jobName: CommandQueueName,
private val workManager: WorkManager
private val workManager: WorkManager,
) : CommandQueue {

private val disposable = CompositeDisposable()
Expand Down Expand Up @@ -167,7 +167,8 @@ class CommandQueueImplementation @Inject constructor(
synchronized(queue) {
for (i in queue.indices.reversed()) {
if (queue[i].commandType == type) {
queue.removeAt(i)
queue.removeAt(i).callback
?.result(instantiator.providePumpEnactResult().success(false).enacted(false))?.run()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class UserEntryPresentationHelperImpl @Inject constructor(
Sources.BgFragment -> R.drawable.ic_aaps
Sources.Ottai -> R.drawable.ic_ottai
Sources.SyaiTag -> R.drawable.ic_syai_tag
Sources.Remora -> R.drawable.ic_remora
}

override fun actionToColoredString(action: Action): Spanned = when (action) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ dependencies {

ksp(libs.com.google.dagger.compiler)
ksp(libs.com.google.dagger.android.processor)

implementation("de.tebbeubben.remora:lib")
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import dagger.android.ContributesAndroidInjector
SkinsModule::class,
ActionsModule::class,
OverviewModule::class,
RemoraModule::class
]
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package app.aaps.plugins.main.di

import app.aaps.plugins.main.general.remora.RemoraFragment
import dagger.Module
import dagger.android.ContributesAndroidInjector

@Module
@Suppress("unused")
abstract class RemoraModule {

@ContributesAndroidInjector abstract fun contributesRemoraFragment(): RemoraFragment
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package app.aaps.plugins.main.general.remora

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import app.aaps.plugins.main.R
import dagger.android.support.DaggerFragment
import de.tebbeubben.remora.lib.ui.RemoraLibActivity

class RemoraFragment : DaggerFragment() {

@SuppressLint("MissingInflatedId")
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.remora_fragment, container, false)
val launchActivityButton: Button = view.findViewById(R.id.launch_activity_button)
launchActivityButton.setOnClickListener {
val intent = Intent(activity, RemoraLibActivity::class.java)
startActivity(intent)
}
return view
}
}
Loading