ProfileInterface rename

This commit is contained in:
Milos Kozak 2021-04-14 22:58:21 +02:00
parent bb82f41b9e
commit 312136451b
23 changed files with 51 additions and 62 deletions

View file

@ -381,7 +381,7 @@ class MainActivity : NoSplashAppCompatActivity() {
if (!config.NSCLIENT && !config.PUMPCONTROL) if (!config.NSCLIENT && !config.PUMPCONTROL)
activePlugin.activeAPS.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Aps", it::class.java.simpleName) } activePlugin.activeAPS.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Aps", it::class.java.simpleName) }
activePlugin.activeBgSource.let { fabricPrivacy.firebaseAnalytics.setUserProperty("BgSource", it::class.java.simpleName) } activePlugin.activeBgSource.let { fabricPrivacy.firebaseAnalytics.setUserProperty("BgSource", it::class.java.simpleName) }
fabricPrivacy.firebaseAnalytics.setUserProperty("Profile", activePlugin.activeProfileInterface.javaClass.simpleName) fabricPrivacy.firebaseAnalytics.setUserProperty("Profile", activePlugin.activeProfileSource.javaClass.simpleName)
activePlugin.activeSensitivity.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Sensitivity", it::class.java.simpleName) } activePlugin.activeSensitivity.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Sensitivity", it::class.java.simpleName) }
activePlugin.activeInsulin.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Insulin", it::class.java.simpleName) } activePlugin.activeInsulin.let { fabricPrivacy.firebaseAnalytics.setUserProperty("Insulin", it::class.java.simpleName) }
// Add to crash log too // Add to crash log too

View file

@ -98,7 +98,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
} }
// Active profile // Active profile
profileList = activePlugin.activeProfileInterface.profile?.getProfileList() ?: ArrayList() profileList = activePlugin.activeProfileSource.profile?.getProfileList() ?: ArrayList()
binding.availableProfileList.setOnClickListener { binding.availableProfileList.setOnClickListener {
PopupMenu(this, binding.availableProfileList).apply { PopupMenu(this, binding.availableProfileList).apply {
@ -233,7 +233,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
ProfileType.MOTOL_DEFAULT -> defaultProfile.profile(age, tdd, weight, profileFunction.getUnits()) ProfileType.MOTOL_DEFAULT -> defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())
ProfileType.DPV_DEFAULT -> defaultProfileDPV.profile(age, tdd, basalPct, profileFunction.getUnits()) ProfileType.DPV_DEFAULT -> defaultProfileDPV.profile(age, tdd, basalPct, profileFunction.getUnits())
ProfileType.CURRENT -> profileFunction.getProfile()?.convertToNonCustomizedProfile() ProfileType.CURRENT -> profileFunction.getProfile()?.convertToNonCustomizedProfile()
ProfileType.AVAILABLE_PROFILE -> activePlugin.activeProfileInterface.profile?.getSpecificProfile(profileList[profileUsed[tab]].toString()) ProfileType.AVAILABLE_PROFILE -> activePlugin.activeProfileSource.profile?.getSpecificProfile(profileList[profileUsed[tab]].toString())
ProfileType.PROFILE_SWITCH -> profileSwitch[profileSwitchUsed[tab]].profileObject?.convertToNonCustomizedProfile() ProfileType.PROFILE_SWITCH -> profileSwitch[profileSwitchUsed[tab]].profileObject?.convertToNonCustomizedProfile()
} }
} catch (e: Exception) { } catch (e: Exception) {

View file

@ -41,7 +41,7 @@ class SurveyActivity : NoSplashAppCompatActivity() {
binding.id.text = InstanceId.instanceId() binding.id.text = InstanceId.instanceId()
val profileStore = activePlugin.activeProfileInterface.profile val profileStore = activePlugin.activeProfileSource.profile
val profileList = profileStore?.getProfileList() ?: return val profileList = profileStore?.getProfileList() ?: return
binding.spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList) binding.spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList)

View file

