jetpack bindings in core

This commit is contained in:
Milos Kozak 2021-01-18 23:59:01 +01:00
parent e26ae1af7d
commit 9eaeafea3f
8 changed files with 183 additions and 138 deletions

View file

@ -1,7 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
android { android {
compileSdkVersion 28 compileSdkVersion 28

View file

@ -10,6 +10,7 @@ import android.view.WindowManager
import dagger.android.support.DaggerDialogFragment import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.activities.BolusProgressHelperActivity import info.nightscout.androidaps.activities.BolusProgressHelperActivity
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.core.databinding.DialogBolusprogressBinding
import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -21,10 +22,10 @@ import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.dialog_bolusprogress.*
import javax.inject.Inject import javax.inject.Inject
class BolusProgressDialog : DaggerDialogFragment() { class BolusProgressDialog : DaggerDialogFragment() {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@ -34,6 +35,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
companion object { companion object {
@JvmField @JvmField
var bolusEnded = false var bolusEnded = false
@ -57,31 +59,39 @@ class BolusProgressDialog : DaggerDialogFragment() {
return this return this
} }
private var _binding: DialogBolusprogressBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View {
dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE) dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
isCancelable = false isCancelable = false
dialog?.setCanceledOnTouchOutside(false) dialog?.setCanceledOnTouchOutside(false)
return inflater.inflate(R.layout.dialog_bolusprogress, container, false)
_binding = DialogBolusprogressBinding.inflate(inflater, container, false)
return binding.root
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
savedInstanceState?.let { savedInstanceState?.let {
amount = it.getDouble("amount") amount = it.getDouble("amount")
} }
overview_bolusprogress_title.text = resourceHelper.gs(R.string.goingtodeliver, amount) binding.title.text = resourceHelper.gs(R.string.goingtodeliver, amount)
overview_bolusprogress_stop.setOnClickListener { binding.stop.setOnClickListener {
aapsLogger.debug(LTag.UI, "Stop bolus delivery button pressed") aapsLogger.debug(LTag.UI, "Stop bolus delivery button pressed")
stopPressed = true stopPressed = true
overview_bolusprogress_stoppressed.visibility = View.VISIBLE binding.stoppressed.visibility = View.VISIBLE
overview_bolusprogress_stop.visibility = View.INVISIBLE binding.stop.visibility = View.INVISIBLE
commandQueue.cancelAllBoluses() commandQueue.cancelAllBoluses()
} }
val defaultState = resourceHelper.gs(R.string.waitingforpump) val defaultState = resourceHelper.gs(R.string.waitingforpump)
overview_bolusprogress_progressbar.max = 100 binding.progressbar.max = 100
state = savedInstanceState?.getString("state", defaultState) ?: defaultState state = savedInstanceState?.getString("state", defaultState) ?: defaultState
overview_bolusprogress_status.text = state binding.status.text = state
stopPressed = false stopPressed = false
} }
@ -102,7 +112,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
disposable.add(rxBus disposable.add(rxBus
.toObservable(EventPumpStatusChanged::class.java) .toObservable(EventPumpStatusChanged::class.java)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ overview_bolusprogress_status.text = it.getStatus(resourceHelper) }) { fabricPrivacy.logException(it) } .subscribe({ binding.status.text = it.getStatus(resourceHelper) }) { fabricPrivacy.logException(it) }
) )
disposable.add(rxBus disposable.add(rxBus
.toObservable(EventDismissBolusProgressIfRunning::class.java) .toObservable(EventDismissBolusProgressIfRunning::class.java)
@ -114,10 +124,10 @@ class BolusProgressDialog : DaggerDialogFragment() {
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
aapsLogger.debug(LTag.UI, "Status: ${it.status} Percent: ${it.percent}") aapsLogger.debug(LTag.UI, "Status: ${it.status} Percent: ${it.percent}")
overview_bolusprogress_status.text = it.status binding.status.text = it.status
overview_bolusprogress_progressbar.progress = it.percent binding.progressbar.progress = it.percent
if (it.percent == 100) { if (it.percent == 100) {
overview_bolusprogress_stop.visibility = View.INVISIBLE binding.stop.visibility = View.INVISIBLE
scheduleDismiss() scheduleDismiss()
} }
state = it.status state = it.status
@ -151,9 +161,15 @@ class BolusProgressDialog : DaggerDialogFragment() {
outState.putDouble("amount", amount) outState.putDouble("amount", amount)
} }
override fun onDestroyView() {
super.onDestroyView()
disposable.clear()
_binding = null
}
private fun scheduleDismiss() { private fun scheduleDismiss() {
aapsLogger.debug(LTag.UI, "scheduleDismiss") aapsLogger.debug(LTag.UI, "scheduleDismiss")
Thread(Runnable { Thread {
SystemClock.sleep(5000) SystemClock.sleep(5000)
bolusEnded = true bolusEnded = true
activity?.runOnUiThread { activity?.runOnUiThread {
@ -166,6 +182,6 @@ class BolusProgressDialog : DaggerDialogFragment() {
} }
} }
} }
}).start() }.start()
} }
} }

