transfer overview configuration to NSClient
This commit is contained in:
parent
5f1492976b
commit
30624053e3
19 changed files with 246 additions and 129 deletions
|
@ -173,8 +173,8 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null,
|
protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null,
|
||||||
UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) }),
|
UIRunnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed)) { finish() } },
|
||||||
UIRunnable(Runnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) })
|
UIRunnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed)) { finish() } }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,14 +193,14 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
val pageAdapter = TabPageAdapter(this)
|
val pageAdapter = TabPageAdapter(this)
|
||||||
main_navigation_view.setNavigationItemSelectedListener { true }
|
main_navigation_view.setNavigationItemSelectedListener { true }
|
||||||
val menu = main_navigation_view.menu.also { it.clear() }
|
val menu = main_navigation_view.menu.also { it.clear() }
|
||||||
for (p in activePlugin.pluginsList) {
|
for (p in activePlugin.getPluginsList()) {
|
||||||
pageAdapter.registerNewFragment(p)
|
pageAdapter.registerNewFragment(p)
|
||||||
if (p.isEnabled() && p.hasFragment() && !p.isFragmentVisible() && !p.pluginDescription.neverVisible) {
|
if (p.isEnabled() && p.hasFragment() && !p.isFragmentVisible() && !p.pluginDescription.neverVisible) {
|
||||||
val menuItem = menu.add(p.name)
|
val menuItem = menu.add(p.name)
|
||||||
menuItem.isCheckable = true
|
menuItem.isCheckable = true
|
||||||
menuItem.setOnMenuItemClickListener {
|
menuItem.setOnMenuItemClickListener {
|
||||||
val intent = Intent(this, SingleFragmentActivity::class.java)
|
val intent = Intent(this, SingleFragmentActivity::class.java)
|
||||||
intent.putExtra("plugin", activePlugin.pluginsList.indexOf(p))
|
intent.putExtra("plugin", activePlugin.getPluginsList().indexOf(p))
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
main_drawer_layout.closeDrawers()
|
main_drawer_layout.closeDrawers()
|
||||||
true
|
true
|
||||||
|
@ -274,7 +274,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.nav_preferences -> {
|
R.id.nav_preferences -> {
|
||||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, Runnable {
|
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||||
val i = Intent(this, PreferencesActivity::class.java)
|
val i = Intent(this, PreferencesActivity::class.java)
|
||||||
i.putExtra("id", -1)
|
i.putExtra("id", -1)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
|
@ -323,7 +323,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
R.id.nav_plugin_preferences -> {
|
R.id.nav_plugin_preferences -> {
|
||||||
val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem)
|
val plugin = (main_pager.adapter as TabPageAdapter).getPluginAt(main_pager.currentItem)
|
||||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, Runnable {
|
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||||
val i = Intent(this, PreferencesActivity::class.java)
|
val i = Intent(this, PreferencesActivity::class.java)
|
||||||
i.putExtra("id", plugin.preferencesId)
|
i.putExtra("id", plugin.preferencesId)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
|
|
|
@ -46,17 +46,17 @@ class ConfigBuilderPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAlwaysEnabledPluginsEnabled() {
|
private fun setAlwaysEnabledPluginsEnabled() {
|
||||||
for (plugin in activePlugin.pluginsList) {
|
for (plugin in activePlugin.getPluginsList()) {
|
||||||
if (plugin.pluginDescription.alwaysEnabled) plugin.setPluginEnabled(plugin.getType(), true)
|
if (plugin.pluginDescription.alwaysEnabled) plugin.setPluginEnabled(plugin.getType(), true)
|
||||||
}
|
}
|
||||||
storeSettings("setAlwaysEnabledPluginsEnabled")
|
storeSettings("setAlwaysEnabledPluginsEnabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun storeSettings(from: String) {
|
override fun storeSettings(from: String) {
|
||||||
activePlugin.pluginsList
|
activePlugin.getPluginsList()
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: $from")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: $from")
|
||||||
activePlugin.verifySelectionInCategories()
|
activePlugin.verifySelectionInCategories()
|
||||||
for (p in activePlugin.pluginsList) {
|
for (p in activePlugin.getPluginsList()) {
|
||||||
val type = p.getType()
|
val type = p.getType()
|
||||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwaysVisible) continue
|
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwaysVisible) continue
|
||||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible) continue
|
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible) continue
|
||||||
|
@ -82,7 +82,7 @@ class ConfigBuilderPlugin @Inject constructor(
|
||||||
|
|
||||||
private fun loadSettings() {
|
private fun loadSettings() {
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Loading stored settings")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Loading stored settings")
|
||||||
for (p in activePlugin.pluginsList) {
|
for (p in activePlugin.getPluginsList()) {
|
||||||
val type = p.getType()
|
val type = p.getType()
|
||||||
loadPref(p, type, true)
|
loadPref(p, type, true)
|
||||||
if (p.getType() == PluginType.PUMP) {
|
if (p.getType() == PluginType.PUMP) {
|
||||||
|
@ -110,7 +110,7 @@ class ConfigBuilderPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun logPluginStatus() {
|
fun logPluginStatus() {
|
||||||
for (p in activePlugin.pluginsList) {
|
for (p in activePlugin.getPluginsList()) {
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, p.name + ":" +
|
aapsLogger.debug(LTag.CONFIGBUILDER, p.name + ":" +
|
||||||
(if (p.isEnabled(PluginType.GENERAL)) " GENERAL" else "") +
|
(if (p.isEnabled(PluginType.GENERAL)) " GENERAL" else "") +
|
||||||
(if (p.isEnabled(PluginType.TREATMENT)) " TREATMENT" else "") +
|
(if (p.isEnabled(PluginType.TREATMENT)) " TREATMENT" else "") +
|
||||||
|
|
|
@ -15,13 +15,13 @@ class PluginStore @Inject constructor(
|
||||||
|
|
||||||
lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
|
lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
|
||||||
|
|
||||||
private var activeBgSource: BgSourceInterface? = null
|
private var activeBgSourceStore: BgSourceInterface? = null
|
||||||
private var activePump: PumpInterface? = null
|
private var activePumpStore: PumpInterface? = null
|
||||||
private var activeProfile: ProfileInterface? = null
|
private var activeProfile: ProfileInterface? = null
|
||||||
private var activeAPS: APSInterface? = null
|
private var activeAPSStore: APSInterface? = null
|
||||||
private var activeInsulin: InsulinInterface? = null
|
private var activeInsulinStore: InsulinInterface? = null
|
||||||
private var activeSensitivity: SensitivityInterface? = null
|
private var activeSensitivityStore: SensitivityInterface? = null
|
||||||
private var activeTreatments: TreatmentsInterface? = null
|
private var activeTreatmentsStore: TreatmentsInterface? = null
|
||||||
|
|
||||||
fun loadDefaults() {
|
fun loadDefaults() {
|
||||||
verifySelectionInCategories()
|
verifySelectionInCategories()
|
||||||
|
@ -71,34 +71,34 @@ class PluginStore @Inject constructor(
|
||||||
// PluginType.APS
|
// PluginType.APS
|
||||||
if (!config.NSCLIENT && !config.PUMPCONTROL) {
|
if (!config.NSCLIENT && !config.PUMPCONTROL) {
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.APS)
|
pluginsInCategory = getSpecificPluginsList(PluginType.APS)
|
||||||
activeAPS = getTheOneEnabledInArray(pluginsInCategory, PluginType.APS) as APSInterface?
|
activeAPSStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.APS) as APSInterface?
|
||||||
if (activeAPS == null) {
|
if (activeAPSStore == null) {
|
||||||
activeAPS = getDefaultPlugin(PluginType.APS) as APSInterface
|
activeAPSStore = getDefaultPlugin(PluginType.APS) as APSInterface
|
||||||
(activeAPS as PluginBase).setPluginEnabled(PluginType.APS, true)
|
(activeAPSStore as PluginBase).setPluginEnabled(PluginType.APS, true)
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting APSInterface")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting APSInterface")
|
||||||
}
|
}
|
||||||
setFragmentVisiblities((activeAPS as PluginBase).name, pluginsInCategory, PluginType.APS)
|
setFragmentVisiblities((activeAPSStore as PluginBase).name, pluginsInCategory, PluginType.APS)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluginType.INSULIN
|
// PluginType.INSULIN
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.INSULIN)
|
pluginsInCategory = getSpecificPluginsList(PluginType.INSULIN)
|
||||||
activeInsulin = getTheOneEnabledInArray(pluginsInCategory, PluginType.INSULIN) as InsulinInterface?
|
activeInsulinStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.INSULIN) as InsulinInterface?
|
||||||
if (activeInsulin == null) {
|
if (activeInsulinStore == null) {
|
||||||
activeInsulin = getDefaultPlugin(PluginType.INSULIN) as InsulinInterface
|
activeInsulinStore = getDefaultPlugin(PluginType.INSULIN) as InsulinInterface
|
||||||
(activeInsulin as PluginBase).setPluginEnabled(PluginType.INSULIN, true)
|
(activeInsulinStore as PluginBase).setPluginEnabled(PluginType.INSULIN, true)
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting InsulinInterface")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting InsulinInterface")
|
||||||
}
|
}
|
||||||
setFragmentVisiblities((activeInsulin as PluginBase).name, pluginsInCategory, PluginType.INSULIN)
|
setFragmentVisiblities((activeInsulinStore as PluginBase).name, pluginsInCategory, PluginType.INSULIN)
|
||||||
|
|
||||||
// PluginType.SENSITIVITY
|
// PluginType.SENSITIVITY
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.SENSITIVITY)
|
pluginsInCategory = getSpecificPluginsList(PluginType.SENSITIVITY)
|
||||||
activeSensitivity = getTheOneEnabledInArray(pluginsInCategory, PluginType.SENSITIVITY) as SensitivityInterface?
|
activeSensitivityStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.SENSITIVITY) as SensitivityInterface?
|
||||||
if (activeSensitivity == null) {
|
if (activeSensitivityStore == null) {
|
||||||
activeSensitivity = getDefaultPlugin(PluginType.SENSITIVITY) as SensitivityInterface
|
activeSensitivityStore = getDefaultPlugin(PluginType.SENSITIVITY) as SensitivityInterface
|
||||||
(activeSensitivity as PluginBase).setPluginEnabled(PluginType.SENSITIVITY, true)
|
(activeSensitivityStore as PluginBase).setPluginEnabled(PluginType.SENSITIVITY, true)
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting SensitivityInterface")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting SensitivityInterface")
|
||||||
}
|
}
|
||||||
setFragmentVisiblities((activeSensitivity as PluginBase).name, pluginsInCategory, PluginType.SENSITIVITY)
|
setFragmentVisiblities((activeSensitivityStore as PluginBase).name, pluginsInCategory, PluginType.SENSITIVITY)
|
||||||
|
|
||||||
// PluginType.PROFILE
|
// PluginType.PROFILE
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.PROFILE)
|
pluginsInCategory = getSpecificPluginsList(PluginType.PROFILE)
|
||||||
|
@ -112,33 +112,33 @@ class PluginStore @Inject constructor(
|
||||||
|
|
||||||
// PluginType.BGSOURCE
|
// PluginType.BGSOURCE
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.BGSOURCE)
|
pluginsInCategory = getSpecificPluginsList(PluginType.BGSOURCE)
|
||||||
activeBgSource = getTheOneEnabledInArray(pluginsInCategory, PluginType.BGSOURCE) as BgSourceInterface?
|
activeBgSourceStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.BGSOURCE) as BgSourceInterface?
|
||||||
if (activeBgSource == null) {
|
if (activeBgSourceStore == null) {
|
||||||
activeBgSource = getDefaultPlugin(PluginType.BGSOURCE) as BgSourceInterface
|
activeBgSourceStore = getDefaultPlugin(PluginType.BGSOURCE) as BgSourceInterface
|
||||||
(activeBgSource as PluginBase).setPluginEnabled(PluginType.BGSOURCE, true)
|
(activeBgSourceStore as PluginBase).setPluginEnabled(PluginType.BGSOURCE, true)
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting BgInterface")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting BgInterface")
|
||||||
}
|
}
|
||||||
setFragmentVisiblities((activeBgSource as PluginBase).name, pluginsInCategory, PluginType.PUMP)
|
setFragmentVisiblities((activeBgSourceStore as PluginBase).name, pluginsInCategory, PluginType.PUMP)
|
||||||
|
|
||||||
// PluginType.PUMP
|
// PluginType.PUMP
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.PUMP)
|
pluginsInCategory = getSpecificPluginsList(PluginType.PUMP)
|
||||||
activePump = getTheOneEnabledInArray(pluginsInCategory, PluginType.PUMP) as PumpInterface?
|
activePumpStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.PUMP) as PumpInterface?
|
||||||
if (activePump == null) {
|
if (activePumpStore == null) {
|
||||||
activePump = getDefaultPlugin(PluginType.PUMP) as PumpInterface
|
activePumpStore = getDefaultPlugin(PluginType.PUMP) as PumpInterface
|
||||||
(activePump as PluginBase).setPluginEnabled(PluginType.PUMP, true)
|
(activePumpStore as PluginBase).setPluginEnabled(PluginType.PUMP, true)
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting PumpInterface")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting PumpInterface")
|
||||||
}
|
}
|
||||||
setFragmentVisiblities((activePump as PluginBase).name, pluginsInCategory, PluginType.PUMP)
|
setFragmentVisiblities((activePumpStore as PluginBase).name, pluginsInCategory, PluginType.PUMP)
|
||||||
|
|
||||||
// PluginType.TREATMENT
|
// PluginType.TREATMENT
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.TREATMENT)
|
pluginsInCategory = getSpecificPluginsList(PluginType.TREATMENT)
|
||||||
activeTreatments = getTheOneEnabledInArray(pluginsInCategory, PluginType.TREATMENT) as TreatmentsInterface?
|
activeTreatmentsStore = getTheOneEnabledInArray(pluginsInCategory, PluginType.TREATMENT) as TreatmentsInterface?
|
||||||
if (activeTreatments == null) {
|
if (activeTreatmentsStore == null) {
|
||||||
activeTreatments = getDefaultPlugin(PluginType.TREATMENT) as TreatmentsInterface
|
activeTreatmentsStore = getDefaultPlugin(PluginType.TREATMENT) as TreatmentsInterface
|
||||||
(activeTreatments as PluginBase).setPluginEnabled(PluginType.TREATMENT, true)
|
(activeTreatmentsStore as PluginBase).setPluginEnabled(PluginType.TREATMENT, true)
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting PumpInterface")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting PumpInterface")
|
||||||
}
|
}
|
||||||
setFragmentVisiblities((activeTreatments as PluginBase).name, pluginsInCategory, PluginType.TREATMENT)
|
setFragmentVisiblities((activeTreatmentsStore as PluginBase).name, pluginsInCategory, PluginType.TREATMENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,27 +203,31 @@ class PluginStore @Inject constructor(
|
||||||
|
|
||||||
// ***** Interface *****
|
// ***** Interface *****
|
||||||
|
|
||||||
override fun getActiveBgSource(): BgSourceInterface {
|
override val activeBgSource: BgSourceInterface
|
||||||
return activeBgSource ?: checkNotNull(activeBgSource) { "No bg source selected" }
|
get() = activeBgSourceStore ?: checkNotNull(activeBgSourceStore) { "No bg source selected" }
|
||||||
}
|
|
||||||
|
|
||||||
override fun getActiveProfileInterface(): ProfileInterface =
|
override val activeProfileInterface: ProfileInterface
|
||||||
activeProfile ?: checkNotNull(activeProfile) { "No profile selected" }
|
get() = activeProfile ?: checkNotNull(activeProfile) { "No profile selected" }
|
||||||
|
|
||||||
override fun getActiveInsulin(): InsulinInterface =
|
override val activeInsulin: InsulinInterface
|
||||||
activeInsulin ?: checkNotNull(activeInsulin) { "No insulin selected" }
|
get() = activeInsulinStore ?: checkNotNull(activeInsulinStore) { "No insulin selected" }
|
||||||
|
|
||||||
override fun getActiveAPS(): APSInterface =
|
override val activeAPS: APSInterface
|
||||||
activeAPS ?: checkNotNull(activeAPS) { "No APS selected" }
|
get() = activeAPSStore ?: checkNotNull(activeAPSStore) { "No APS selected" }
|
||||||
|
|
||||||
override fun getActivePump(): PumpInterface =
|
override val activePump: PumpInterface
|
||||||
activePump ?: checkNotNull(activePump) { "No pump selected" }
|
get() = activePumpStore ?: checkNotNull(activePumpStore) { "No pump selected" }
|
||||||
|
|
||||||
override fun getActiveSensitivity(): SensitivityInterface =
|
override val activeSensitivity: SensitivityInterface
|
||||||
activeSensitivity ?: checkNotNull(activeSensitivity) { "No sensitivity selected" }
|
get() = activeSensitivityStore
|
||||||
|
?: checkNotNull(activeSensitivityStore) { "No sensitivity selected" }
|
||||||
|
|
||||||
override fun getActiveTreatments(): TreatmentsInterface =
|
override val activeTreatments: TreatmentsInterface
|
||||||
activeTreatments ?: checkNotNull(activeTreatments) { "No treatments selected" }
|
get() = activeTreatmentsStore
|
||||||
|
?: checkNotNull(activeTreatmentsStore) { "No treatments selected" }
|
||||||
|
|
||||||
|
override val activeOverview: OverviewInterface
|
||||||
|
get() = getSpecificPluginsListByInterface(OverviewInterface::class.java).first() as OverviewInterface
|
||||||
|
|
||||||
override fun getPluginsList(): ArrayList<PluginBase> = ArrayList(plugins)
|
override fun getPluginsList(): ArrayList<PluginBase> = ArrayList(plugins)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
|
import info.nightscout.androidaps.interfaces.OverviewInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
@ -16,9 +17,12 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationStore
|
import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationStore
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||||
|
import info.nightscout.androidaps.utils.extensions.*
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -28,6 +32,7 @@ class OverviewPlugin @Inject constructor(
|
||||||
private val notificationStore: NotificationStore,
|
private val notificationStore: NotificationStore,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val sp: SP,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
private val config: Config
|
private val config: Config
|
||||||
|
@ -41,7 +46,7 @@ class OverviewPlugin @Inject constructor(
|
||||||
.preferencesId(R.xml.pref_overview)
|
.preferencesId(R.xml.pref_overview)
|
||||||
.description(R.string.description_overview),
|
.description(R.string.description_overview),
|
||||||
aapsLogger, resourceHelper, injector
|
aapsLogger, resourceHelper, injector
|
||||||
) {
|
), OverviewInterface {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -82,4 +87,57 @@ class OverviewPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun configuration(): JSONObject =
|
||||||
|
JSONObject()
|
||||||
|
.putString(R.string.key_quickwizard, sp, resourceHelper)
|
||||||
|
.putInt(R.string.key_eatingsoon_duration, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_eatingsoon_target, sp, resourceHelper)
|
||||||
|
.putInt(R.string.key_activity_duration, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_activity_target, sp, resourceHelper)
|
||||||
|
.putInt(R.string.key_hypo_duration, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_hypo_target, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_low_mark, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_high_mark, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_cage_warning, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_cage_critical, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_iage_warning, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_iage_critical, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_sage_warning, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_sage_critical, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_sbat_warning, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_sbat_critical, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_bage_warning, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_bage_critical, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_res_warning, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_res_critical, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_bat_warning, sp, resourceHelper)
|
||||||
|
.putDouble(R.string.key_statuslights_bat_critical, sp, resourceHelper)
|
||||||
|
|
||||||
|
override fun applyConfiguration(configuration: JSONObject) {
|
||||||
|
configuration
|
||||||
|
.storeString(R.string.key_quickwizard, sp, resourceHelper)
|
||||||
|
.storeInt(R.string.key_eatingsoon_duration, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_eatingsoon_target, sp, resourceHelper)
|
||||||
|
.storeInt(R.string.key_activity_duration, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_activity_target, sp, resourceHelper)
|
||||||
|
.storeInt(R.string.key_hypo_duration, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_hypo_target, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_low_mark, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_high_mark, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_cage_warning, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_cage_critical, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_iage_warning, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_iage_critical, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_sage_warning, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_sage_critical, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_sbat_warning, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_sbat_critical, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_bage_warning, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_bage_critical, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_res_warning, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_res_critical, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_bat_warning, sp, resourceHelper)
|
||||||
|
.storeDouble(R.string.key_statuslights_bat_critical, sp, resourceHelper)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@ class InsulinFragment : DaggerFragment() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
insulin_name?.setText(activePlugin.getActiveInsulin().friendlyName)
|
insulin_name?.setText(activePlugin.activeInsulin.friendlyName)
|
||||||
insulin_comment?.setText(activePlugin.getActiveInsulin().comment)
|
insulin_comment?.setText(activePlugin.activeInsulin.comment)
|
||||||
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.getActiveInsulin().dia + "h"
|
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.activeInsulin.dia + "h"
|
||||||
insulin_graph?.show(activePlugin.getActiveInsulin())
|
insulin_graph?.show(activePlugin.activeInsulin)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,6 +6,8 @@ import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.utils.extensions.storeInt
|
||||||
|
import info.nightscout.androidaps.utils.extensions.putInt
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
@ -28,10 +30,9 @@ class InsulinOrefFreePeakPlugin @Inject constructor(
|
||||||
|
|
||||||
override val friendlyName get(): String = resourceHelper.gs(R.string.free_peak_oref)
|
override val friendlyName get(): String = resourceHelper.gs(R.string.free_peak_oref)
|
||||||
|
|
||||||
override fun configuration(): JSONObject = JSONObject().put(resourceHelper.gs(R.string.key_insulin_oref_peak), peak)
|
override fun configuration(): JSONObject = JSONObject().putInt(R.string.key_insulin_oref_peak, sp, resourceHelper)
|
||||||
override fun applyConfiguration(configuration: JSONObject) {
|
override fun applyConfiguration(configuration: JSONObject) {
|
||||||
if (configuration.has(resourceHelper.gs(R.string.key_insulin_oref_peak)))
|
configuration.storeInt(R.string.key_insulin_oref_peak, sp, resourceHelper)
|
||||||
sp.putInt(R.string.key_insulin_oref_peak, configuration.getInt(resourceHelper.gs(R.string.key_insulin_oref_peak)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun commentStandardText(): String {
|
override fun commentStandardText(): String {
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TddCalculator @Inject constructor(
|
||||||
val absoluteRate = tbr?.tempBasalConvertedToAbsolute(t, profile) ?: profile.getBasal(t)
|
val absoluteRate = tbr?.tempBasalConvertedToAbsolute(t, profile) ?: profile.getBasal(t)
|
||||||
tdd.basal += absoluteRate / 60.0 * 5.0
|
tdd.basal += absoluteRate / 60.0 * 5.0
|
||||||
|
|
||||||
if (!activePlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
if (!activePlugin.activePump.isFakingTempsByExtendedBoluses()) {
|
||||||
// they are not included in TBRs
|
// they are not included in TBRs
|
||||||
val eb = getExtendedBolusFromHistory(t)
|
val eb = getExtendedBolusFromHistory(t)
|
||||||
val absoluteEbRate = eb?.absoluteRate() ?: 0.0
|
val absoluteEbRate = eb?.absoluteRate() ?: 0.0
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.utils.wizard
|
package info.nightscout.androidaps.utils.wizard
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
@ -16,7 +17,7 @@ class QuickWizard @Inject constructor(
|
||||||
private var storage = JSONArray()
|
private var storage = JSONArray()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setData(JSONArray(sp.getString("QuickWizard", "[]")))
|
setData(JSONArray(sp.getString(R.string.key_quickwizard, "[]")))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getActive(): QuickWizardEntry? {
|
fun getActive(): QuickWizardEntry? {
|
||||||
|
@ -32,7 +33,7 @@ class QuickWizard @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun save() {
|
fun save() {
|
||||||
sp.putString("QuickWizard", storage.toString())
|
sp.putString(R.string.key_quickwizard, storage.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun size(): Int = storage.length()
|
fun size(): Int = storage.length()
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ProfileTest : TestBaseWithProfile() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun prepare() {
|
fun prepare() {
|
||||||
`when`(activePluginProvider.getActivePump()).thenReturn(virtualPumpPlugin)
|
`when`(activePluginProvider.activePump).thenReturn(virtualPumpPlugin)
|
||||||
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
|
`when`(virtualPumpPlugin.pumpDescription).thenReturn(pumpDescription)
|
||||||
`when`(resourceHelper.gs(R.string.profile_per_unit)).thenReturn("/U")
|
`when`(resourceHelper.gs(R.string.profile_per_unit)).thenReturn("/U")
|
||||||
`when`(resourceHelper.gs(R.string.profile_carbs_per_unit)).thenReturn("g/U")
|
`when`(resourceHelper.gs(R.string.profile_carbs_per_unit)).thenReturn("g/U")
|
||||||
|
|
|
@ -61,7 +61,7 @@ class LoopPluginTest : TestBase() {
|
||||||
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, nsUpload)
|
hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, nsUpload)
|
||||||
|
|
||||||
loopPlugin = LoopPlugin(injector, aapsLogger, rxBus, sp, constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, actionStringHandler, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, nsUpload, hardLimits)
|
loopPlugin = LoopPlugin(injector, aapsLogger, rxBus, sp, constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, actionStringHandler, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, nsUpload, hardLimits)
|
||||||
`when`(activePlugin.getActivePump()).thenReturn(virtualPumpPlugin)
|
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public interface ActivePluginProvider {
|
|
||||||
|
|
||||||
@NotNull BgSourceInterface getActiveBgSource(); // Forced to Dexcom
|
|
||||||
|
|
||||||
@NotNull ProfileInterface getActiveProfileInterface(); // Forced to LocalProfile if not changed
|
|
||||||
|
|
||||||
@NotNull InsulinInterface getActiveInsulin(); // Forced to RapidActing if not changed
|
|
||||||
|
|
||||||
@NotNull APSInterface getActiveAPS(); // Forced to SMB
|
|
||||||
|
|
||||||
@NotNull PumpInterface getActivePump(); // Use in places not reachable without active pump. Otherwise IllegalStateException is thrown
|
|
||||||
|
|
||||||
@NotNull SensitivityInterface getActiveSensitivity(); // Forced to oref1 if not changed
|
|
||||||
|
|
||||||
@NotNull TreatmentsInterface getActiveTreatments(); // Forced to treatments
|
|
||||||
|
|
||||||
@NotNull ArrayList<PluginBase> getPluginsList();
|
|
||||||
|
|
||||||
@NotNull ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, PluginType type);
|
|
||||||
|
|
||||||
@NotNull ArrayList<PluginBase> getSpecificPluginsVisibleInList(PluginType type);
|
|
||||||
|
|
||||||
@NotNull ArrayList<PluginBase> getSpecificPluginsListByInterface(Class interfaceClass);
|
|
||||||
|
|
||||||
// @NotNull ArrayList<PluginBase> getSpecificPluginsVisibleInList(Class interfaceClass);
|
|
||||||
|
|
||||||
void verifySelectionInCategories();
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
interface ActivePluginProvider {
|
||||||
|
|
||||||
|
val activeBgSource: BgSourceInterface // Forced to Dexcom
|
||||||
|
val activeProfileInterface: ProfileInterface // Forced to LocalProfile if not changed
|
||||||
|
val activeInsulin: InsulinInterface // Forced to RapidActing if not changed
|
||||||
|
val activeAPS: APSInterface // Forced to SMB
|
||||||
|
val activePump: PumpInterface // Use in places not reachable without active pump. Otherwise IllegalStateException is thrown
|
||||||
|
val activeSensitivity: SensitivityInterface // Forced to oref1 if not changed
|
||||||
|
val activeTreatments: TreatmentsInterface // Forced to treatments
|
||||||
|
val activeOverview: OverviewInterface // Forced to overview
|
||||||
|
|
||||||
|
fun getPluginsList(): ArrayList<PluginBase>
|
||||||
|
|
||||||
|
fun getSpecificPluginsVisibleInListByInterface(interfaceClass: Class<*>, type: PluginType): ArrayList<PluginBase>
|
||||||
|
fun getSpecificPluginsVisibleInList(type: PluginType): ArrayList<PluginBase>
|
||||||
|
fun getSpecificPluginsListByInterface(interfaceClass: Class<*>): ArrayList<PluginBase>
|
||||||
|
fun verifySelectionInCategories()
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
interface ConfigExportImportInterface {
|
||||||
|
|
||||||
|
fun configuration(): JSONObject
|
||||||
|
fun applyConfiguration(configuration: JSONObject)
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import info.nightscout.androidaps.data.Iob
|
||||||
import info.nightscout.androidaps.db.Treatment
|
import info.nightscout.androidaps.db.Treatment
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
interface InsulinInterface {
|
interface InsulinInterface : ConfigExportImportInterface{
|
||||||
|
|
||||||
enum class InsulinType(val value: Int) {
|
enum class InsulinType(val value: Int) {
|
||||||
UNKNOWN(-1),
|
UNKNOWN(-1),
|
||||||
|
@ -27,7 +27,4 @@ interface InsulinInterface {
|
||||||
val dia: Double
|
val dia: Double
|
||||||
|
|
||||||
fun iobCalcForTreatment(treatment: Treatment, time: Long, dia: Double): Iob
|
fun iobCalcForTreatment(treatment: Treatment, time: Long, dia: Double): Iob
|
||||||
|
|
||||||
fun configuration(): JSONObject
|
|
||||||
fun applyConfiguration(configuration: JSONObject)
|
|
||||||
}
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.interfaces
|
||||||
|
|
||||||
|
interface OverviewInterface : ConfigExportImportInterface
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.interfaces
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
interface SensitivityInterface {
|
interface SensitivityInterface : ConfigExportImportInterface {
|
||||||
|
|
||||||
enum class SensitivityType(val value: Int) {
|
enum class SensitivityType(val value: Int) {
|
||||||
UNKNOWN(-1),
|
UNKNOWN(-1),
|
||||||
|
@ -20,9 +20,6 @@ interface SensitivityInterface {
|
||||||
val id: SensitivityType
|
val id: SensitivityType
|
||||||
fun detectSensitivity(plugin: IobCobCalculatorInterface, fromTime: Long, toTime: Long): AutosensResult
|
fun detectSensitivity(plugin: IobCobCalculatorInterface, fromTime: Long, toTime: Long): AutosensResult
|
||||||
|
|
||||||
fun configuration(): JSONObject
|
|
||||||
fun applyConfiguration(configuration: JSONObject)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MIN_HOURS = 1.0
|
const val MIN_HOURS = 1.0
|
||||||
const val MIN_HOURS_FULL_AUTOSENS = 4.0
|
const val MIN_HOURS_FULL_AUTOSENS = 4.0
|
||||||
|
|
|
@ -24,22 +24,28 @@ class RunningConfiguration @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger
|
private val aapsLogger: AAPSLogger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
private var counter = 0
|
||||||
|
private val every = 20 // Send only every 20 devicestatus to save traffic
|
||||||
|
|
||||||
// called in AAPS mode only
|
// called in AAPS mode only
|
||||||
fun configuration(): JSONObject {
|
fun configuration(): JSONObject {
|
||||||
val json = JSONObject()
|
val json = JSONObject()
|
||||||
try {
|
if (counter++ % every == 0)
|
||||||
val insulinInterface = activePlugin.activeInsulin
|
try {
|
||||||
val sensitivityInterface = activePlugin.activeSensitivity
|
val insulinInterface = activePlugin.activeInsulin
|
||||||
val pumpInterface = activePlugin.activePump
|
val sensitivityInterface = activePlugin.activeSensitivity
|
||||||
|
val pumpInterface = activePlugin.activePump
|
||||||
|
val overviewInterface = activePlugin.activeOverview
|
||||||
|
|
||||||
json.put("insulin", insulinInterface.id.value)
|
json.put("insulin", insulinInterface.id.value)
|
||||||
json.put("insulinConfiguration", insulinInterface.configuration())
|
json.put("insulinConfiguration", insulinInterface.configuration())
|
||||||
json.put("sensitivity", sensitivityInterface.id.value)
|
json.put("sensitivity", sensitivityInterface.id.value)
|
||||||
json.put("sensitivityConfiguration", sensitivityInterface.configuration())
|
json.put("sensitivityConfiguration", sensitivityInterface.configuration())
|
||||||
json.put("pump", pumpInterface.model().description)
|
json.put("overviewConfiguration", overviewInterface.configuration())
|
||||||
} catch (e: JSONException) {
|
json.put("pump", pumpInterface.model().description)
|
||||||
aapsLogger.error("Unhandled exception", e)
|
} catch (e: JSONException) {
|
||||||
}
|
aapsLogger.error("Unhandled exception", e)
|
||||||
|
}
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +74,12 @@ class RunningConfiguration @Inject constructor(
|
||||||
sensitivityPlugin.applyConfiguration(configuration.getJSONObject("sensitivityConfiguration"))
|
sensitivityPlugin.applyConfiguration(configuration.getJSONObject("sensitivityConfiguration"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val pumpType = JsonHelper.safeGetString(configuration, "pump", PumpType.GenericAAPS.description)
|
val pumpType = JsonHelper.safeGetString(configuration, "pump", PumpType.GenericAAPS.description)
|
||||||
sp.putString(R.string.key_virtualpump_type, pumpType)
|
sp.putString(R.string.key_virtualpump_type, pumpType)
|
||||||
activePlugin.activePump.pumpDescription.setPumpDescription(PumpType.getByDescription(pumpType))
|
activePlugin.activePump.pumpDescription.setPumpDescription(PumpType.getByDescription(pumpType))
|
||||||
|
|
||||||
|
if (configuration.has("overviewConfiguration"))
|
||||||
|
activePlugin.activeOverview.applyConfiguration(configuration.getJSONObject("overviewConfiguration"))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package info.nightscout.androidaps.utils.extensions
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
fun JSONObject.putInt(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject =
|
||||||
|
if (sp.contains(key)) put(resourceHelper.gs(key), sp.getInt(key, 0)) else this
|
||||||
|
|
||||||
|
fun JSONObject.putLong(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject =
|
||||||
|
if (sp.contains(key)) put(resourceHelper.gs(key), sp.getLong(key, 0)) else this
|
||||||
|
|
||||||
|
fun JSONObject.putDouble(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject =
|
||||||
|
if (sp.contains(key)) put(resourceHelper.gs(key), sp.getDouble(key, 0.0)) else this
|
||||||
|
|
||||||
|
fun JSONObject.putString(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject =
|
||||||
|
if (sp.contains(key)) put(resourceHelper.gs(key), sp.getString(key, "")) else this
|
||||||
|
|
||||||
|
fun JSONObject.putBoolean(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject =
|
||||||
|
if (sp.contains(key)) put(resourceHelper.gs(key), sp.getBoolean(key, false)) else this
|
||||||
|
|
||||||
|
fun JSONObject.storeInt(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject {
|
||||||
|
if (has(resourceHelper.gs(key))) sp.putInt(key, getInt(resourceHelper.gs(key)))
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun JSONObject.storeLong(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject {
|
||||||
|
if (has(resourceHelper.gs(key))) sp.putLong(key, getLong(resourceHelper.gs(key)))
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun JSONObject.storeDouble(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject {
|
||||||
|
if (has(resourceHelper.gs(key))) sp.putDouble(key, getDouble(resourceHelper.gs(key)))
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun JSONObject.storeString(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject {
|
||||||
|
if (has(resourceHelper.gs(key))) sp.putString(key, getString(resourceHelper.gs(key)))
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun JSONObject.storeBoolean(@StringRes key: Int, sp: SP, resourceHelper: ResourceHelper): JSONObject {
|
||||||
|
if (has(resourceHelper.gs(key))) sp.putBoolean(key, getBoolean(resourceHelper.gs(key)))
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
<string name="key_gradually_increase_notification_volume" translatable="false">gradually_increase_notification_volume</string>
|
<string name="key_gradually_increase_notification_volume" translatable="false">gradually_increase_notification_volume</string>
|
||||||
<string name="key_ns_sync_use_absolute" translatable="false">ns_sync_use_absolute</string>
|
<string name="key_ns_sync_use_absolute" translatable="false">ns_sync_use_absolute</string>
|
||||||
<string name="key_virtualpump_type" translatable="false">virtualpump_type</string>
|
<string name="key_virtualpump_type" translatable="false">virtualpump_type</string>
|
||||||
|
<string name="key_quickwizard" translatable="false">QuickWizard</string>
|
||||||
|
|
||||||
<!-- General-->
|
<!-- General-->
|
||||||
<string name="error">Error</string>
|
<string name="error">Error</string>
|
||||||
|
|
Loading…
Reference in a new issue