:plugins:source module

This commit is contained in:
Milos Kozak 2022-12-09 16:20:40 +01:00
parent 16bf64129d
commit bc9ec4c9c5
51 changed files with 290 additions and 190 deletions

View file

@ -203,6 +203,7 @@ dependencies {
implementation project(':plugins:main')
implementation project(':plugins:openhumans')
implementation project(':plugins:sensitivity')
implementation project(':plugins:source')
implementation project(':plugins:sync')
implementation project(':implementation')
implementation project(':database:entities')

View file

@ -48,14 +48,6 @@ import info.nightscout.plugins.general.autotune.AutotunePlugin
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.plugins.general.wear.WearPlugin
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.plugins.source.AidexPlugin
import info.nightscout.plugins.source.DexcomPlugin
import info.nightscout.plugins.source.EversensePlugin
import info.nightscout.plugins.source.GlimpPlugin
import info.nightscout.plugins.source.GlunovoPlugin
import info.nightscout.plugins.source.IntelligoPlugin
import info.nightscout.plugins.source.PoctechPlugin
import info.nightscout.plugins.source.TomatoPlugin
import info.nightscout.plugins.sync.nsclient.NSClientPlugin
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
@ -72,6 +64,14 @@ import info.nightscout.sensitivity.SensitivityWeightedAveragePlugin
import info.nightscout.shared.SafeParse
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.source.AidexPlugin
import info.nightscout.source.DexcomPlugin
import info.nightscout.source.EversensePlugin
import info.nightscout.source.GlimpPlugin
import info.nightscout.source.GlunovoPlugin
import info.nightscout.source.IntelligoPlugin
import info.nightscout.source.PoctechPlugin
import info.nightscout.source.TomatoPlugin
import javax.inject.Inject
class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeListener {

View file

@ -36,6 +36,7 @@ import info.nightscout.pump.virtual.di.VirtualPumpModule
import info.nightscout.rx.di.RxModule
import info.nightscout.shared.di.SharedModule
import info.nightscout.shared.impl.di.SharedImplModule
import info.nightscout.source.di.SourceModule
import info.nightscout.ui.di.UiModule
import info.nightscout.workflow.di.WorkflowModule
import javax.inject.Singleton
@ -66,6 +67,7 @@ import javax.inject.Singleton
UiModule::class,
ValidatorsModule::class,
PluginsConstraintsModule::class,
SourceModule::class,
SyncModule::class,
WorkflowModule::class,

View file

@ -41,17 +41,6 @@ import info.nightscout.plugins.general.wear.WearPlugin
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin
import info.nightscout.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.source.AidexPlugin
import info.nightscout.plugins.source.DexcomPlugin
import info.nightscout.plugins.source.GlimpPlugin
import info.nightscout.plugins.source.GlunovoPlugin
import info.nightscout.plugins.source.IntelligoPlugin
import info.nightscout.plugins.source.MM640gPlugin
import info.nightscout.plugins.source.NSClientSourcePlugin
import info.nightscout.plugins.source.PoctechPlugin
import info.nightscout.plugins.source.RandomBgPlugin
import info.nightscout.plugins.source.TomatoPlugin
import info.nightscout.plugins.source.XdripPlugin
import info.nightscout.plugins.sync.nsclient.NSClientPlugin
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
@ -62,6 +51,17 @@ import info.nightscout.pump.virtual.VirtualPumpPlugin
import info.nightscout.sensitivity.SensitivityAAPSPlugin
import info.nightscout.sensitivity.SensitivityOref1Plugin
import info.nightscout.sensitivity.SensitivityWeightedAveragePlugin
import info.nightscout.source.AidexPlugin
import info.nightscout.source.DexcomPlugin
import info.nightscout.source.GlimpPlugin
import info.nightscout.source.GlunovoPlugin
import info.nightscout.source.IntelligoPlugin
import info.nightscout.source.MM640gPlugin
import info.nightscout.source.NSClientSourcePlugin
import info.nightscout.source.PoctechPlugin
import info.nightscout.source.RandomBgPlugin
import info.nightscout.source.TomatoPlugin
import info.nightscout.source.XdripPlugin
import javax.inject.Qualifier
@Suppress("unused")

View file

@ -12,17 +12,17 @@ import info.nightscout.core.utils.extensions.copyString
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.interfaces.receivers.Intents
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.plugins.source.AidexPlugin
import info.nightscout.plugins.source.DexcomPlugin
import info.nightscout.plugins.source.EversensePlugin
import info.nightscout.plugins.source.GlimpPlugin
import info.nightscout.plugins.source.MM640gPlugin
import info.nightscout.plugins.source.PoctechPlugin
import info.nightscout.plugins.source.TomatoPlugin
import info.nightscout.plugins.source.XdripPlugin
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.BundleLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.source.AidexPlugin
import info.nightscout.source.DexcomPlugin
import info.nightscout.source.EversensePlugin
import info.nightscout.source.GlimpPlugin
import info.nightscout.source.MM640gPlugin
import info.nightscout.source.PoctechPlugin
import info.nightscout.source.TomatoPlugin
import info.nightscout.source.XdripPlugin
import javax.inject.Inject
open class DataReceiver : DaggerBroadcastReceiver() {

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.workflow
import info.nightscout.interfaces.workflow.WorkerClasses
import info.nightscout.plugins.general.food.FoodPlugin
import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.source.NSClientSourcePlugin
import info.nightscout.source.NSClientSourcePlugin
import javax.inject.Inject
class WorkerClassesImpl @Inject constructor(): WorkerClasses{

View file

@ -37,14 +37,14 @@ import info.nightscout.plugins.constraints.ConstraintsImpl
import info.nightscout.plugins.constraints.objectives.ObjectivesPlugin
import info.nightscout.plugins.constraints.objectives.objectives.Objective
import info.nightscout.plugins.constraints.safety.SafetyPlugin
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.plugins.source.GlimpPlugin
import info.nightscout.pump.combo.ComboPlugin
import info.nightscout.pump.combo.ruffyscripter.RuffyScripter
import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.R
import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.pump.virtual.VirtualPumpPlugin
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.source.GlimpPlugin
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

View file

@ -21,7 +21,7 @@ import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.aps.loop.LoopFragment
import info.nightscout.plugins.aps.loop.LoopPlugin
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.pump.virtual.VirtualPumpPlugin
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP

View file

@ -19,9 +19,9 @@ import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
import info.nightscout.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.plugins.constraints.safety.SafetyPlugin
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.plugins.source.GlimpPlugin
import info.nightscout.pump.virtual.VirtualPumpPlugin
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.source.GlimpPlugin
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

View file

@ -1,3 +1,8 @@
package info.nightscout.interfaces.source
interface DexcomBoyda
interface DexcomBoyda {
fun isEnabled(): Boolean
fun requestPermissionIfNeeded()
fun findDexcomPackageName(): String?
}

View file

@ -0,0 +1,5 @@
package info.nightscout.interfaces.source
interface XDrip {
fun isEnabled(): Boolean
}

View file

@ -21,6 +21,8 @@ files:
translation: /plugins/openhumans/src/main/res/values-%android_code%/strings.xml
- source: /plugins/sensitivity/src/main/res/values/strings.xml
translation: /plugins/sensitivity/src/main/res/values-%android_code%/strings.xml
- source: /plugins/source/src/main/res/values/strings.xml
translation: /plugins/source/src/main/res/values-%android_code%/strings.xml
- source: /plugins/insulin/src/main/res/values/strings.xml
translation: /plugins/insulin/src/main/res/values-%android_code%/strings.xml
- source: /plugins/configuration/src/main/res/values/strings.xml

View file

@ -85,7 +85,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
}
val injector = HasAndroidInjector {
private val injector = HasAndroidInjector {
AndroidInjector {
if (it is Command) {
it.aapsLogger = aapsLogger

View file

@ -37,7 +37,7 @@ class BgQualityCheckPluginTest : TestBase() {
private lateinit var plugin: BgQualityCheckPlugin
private val injector = HasAndroidInjector { AndroidInjector { } }
val now = 100000000L
private val now = 100000000L
//private val autosensDataStore = AutosensDataStoreObject()
@BeforeEach
@ -234,6 +234,9 @@ class BgQualityCheckPluginTest : TestBase() {
class DexcomPlugin : BgSource, DexcomBoyda {
override fun shouldUploadToNs(glucoseValue: GlucoseValue): Boolean = true
override fun isEnabled(): Boolean = false
override fun requestPermissionIfNeeded() {}
override fun findDexcomPackageName(): String? = null
}
`when`(activePlugin.activeBgSource).thenReturn(DexcomPlugin())
plugin.processBgData()

View file

@ -19,10 +19,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".source.activities.RequestDexcomPermissionActivity"
android:exported="false" />
<activity
android:name="info.nightscout.plugins.general.overview.activities.QuickWizardListActivity"
android:exported="false"

View file

@ -17,7 +17,6 @@ import info.nightscout.plugins.iob.iobCobCalculator.data.AutosensDataObject
FoodModule::class,
SMSCommunicatorModule::class,
ProfileModule::class,
SourceModule::class,
SkinsModule::class,
SkinsUiModule::class,
ActionsModule::class,

View file

@ -3,10 +3,12 @@ package info.nightscout.plugins.di
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.plugins.profile.ProfileFragment
import info.nightscout.plugins.profile.ProfilePlugin
@Module
@Suppress("unused")
abstract class ProfileModule {
@ContributesAndroidInjector abstract fun contributesNSProfileWorker(): ProfilePlugin.NSProfileWorker
@ContributesAndroidInjector abstract fun contributesLocalProfileFragment(): ProfileFragment
}

View file

@ -64,6 +64,8 @@ import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.protection.ProtectionCheck
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.source.DexcomBoyda
import info.nightscout.interfaces.source.XDrip
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.TrendCalculator
@ -74,8 +76,6 @@ import info.nightscout.plugins.general.overview.graphData.GraphData
import info.nightscout.plugins.general.overview.notifications.NotificationStore
import info.nightscout.plugins.general.overview.notifications.events.EventUpdateOverviewNotification
import info.nightscout.plugins.skins.SkinProvider
import info.nightscout.plugins.source.DexcomPlugin
import info.nightscout.plugins.source.XdripPlugin
import info.nightscout.plugins.ui.StatusLightHandler
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
@ -127,9 +127,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
@Inject lateinit var loop: Loop
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var iobCobCalculator: IobCobCalculator
@Inject lateinit var dexcomPlugin: DexcomPlugin
@Inject lateinit var dexcomMediator: DexcomPlugin.DexcomMediator
@Inject lateinit var xdripPlugin: XdripPlugin
@Inject lateinit var dexcomBoyda: DexcomBoyda
@Inject lateinit var xDrip: XDrip
@Inject lateinit var notificationStore: NotificationStore
@Inject lateinit var quickWizard: QuickWizard
@Inject lateinit var config: Config
@ -400,10 +399,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
R.id.cgm_button -> {
if (xdripPlugin.isEnabled())
if (xDrip.isEnabled())
openCgmApp("com.eveningoutpost.dexdrip")
else if (dexcomPlugin.isEnabled()) {
dexcomMediator.findDexcomPackageName()?.let {
else if (dexcomBoyda.isEnabled()) {
dexcomBoyda.findDexcomPackageName()?.let {
openCgmApp(it)
}
?: ToastUtils.infoToast(activity, rh.gs(R.string.dexcom_app_not_installed))
@ -411,11 +410,11 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
R.id.calibration_button -> {
if (xdripPlugin.isEnabled()) {
if (xDrip.isEnabled()) {
uiInteraction.runCalibrationDialog(childFragmentManager)
} else if (dexcomPlugin.isEnabled()) {
} else if (dexcomBoyda.isEnabled()) {
try {
dexcomMediator.findDexcomPackageName()?.let {
dexcomBoyda.findDexcomPackageName()?.let {
startActivity(
Intent("com.dexcom.cgm.activities.MeterEntryActivity")
.setPackage(it)
@ -577,8 +576,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
&& sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility()
// **** Calibration & CGM buttons ****
val xDripIsBgSource = xdripPlugin.isEnabled()
val dexcomIsSource = dexcomPlugin.isEnabled()
val xDripIsBgSource = xDrip.isEnabled()
val dexcomIsSource = dexcomBoyda.isEnabled()
binding.buttonsLayout.calibrationButton.visibility = (xDripIsBgSource && actualBG != null && sp.getBoolean(R.string.key_show_calibration_button, true)).toVisibility()
if (dexcomIsSource) {
binding.buttonsLayout.cgmButton.setCompoundDrawablesWithIntrinsicBounds(null, rh.gd(R.drawable.ic_byoda), null, null)

View file

@ -344,48 +344,6 @@
<string name="graph_scale">Graph scale</string>
<string name="graph_menu_divider_header">Graph</string>
<!-- Source -->
<string name="key_dexcom_log_ns_sensor_change" translatable="false">dexcom_lognssensorchange</string>
<string name="key_last_processed_glunovo_timestamp" translatable="false">last_processed_glunovo_timestamp</string>
<string name="key_last_processed_intelligo_timestamp" translatable="false">last_processed_intelligo_timestamp</string>
<string name="ns_client_bg">NSClient BG</string>
<string name="ns_client_bg_short">NS BG</string>
<string name="description_source_ns_client">Downloads BG data from Nightscout</string>
<string name="xdrip">xDrip+</string>
<string name="description_source_xdrip">Receive BG values from xDrip+.</string>
<string name="dexcom_app_patched">BYODA</string>
<string name="dexcom_short">BYODA</string>
<string name="description_source_dexcom">Receive BG values from the \'Build Your Own Dexcom App\'.</string>
<string name="eversense">Eversense App (patched)</string>
<string name="eversense_shortname" translatable="false">EVR</string>
<string name="description_source_eversense">Receive BG values from the patched Eversense app.</string>
<string name="glimp">Glimp</string>
<string name="description_source_glimp">Receive BG values from Glimp.</string>
<string name="mm640g">MM640g</string>
<string name="description_source_mm640g">Receive BG values from the 600SeriesAndroidUploader.</string>
<string name="poctech">Poctech</string>
<string name="description_source_poctech">Receive BG values from Poctech app</string>
<string name="glunovo">Glunovo</string>
<string name="description_source_glunovo">Receive values from Glunovo app</string>
<string name="intelligo">Intelligo</string>
<string name="description_source_intelligo">Receive values from Intelligo app</string>
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="description_source_tomato">Receive BG values from Tomato app (MiaoMiao device)</string>
<string name="aidex">GlucoRx Aidex</string>
<string name="aidex_short">Aidex</string>
<string name="description_source_aidex">Receive BG values from GlucoRx Aidex CGMS.</string>
<string name="random_bg">Random BG</string>
<string name="description_source_random_bg">Generate random BG data (Demo mode only)</string>
<string name="random_bg_short">BG</string>
<string name="do_xdrip_upload_title">Send BG data to xDrip+</string>
<string name="do_xdrip_upload_summary">In xDrip+ select 640g/Eversense data source</string>
<string name="bgsource_upload">BG upload settings</string>
<string name="dexcom_log_ns_sensor_change_title">Log sensor change to NS</string>
<string name="dexcom_log_ns_sensor_change_summary">Create event \"Sensor Change\" in NS automatically on sensor start</string>
<!-- Skins -->
<string name="key_skin" translatable="false">skin</string>

1
plugins/source/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

View file

@ -0,0 +1,28 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-allopen'
id 'com.hiya.jacoco-android'
}
apply from: "${project.rootDir}/core/main/android_dependencies.gradle"
apply from: "${project.rootDir}/core/main/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/main/allopen_dependencies.gradle"
apply from: "${project.rootDir}/core/main/test_dependencies.gradle"
apply from: "${project.rootDir}/core/main/jacoco_global.gradle"
android {
namespace 'info.nightscout.source'
}
dependencies {
implementation project(':app-wear-shared:shared')
implementation project(':database:entities')
implementation project(':database:impl')
implementation project(':core:interfaces')
implementation project(':core:main')
implementation project(':core:ns-sdk')
implementation project(':core:ui')
implementation project(':core:utils')
}

View file

21
plugins/source/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity
android:name="info.nightscout.source.activities.RequestDexcomPermissionActivity"
android:exported="false" />
</application>
</manifest>

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import androidx.work.WorkerParameters
@ -17,7 +17,6 @@ import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.receivers.Intents
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.os.Bundle
import android.util.SparseArray
@ -29,9 +29,6 @@ import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.SourceFragmentBinding
import info.nightscout.plugins.databinding.SourceItemBinding
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNewBG
@ -41,6 +38,8 @@ import info.nightscout.shared.extensions.toVisibility
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import info.nightscout.source.databinding.SourceFragmentBinding
import info.nightscout.source.databinding.SourceItemBinding
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import java.util.concurrent.TimeUnit

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import android.content.Intent
@ -28,8 +28,6 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.source.BgSource
import info.nightscout.interfaces.source.DexcomBoyda
import info.nightscout.plugins.R
import info.nightscout.plugins.source.activities.RequestDexcomPermissionActivity
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.extensions.safeGetInstalledPackages
@ -37,6 +35,7 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import info.nightscout.source.activities.RequestDexcomPermissionActivity
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.abs
@ -47,7 +46,7 @@ class DexcomPlugin @Inject constructor(
rh: ResourceHelper,
aapsLogger: AAPSLogger,
private val sp: SP,
private val dexcomMediator: DexcomMediator,
private val context: Context,
config: Config
) : PluginBase(
PluginDescription()
@ -77,7 +76,7 @@ class DexcomPlugin @Inject constructor(
override fun onStart() {
super.onStart()
dexcomMediator.requestPermissionIfNeeded()
requestPermissionIfNeeded()
}
// cannot be inner class because of needed injection
@ -222,6 +221,22 @@ class DexcomPlugin @Inject constructor(
}
}
override fun requestPermissionIfNeeded() {
if (ContextCompat.checkSelfPermission(context, PERMISSION) != PackageManager.PERMISSION_GRANTED) {
val intent = Intent(context, RequestDexcomPermissionActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
}
}
override fun findDexcomPackageName(): String? {
val packageManager = context.packageManager
for (packageInfo in packageManager.safeGetInstalledPackages(0)) {
if (PACKAGE_NAMES.contains(packageInfo.packageName)) return packageInfo.packageName
}
return null
}
companion object {
private val PACKAGE_NAMES = arrayOf(
@ -232,23 +247,4 @@ class DexcomPlugin @Inject constructor(
)
const val PERMISSION = "com.dexcom.cgm.EXTERNAL_PERMISSION"
}
class DexcomMediator @Inject constructor(val context: Context) {
fun requestPermissionIfNeeded() {
if (ContextCompat.checkSelfPermission(context, PERMISSION) != PackageManager.PERMISSION_GRANTED) {
val intent = Intent(context, RequestDexcomPermissionActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
}
}
fun findDexcomPackageName(): String? {
val packageManager = context.packageManager
for (packageInfo in packageManager.safeGetInstalledPackages(0)) {
if (PACKAGE_NAMES.contains(packageInfo.packageName)) return packageInfo.packageName
}
return null
}
}
}

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import androidx.work.WorkerParameters
@ -17,7 +17,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import androidx.work.WorkerParameters
@ -15,7 +15,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import android.net.Uri
@ -20,7 +20,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import android.content.pm.PackageManager
@ -22,7 +22,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.extensions.safeGetInstalledPackages

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import androidx.work.WorkerParameters
@ -15,7 +15,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import androidx.work.WorkerParameters
@ -21,7 +21,6 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.interfaces.source.DoingOwnUploadSource
import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.plugins.R
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventDismissNotification
import info.nightscout.rx.logging.AAPSLogger

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import androidx.work.WorkerParameters
@ -16,7 +16,6 @@ import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.interfaces.utils.JsonHelper.safeGetString
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.os.Handler
import android.os.HandlerThread
@ -16,7 +16,6 @@ import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.pump.VirtualPump
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import androidx.work.WorkerParameters
@ -14,7 +14,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.source.BgSource
import info.nightscout.plugins.R
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper

View file

@ -1,4 +1,4 @@
package info.nightscout.plugins.source
package info.nightscout.source
import android.content.Context
import androidx.work.WorkerParameters
@ -16,7 +16,7 @@ import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.receivers.Intents
import info.nightscout.interfaces.source.BgSource
import info.nightscout.interfaces.source.DoingOwnUploadSource
import info.nightscout.plugins.R
import info.nightscout.interfaces.source.XDrip
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
@ -36,7 +36,7 @@ class XdripPlugin @Inject constructor(
.pluginName(R.string.xdrip)
.description(R.string.description_source_xdrip),
aapsLogger, rh, injector
), BgSource, DoingOwnUploadSource {
), BgSource, DoingOwnUploadSource, XDrip {
private var advancedFiltering = false
override var sensorBatteryLevel = -1

View file

@ -1,8 +1,8 @@
package info.nightscout.plugins.source.activities
package info.nightscout.source.activities
import android.os.Bundle
import info.nightscout.core.ui.activities.DialogAppCompatActivity
import info.nightscout.plugins.source.DexcomPlugin
import info.nightscout.source.DexcomPlugin
class RequestDexcomPermissionActivity : DialogAppCompatActivity() {

View file

@ -1,21 +1,22 @@
package info.nightscout.plugins.di
package info.nightscout.source.di
import dagger.Binds
import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.interfaces.source.DexcomBoyda
import info.nightscout.interfaces.source.NSClientSource
import info.nightscout.plugins.profile.ProfilePlugin
import info.nightscout.plugins.source.AidexPlugin
import info.nightscout.plugins.source.BGSourceFragment
import info.nightscout.plugins.source.DexcomPlugin
import info.nightscout.plugins.source.EversensePlugin
import info.nightscout.plugins.source.GlimpPlugin
import info.nightscout.plugins.source.MM640gPlugin
import info.nightscout.plugins.source.NSClientSourcePlugin
import info.nightscout.plugins.source.PoctechPlugin
import info.nightscout.plugins.source.TomatoPlugin
import info.nightscout.plugins.source.XdripPlugin
import info.nightscout.plugins.source.activities.RequestDexcomPermissionActivity
import info.nightscout.interfaces.source.XDrip
import info.nightscout.source.AidexPlugin
import info.nightscout.source.BGSourceFragment
import info.nightscout.source.DexcomPlugin
import info.nightscout.source.EversensePlugin
import info.nightscout.source.GlimpPlugin
import info.nightscout.source.MM640gPlugin
import info.nightscout.source.NSClientSourcePlugin
import info.nightscout.source.PoctechPlugin
import info.nightscout.source.TomatoPlugin
import info.nightscout.source.XdripPlugin
import info.nightscout.source.activities.RequestDexcomPermissionActivity
@Module(
includes = [
@ -28,7 +29,6 @@ abstract class SourceModule {
@ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment
@ContributesAndroidInjector abstract fun contributesNSProfileWorker(): ProfilePlugin.NSProfileWorker
@ContributesAndroidInjector abstract fun contributesNSClientSourceWorker(): NSClientSourcePlugin.NSClientSourceWorker
@ContributesAndroidInjector abstract fun contributesXdripWorker(): XdripPlugin.XdripWorker
@ContributesAndroidInjector abstract fun contributesDexcomWorker(): DexcomPlugin.DexcomWorker
@ -43,6 +43,9 @@ abstract class SourceModule {
@Module
interface Bindings {
@Binds fun bindNSClientSource(nsClientSourcePlugin: NSClientSourcePlugin): NSClientSource
@Binds fun bindDexcomBoyda(dexcomPlugin: DexcomPlugin): DexcomBoyda
@Binds fun bindXDrip(xdripPlugin: XdripPlugin): XDrip
}
}

View file

@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="2dp"
tools:context=".source.BGSourceFragment">
tools:context=".BGSourceFragment">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"

View file

@ -54,7 +54,8 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
app:srcCompat="@drawable/ic_flat" />
app:srcCompat="@drawable/ic_flat"
android:contentDescription="@string/direction" />
<TextView
android:id="@+id/ns"

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Source -->
<string name="key_dexcom_log_ns_sensor_change" translatable="false">dexcom_lognssensorchange</string>
<string name="key_last_processed_glunovo_timestamp" translatable="false">last_processed_glunovo_timestamp</string>
<string name="key_last_processed_intelligo_timestamp" translatable="false">last_processed_intelligo_timestamp</string>
<string name="ns_client_bg">NSClient BG</string>
<string name="ns_client_bg_short">NS BG</string>
<string name="description_source_ns_client">Downloads BG data from Nightscout</string>
<string name="xdrip">xDrip+</string>
<string name="description_source_xdrip">Receive BG values from xDrip+.</string>
<string name="dexcom_app_patched">BYODA</string>
<string name="dexcom_short">BYODA</string>
<string name="description_source_dexcom">Receive BG values from the \'Build Your Own Dexcom App\'.</string>
<string name="eversense">Eversense App (patched)</string>
<string name="eversense_shortname" translatable="false">EVR</string>
<string name="description_source_eversense">Receive BG values from the patched Eversense app.</string>
<string name="glimp">Glimp</string>
<string name="description_source_glimp">Receive BG values from Glimp.</string>
<string name="mm640g">MM640g</string>
<string name="description_source_mm640g">Receive BG values from the 600SeriesAndroidUploader.</string>
<string name="poctech">Poctech</string>
<string name="description_source_poctech">Receive BG values from Poctech app</string>
<string name="glunovo">Glunovo</string>
<string name="description_source_glunovo">Receive values from Glunovo app</string>
<string name="intelligo">Intelligo</string>
<string name="description_source_intelligo">Receive values from Intelligo app</string>
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="description_source_tomato">Receive BG values from Tomato app (MiaoMiao device)</string>
<string name="aidex">GlucoRx Aidex</string>
<string name="aidex_short">Aidex</string>
<string name="description_source_aidex">Receive BG values from GlucoRx Aidex CGMS.</string>
<string name="random_bg">Random BG</string>
<string name="description_source_random_bg">Generate random BG data (Demo mode only)</string>
<string name="random_bg_short">BG</string>
<string name="do_xdrip_upload_title">Send BG data to xDrip+</string>
<string name="do_xdrip_upload_summary">In xDrip+ select 640g/Eversense data source</string>
<string name="bgsource_upload">BG upload settings</string>
<string name="dexcom_log_ns_sensor_change_title">Log sensor change to NS</string>
<string name="dexcom_log_ns_sensor_change_summary">Create event \"Sensor Change\" in NS automatically on sensor start</string>
<string name="direction">direction</string>
</resources>

View file

@ -0,0 +1,37 @@
package info.nightscout.androidaps
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.logging.AAPSLoggerTest
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.Mockito
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.quality.Strictness
import java.util.Locale
@ExtendWith(MockitoExtension::class)
@MockitoSettings(strictness = Strictness.LENIENT)
open class TestBase {
val aapsLogger = AAPSLoggerTest()
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
@BeforeEach
fun setupLocale() {
Locale.setDefault(Locale.ENGLISH)
System.setProperty("disableFirebase", "true")
}
// Workaround for Kotlin nullability.
// https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791
// https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin
fun <T> anyObject(): T {
Mockito.any<T>()
return uninitialized()
}
@Suppress("Unchecked_Cast")
fun <T> uninitialized(): T = null as T
}

View file

@ -1,12 +1,10 @@
package info.nightscout.androidaps.plugins.source
package info.nightscout.source
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.plugins.source.GlimpPlugin
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -20,10 +18,10 @@ class GlimpPluginTest : TestBase() {
@BeforeEach
fun setup() {
glimpPlugin = GlimpPlugin(HasAndroidInjector { AndroidInjector { } }, rh, aapsLogger, sp)
glimpPlugin = GlimpPlugin({ AndroidInjector { } }, rh, aapsLogger, sp)
}
@Test fun advancedFilteringSupported() {
Assert.assertEquals(false, glimpPlugin.advancedFilteringSupported())
Assertions.assertEquals(false, glimpPlugin.advancedFilteringSupported())
}
}

View file

@ -1,12 +1,10 @@
package info.nightscout.androidaps.plugins.source
package info.nightscout.source
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.plugins.source.MM640gPlugin
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -20,10 +18,10 @@ class MM640GPluginTest : TestBase() {
@BeforeEach
fun setup() {
mM640gPlugin = MM640gPlugin(HasAndroidInjector { AndroidInjector { } }, rh, aapsLogger, sp)
mM640gPlugin = MM640gPlugin({ AndroidInjector { } }, rh, aapsLogger, sp)
}
@Test fun advancedFilteringSupported() {
Assert.assertEquals(false, mM640gPlugin.advancedFilteringSupported())
Assertions.assertEquals(false, mM640gPlugin.advancedFilteringSupported())
}
}

View file

@ -1,29 +1,27 @@
package info.nightscout.androidaps.plugins.source
package info.nightscout.source
import dagger.android.AndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.Config
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
class NSClientPluginTest : TestBase() {
private lateinit var nsClientSourcePlugin: info.nightscout.plugins.source.NSClientSourcePlugin
private lateinit var nsClientSourcePlugin: NSClientSourcePlugin
@Mock lateinit var rh: ResourceHelper
@Mock lateinit var sp: SP
@Mock lateinit var config: Config
@BeforeEach
fun setup() {
nsClientSourcePlugin = info.nightscout.plugins.source.NSClientSourcePlugin({ AndroidInjector { } }, rh, aapsLogger, config)
nsClientSourcePlugin = NSClientSourcePlugin({ AndroidInjector { } }, rh, aapsLogger, config)
}
@Test fun advancedFilteringSupported() {
Assert.assertEquals(false, nsClientSourcePlugin.advancedFilteringSupported())
Assertions.assertEquals(false, nsClientSourcePlugin.advancedFilteringSupported())
}
}

View file

@ -1,11 +1,9 @@
package info.nightscout.androidaps.plugins.source
package info.nightscout.source
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.plugins.source.XdripPlugin
import info.nightscout.shared.interfaces.ResourceHelper
import org.junit.Assert
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -18,10 +16,10 @@ class XdripPluginTest : TestBase() {
@BeforeEach
fun setup() {
xdripPlugin = XdripPlugin(HasAndroidInjector { AndroidInjector { } }, rh, aapsLogger)
xdripPlugin = XdripPlugin({ AndroidInjector { } }, rh, aapsLogger)
}
@Test fun advancedFilteringSupported() {
Assert.assertEquals(false, xdripPlugin.advancedFilteringSupported())
Assertions.assertEquals(false, xdripPlugin.advancedFilteringSupported())
}
}

View file

@ -22,6 +22,7 @@ include ':plugins:insulin'
include ':plugins:main'
include ':plugins:openhumans'
include ':plugins:sensitivity'
include ':plugins:source'
include ':plugins:constraints'
include ':pump:combo'
include ':pump:combov2'