View file

@ -7,6 +7,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import dagger.android.support.DaggerDialogFragment import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.core.databinding.DialogBolusprogressBinding
import info.nightscout.androidaps.events.EventNtpStatus import info.nightscout.androidaps.events.EventNtpStatus
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
@ -16,10 +17,10 @@ import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.dialog_bolusprogress.*
import javax.inject.Inject import javax.inject.Inject
class NtpProgressDialog : DaggerDialogFragment() { class NtpProgressDialog : DaggerDialogFragment() {
@Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@ -30,26 +31,33 @@ class NtpProgressDialog : DaggerDialogFragment() {
private var state: String? = null private var state: String? = null
private var percent = 0 private var percent = 0
private var _binding: DialogBolusprogressBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View {
isCancelable = false isCancelable = false
state = savedInstanceState?.getString("state", null) state = savedInstanceState?.getString("state", null)
percent = savedInstanceState?.getInt("percent", 0) ?: 0 percent = savedInstanceState?.getInt("percent", 0) ?: 0
return inflater.inflate(R.layout.dialog_bolusprogress, container, false) _binding = DialogBolusprogressBinding.inflate(inflater, container, false)
return binding.root
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val defaultMessage = resourceHelper.gs(R.string.timedetection) val defaultMessage = resourceHelper.gs(R.string.timedetection)
dialog?.setTitle(resourceHelper.gs(R.string.objectives)) dialog?.setTitle(resourceHelper.gs(R.string.objectives))
overview_bolusprogress_stop.setOnClickListener { dismiss() } binding.stop.setOnClickListener { dismiss() }
overview_bolusprogress_status.text = state ?: defaultMessage binding.status.text = state ?: defaultMessage
overview_bolusprogress_progressbar.max = 100 binding.progressbar.max = 100
overview_bolusprogress_progressbar.progress = percent binding.progressbar.progress = percent
overview_bolusprogress_stop.text = resourceHelper.gs(R.string.close) binding.stop.text = resourceHelper.gs(R.string.close)
overview_bolusprogress_title.text = resourceHelper.gs(R.string.please_wait) binding.title.text = resourceHelper.gs(R.string.please_wait)
} }
override fun onResume() { override fun onResume() {
@ -65,16 +73,18 @@ class NtpProgressDialog : DaggerDialogFragment() {
.toObservable(EventNtpStatus::class.java) .toObservable(EventNtpStatus::class.java)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ event: EventNtpStatus -> .subscribe({ event: EventNtpStatus ->
aapsLogger.debug(LTag.UI, "Status: " + event.status + " Percent: " + event.percent) if (_binding != null) {
overview_bolusprogress_status?.text = event.status aapsLogger.debug(LTag.UI, "Status: " + event.status + " Percent: " + event.percent)
overview_bolusprogress_progressbar?.progress = event.percent binding.status.text = event.status
if (event.percent == 100) { binding.progressbar.progress = event.percent
SystemClock.sleep(100) if (event.percent == 100) {
dismiss() SystemClock.sleep(100)
dismiss()
}
state = event.status
percent = event.percent
} }
state = event.status }, fabricPrivacy::logException)
percent = event.percent
}) { fabricPrivacy.logException(it) }
} }
override fun onPause() { override fun onPause() {
@ -83,6 +93,12 @@ class NtpProgressDialog : DaggerDialogFragment() {
disposable.clear() disposable.clear()
} }
override fun onDestroyView() {
super.onDestroyView()
disposable.clear()
_binding = null
}
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
outState.putString("state", state) outState.putString("state", state)
outState.putInt("percent", percent) outState.putInt("percent", percent)

View file

@ -11,21 +11,20 @@ import dagger.android.HasAndroidInjector
import dagger.android.support.DaggerDialogFragment import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.core.databinding.DialogProfileviewerBinding
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import kotlinx.android.synthetic.main.close.*
import kotlinx.android.synthetic.main.dialog_profileviewer.*
import org.json.JSONObject import org.json.JSONObject
import java.text.DecimalFormat import java.text.DecimalFormat
import javax.inject.Inject import javax.inject.Inject
class ProfileViewerDialog : DaggerDialogFragment() { class ProfileViewerDialog : DaggerDialogFragment() {
@Inject lateinit var injector: HasAndroidInjector @Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var activePlugin: ActivePluginProvider
@ -48,8 +47,14 @@ class ProfileViewerDialog : DaggerDialogFragment() {
private var customProfileName: String = "" private var customProfileName: String = ""
private var customProfileUnits: String = Constants.MGDL private var customProfileUnits: String = Constants.MGDL
private var _binding: DialogProfileviewerBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View {
// load data from bundle // load data from bundle
(savedInstanceState ?: arguments)?.let { bundle -> (savedInstanceState ?: arguments)?.let { bundle ->
time = bundle.getLong("time", 0) time = bundle.getLong("time", 0)
@ -66,13 +71,14 @@ class ProfileViewerDialog : DaggerDialogFragment() {
isCancelable = true isCancelable = true
dialog?.setCanceledOnTouchOutside(false) dialog?.setCanceledOnTouchOutside(false)
return inflater.inflate(R.layout.dialog_profileviewer, container, false) _binding = DialogProfileviewerBinding.inflate(inflater, container, false)
return binding.root
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
close.setOnClickListener { dismiss() } binding.closeLayout.close.setOnClickListener { dismiss() }
val profile: Profile? val profile: Profile?
val profile2: Profile? val profile2: Profile?
@ -85,7 +91,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
profileName = activePlugin.activeTreatments.getProfileSwitchFromHistory(time)?.customizedName profileName = activePlugin.activeTreatments.getProfileSwitchFromHistory(time)?.customizedName
date = dateUtil.dateAndTimeString(activePlugin.activeTreatments.getProfileSwitchFromHistory(time)?.date date = dateUtil.dateAndTimeString(activePlugin.activeTreatments.getProfileSwitchFromHistory(time)?.date
?: 0) ?: 0)
profileview_datelayout.visibility = View.VISIBLE binding.datelayout.visibility = View.VISIBLE
} }
Mode.CUSTOM_PROFILE -> { Mode.CUSTOM_PROFILE -> {
@ -93,16 +99,16 @@ class ProfileViewerDialog : DaggerDialogFragment() {
profile2 = null profile2 = null
profileName = customProfileName profileName = customProfileName
date = "" date = ""
profileview_datelayout.visibility = View.GONE binding.datelayout.visibility = View.GONE
} }
Mode.PROFILE_COMPARE -> { Mode.PROFILE_COMPARE -> {
profile = Profile(injector, JSONObject(customProfileJson), customProfileUnits) profile = Profile(injector, JSONObject(customProfileJson), customProfileUnits)
profile2 = Profile(injector, JSONObject(customProfileJson2), customProfileUnits) profile2 = Profile(injector, JSONObject(customProfileJson2), customProfileUnits)
profileName = customProfileName profileName = customProfileName
header_icon.setImageResource(R.drawable.ic_compare_profiles) binding.headerIcon.setImageResource(R.drawable.ic_compare_profiles)
date = "" date = ""
profileview_datelayout.visibility = View.GONE binding.datelayout.visibility = View.GONE
} }
Mode.DB_PROFILE -> { Mode.DB_PROFILE -> {
@ -111,43 +117,43 @@ class ProfileViewerDialog : DaggerDialogFragment() {
profile2 = null profile2 = null
profileName = if (profileList.isNotEmpty()) profileList[0].customizedName else null profileName = if (profileList.isNotEmpty()) profileList[0].customizedName else null
date = if (profileList.isNotEmpty()) dateUtil.dateAndTimeString(profileList[0].date) else null date = if (profileList.isNotEmpty()) dateUtil.dateAndTimeString(profileList[0].date) else null
profileview_datelayout.visibility = View.VISIBLE binding.datelayout.visibility = View.VISIBLE
} }
} }
profileview_noprofile.visibility = View.VISIBLE binding.noprofile.visibility = View.VISIBLE
if (mode == Mode.PROFILE_COMPARE) if (mode == Mode.PROFILE_COMPARE)
profile?.let { profile1 -> profile?.let { profile1 ->
profile2?.let { profile2 -> profile2?.let { profile2 ->
profileview_units.text = profileFunction.getUnits() binding.units.text = profileFunction.getUnits()
profileview_dia.text = HtmlHelper.fromHtml(formatColors("", profile1.dia, profile2.dia, DecimalFormat("0.00"), resourceHelper.gs(R.string.shorthour))) binding.dia.text = HtmlHelper.fromHtml(formatColors("", profile1.dia, profile2.dia, DecimalFormat("0.00"), resourceHelper.gs(R.string.shorthour)))
val profileNames =profileName!!.split("\n").toTypedArray() val profileNames = profileName!!.split("\n").toTypedArray()
profileview_activeprofile.text = HtmlHelper.fromHtml(formatColors(profileNames[0], profileNames[1])) binding.activeprofile.text = HtmlHelper.fromHtml(formatColors(profileNames[0], profileNames[1]))
profileview_date.text = date binding.date.text = date
profileview_ic.text = ics(profile1, profile2) binding.ic.text = ics(profile1, profile2)
profileview_isf.text = isfs(profile1, profile2) binding.isf.text = isfs(profile1, profile2)
profileview_basal.text = basals(profile1, profile2) binding.basal.text = basals(profile1, profile2)
profileview_target.text = targets(profile1, profile2) binding.target.text = targets(profile1, profile2)
basal_graph.show(profile1, profile2) binding.basalGraph.show(profile1, profile2)
} }
profileview_noprofile.visibility = View.GONE binding.noprofile.visibility = View.GONE
profileview_invalidprofile.visibility = if (profile1.isValid("ProfileViewDialog")) View.GONE else View.VISIBLE binding.invalidprofile.visibility = if (profile1.isValid("ProfileViewDialog")) View.GONE else View.VISIBLE
} }
else else
profile?.let { profile?.let {
profileview_units.text = it.units binding.units.text = it.units
profileview_dia.text = resourceHelper.gs(R.string.format_hours, it.dia) binding.dia.text = resourceHelper.gs(R.string.format_hours, it.dia)
profileview_activeprofile.text = profileName binding.activeprofile.text = profileName
profileview_date.text = date binding.date.text = date
profileview_ic.text = it.icList binding.ic.text = it.icList
profileview_isf.text = it.isfList binding.isf.text = it.isfList
profileview_basal.text = it.basalList binding.basal.text = it.basalList
profileview_target.text = it.targetList binding.target.text = it.targetList
basal_graph.show(it) binding.basalGraph.show(it)
profileview_noprofile.visibility = View.GONE binding.noprofile.visibility = View.GONE
profileview_invalidprofile.visibility = if (it.isValid("ProfileViewDialog")) View.GONE else View.VISIBLE binding.invalidprofile.visibility = if (it.isValid("ProfileViewDialog")) View.GONE else View.VISIBLE
} }
} }
@ -167,6 +173,11 @@ class ProfileViewerDialog : DaggerDialogFragment() {
bundle.putString("customProfile2", customProfileJson2) bundle.putString("customProfile2", customProfileJson2)
} }
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
private fun formatColors(label: String, value1: Double, value2: Double, format: DecimalFormat, units: String): String { private fun formatColors(label: String, value1: Double, value2: Double, format: DecimalFormat, units: String): String {
return formatColors(label, format.format(value1), format.format(value2), units) return formatColors(label, format.format(value1), format.format(value2), units)
} }
@ -226,7 +237,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
prev1 = val1 prev1 = val1
prev2 = val2 prev2 = val2
} }
return HtmlHelper.fromHtml(s.delete(s.length-4, s.length).toString()) return HtmlHelper.fromHtml(s.delete(s.length - 4, s.length).toString())
} }
private fun isfs(profile1: Profile, profile2: Profile): Spanned { private fun isfs(profile1: Profile, profile2: Profile): Spanned {
@ -244,10 +255,10 @@ class ProfileViewerDialog : DaggerDialogFragment() {
prev1 = val1 prev1 = val1
prev2 = val2 prev2 = val2
} }
return HtmlHelper.fromHtml(s.delete(s.length-4, s.length).toString()) return HtmlHelper.fromHtml(s.delete(s.length - 4, s.length).toString())
} }
private fun targets(profile1: Profile, profile2: Profile):Spanned { private fun targets(profile1: Profile, profile2: Profile): Spanned {
var prev1l = -1.0 var prev1l = -1.0
var prev1h = -1.0 var prev1h = -1.0
var prev2l = -1.0 var prev2l = -1.0
@ -261,7 +272,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
val val2h = profile2.getTargetHighMgdlTimeFromMidnight(hour * 60 * 60) val val2h = profile2.getTargetHighMgdlTimeFromMidnight(hour * 60 * 60)
val txt1 = Profile.format_HH_MM(hour * 60 * 60) + " " + Profile.toUnitsString(val1l, val1l * Constants.MGDL_TO_MMOLL, units) + " - " + Profile.toUnitsString(val1h, val1h * Constants.MGDL_TO_MMOLL, units) + " " + units val txt1 = Profile.format_HH_MM(hour * 60 * 60) + " " + Profile.toUnitsString(val1l, val1l * Constants.MGDL_TO_MMOLL, units) + " - " + Profile.toUnitsString(val1h, val1h * Constants.MGDL_TO_MMOLL, units) + " " + units
val txt2 = Profile.format_HH_MM(hour * 60 * 60) + " " + Profile.toUnitsString(val2l, val2l * Constants.MGDL_TO_MMOLL, units) + " - " + Profile.toUnitsString(val2h, val2h * Constants.MGDL_TO_MMOLL, units) + " " + units val txt2 = Profile.format_HH_MM(hour * 60 * 60) + " " + Profile.toUnitsString(val2l, val2l * Constants.MGDL_TO_MMOLL, units) + " - " + Profile.toUnitsString(val2h, val2h * Constants.MGDL_TO_MMOLL, units) + " " + units
if (val1l != prev1l || val1h != prev1h || val2l != prev2l || val2h != prev2h ) { if (val1l != prev1l || val1h != prev1h || val2l != prev2l || val2h != prev2h) {
s.append(formatColors(txt1, txt2)) s.append(formatColors(txt1, txt2))
s.append("<br>") s.append("<br>")
} }
@ -270,6 +281,6 @@ class ProfileViewerDialog : DaggerDialogFragment() {
prev2l = val2l prev2l = val2l
prev2h = val2h prev2h = val2h
} }
return HtmlHelper.fromHtml(s.delete(s.length-4, s.length).toString()) return HtmlHelper.fromHtml(s.delete(s.length - 4, s.length).toString())
} }
} }