@ -39,7 +39,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.events.EventReloadProfileSwitchData; import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
import info.nightscout.androidaps.interfaces.ActivePlugin; import info.nightscout.androidaps.interfaces.ActivePlugin;
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.ProfileSource;
import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.interfaces.ProfileStore;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
@ -873,8 +873,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (trJson.has("profileJson")) if (trJson.has("profileJson"))
profileSwitch.profileJson = trJson.getString("profileJson"); profileSwitch.profileJson = trJson.getString("profileJson");
else { else {
ProfileInterface profileInterface = activePlugin.getActiveProfileInterface(); ProfileSource profileSource = activePlugin.getActiveProfileSource();
ProfileStore store = profileInterface.getProfile(); ProfileStore store = profileSource.getProfile();
if (store != null) { if (store != null) {
Profile profile = store.getSpecificProfile(profileSwitch.profileName); Profile profile = store.getSpecificProfile(profileSwitch.profileName);
if (profile != null) { if (profile != null) {

View file

@ -198,7 +198,7 @@ class LoopDialog : DaggerDialogFragment() {
} }
} }
val profile = profileFunction.getProfile() val profile = profileFunction.getProfile()
val profileStore = activePlugin.activeProfileInterface.profile val profileStore = activePlugin.activeProfileSource.profile
if (profile == null || profileStore == null) { if (profile == null || profileStore == null) {
ToastUtils.showToastInUiThread(ctx, resourceHelper.gs(R.string.noprofile)) ToastUtils.showToastInUiThread(ctx, resourceHelper.gs(R.string.noprofile))

View file

@ -68,7 +68,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
// profile // profile
context?.let { context -> context?.let { context ->
val profileStore = activePlugin.activeProfileInterface.profile val profileStore = activePlugin.activeProfileSource.profile
?: return ?: return
val profileList = profileStore.getProfileList() val profileList = profileStore.getProfileList()
val adapter = ArrayAdapter(context, R.layout.spinner_centered, profileList) val adapter = ArrayAdapter(context, R.layout.spinner_centered, profileList)
@ -103,7 +103,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
override fun submit(): Boolean { override fun submit(): Boolean {
if (_binding == null) return false if (_binding == null) return false
val profileStore = activePlugin.activeProfileInterface.profile val profileStore = activePlugin.activeProfileSource.profile
?: return false ?: return false
val actions: LinkedList<String> = LinkedList() val actions: LinkedList<String> = LinkedList()

View file

@ -244,7 +244,7 @@ class WizardDialog : DaggerDialogFragment() {
private fun initDialog() { private fun initDialog() {
val profile = profileFunction.getProfile() val profile = profileFunction.getProfile()
val profileStore = activePlugin.activeProfileInterface.profile val profileStore = activePlugin.activeProfileSource.profile
if (profile == null || profileStore == null) { if (profile == null || profileStore == null) {
ToastUtils.showToastInUiThread(ctx, resourceHelper.gs(R.string.noprofile)) ToastUtils.showToastInUiThread(ctx, resourceHelper.gs(R.string.noprofile))
@ -283,7 +283,7 @@ class WizardDialog : DaggerDialogFragment() {
} }
private fun calculateInsulin() { private fun calculateInsulin() {
val profileStore = activePlugin.activeProfileInterface.profile val profileStore = activePlugin.activeProfileSource.profile
if (binding.profile.selectedItem == null || profileStore == null) if (binding.profile.selectedItem == null || profileStore == null)
return // not initialized yet return // not initialized yet
var profileName = binding.profile.selectedItem.toString() var profileName = binding.profile.selectedItem.toString()

View file

@ -69,7 +69,7 @@ class ConfigBuilderPlugin @Inject constructor(
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible) continue if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible) continue
savePref(p, type, true) savePref(p, type, true)
if (type == PluginType.PUMP) { if (type == PluginType.PUMP) {
if (p is ProfileInterface) { // Store state of optional Profile interface if (p is ProfileSource) { // Store state of optional Profile interface
savePref(p, PluginType.PROFILE, false) savePref(p, PluginType.PROFILE, false)
} }
} }
@ -93,7 +93,7 @@ class ConfigBuilderPlugin @Inject constructor(
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) {
if (p is ProfileInterface) { if (p is ProfileSource) {
loadPref(p, PluginType.PROFILE, false) loadPref(p, PluginType.PROFILE, false)
} }
} }
@ -183,7 +183,7 @@ class ConfigBuilderPlugin @Inject constructor(
PluginType.INSULIN -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(Insulin::class.java) PluginType.INSULIN -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(Insulin::class.java)
PluginType.SENSITIVITY -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(Sensitivity::class.java) PluginType.SENSITIVITY -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(Sensitivity::class.java)
PluginType.APS -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(APS::class.java) PluginType.APS -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(APS::class.java)
PluginType.PROFILE -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(ProfileInterface::class.java) PluginType.PROFILE -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(ProfileSource::class.java)
PluginType.BGSOURCE -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(BgSource::class.java) PluginType.BGSOURCE -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(BgSource::class.java)
PluginType.TREATMENT -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(TreatmentsInterface::class.java) PluginType.TREATMENT -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(TreatmentsInterface::class.java)
PluginType.PUMP -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(Pump::class.java) PluginType.PUMP -> pluginsInCategory = activePlugin.getSpecificPluginsListByInterface(Pump::class.java)

View file

@ -17,7 +17,7 @@ class PluginStore @Inject constructor(
private var activeBgSourceStore: BgSource? = null private var activeBgSourceStore: BgSource? = null
private var activePumpStore: Pump? = null private var activePumpStore: Pump? = null
private var activeProfile: ProfileInterface? = null private var activeProfile: ProfileSource? = null
private var activeAPSStore: APS? = null private var activeAPSStore: APS? = null
private var activeInsulinStore: Insulin? = null private var activeInsulinStore: Insulin? = null
private var activeSensitivityStore: Sensitivity? = null private var activeSensitivityStore: Sensitivity? = null
@ -94,9 +94,9 @@ class PluginStore @Inject constructor(
// PluginType.PROFILE // PluginType.PROFILE
pluginsInCategory = getSpecificPluginsList(PluginType.PROFILE) pluginsInCategory = getSpecificPluginsList(PluginType.PROFILE)
activeProfile = getTheOneEnabledInArray(pluginsInCategory, PluginType.PROFILE) as ProfileInterface? activeProfile = getTheOneEnabledInArray(pluginsInCategory, PluginType.PROFILE) as ProfileSource?
if (activeProfile == null) { if (activeProfile == null) {
activeProfile = getDefaultPlugin(PluginType.PROFILE) as ProfileInterface activeProfile = getDefaultPlugin(PluginType.PROFILE) as ProfileSource
(activeProfile as PluginBase).setPluginEnabled(PluginType.PROFILE, true) (activeProfile as PluginBase).setPluginEnabled(PluginType.PROFILE, true)
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting ProfileInterface") aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting ProfileInterface")
} }
@ -159,7 +159,7 @@ class PluginStore @Inject constructor(
override val activeBgSource: BgSource override val activeBgSource: BgSource
get() = activeBgSourceStore ?: checkNotNull(activeBgSourceStore) { "No bg source selected" } get() = activeBgSourceStore ?: checkNotNull(activeBgSourceStore) { "No bg source selected" }
override val activeProfileInterface: ProfileInterface override val activeProfileSource: ProfileSource
get() = activeProfile ?: checkNotNull(activeProfile) { "No profile selected" } get() = activeProfile ?: checkNotNull(activeProfile) { "No profile selected" }
override val activeInsulin: Insulin override val activeInsulin: Insulin

View file

@ -265,7 +265,7 @@ class ActionsFragment : DaggerFragment() {
val pump = activePlugin.activePump val pump = activePlugin.activePump
profileSwitch?.visibility = ( profileSwitch?.visibility = (
activePlugin.activeProfileInterface.profile != null && activePlugin.activeProfileSource.profile != null &&
pump.pumpDescription.isSetBasalProfileCapable && pump.pumpDescription.isSetBasalProfileCapable &&
pump.isInitialized() && pump.isInitialized() &&
!pump.isSuspended()).toVisibility() !pump.isSuspended()).toVisibility()

View file

@ -545,7 +545,7 @@ class SmsCommunicatorPlugin @Inject constructor(
} }
private fun processPROFILE(divided: Array<String>, receivedSms: Sms) { // load profiles private fun processPROFILE(divided: Array<String>, receivedSms: Sms) { // load profiles
val anInterface = activePlugin.activeProfileInterface val anInterface = activePlugin.activeProfileSource
val store = anInterface.profile val store = anInterface.profile
if (store == null) { if (store == null) {
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.notconfigured))) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.notconfigured)))

View file

@ -46,7 +46,7 @@ class LocalProfilePlugin @Inject constructor(
.description(R.string.description_profile_local) .description(R.string.description_profile_local)
.setDefault(), .setDefault(),
aapsLogger, resourceHelper, injector aapsLogger, resourceHelper, injector
), ProfileInterface { ), ProfileSource {
private var rawProfile: ProfileStore? = null private var rawProfile: ProfileStore? = null
@ -58,6 +58,7 @@ class LocalProfilePlugin @Inject constructor(
} }
class SingleProfile { class SingleProfile {
internal var name: String? = null internal var name: String? = null
internal var mgdl: Boolean = false internal var mgdl: Boolean = false
internal var dia: Double = Constants.defaultDIA internal var dia: Double = Constants.defaultDIA
@ -350,12 +351,10 @@ class LocalProfilePlugin @Inject constructor(
return ProfileStore(injector, json) return ProfileStore(injector, json)
} }
override fun getProfile(): ProfileStore? { override val profile: ProfileStore?
return rawProfile get() = rawProfile
}
override fun getProfileName(): String { override val profileName: String
return DecimalFormatter.to2Decimal(rawProfile?.getDefaultProfile()?.percentageBasalSum() get() = DecimalFormatter.to2Decimal(rawProfile?.getDefaultProfile()?.percentageBasalSum()
?: 0.0) + "U " ?: 0.0) + "U "
}
} }

View file

@ -11,7 +11,7 @@ import info.nightscout.androidaps.events.EventProfileStoreChanged
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
import info.nightscout.androidaps.interfaces.ProfileInterface import info.nightscout.androidaps.interfaces.ProfileSource
import info.nightscout.androidaps.interfaces.ProfileStore import info.nightscout.androidaps.interfaces.ProfileStore
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
@ -44,9 +44,12 @@ class NSProfilePlugin @Inject constructor(
.showInList(!config.NSCLIENT) .showInList(!config.NSCLIENT)
.description(R.string.description_profile_nightscout), .description(R.string.description_profile_nightscout),
aapsLogger, resourceHelper, injector aapsLogger, resourceHelper, injector
), ProfileInterface { ), ProfileSource {
private var profile: ProfileStore? = null override var profile: ProfileStore? = null
override val profileName: String?
get() = profile?.getDefaultProfileName()
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -71,13 +74,6 @@ class NSProfilePlugin @Inject constructor(
} }
} }
override fun getProfile(): ProfileStore? {
return profile
}
override fun getProfileName(): String {
return profile!!.getDefaultProfileName()!!
}
// cannot be inner class because of needed injection // cannot be inner class because of needed injection
class NSProfileWorker( class NSProfileWorker(

View file

@ -380,7 +380,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
profileSwitch.source = Source.USER; profileSwitch.source = Source.USER;
profileSwitch.profileName = profileFunction.getProfileName(System.currentTimeMillis(), false, false); profileSwitch.profileName = profileFunction.getProfileName(System.currentTimeMillis(), false, false);
profileSwitch.profileJson = profileFunction.getProfile().getData().toString(); profileSwitch.profileJson = profileFunction.getProfile().getData().toString();
profileSwitch.profilePlugin = activePlugin.getActiveProfileInterface().getClass().getName(); profileSwitch.profilePlugin = activePlugin.getActiveProfileSource().getClass().getName();
profileSwitch.durationInMinutes = duration; profileSwitch.durationInMinutes = duration;
profileSwitch.isCPP = percentage != 100 || timeShift != 0; profileSwitch.isCPP = percentage != 100 || timeShift != 0;
profileSwitch.timeshift = timeShift; profileSwitch.timeshift = timeShift;

View file

@ -173,7 +173,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
`when`(iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended()).thenReturn(IobTotal(0)) `when`(iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended()).thenReturn(IobTotal(0))
`when`(treatmentsInterface.service).thenReturn(treatmentService) `when`(treatmentsInterface.service).thenReturn(treatmentService)
`when`(activePlugin.activeProfileInterface).thenReturn(localProfilePlugin) `when`(activePlugin.activeProfileSource).thenReturn(localProfilePlugin)
`when`(profileFunction.getUnits()).thenReturn(Constants.MGDL) `when`(profileFunction.getUnits()).thenReturn(Constants.MGDL)

View file

@ -53,7 +53,7 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadyset))?.run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadyset))?.run()
return return
} }
val profileStore = activePlugin.activeProfileInterface.profile ?: return val profileStore = activePlugin.activeProfileSource.profile ?: return
if (profileStore.getSpecificProfile(inputProfileName.value) == null) { if (profileStore.getSpecificProfile(inputProfileName.value) == null) {
aapsLogger.error(LTag.AUTOMATION, "Selected profile does not exist! - ${inputProfileName.value}") aapsLogger.error(LTag.AUTOMATION, "Selected profile does not exist! - ${inputProfileName.value}")
callback.result(PumpEnactResult(injector).success(false).comment(R.string.notexists))?.run() callback.result(PumpEnactResult(injector).success(false).comment(R.string.notexists))?.run()
@ -88,5 +88,5 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
return this return this
} }
override fun isValid(): Boolean = activePlugin.activeProfileInterface.profile?.getSpecificProfile(inputProfileName.value) != null override fun isValid(): Boolean = activePlugin.activeProfileSource.profile?.getSpecificProfile(inputProfileName.value) != null
} }

View file

@ -15,7 +15,7 @@ class InputProfileName(private val resourceHelper: ResourceHelper, private val a
var value: String = name var value: String = name
override fun addToLayout(root: LinearLayout) { override fun addToLayout(root: LinearLayout) {
val profileStore = activePlugin.activeProfileInterface.profile ?: return val profileStore = activePlugin.activeProfileSource.profile ?: return
val profileList = profileStore.getProfileList() val profileList = profileStore.getProfileList()
val adapter = ArrayAdapter(root.context, R.layout.spinner_centered, profileList) val adapter = ArrayAdapter(root.context, R.layout.spinner_centered, profileList)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)

View file

@ -42,7 +42,7 @@ open class ActionsTestBase : TestBaseWithProfile() {
@Mock lateinit var commandQueue: CommandQueueProvider @Mock lateinit var commandQueue: CommandQueueProvider
@Mock lateinit var configBuilder: ConfigBuilder @Mock lateinit var configBuilder: ConfigBuilder
@Mock lateinit var activePlugin: ActivePlugin @Mock lateinit var activePlugin: ActivePlugin
@Mock lateinit var profilePlugin: ProfileInterface @Mock lateinit var profilePlugin: ProfileSource
@Mock lateinit var smsCommunicatorPlugin: SmsCommunicator @Mock lateinit var smsCommunicatorPlugin: SmsCommunicator
@Mock lateinit var loopPlugin: TestLoopPlugin @Mock lateinit var loopPlugin: TestLoopPlugin
@Mock lateinit var uel: UserEntryLogger @Mock lateinit var uel: UserEntryLogger
@ -133,7 +133,7 @@ open class ActionsTestBase : TestBaseWithProfile() {
testPumpPlugin = TestPumpPlugin(pluginDescription, aapsLogger, resourceHelper, injector) testPumpPlugin = TestPumpPlugin(pluginDescription, aapsLogger, resourceHelper, injector)
`when`(activePlugin.activePump).thenReturn(testPumpPlugin) `when`(activePlugin.activePump).thenReturn(testPumpPlugin)
`when`(profileFunction.getUnits()).thenReturn(Constants.MGDL) `when`(profileFunction.getUnits()).thenReturn(Constants.MGDL)
`when`(activePlugin.activeProfileInterface).thenReturn(profilePlugin) `when`(activePlugin.activeProfileSource).thenReturn(profilePlugin)
`when`(profilePlugin.profile).thenReturn(getValidProfileStore()) `when`(profilePlugin.profile).thenReturn(getValidProfileStore())
} }
} }

View file

@ -14,7 +14,7 @@ interface ActivePlugin {
* Currently selected Profile plugin * Currently selected Profile plugin
* Default LocalProfile * Default LocalProfile
*/ */
val activeProfileInterface: ProfileInterface val activeProfileSource: ProfileSource
/** /**
* Currently selected Insulin plugin * Currently selected Insulin plugin

View file

@ -66,9 +66,8 @@ abstract class PluginBase(
fun isDefault() = pluginDescription.defaultPlugin fun isDefault() = pluginDescription.defaultPlugin
/** /**
* So far plugin can have it's main type + ConstraintInterface + ProfileInterface * So far plugin can have it's main type + ConstraintInterface
* ConstraintInterface is enabled if main plugin is enabled * ConstraintInterface is enabled if main plugin is enabled
* ProfileInterface can be enabled only if main interface is enable
*/ */
fun setPluginEnabled(type: PluginType, newState: Boolean) { fun setPluginEnabled(type: PluginType, newState: Boolean) {
if (type == pluginDescription.mainType) { if (type == pluginDescription.mainType) {

View file

@ -1,12 +0,0 @@
package info.nightscout.androidaps.interfaces;
import androidx.annotation.Nullable;
/**
* Created by mike on 14.06.2016.
*/
public interface ProfileInterface {
@Nullable
ProfileStore getProfile();
String getProfileName();
}

View file

@ -0,0 +1,7 @@
package info.nightscout.androidaps.interfaces
interface ProfileSource {
val profile: ProfileStore?
val profileName: String?
}

View file

@ -42,7 +42,7 @@ class ProfileFunctionImplementation @Inject constructor(
var profileName = resourceHelper.gs(R.string.noprofileselected) var profileName = resourceHelper.gs(R.string.noprofileselected)
val activeTreatments = activePlugin.activeTreatments val activeTreatments = activePlugin.activeTreatments
val activeProfile = activePlugin.activeProfileInterface val activeProfile = activePlugin.activeProfileSource
val profileSwitch = activeTreatments.getProfileSwitchFromHistory(time) val profileSwitch = activeTreatments.getProfileSwitchFromHistory(time)
if (profileSwitch != null) { if (profileSwitch != null) {
@ -75,7 +75,7 @@ class ProfileFunctionImplementation @Inject constructor(
override fun getProfile(time: Long): Profile? = getProfile(time, activePlugin.activeTreatments) override fun getProfile(time: Long): Profile? = getProfile(time, activePlugin.activeTreatments)
override fun getProfile(time: Long, activeTreatments: TreatmentsInterface): Profile? { override fun getProfile(time: Long, activeTreatments: TreatmentsInterface): Profile? {
val activeProfile = activePlugin.activeProfileInterface val activeProfile = activePlugin.activeProfileSource
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time)); //log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
val profileSwitch = activeTreatments.getProfileSwitchFromHistory(time) val profileSwitch = activeTreatments.getProfileSwitchFromHistory(time)