Merge pull request #1908 from Andries-Smit/feat/local-profile-select-active

Feat: local profile select active
This commit is contained in:
Milos Kozak 2022-07-12 18:06:46 +02:00 committed by GitHub
commit 336b079875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged
@ -52,6 +53,7 @@ class LocalProfileFragment : DaggerFragment() {
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var localProfilePlugin: LocalProfilePlugin
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var hardLimits: HardLimits
@Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var dateUtil: DateUtil
@ -117,6 +119,11 @@ class LocalProfileFragment : DaggerFragment() {
})
binding.diaLabel.labelFor = binding.dia.editTextId
binding.unlock.setOnClickListener { queryProtection() }
val profiles = localProfilePlugin.profile?.getProfileList() ?: ArrayList()
val activeProfile = profileFunction.getProfileName()
val profileIndex = profiles.indexOf(activeProfile)
localProfilePlugin.currentProfileIndex = if (profileIndex >= 0) profileIndex else 0
}
fun build() {