2021-05-23 21:38:30 +02:00
|
|
|
package info.nightscout.androidaps.activities
|
2019-12-29 00:07:30 +01:00
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.view.View
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
import androidx.fragment.app.FragmentTransaction
|
|
|
|
import info.nightscout.androidaps.R
|
2021-05-23 21:38:30 +02:00
|
|
|
import info.nightscout.androidaps.activities.fragments.*
|
2021-02-03 15:52:43 +01:00
|
|
|
import info.nightscout.androidaps.databinding.TreatmentsFragmentBinding
|
2021-05-23 21:38:30 +02:00
|
|
|
import info.nightscout.androidaps.extensions.toVisibility
|
2021-04-14 00:45:30 +02:00
|
|
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
2021-03-02 23:32:30 +01:00
|
|
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
2019-12-29 00:07:30 +01:00
|
|
|
import javax.inject.Inject
|
|
|
|
|
2021-05-23 21:38:30 +02:00
|
|
|
class TreatmentsActivity : NoSplashAppCompatActivity() {
|
2021-02-03 15:52:43 +01:00
|
|
|
|
2021-03-02 23:32:30 +01:00
|
|
|
@Inject lateinit var buildHelper: BuildHelper
|
2021-05-23 21:38:30 +02:00
|
|
|
@Inject lateinit var activePlugin: ActivePlugin
|
2021-02-03 15:52:43 +01:00
|
|
|
|
2021-05-23 21:38:30 +02:00
|
|
|
private lateinit var binding: TreatmentsFragmentBinding
|
2019-12-29 00:07:30 +01:00
|
|
|
|
2021-05-23 21:38:30 +02:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
binding = TreatmentsFragmentBinding.inflate(layoutInflater)
|
|
|
|
setContentView(binding.root)
|
2019-12-29 00:07:30 +01:00
|
|
|
|
2021-03-02 23:32:30 +01:00
|
|
|
binding.tempBasals.visibility = buildHelper.isEngineeringMode().toVisibility()
|
|
|
|
binding.extendedBoluses.visibility = (buildHelper.isEngineeringMode() && !activePlugin.activePump.isFakingTempsByExtendedBoluses).toVisibility()
|
|
|
|
|
2021-02-03 15:52:43 +01:00
|
|
|
binding.treatments.setOnClickListener {
|
2021-03-25 23:52:08 +01:00
|
|
|
setFragment(TreatmentsBolusCarbsFragment())
|
2019-12-29 00:07:30 +01:00
|
|
|
setBackgroundColorOnSelected(it)
|
|
|
|
}
|
2021-02-03 22:40:13 +01:00
|
|
|
binding.extendedBoluses.setOnClickListener {
|
2019-12-29 00:07:30 +01:00
|
|
|
setFragment(TreatmentsExtendedBolusesFragment())
|
|
|
|
setBackgroundColorOnSelected(it)
|
|
|
|
}
|
2021-02-03 22:40:13 +01:00
|
|
|
binding.tempBasals.setOnClickListener {
|
2019-12-29 00:07:30 +01:00
|
|
|
setFragment(TreatmentsTemporaryBasalsFragment())
|
|
|
|
setBackgroundColorOnSelected(it)
|
|
|
|
}
|
2021-02-03 22:40:13 +01:00
|
|
|
binding.tempTargets.setOnClickListener {
|
2019-12-29 00:07:30 +01:00
|
|
|
setFragment(TreatmentsTempTargetFragment())
|
|
|
|
setBackgroundColorOnSelected(it)
|
|
|
|
}
|
2021-02-03 22:40:13 +01:00
|
|
|
binding.profileSwitches.setOnClickListener {
|
2019-12-29 00:07:30 +01:00
|
|
|
setFragment(TreatmentsProfileSwitchFragment())
|
|
|
|
setBackgroundColorOnSelected(it)
|
|
|
|
}
|
2021-02-03 15:52:43 +01:00
|
|
|
binding.careportal.setOnClickListener {
|
2019-12-29 00:07:30 +01:00
|
|
|
setFragment(TreatmentsCareportalFragment())
|
|
|
|
setBackgroundColorOnSelected(it)
|
|
|
|
}
|
2021-02-09 17:57:28 +01:00
|
|
|
binding.userentry.setOnClickListener {
|
|
|
|
setFragment(TreatmentsUserEntryFragment())
|
|
|
|
setBackgroundColorOnSelected(it)
|
|
|
|
}
|
2021-03-25 23:52:08 +01:00
|
|
|
setFragment(TreatmentsBolusCarbsFragment())
|
2021-02-03 15:52:43 +01:00
|
|
|
setBackgroundColorOnSelected(binding.treatments)
|
2019-12-29 00:07:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun setFragment(selectedFragment: Fragment) {
|
2021-05-23 21:38:30 +02:00
|
|
|
supportFragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.fragment_container, selectedFragment)
|
|
|
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
2021-02-03 15:52:43 +01:00
|
|
|
.commit()
|
2019-12-29 00:07:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun setBackgroundColorOnSelected(selected: View) {
|
2021-02-03 15:52:43 +01:00
|
|
|
binding.treatments.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
2021-02-03 22:40:13 +01:00
|
|
|
binding.extendedBoluses.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
|
|
|
binding.tempBasals.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
|
|
|
binding.tempTargets.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
|
|
|
binding.profileSwitches.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
2021-02-03 15:52:43 +01:00
|
|
|
binding.careportal.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
2021-02-09 17:57:28 +01:00
|
|
|
binding.userentry.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground))
|
2019-12-30 00:53:44 +01:00
|
|
|
selected.setBackgroundColor(resourceHelper.gc(R.color.tabBgColorSelected))
|
2019-12-29 00:07:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-23 21:38:30 +02:00
|
|
|
}
|