View file

@ -3,8 +3,8 @@ package info.nightscout.androidaps.plugins.general.maintenance
import android.os.Parcelable import android.os.Parcelable
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefMetadata import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefMetadata
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsMetadataKey import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsMetadataKey
import kotlinx.android.parcel.Parcelize import kotlinx.parcelize.RawValue
import kotlinx.android.parcel.RawValue import kotlinx.parcelize.Parcelize
import java.io.File import java.io.File
@Parcelize @Parcelize

View file

@ -5,7 +5,7 @@ import android.os.Parcelable
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import kotlinx.android.parcel.Parcelize import kotlinx.parcelize.Parcelize
import java.io.File import java.io.File
enum class PrefsMetadataKey(val key: String, @DrawableRes val icon: Int, @StringRes val label: Int) { enum class PrefsMetadataKey(val key: String, @DrawableRes val icon: Int, @StringRes val label: Int) {

View file

@ -4,8 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context="info.nightscout.androidaps.dialogs.BolusProgressDialog" tools:context="info.nightscout.androidaps.dialogs.BolusProgressDialog">
>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -22,15 +21,15 @@
app:srcCompat="@drawable/ic_trending_flat_white_48dp" /> app:srcCompat="@drawable/ic_trending_flat_white_48dp" />
<TextView <TextView
android:id="@+id/overview_bolusprogress_title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:textAlignment="center"
android:layout_toEndOf="@id/header_icon" android:layout_toEndOf="@id/header_icon"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout> </RelativeLayout>
@ -41,16 +40,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="5dp" /> android:padding="5dp" />
<TextView
android:id="@+id/overview_bolusprogress_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center_horizontal" />
<TextView <TextView
android:id="@+id/overview_bolusprogress_stoppressed" android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
<TextView
android:id="@+id/stoppressed"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
@ -62,18 +62,18 @@
android:visibility="gone" /> android:visibility="gone" />
<ProgressBar <ProgressBar
android:id="@+id/overview_bolusprogress_progressbar" android:id="@+id/progressbar"
style="@android:style/Widget.ProgressBar.Horizontal" style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_marginRight="5dp"
android:maxHeight="5dp" android:maxHeight="5dp"
android:minHeight="3dp" /> android:minHeight="3dp" />
<Button <Button
android:id="@+id/overview_bolusprogress_stop" android:id="@+id/stop"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"

View file

@ -29,7 +29,7 @@
app:srcCompat="@drawable/ic_home_profile" /> app:srcCompat="@drawable/ic_home_profile" />
<TextView <TextView
android:id="@+id/profileview_activeprofile" android:id="@+id/activeprofile"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
@ -37,8 +37,8 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:textAlignment="center"
android:layout_toEndOf="@id/header_icon" android:layout_toEndOf="@id/header_icon"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout> </RelativeLayout>
@ -51,7 +51,7 @@
android:padding="5dp" /> android:padding="5dp" />
<TextView <TextView
android:id="@+id/profileview_invalidprofile" android:id="@+id/invalidprofile"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
@ -62,7 +62,7 @@
android:visibility="gone" /> android:visibility="gone" />
<TextView <TextView
android:id="@+id/profileview_noprofile" android:id="@+id/noprofile"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
@ -73,7 +73,7 @@
android:visibility="gone" /> android:visibility="gone" />
<LinearLayout <LinearLayout
android:id="@+id/profileview_datelayout" android:id="@+id/datelayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
@ -82,29 +82,29 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="2" android:layout_weight="2"
android:gravity="end" android:gravity="end"
android:layout_marginEnd="5dp"
android:text="@string/date" android:text="@string/date"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_width="5dp" android:layout_width="5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:layout_marginEnd="2dp" android:layout_marginEnd="2dp"
android:layout_weight="0"
android:gravity="center_horizontal"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/profileview_date" android:id="@+id/date"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:layout_marginStart="5dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
@ -127,29 +127,29 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="2" android:layout_weight="2"
android:gravity="end" android:gravity="end"
android:layout_marginEnd="5dp"
android:text="@string/units_label" android:text="@string/units_label"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_width="5dp" android:layout_width="5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:layout_marginEnd="2dp" android:layout_marginEnd="2dp"
android:layout_weight="0"
android:gravity="center_horizontal"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/profileview_units" android:id="@+id/units"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:layout_marginStart="5dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
@ -172,29 +172,29 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="2" android:layout_weight="2"
android:gravity="end" android:gravity="end"
android:layout_marginEnd="5dp"
android:text="@string/dia_label" android:text="@string/dia_label"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_width="5dp" android:layout_width="5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:layout_marginEnd="2dp" android:layout_marginEnd="2dp"
android:layout_weight="0"
android:gravity="center_horizontal"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/profileview_dia" android:id="@+id/dia"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:layout_marginStart="5dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
@ -217,29 +217,29 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="2" android:layout_weight="2"
android:gravity="end" android:gravity="end"
android:layout_marginEnd="5dp"
android:text="@string/ic_label" android:text="@string/ic_label"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_width="5dp" android:layout_width="5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:layout_marginEnd="2dp" android:layout_marginEnd="2dp"
android:layout_weight="0"
android:gravity="center_horizontal"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/profileview_ic" android:id="@+id/ic"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:layout_marginStart="5dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
@ -262,29 +262,29 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="2" android:layout_weight="2"
android:gravity="end" android:gravity="end"
android:layout_marginEnd="5dp"
android:text="@string/isf_label" android:text="@string/isf_label"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_width="5dp" android:layout_width="5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:layout_marginEnd="2dp" android:layout_marginEnd="2dp"
android:layout_weight="0"
android:gravity="center_horizontal"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/profileview_isf" android:id="@+id/isf"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:layout_marginStart="5dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
@ -307,29 +307,29 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="2" android:layout_weight="2"
android:gravity="end" android:gravity="end"
android:layout_marginEnd="5dp"
android:text="@string/basal_label" android:text="@string/basal_label"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_width="5dp" android:layout_width="5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:layout_marginEnd="2dp" android:layout_marginEnd="2dp"
android:layout_weight="0"
android:gravity="center_horizontal"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/profileview_basal" android:id="@+id/basal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:layout_marginStart="5dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
@ -343,29 +343,29 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="2" android:layout_weight="2"
android:gravity="end" android:gravity="end"
android:layout_marginEnd="5dp"
android:text="" android:text=""
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_width="5dp" android:layout_width="5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:layout_marginEnd="2dp" android:layout_marginEnd="2dp"
android:layout_weight="0"
android:gravity="center_horizontal"
android:text="" android:text=""
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/profileview_basaltotal" android:id="@+id/basaltotal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="17dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:layout_marginStart="17dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
@ -394,35 +394,37 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="2" android:layout_weight="2"
android:gravity="end" android:gravity="end"
android:layout_marginEnd="5dp"
android:text="@string/target_label" android:text="@string/target_label"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:layout_width="5dp" android:layout_width="5dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:layout_marginStart="2dp" android:layout_marginStart="2dp"
android:layout_marginEnd="2dp" android:layout_marginEnd="2dp"
android:layout_weight="0"
android:gravity="center_horizontal"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/profileview_target" android:id="@+id/target"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:layout_marginStart="5dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
</LinearLayout> </LinearLayout>
<include layout="@layout/close" /> <include
android:id="@+id/close_layout"
layout="@layout/close" />
</LinearLayout> </LinearLayout>