WizardDialogInfo, ProfileFunction
This commit is contained in:
parent
db9b453276
commit
416735e916
18 changed files with 276 additions and 226 deletions
|
@ -30,6 +30,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment
|
|||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpFragment
|
||||
import info.nightscout.androidaps.plugins.source.BGSourceFragment
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsFragment
|
||||
import info.nightscout.androidaps.dialogs.WizardInfoDialog
|
||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment
|
||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsCareportalFragment
|
||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsProfileSwitchFragment
|
||||
|
@ -45,12 +46,6 @@ abstract class FragmentsModule {
|
|||
@ContributesAndroidInjector abstract fun contributesBGSourceFragment(): BGSourceFragment
|
||||
@ContributesAndroidInjector abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment
|
||||
@ContributesAndroidInjector abstract fun contributesDanaRFragment(): DanaRFragment
|
||||
@ContributesAndroidInjector abstract fun contributesEditActionDialog(): EditActionDialog
|
||||
@ContributesAndroidInjector abstract fun contributesEditEventDialog(): EditEventDialog
|
||||
@ContributesAndroidInjector abstract fun contributesEditTriggerDialog(): EditTriggerDialog
|
||||
@ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
||||
@ContributesAndroidInjector abstract fun contributesChooseActionDialog(): ChooseActionDialog
|
||||
@ContributesAndroidInjector abstract fun contributesChooseTriggerDialog(): ChooseTriggerDialog
|
||||
@ContributesAndroidInjector abstract fun contributesLocalProfileFragment(): LocalProfileFragment
|
||||
@ContributesAndroidInjector abstract fun contributesObjectivesFragment(): ObjectivesFragment
|
||||
@ContributesAndroidInjector abstract fun contributesOpenAPSAMAFragment(): OpenAPSAMAFragment
|
||||
|
@ -72,9 +67,15 @@ abstract class FragmentsModule {
|
|||
@ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog
|
||||
@ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog
|
||||
@ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog
|
||||
@ContributesAndroidInjector abstract fun contributesEditActionDialog(): EditActionDialog
|
||||
@ContributesAndroidInjector abstract fun contributesEditEventDialog(): EditEventDialog
|
||||
@ContributesAndroidInjector abstract fun contributesEditTriggerDialog(): EditTriggerDialog
|
||||
@ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
||||
@ContributesAndroidInjector abstract fun contributesErrorDialog(): ErrorDialog
|
||||
@ContributesAndroidInjector abstract fun contributesExtendedBolusDialog(): ExtendedBolusDialog
|
||||
@ContributesAndroidInjector abstract fun contributesFillDialog(): FillDialog
|
||||
@ContributesAndroidInjector abstract fun contributesChooseActionDialog(): ChooseActionDialog
|
||||
@ContributesAndroidInjector abstract fun contributesChooseTriggerDialog(): ChooseTriggerDialog
|
||||
@ContributesAndroidInjector abstract fun contributesInsulinDialog(): InsulinDialog
|
||||
@ContributesAndroidInjector abstract fun contributesNtpProgressDialog(): NtpProgressDialog
|
||||
@ContributesAndroidInjector abstract fun contributesObjectivesExamDialog(): ObjectivesExamDialog
|
||||
|
@ -84,4 +85,5 @@ abstract class FragmentsModule {
|
|||
@ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog
|
||||
@ContributesAndroidInjector abstract fun contributesTreatmentDialog(): TreatmentDialog
|
||||
@ContributesAndroidInjector abstract fun contributesWizardDialog(): WizardDialog
|
||||
@ContributesAndroidInjector abstract fun contributesWizardInfoDialog(): WizardInfoDialog
|
||||
}
|
|
@ -29,9 +29,13 @@ import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
|||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.SafeParse
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.utils.toVisibility
|
||||
import info.nightscout.androidaps.utils.wizard.BolusWizard
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -250,8 +254,8 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
treatmentsPlugin.updateTotalIOBTempBasals()
|
||||
val basalIob = treatmentsPlugin.lastCalculationTempBasals.round()
|
||||
|
||||
treatments_wizard_bolusiobinsulin.text = StringUtils.formatInsulin(-bolusIob.iob)
|
||||
treatments_wizard_basaliobinsulin.text = StringUtils.formatInsulin(-basalIob.basaliob)
|
||||
treatments_wizard_bolusiobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, -bolusIob.iob)
|
||||
treatments_wizard_basaliobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, -basalIob.basaliob)
|
||||
|
||||
calculateInsulin()
|
||||
|
||||
|
@ -308,19 +312,19 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
|
||||
wizard?.let { wizard ->
|
||||
treatments_wizard_bg.text = String.format(resourceHelper.gs(R.string.format_bg_isf), BgReading().value(Profile.toMgdl(bg, profileFunction.getUnits())).valueToUnitsToString(profileFunction.getUnits()), wizard.sens)
|
||||
treatments_wizard_bginsulin.text = StringUtils.formatInsulin(wizard.insulinFromBG)
|
||||
treatments_wizard_bginsulin.text = resourceHelper.gs(R.string.formatinsulinunits, wizard.insulinFromBG)
|
||||
|
||||
treatments_wizard_carbs.text = String.format(resourceHelper.gs(R.string.format_carbs_ic), carbs.toDouble(), wizard.ic)
|
||||
treatments_wizard_carbsinsulin.text = StringUtils.formatInsulin(wizard.insulinFromCarbs)
|
||||
treatments_wizard_carbsinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, wizard.insulinFromCarbs)
|
||||
|
||||
treatments_wizard_bolusiobinsulin.text = StringUtils.formatInsulin(wizard.insulinFromBolusIOB)
|
||||
treatments_wizard_basaliobinsulin.text = StringUtils.formatInsulin(wizard.insulinFromBasalsIOB)
|
||||
treatments_wizard_bolusiobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, wizard.insulinFromBolusIOB)
|
||||
treatments_wizard_basaliobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, wizard.insulinFromBasalsIOB)
|
||||
|
||||
treatments_wizard_correctioninsulin.text = StringUtils.formatInsulin(wizard.insulinFromCorrection)
|
||||
treatments_wizard_correctioninsulin.text = resourceHelper.gs(R.string.formatinsulinunits, wizard.insulinFromCorrection)
|
||||
|
||||
// Superbolus
|
||||
treatments_wizard_sb.text = if (treatments_wizard_sbcheckbox.isChecked) resourceHelper.gs(R.string.twohours) else ""
|
||||
treatments_wizard_sbinsulin.text = StringUtils.formatInsulin(wizard.insulinFromSuperBolus)
|
||||
treatments_wizard_sbinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, wizard.insulinFromSuperBolus)
|
||||
|
||||
// Trend
|
||||
if (treatments_wizard_bgtrendcheckbox.isChecked && wizard.glucoseStatus != null) {
|
||||
|
@ -330,12 +334,12 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
} else {
|
||||
treatments_wizard_bgtrend.text = ""
|
||||
}
|
||||
treatments_wizard_bgtrendinsulin.text = StringUtils.formatInsulin(wizard.insulinFromTrend)
|
||||
treatments_wizard_bgtrendinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, wizard.insulinFromTrend)
|
||||
|
||||
// COB
|
||||
if (treatments_wizard_cobcheckbox.isChecked) {
|
||||
treatments_wizard_cob.text = String.format(resourceHelper.gs(R.string.format_cob_ic), cob, wizard.ic)
|
||||
treatments_wizard_cobinsulin.text = StringUtils.formatInsulin(wizard.insulinFromCOB)
|
||||
treatments_wizard_cobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, wizard.insulinFromCOB)
|
||||
} else {
|
||||
treatments_wizard_cob.text = ""
|
||||
treatments_wizard_cobinsulin.text = ""
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package info.nightscout.androidaps.dialogs
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import dagger.android.support.DaggerDialogFragment
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.JsonHelper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import kotlinx.android.synthetic.main.dialog_wizardinfo.*
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class WizardInfoDialog : DaggerDialogFragment() {
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
|
||||
private var json: JSONObject? = null
|
||||
|
||||
fun setData(json: JSONObject) {
|
||||
this.json = json
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
|
||||
isCancelable = true
|
||||
dialog?.setCanceledOnTouchOutside(false)
|
||||
return inflater.inflate(R.layout.dialog_wizardinfo, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
close.setOnClickListener { dismiss() }
|
||||
val units = profileFunction.getUnits()
|
||||
val bgString =
|
||||
if (units == Constants.MGDL) DecimalFormatter.to0Decimal(JsonHelper.safeGetDouble(json, "bg"))
|
||||
else DecimalFormatter.to1Decimal(JsonHelper.safeGetDouble(json, "bg"))
|
||||
// BG
|
||||
treatments_wizard_bg.text = resourceHelper.gs(R.string.format_bg_isf, bgString, JsonHelper.safeGetDouble(json, "isf"))
|
||||
treatments_wizard_bginsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "insulinbg"))
|
||||
treatments_wizard_bgcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "insulinbgused")
|
||||
treatments_wizard_ttcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "ttused")
|
||||
// Trend
|
||||
treatments_wizard_bgtrend.text = JsonHelper.safeGetString(json, "trend")
|
||||
treatments_wizard_bgtrendinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "insulintrend"))
|
||||
treatments_wizard_bgtrendcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "trendused")
|
||||
// COB
|
||||
treatments_wizard_cob.text = resourceHelper.gs(R.string.format_cob_ic, JsonHelper.safeGetDouble(json, "cob"), JsonHelper.safeGetDouble(json, "ic"))
|
||||
treatments_wizard_cobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "insulincob"))
|
||||
treatments_wizard_cobcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "cobused")
|
||||
// Bolus IOB
|
||||
treatments_wizard_bolusiobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "bolusiob"))
|
||||
treatments_wizard_bolusiobcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "bolusiobused")
|
||||
// Basal IOB
|
||||
treatments_wizard_basaliobinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "basaliob"))
|
||||
treatments_wizard_basaliobcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "basaliobused")
|
||||
// Superbolus
|
||||
treatments_wizard_sbinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "insulinsuperbolus"))
|
||||
treatments_wizard_sbcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "superbolusused")
|
||||
// Carbs
|
||||
treatments_wizard_carbs.text = resourceHelper.gs(R.string.format_carbs_ic, JsonHelper.safeGetDouble(json, "carbs"), JsonHelper.safeGetDouble(json, "ic"))
|
||||
treatments_wizard_carbsinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "insulincarbs"))
|
||||
// Correction
|
||||
treatments_wizard_correctioninsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "othercorrection"))
|
||||
// Profile
|
||||
treatments_wizard_profile.text = JsonHelper.safeGetString(json, "profile")
|
||||
// Notes
|
||||
treatments_wizard_notes.text = JsonHelper.safeGetString(json, "notes")
|
||||
// Percentage
|
||||
treatments_wizard_percent_used.text = DecimalFormatter.to0Decimal(JsonHelper.safeGetDouble(json, "percentageCorrection", 100.0)) + "%"
|
||||
// Total
|
||||
treatments_wizard_totalinsulin.text = resourceHelper.gs(R.string.formatinsulinunits, JsonHelper.safeGetDouble(json, "insulin"))
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
}
|
|
@ -1,21 +1,28 @@
|
|||
package info.nightscout.androidaps.plugins.configBuilder
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.CheckBox
|
||||
import android.widget.ImageButton
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RadioButton
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.PreferencesActivity
|
||||
import info.nightscout.androidaps.events.EventRebuildTabs
|
||||
import info.nightscout.androidaps.interfaces.*
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.PasswordProtection
|
||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.toVisibility
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.configbuilder_fragment.*
|
||||
|
@ -25,6 +32,7 @@ import javax.inject.Inject
|
|||
class ConfigBuilderFragment : DaggerFragment() {
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
private val pluginViewHolders = ArrayList<PluginViewHolder>()
|
||||
|
@ -86,7 +94,8 @@ class ConfigBuilderFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
private fun createViewsForPlugins(@StringRes title: Int, @StringRes description: Int, pluginType: PluginType, plugins: List<PluginBase>) {
|
||||
if (plugins.size == 0) return
|
||||
if (plugins.isEmpty()) return
|
||||
@Suppress("InflateParams")
|
||||
val parent = layoutInflater.inflate(R.layout.configbuilder_single_category, null) as LinearLayout
|
||||
(parent.findViewById<View>(R.id.category_title) as TextView).text = resourceHelper.gs(title)
|
||||
(parent.findViewById<View>(R.id.category_description) as TextView).text = resourceHelper.gs(description)
|
||||
|
@ -99,4 +108,75 @@ class ConfigBuilderFragment : DaggerFragment() {
|
|||
configbuilder_categories.addView(parent)
|
||||
}
|
||||
|
||||
inner class PluginViewHolder internal constructor(private val fragment: ConfigBuilderFragment,
|
||||
private val pluginType: PluginType,
|
||||
private val plugin: PluginBase) {
|
||||
|
||||
@Suppress("InflateParams")
|
||||
val baseView: LinearLayout = fragment.layoutInflater.inflate(R.layout.configbuilder_single_plugin, null) as LinearLayout
|
||||
private val enabledExclusive: RadioButton
|
||||
private val enabledInclusive: CheckBox
|
||||
private val pluginName: TextView
|
||||
private val pluginDescription: TextView
|
||||
private val pluginPreferences: ImageButton
|
||||
private val pluginVisibility: CheckBox
|
||||
|
||||
init {
|
||||
enabledExclusive = baseView.findViewById(R.id.plugin_enabled_exclusive)
|
||||
enabledInclusive = baseView.findViewById(R.id.plugin_enabled_inclusive)
|
||||
pluginName = baseView.findViewById(R.id.plugin_name)
|
||||
pluginDescription = baseView.findViewById(R.id.plugin_description)
|
||||
pluginPreferences = baseView.findViewById(R.id.plugin_preferences)
|
||||
pluginVisibility = baseView.findViewById(R.id.plugin_visibility)
|
||||
|
||||
pluginVisibility.setOnClickListener {
|
||||
plugin.setFragmentVisible(pluginType, pluginVisibility.isChecked)
|
||||
configBuilderPlugin.storeSettings("CheckedCheckboxVisible")
|
||||
rxBus.send(EventRebuildTabs())
|
||||
configBuilderPlugin.logPluginStatus()
|
||||
}
|
||||
|
||||
enabledExclusive.setOnClickListener {
|
||||
plugin.switchAllowed(if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
||||
}
|
||||
enabledInclusive.setOnClickListener {
|
||||
plugin.switchAllowed(if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
||||
}
|
||||
|
||||
pluginPreferences.setOnClickListener {
|
||||
PasswordProtection.QueryPassword(fragment.context, R.string.settings_password, "settings_password", {
|
||||
val i = Intent(fragment.context, PreferencesActivity::class.java)
|
||||
i.putExtra("id", plugin.preferencesId)
|
||||
fragment.startActivity(i)
|
||||
}, null)
|
||||
}
|
||||
update()
|
||||
}
|
||||
|
||||
fun update() {
|
||||
enabledExclusive.visibility = areMultipleSelectionsAllowed(pluginType).not().toVisibility()
|
||||
enabledInclusive.visibility = areMultipleSelectionsAllowed(pluginType).toVisibility()
|
||||
enabledExclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
enabledExclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
pluginName.text = plugin.name
|
||||
if (plugin.description == null)
|
||||
pluginDescription.visibility = View.GONE
|
||||
else {
|
||||
pluginDescription.visibility = View.VISIBLE
|
||||
pluginDescription.text = plugin.description
|
||||
}
|
||||
pluginPreferences.visibility = if (plugin.preferencesId == -1 || !plugin.isEnabled(pluginType)) View.INVISIBLE else View.VISIBLE
|
||||
pluginVisibility.visibility = plugin.hasFragment().toVisibility()
|
||||
pluginVisibility.isEnabled = !(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwaysVisible) && plugin.isEnabled(pluginType)
|
||||
pluginVisibility.isChecked = plugin.isFragmentVisible()
|
||||
}
|
||||
|
||||
private fun areMultipleSelectionsAllowed(type: PluginType): Boolean {
|
||||
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS || type == PluginType.LOOP
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,72 +16,3 @@ import info.nightscout.androidaps.plugins.bus.RxBus
|
|||
import info.nightscout.androidaps.utils.PasswordProtection
|
||||
import info.nightscout.androidaps.utils.toVisibility
|
||||
|
||||
class PluginViewHolder internal constructor(private val fragment: ConfigBuilderFragment,
|
||||
private val pluginType: PluginType,
|
||||
private val plugin: PluginBase) {
|
||||
|
||||
val baseView: LinearLayout = fragment.layoutInflater.inflate(R.layout.configbuilder_single_plugin, null) as LinearLayout
|
||||
private val enabledExclusive: RadioButton
|
||||
private val enabledInclusive: CheckBox
|
||||
private val pluginName: TextView
|
||||
private val pluginDescription: TextView
|
||||
private val pluginPreferences: ImageButton
|
||||
private val pluginVisibility: CheckBox
|
||||
|
||||
init {
|
||||
enabledExclusive = baseView.findViewById(R.id.plugin_enabled_exclusive)
|
||||
enabledInclusive = baseView.findViewById(R.id.plugin_enabled_inclusive)
|
||||
pluginName = baseView.findViewById(R.id.plugin_name)
|
||||
pluginDescription = baseView.findViewById(R.id.plugin_description)
|
||||
pluginPreferences = baseView.findViewById(R.id.plugin_preferences)
|
||||
pluginVisibility = baseView.findViewById(R.id.plugin_visibility)
|
||||
|
||||
pluginVisibility.setOnClickListener {
|
||||
plugin.setFragmentVisible(pluginType, pluginVisibility.isChecked)
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible")
|
||||
RxBus.INSTANCE.send(EventRebuildTabs())
|
||||
ConfigBuilderPlugin.getPlugin().logPluginStatus()
|
||||
}
|
||||
|
||||
enabledExclusive.setOnClickListener {
|
||||
plugin.switchAllowed(if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
||||
}
|
||||
enabledInclusive.setOnClickListener {
|
||||
plugin.switchAllowed(if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
||||
}
|
||||
|
||||
pluginPreferences.setOnClickListener {
|
||||
PasswordProtection.QueryPassword(fragment.context, R.string.settings_password, "settings_password", {
|
||||
val i = Intent(fragment.context, PreferencesActivity::class.java)
|
||||
i.putExtra("id", plugin.preferencesId)
|
||||
fragment.startActivity(i)
|
||||
}, null)
|
||||
}
|
||||
update()
|
||||
}
|
||||
|
||||
fun update() {
|
||||
enabledExclusive.visibility = areMultipleSelectionsAllowed(pluginType).not().toVisibility()
|
||||
enabledInclusive.visibility = areMultipleSelectionsAllowed(pluginType).toVisibility()
|
||||
enabledExclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
enabledExclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
pluginName.text = plugin.name
|
||||
if (plugin.description == null)
|
||||
pluginDescription.visibility = View.GONE
|
||||
else {
|
||||
pluginDescription.visibility = View.VISIBLE
|
||||
pluginDescription.text = plugin.description
|
||||
}
|
||||
pluginPreferences.visibility = if (plugin.preferencesId == -1 || !plugin.isEnabled(pluginType)) View.INVISIBLE else View.VISIBLE
|
||||
pluginVisibility.visibility = plugin.hasFragment().toVisibility()
|
||||
pluginVisibility.isEnabled = !(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwaysVisible) && plugin.isEnabled(pluginType)
|
||||
pluginVisibility.isChecked = plugin.isFragmentVisible()
|
||||
}
|
||||
|
||||
private fun areMultipleSelectionsAllowed(type: PluginType): Boolean {
|
||||
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS || type == PluginType.LOOP
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class WearPlugin internal @Inject constructor(
|
||||
class WearPlugin @Inject constructor(
|
||||
private val rxBus: RxBusWrapper,
|
||||
private val resourceHelper: ResourceHelper,
|
||||
private val sp: SP,
|
||||
|
@ -45,40 +45,42 @@ class WearPlugin internal @Inject constructor(
|
|||
disposable.add(rxBus
|
||||
.toObservable(EventOpenAPSUpdateGui::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendDataToWatch(true, true, false) }) { FabricPrivacy.logException(it) })
|
||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventExtendedBolusChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendDataToWatch(true, true, false) }) { FabricPrivacy.logException(it) })
|
||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventTempBasalChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event: EventTempBasalChange? -> sendDataToWatch(true, true, false) }) { FabricPrivacy.logException(it) })
|
||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventTreatmentChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ sendDataToWatch(true, true, false) }) { FabricPrivacy.logException(it) })
|
||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = false) }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventNewBasalProfile::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event: EventNewBasalProfile? -> sendDataToWatch(false, true, false) }) { FabricPrivacy.logException(it) })
|
||||
.subscribe({ sendDataToWatch(status = false, basals = true, bgValue = false) }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event: EventAutosensCalculationFinished? -> sendDataToWatch(true, true, true) }) { FabricPrivacy.logException(it) })
|
||||
.subscribe({ sendDataToWatch(status = true, basals = true, bgValue = true) }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventPreferenceChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event: EventPreferenceChange? ->
|
||||
.subscribe({
|
||||
// possibly new high or low mark
|
||||
resendDataToWatch()
|
||||
// status may be formated differently
|
||||
sendDataToWatch(true, false, false)
|
||||
// status may be formatted differently
|
||||
sendDataToWatch(status = true, basals = false, bgValue = false)
|
||||
}) { FabricPrivacy.logException(it) })
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventRefreshOverview::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event: EventRefreshOverview? -> if (WatchUpdaterService.shouldReportLoopStatus(loopPlugin.get().isEnabled(PluginType.LOOP))) sendDataToWatch(true, false, false) }) { FabricPrivacy.logException(it) })
|
||||
.subscribe({
|
||||
if (WatchUpdaterService.shouldReportLoopStatus(loopPlugin.get().isEnabled(PluginType.LOOP)))
|
||||
sendDataToWatch(status = true, basals = false, bgValue = false) }) { FabricPrivacy.logException(it) })
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventBolusRequested::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
|
@ -148,10 +150,10 @@ class WearPlugin internal @Inject constructor(
|
|||
mainApp.startService(Intent(mainApp, WatchUpdaterService::class.java).setAction(WatchUpdaterService.ACTION_OPEN_SETTINGS))
|
||||
}
|
||||
|
||||
fun requestNotificationCancel(actionstring: String?) { //Log.d(TAG, "WR: WearPlugin:requestNotificationCancel");
|
||||
fun requestNotificationCancel(actionString: String?) { //Log.d(TAG, "WR: WearPlugin:requestNotificationCancel");
|
||||
val intent = Intent(mainApp, WatchUpdaterService::class.java)
|
||||
.setAction(WatchUpdaterService.ACTION_CANCEL_NOTIFICATION)
|
||||
intent.putExtra("actionstring", actionstring)
|
||||
intent.putExtra("actionstring", actionString)
|
||||
mainApp.startService(intent)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,11 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
|||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Created by adrian on 13.08.2017.
|
||||
|
@ -22,7 +21,8 @@ import javax.inject.Inject
|
|||
*/
|
||||
abstract class InsulinOrefBasePlugin(
|
||||
val rxBus: RxBusWrapper,
|
||||
val resourceHelper: ResourceHelper
|
||||
val resourceHelper: ResourceHelper,
|
||||
val profileFunction: ProfileFunction
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.INSULIN)
|
||||
.fragmentClass(InsulinFragment::class.java.name)
|
||||
|
@ -54,7 +54,7 @@ abstract class InsulinOrefBasePlugin (
|
|||
|
||||
open val userDefinedDia: Double
|
||||
get() {
|
||||
val profile = ProfileFunctions.getInstance().getProfile()
|
||||
val profile = profileFunction.getProfile()
|
||||
return profile?.dia ?: MIN_DIA
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.insulin
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import javax.inject.Inject
|
||||
|
@ -15,8 +16,9 @@ import javax.inject.Singleton
|
|||
class InsulinOrefFreePeakPlugin @Inject constructor(
|
||||
private val sp: SP,
|
||||
resourceHelper: ResourceHelper,
|
||||
rxBus: RxBusWrapper
|
||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper) {
|
||||
rxBus: RxBusWrapper,
|
||||
profileFunction: ProfileFunction
|
||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) {
|
||||
|
||||
override fun getId(): Int {
|
||||
return InsulinInterface.OREF_FREE_PEAK
|
||||
|
|
|
@ -4,6 +4,7 @@ import info.nightscout.androidaps.MainApp
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import javax.inject.Inject
|
||||
|
@ -13,8 +14,9 @@ import javax.inject.Inject
|
|||
*/
|
||||
class InsulinOrefRapidActingPlugin @Inject constructor(
|
||||
resourceHelper: ResourceHelper,
|
||||
rxBus: RxBusWrapper
|
||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper) {
|
||||
rxBus: RxBusWrapper,
|
||||
profileFunction: ProfileFunction
|
||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) {
|
||||
|
||||
|
||||
override fun getId(): Int {
|
||||
|
|
|
@ -4,6 +4,7 @@ import info.nightscout.androidaps.MainApp
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import javax.inject.Inject
|
||||
|
@ -14,8 +15,9 @@ import javax.inject.Inject
|
|||
class InsulinOrefUltraRapidActingPlugin @Inject constructor(
|
||||
private val sp: SP,
|
||||
resourceHelper: ResourceHelper,
|
||||
rxBus: RxBusWrapper
|
||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper) {
|
||||
rxBus: RxBusWrapper,
|
||||
profileFunction: ProfileFunction
|
||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) {
|
||||
|
||||
|
||||
override fun getId(): Int {
|
||||
|
@ -23,11 +25,11 @@ class InsulinOrefUltraRapidActingPlugin @Inject constructor(
|
|||
}
|
||||
|
||||
override fun getFriendlyName(): String {
|
||||
return MainApp.gs(R.string.ultrarapid_oref)
|
||||
return resourceHelper.gs(R.string.ultrarapid_oref)
|
||||
}
|
||||
|
||||
override fun commentStandardText(): String {
|
||||
return MainApp.gs(R.string.ultrafastactinginsulincomment)
|
||||
return resourceHelper.gs(R.string.ultrafastactinginsulincomment)
|
||||
}
|
||||
|
||||
override val peak = 55
|
||||
|
|
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.interfaces.ProfileInterface
|
|||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
|
@ -33,7 +34,8 @@ class LocalProfilePlugin @Inject constructor(
|
|||
private val aapsLogger: AAPSLogger,
|
||||
private val rxBus: RxBusWrapper,
|
||||
private val resourceHelper: ResourceHelper,
|
||||
private val sp: SP
|
||||
private val sp: SP,
|
||||
private val profileFunction: ProfileFunction
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.PROFILE)
|
||||
.fragmentClass(LocalProfileFragment::class.java.name)
|
||||
|
@ -232,7 +234,7 @@ class LocalProfilePlugin @Inject constructor(
|
|||
aapsLogger.debug(LTag.PROFILE, "Loading stored settings")
|
||||
val p = SingleProfile()
|
||||
|
||||
p.mgdl = sp.getBoolean(LOCAL_PROFILE + "mgdl", ProfileFunctions.getSystemUnits() == Constants.MGDL)
|
||||
p.mgdl = sp.getBoolean(LOCAL_PROFILE + "mgdl", profileFunction.getUnits() == Constants.MGDL)
|
||||
p.dia = sp.getDouble(LOCAL_PROFILE + "dia", Constants.defaultDIA)
|
||||
try {
|
||||
p.ic = JSONArray(sp.getString(LOCAL_PROFILE + "ic", defaultArray))
|
||||
|
@ -351,7 +353,7 @@ class LocalProfilePlugin @Inject constructor(
|
|||
}
|
||||
val p = SingleProfile()
|
||||
p.name = LOCAL_PROFILE + free
|
||||
p.mgdl = ProfileFunctions.getSystemUnits() == Constants.MGDL
|
||||
p.mgdl = profileFunction.getUnits() == Constants.MGDL
|
||||
p.dia = Constants.defaultDIA
|
||||
p.ic = JSONArray(defaultArray)
|
||||
p.isf = JSONArray(defaultArray)
|
||||
|
|
|
@ -9,7 +9,7 @@ import android.widget.ArrayAdapter
|
|||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
|
@ -30,6 +30,7 @@ class NSProfileFragment : DaggerFragment() {
|
|||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -128,7 +129,7 @@ class NSProfileFragment : DaggerFragment() {
|
|||
nsprofile_spinner.adapter = adapter
|
||||
// set selected to actual profile
|
||||
for (p in profileList.indices) {
|
||||
if (profileList[p] == ProfileFunctions.getInstance().getProfileName())
|
||||
if (profileList[p] == profileFunction.getProfileName())
|
||||
nsprofile_spinner.setSelection(p)
|
||||
}
|
||||
profileview_noprofile.visibility = View.GONE
|
||||
|
|
|
@ -21,7 +21,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
|||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
|
@ -42,6 +42,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||
@Inject lateinit var danaRSPlugin: DanaRSPlugin
|
||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||
|
@ -189,7 +190,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
|
|||
}
|
||||
|
||||
RecordTypes.RECORD_TYPE_GLUCOSE -> {
|
||||
holder.value.text = Profile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, ProfileFunctions.getSystemUnits())
|
||||
holder.value.text = Profile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, profileFunction.getUnits())
|
||||
holder.time.visibility = View.VISIBLE
|
||||
holder.value.visibility = View.VISIBLE
|
||||
holder.stringValue.visibility = View.GONE
|
||||
|
|
|
@ -319,7 +319,7 @@ class MedtronicFragment : DaggerFragment() {
|
|||
SetWarnColor.setColorInverse(medtronic_pumpstate_battery, pumpStatus.batteryRemaining.toDouble(), 25.0, 10.0)
|
||||
|
||||
// reservoir
|
||||
medtronic_reservoir.text = MainApp.gs(R.string.reservoirvalue, pumpStatus.reservoirRemainingUnits, pumpStatus.reservoirFullUnits)
|
||||
medtronic_reservoir.text = resourceHelper.gs(R.string.reservoirvalue, pumpStatus.reservoirRemainingUnits, pumpStatus.reservoirFullUnits)
|
||||
SetWarnColor.setColorInverse(medtronic_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
||||
|
||||
medtronic_errors.text = pumpStatus.errorInfo
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.treatments.dialogs
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.JsonHelper
|
||||
import info.nightscout.androidaps.utils.StringUtils
|
||||
import kotlinx.android.synthetic.main.treatments_wizardinfo_dialog.*
|
||||
import org.json.JSONObject
|
||||
|
||||
class WizardInfoDialog : DialogFragment() {
|
||||
private var json: JSONObject? = null
|
||||
|
||||
fun setData(json: JSONObject) {
|
||||
this.json = json
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
|
||||
isCancelable = true
|
||||
return inflater.inflate(R.layout.treatments_wizardinfo_dialog, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
close.setOnClickListener { dismiss() }
|
||||
val units = ProfileFunctions.getSystemUnits()
|
||||
val bg_string: String
|
||||
if (units.equals(Constants.MGDL)) { bg_string = DecimalFormatter.to0Decimal(JsonHelper.safeGetDouble(json, "bg"))} else { bg_string = DecimalFormatter.to1Decimal(JsonHelper.safeGetDouble(json, "bg"))}
|
||||
// BG
|
||||
treatments_wizard_bg.text = MainApp.gs(R.string.format_bg_isf, bg_string , JsonHelper.safeGetDouble(json, "isf"))
|
||||
treatments_wizard_bginsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "insulinbg"))
|
||||
treatments_wizard_bgcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "insulinbgused")
|
||||
treatments_wizard_ttcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "ttused")
|
||||
// Trend
|
||||
treatments_wizard_bgtrend.text = JsonHelper.safeGetString(json, "trend")
|
||||
treatments_wizard_bgtrendinsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "insulintrend"))
|
||||
treatments_wizard_bgtrendcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "trendused")
|
||||
// COB
|
||||
treatments_wizard_cob.text = MainApp.gs(R.string.format_cob_ic, JsonHelper.safeGetDouble(json, "cob"), JsonHelper.safeGetDouble(json, "ic"))
|
||||
treatments_wizard_cobinsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "insulincob"))
|
||||
treatments_wizard_cobcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "cobused")
|
||||
// Bolus IOB
|
||||
treatments_wizard_bolusiobinsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "bolusiob"))
|
||||
treatments_wizard_bolusiobcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "bolusiobused")
|
||||
// Basal IOB
|
||||
treatments_wizard_basaliobinsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "basaliob"))
|
||||
treatments_wizard_basaliobcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "basaliobused")
|
||||
// Superbolus
|
||||
treatments_wizard_sbinsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "insulinsuperbolus"))
|
||||
treatments_wizard_sbcheckbox.isChecked = JsonHelper.safeGetBoolean(json, "superbolusused")
|
||||
// Carbs
|
||||
treatments_wizard_carbs.text = MainApp.gs(R.string.format_carbs_ic, JsonHelper.safeGetDouble(json, "carbs"), JsonHelper.safeGetDouble(json, "ic"))
|
||||
treatments_wizard_carbsinsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "insulincarbs"))
|
||||
// Correction
|
||||
treatments_wizard_correctioninsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "othercorrection"))
|
||||
// Profile
|
||||
treatments_wizard_profile.text = JsonHelper.safeGetString(json, "profile")
|
||||
// Notes
|
||||
treatments_wizard_notes.text = JsonHelper.safeGetString(json, "notes")
|
||||
// Percentage
|
||||
treatments_wizard_percent_used.text = DecimalFormatter.to0Decimal(JsonHelper.safeGetDouble(json, "percentageCorrection", 100.0)) + "%"
|
||||
// Total
|
||||
treatments_wizard_totalinsulin.text = StringUtils.formatInsulin(JsonHelper.safeGetDouble(json, "insulin"))
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientR
|
|||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.dialogs.WizardInfoDialog
|
||||
import info.nightscout.androidaps.dialogs.WizardInfoDialog
|
||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment.RecyclerViewAdapter.TreatmentsViewHolder
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
|
|
|
@ -8,10 +8,6 @@ import info.nightscout.androidaps.R;
|
|||
*/
|
||||
public class StringUtils {
|
||||
|
||||
private StringUtils() {
|
||||
// this constructor is private, since this class should not get instantiated
|
||||
}
|
||||
|
||||
public static String removeSurroundingQuotes(String string) {
|
||||
if (string.length() >= 2 && string.charAt(0) == '"'
|
||||
&& string.charAt(string.length() - 1) == '"') {
|
||||
|
@ -24,8 +20,4 @@ public class StringUtils {
|
|||
public static boolean emptyString(final String str) {
|
||||
return str == null || str.length() == 0;
|
||||
}
|
||||
|
||||
public static String formatInsulin(double insulin) {
|
||||
return String.format(MainApp.gs(R.string.formatinsulinunits), insulin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:focusableInTouchMode="true"
|
||||
android:minWidth="300dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
tools:context=".dialogs.WizardInfoDialog">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dip"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="-15dp"
|
||||
android:background="@color/listdelimiter" />
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/dialog_title_background"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp">
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:paddingBottom="10dp"
|
||||
android:contentDescription="@string/carbs"
|
||||
android:src="@drawable/icon_calculator" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="@string/wear_wizard_settings"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/spacer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -466,7 +483,7 @@
|
|||
android:layout_height="56dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@android:color/transparent"
|
||||
android:gravity="end|right"
|
||||
android:gravity="end"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
|
@ -474,11 +491,11 @@
|
|||
android:id="@+id/close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
style="@style/mdtp_ActionButton.Text"
|
||||
android:text="@string/mdtp_ok" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
Loading…
Reference in a new issue