From a0fbf9ec96fe1fcbad89935881c72383e51769b7 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 10 Feb 2022 19:21:42 +0100 Subject: [PATCH] Group list treatments and BG by date --- .../fragments/TreatmentsBolusCarbsFragment.kt | 14 +- .../fragments/TreatmentsCareportalFragment.kt | 13 +- .../TreatmentsExtendedBolusesFragment.kt | 13 +- .../TreatmentsProfileSwitchFragment.kt | 7 +- .../fragments/TreatmentsTempTargetFragment.kt | 9 +- .../TreatmentsTemporaryBasalsFragment.kt | 15 +- .../fragments/TreatmentsUserEntryFragment.kt | 12 +- .../plugins/source/BGSourceFragment.kt | 7 +- app/src/main/res/layout/bgsource_item.xml | 104 +++++++----- .../layout/treatments_bolus_carbs_item.xml | 31 +++- .../res/layout/treatments_careportal_item.xml | 20 ++- .../layout/treatments_extendedbolus_item.xml | 20 ++- .../layout/treatments_profileswitch_item.xml | 20 ++- .../res/layout/treatments_tempbasals_item.xml | 20 ++- .../res/layout/treatments_temptarget_item.xml | 18 +- .../res/layout/treatments_user_entry_item.xml | 154 ++++++++++-------- .../nightscout/androidaps/utils/DateUtil.kt | 7 + 17 files changed, 323 insertions(+), 161 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsBolusCarbsFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsBolusCarbsFragment.kt index f4614d5a41..3ed805966e 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsBolusCarbsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsBolusCarbsFragment.kt @@ -271,6 +271,8 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { _binding = null } + private fun timestamp(ml: MealLink): Long = ml.bolusCalculatorResult?.let { it.timestamp } ?: ml.bolus?.let { it.timestamp } ?: ml.carbs?.let { it.timestamp } ?: 0L + inner class RecyclerViewAdapter internal constructor(var mealLinks: List) : RecyclerView.Adapter() { override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): MealLinkLoadedViewHolder = @@ -280,16 +282,20 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { val profile = profileFunction.getProfile() ?: return val ml = mealLinks[position] + val sameDayPrevious = position > 0 && dateUtil.isSameDay(timestamp(ml), timestamp(mealLinks[position - 1])) + holder.binding.date.visibility = sameDayPrevious.not().toVisibility() + holder.binding.date.text = dateUtil.dateString(timestamp(ml)) + // Metadata holder.binding.metadataLayout.visibility = (ml.bolusCalculatorResult != null && (ml.bolusCalculatorResult.isValid || binding.showInvalidated.isChecked)).toVisibility() ml.bolusCalculatorResult?.let { bolusCalculatorResult -> - holder.binding.date.text = dateUtil.dateAndTimeString(bolusCalculatorResult.timestamp) + holder.binding.calcTime.text = dateUtil.timeString(bolusCalculatorResult.timestamp) } // Bolus holder.binding.bolusLayout.visibility = (ml.bolus != null && (ml.bolus.isValid || binding.showInvalidated.isChecked)).toVisibility() ml.bolus?.let { bolus -> - holder.binding.bolusDate.text = dateUtil.timeString(bolus.timestamp) + holder.binding.bolusTime.text = dateUtil.timeString(bolus.timestamp) holder.binding.insulin.text = rh.gs(R.string.formatinsulinunits, bolus.amount) holder.binding.bolusNs.visibility = (bolus.interfaceIDs.nightscoutId != null).toVisibility() holder.binding.bolusPump.visibility = (bolus.interfaceIDs.pumpId != null).toVisibility() @@ -317,7 +323,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { // Carbs holder.binding.carbsLayout.visibility = (ml.carbs != null && (ml.carbs.isValid || binding.showInvalidated.isChecked)).toVisibility() ml.carbs?.let { carbs -> - holder.binding.carbsDate.text = dateUtil.timeString(carbs.timestamp) + holder.binding.carbsTime.text = dateUtil.timeString(carbs.timestamp) holder.binding.carbs.text = rh.gs(R.string.format_carbs, carbs.amount.toInt()) holder.binding.carbsDuration.text = if (carbs.duration > 0) rh.gs(R.string.format_mins, T.msecs(carbs.duration).mins().toInt()) else "" holder.binding.carbsNs.visibility = (carbs.interfaceIDs.nightscoutId != null).toVisibility() @@ -330,6 +336,8 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { holder.binding.bolusRemove.tag = ml holder.binding.carbsRemove.tag = ml holder.binding.calculation.tag = ml + val nextTimestamp = if (mealLinks.size != position + 1) timestamp(mealLinks[position + 1]) else 0L + holder.binding.delimiter.visibility = dateUtil.isSameDay(timestamp(ml), nextTimestamp).toVisibility() } override fun getItemCount(): Int { diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsCareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsCareportalFragment.kt index ac640df4f6..0dca0e416f 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsCareportalFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsCareportalFragment.kt @@ -152,7 +152,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { _binding = null } - inner class RecyclerViewAdapter internal constructor(private var list: List) : RecyclerView.Adapter() { + inner class RecyclerViewAdapter internal constructor(private var therapyList: List) : RecyclerView.Adapter() { override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): TherapyEventsViewHolder { val v = LayoutInflater.from(viewGroup.context).inflate(R.layout.treatments_careportal_item, viewGroup, false) @@ -160,18 +160,23 @@ class TreatmentsCareportalFragment : DaggerFragment() { } override fun onBindViewHolder(holder: TherapyEventsViewHolder, position: Int) { - val therapyEvent = list[position] + val therapyEvent = therapyList[position] holder.binding.ns.visibility = (therapyEvent.interfaceIDs.nightscoutId != null).toVisibility() holder.binding.invalid.visibility = therapyEvent.isValid.not().toVisibility() - holder.binding.date.text = dateUtil.dateAndTimeString(therapyEvent.timestamp) + val sameDayPrevious = position > 0 && dateUtil.isSameDay(therapyEvent.timestamp, therapyList[position - 1].timestamp) + holder.binding.date.visibility = sameDayPrevious.not().toVisibility() + holder.binding.date.text = dateUtil.dateString(therapyEvent.timestamp) + holder.binding.time.text = dateUtil.timeString(therapyEvent.timestamp) holder.binding.duration.text = if (therapyEvent.duration == 0L) "" else dateUtil.niceTimeScalar(therapyEvent.duration, rh) holder.binding.note.text = therapyEvent.note holder.binding.type.text = translator.translate(therapyEvent.type) holder.binding.remove.tag = therapyEvent + val nextTimestamp = if (therapyList.size != position + 1) therapyList[position + 1].timestamp else 0L + holder.binding.delimiter.visibility = dateUtil.isSameDay(therapyEvent.timestamp, nextTimestamp).toVisibility() } override fun getItemCount(): Int { - return list.size + return therapyList.size } inner class TherapyEventsViewHolder(view: View) : RecyclerView.ViewHolder(view) { diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsExtendedBolusesFragment.kt index 4f9609043e..bdd0e4f424 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsExtendedBolusesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsExtendedBolusesFragment.kt @@ -125,13 +125,16 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { holder.binding.ns.visibility = (extendedBolus.interfaceIDs.nightscoutId != null).toVisibility() holder.binding.ph.visibility = (extendedBolus.interfaceIDs.pumpId != null).toVisibility() holder.binding.invalid.visibility = extendedBolus.isValid.not().toVisibility() + val sameDayPrevious = position > 0 && dateUtil.isSameDay(extendedBolus.timestamp, extendedBolusList[position-1].timestamp) + holder.binding.date.visibility = sameDayPrevious.not().toVisibility() + holder.binding.date.text = dateUtil.dateString(extendedBolus.timestamp) @SuppressLint("SetTextI18n") if (extendedBolus.isInProgress(dateUtil)) { - holder.binding.date.text = dateUtil.dateAndTimeString(extendedBolus.timestamp) - holder.binding.date.setTextColor(rh.gc(R.color.colorActive)) + holder.binding.time.text = dateUtil.timeString(extendedBolus.timestamp) + holder.binding.time.setTextColor(rh.gc(R.color.colorActive)) } else { - holder.binding.date.text = dateUtil.dateAndTimeString(extendedBolus.timestamp) + " - " + dateUtil.timeString(extendedBolus.end) - holder.binding.date.setTextColor(holder.binding.insulin.currentTextColor) + holder.binding.time.text = dateUtil.timeRangeString(extendedBolus.timestamp, extendedBolus.end) + holder.binding.time.setTextColor(holder.binding.insulin.currentTextColor) } val profile = profileFunction.getProfile(extendedBolus.timestamp) ?: return holder.binding.duration.text = rh.gs(R.string.format_mins, T.msecs(extendedBolus.duration).mins()) @@ -141,6 +144,8 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { holder.binding.ratio.text = rh.gs(R.string.pump_basebasalrate, extendedBolus.rate) if (iob.iob != 0.0) holder.binding.iob.setTextColor(rh.gc(R.color.colorActive)) else holder.binding.iob.setTextColor(holder.binding.insulin.currentTextColor) holder.binding.remove.tag = extendedBolus + val nextTimestamp = if (extendedBolusList.size != position + 1) extendedBolusList[position + 1].timestamp else 0L + holder.binding.delimiter.visibility = dateUtil.isSameDay(extendedBolus.timestamp, nextTimestamp).toVisibility() } override fun getItemCount(): Int = extendedBolusList.size diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsProfileSwitchFragment.kt index 7b48ff9684..91b46228be 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsProfileSwitchFragment.kt @@ -181,7 +181,10 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { val profileSwitch = profileSwitchList[position] holder.binding.ph.visibility = (profileSwitch is ProfileSealed.EPS).toVisibility() holder.binding.ns.visibility = (profileSwitch.interfaceIDs_backing?.nightscoutId != null).toVisibility() - holder.binding.date.text = dateUtil.dateAndTimeString(profileSwitch.timestamp) + val sameDayPrevious = position > 0 && dateUtil.isSameDay(profileSwitch.timestamp, profileSwitchList[position - 1].timestamp) + holder.binding.date.visibility = sameDayPrevious.not().toVisibility() + holder.binding.date.text = dateUtil.dateString(profileSwitch.timestamp) + holder.binding.time.text = dateUtil.timeString(profileSwitch.timestamp) holder.binding.duration.text = rh.gs(R.string.format_mins, T.msecs(profileSwitch.duration ?: 0L).mins()) holder.binding.name.text = if (profileSwitch is ProfileSealed.PS) profileSwitch.value.getCustomizedName() else if (profileSwitch is ProfileSealed.EPS) profileSwitch.value.originalCustomizedName else "" if (profileSwitch.isInProgress(dateUtil)) holder.binding.date.setTextColor(rh.gc(R.color.colorActive)) @@ -196,6 +199,8 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { holder.binding.clone.visibility = (profileSwitch is ProfileSealed.PS).toVisibility() holder.binding.spacer.visibility = (profileSwitch is ProfileSealed.PS).toVisibility() holder.binding.root.setBackgroundColor(rh.gc(if (profileSwitch is ProfileSealed.PS) R.color.defaultbackground else R.color.list_delimiter)) + val nextTimestamp = if (profileSwitchList.size != position + 1) profileSwitchList[position + 1].timestamp else 0L + holder.binding.delimiter.visibility = dateUtil.isSameDay(profileSwitch.timestamp, nextTimestamp).toVisibility() } override fun getItemCount(): Int { diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsTempTargetFragment.kt index 53e3fa5eba..c408fd4299 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsTempTargetFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsTempTargetFragment.kt @@ -164,18 +164,23 @@ class TreatmentsTempTargetFragment : DaggerFragment() { holder.binding.ns.visibility = (tempTarget.interfaceIDs.nightscoutId != null).toVisibility() holder.binding.invalid.visibility = tempTarget.isValid.not().toVisibility() holder.binding.remove.visibility = tempTarget.isValid.toVisibility() - holder.binding.date.text = dateUtil.dateAndTimeString(tempTarget.timestamp) + " - " + dateUtil.timeString(tempTarget.end) + val sameDayPrevious = position > 0 && dateUtil.isSameDay(tempTarget.timestamp, tempTargetList[position-1].timestamp) + holder.binding.date.visibility = sameDayPrevious.not().toVisibility() + holder.binding.date.text = dateUtil.dateString(tempTarget.timestamp) + holder.binding.time.text = dateUtil.timeRangeString(tempTarget.timestamp, tempTarget.end) holder.binding.duration.text = rh.gs(R.string.format_mins, T.msecs(tempTarget.duration).mins()) holder.binding.low.text = tempTarget.lowValueToUnitsToString(units) holder.binding.high.text = tempTarget.highValueToUnitsToString(units) holder.binding.reason.text = translator.translate(tempTarget.reason) - holder.binding.date.setTextColor( + holder.binding.time.setTextColor( when { tempTarget.id == currentlyActiveTarget?.id -> rh.gc(R.color.colorActive) tempTarget.timestamp > dateUtil.now() -> rh.gc(R.color.colorScheduled) else -> holder.binding.reasonColon.currentTextColor }) holder.binding.remove.tag = tempTarget + val nextTimestamp = if (tempTargetList.size != position + 1) tempTargetList[position + 1].timestamp else 0L + holder.binding.delimiter.visibility = dateUtil.isSameDay(tempTarget.timestamp, nextTimestamp).toVisibility() } override fun getItemCount(): Int = tempTargetList.size diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsTemporaryBasalsFragment.kt index 9fb0c844ba..6d4c536236 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -15,7 +15,6 @@ import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.ValueWrapper import info.nightscout.androidaps.database.entities.ExtendedBolus import info.nightscout.androidaps.database.entities.TemporaryBasal -import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.ValueWithUnit @@ -165,12 +164,15 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { holder.binding.ns.visibility = (tempBasal.interfaceIDs.nightscoutId != null).toVisibility() holder.binding.invalid.visibility = tempBasal.isValid.not().toVisibility() holder.binding.ph.visibility = (tempBasal.interfaceIDs.pumpId != null).toVisibility() + val sameDayPrevious = position > 0 && dateUtil.isSameDay(tempBasal.timestamp, tempBasalList[position-1].timestamp) + holder.binding.date.visibility = sameDayPrevious.not().toVisibility() + holder.binding.date.text = dateUtil.dateString(tempBasal.timestamp) if (tempBasal.isInProgress) { - holder.binding.date.text = dateUtil.dateAndTimeString(tempBasal.timestamp) - holder.binding.date.setTextColor(rh.gc(R.color.colorActive)) + holder.binding.time.text = dateUtil.timeString(tempBasal.timestamp) + holder.binding.time.setTextColor(rh.gc(R.color.colorActive)) } else { - holder.binding.date.text = dateUtil.dateAndTimeRangeString(tempBasal.timestamp, tempBasal.end) - holder.binding.date.setTextColor(holder.binding.duration.currentTextColor) + holder.binding.time.text = dateUtil.timeRangeString(tempBasal.timestamp, tempBasal.end) + holder.binding.time.setTextColor(holder.binding.duration.currentTextColor) } holder.binding.duration.text = rh.gs(R.string.format_mins, T.msecs(tempBasal.duration).mins()) if (tempBasal.isAbsolute) holder.binding.rate.text = rh.gs(R.string.pump_basebasalrate, tempBasal.rate) @@ -186,6 +188,9 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { holder.binding.superBolusFlag.visibility = (tempBasal.type == TemporaryBasal.Type.SUPERBOLUS).toVisibility() if (abs(iob.basaliob) > 0.01) holder.binding.iob.setTextColor(rh.gc(R.color.colorActive)) else holder.binding.iob.setTextColor(holder.binding.duration.currentTextColor) holder.binding.remove.tag = tempBasal + + val nextTimestamp = if (tempBasalList.size != position + 1) tempBasalList[position + 1].timestamp else 0L + holder.binding.delimiter.visibility = dateUtil.isSameDay(tempBasal.timestamp, nextTimestamp).toVisibility() } override fun getItemCount(): Int = tempBasalList.size diff --git a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsUserEntryFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsUserEntryFragment.kt index 8cb5681995..4d3620052b 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsUserEntryFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/fragments/TreatmentsUserEntryFragment.kt @@ -20,6 +20,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.events.EventTreatmentUpdateGui +import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.T @@ -131,14 +132,19 @@ class TreatmentsUserEntryFragment : DaggerFragment() { override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) { val current = entries[position] - holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) + val sameDayPrevious = position > 0 && dateUtil.isSameDay(current.timestamp, entries[position-1].timestamp) + holder.binding.date.visibility = sameDayPrevious.not().toVisibility() + holder.binding.date.text = dateUtil.dateString(current.timestamp) + holder.binding.time.text = dateUtil.timeStringWithSeconds(current.timestamp) holder.binding.action.text = userEntryPresentationHelper.actionToColoredString(current.action) - holder.binding.s.text = current.note - holder.binding.s.visibility = if (current.note != "") View.VISIBLE else View.GONE + holder.binding.notes.text = current.note + holder.binding.notes.visibility = if (current.note != "") View.VISIBLE else View.GONE holder.binding.iconSource.setImageResource(userEntryPresentationHelper.iconId(current.source)) holder.binding.iconSource.visibility = View.VISIBLE holder.binding.values.text = userEntryPresentationHelper.listToPresentationString(current.values) holder.binding.values.visibility = if (holder.binding.values.text != "") View.VISIBLE else View.GONE + val nextTimestamp = if (entries.size != position + 1) entries[position + 1].timestamp else 0L + holder.binding.delimiter.visibility = dateUtil.isSameDay(current.timestamp, nextTimestamp).toVisibility() } inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index 6b00421a14..901bed4b26 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -7,8 +7,6 @@ import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import androidx.work.ListenableWorker -import androidx.work.workDataOf import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -118,7 +116,10 @@ class BGSourceFragment : DaggerFragment() { val glucoseValue = glucoseValues[position] holder.binding.ns.visibility = (glucoseValue.interfaceIDs.nightscoutId != null).toVisibility() holder.binding.invalid.visibility = (!glucoseValue.isValid).toVisibility() - holder.binding.date.text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + val sameDayPrevious = position > 0 && dateUtil.isSameDay(glucoseValue.timestamp, glucoseValues[position-1].timestamp) + holder.binding.date.visibility = sameDayPrevious.not().toVisibility() + holder.binding.date.text = dateUtil.dateString(glucoseValue.timestamp) + holder.binding.time.text = dateUtil.timeString(glucoseValue.timestamp) holder.binding.value.text = glucoseValue.valueToUnitsString(profileFunction.getUnits()) holder.binding.direction.setImageResource(glucoseValue.trendArrow.directionToIcon()) holder.binding.remove.tag = glucoseValue diff --git a/app/src/main/res/layout/bgsource_item.xml b/app/src/main/res/layout/bgsource_item.xml index aa85296018..a7d9edc675 100644 --- a/app/src/main/res/layout/bgsource_item.xml +++ b/app/src/main/res/layout/bgsource_item.xml @@ -1,68 +1,84 @@ + card_view:cardUseCompatPadding="true"> + android:orientation="vertical"> + android:background="@color/list_delimiter" + android:gravity="center" + android:text="1.1.2000" + android:textAppearance="?android:attr/textAppearanceMedium" /> - + android:gravity="center" + android:orientation="horizontal" + android:padding="6dp"> - + - + - + - + + + + + + + diff --git a/app/src/main/res/layout/treatments_bolus_carbs_item.xml b/app/src/main/res/layout/treatments_bolus_carbs_item.xml index 09295f0a4e..556184cbad 100644 --- a/app/src/main/res/layout/treatments_bolus_carbs_item.xml +++ b/app/src/main/res/layout/treatments_bolus_carbs_item.xml @@ -12,6 +12,20 @@ android:layout_height="wrap_content" android:orientation="vertical"> + + + + - @@ -111,6 +124,7 @@ + + - @@ -158,6 +171,7 @@ + + - @@ -124,6 +137,7 @@ + + - @@ -178,6 +191,7 @@ + + - + android:orientation="horizontal"> + - + - + - + + - - - - - + + diff --git a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt index 2a3aea9e32..20718814ff 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt @@ -6,6 +6,7 @@ import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.shared.SafeParse +import org.apache.commons.lang3.time.DateUtils.isSameDay import org.joda.time.DateTime import org.joda.time.format.DateTimeFormat import org.joda.time.format.ISODateTimeFormat @@ -131,6 +132,10 @@ class DateUtil @Inject constructor(private val context: Context) { return dateAndTimeString(start) + " - " + timeString(end) } + fun timeRangeString(start: Long, end: Long): String { + return timeString(start) + " - " + timeString(end) + } + fun dateAndTimeString(mills: Long): String { return if (mills == 0L) "" else dateString(mills) + " " + timeString(mills) } @@ -207,6 +212,8 @@ class DateUtil @Inject constructor(private val context: Context) { return TimeZone.getDefault().getOffset(timestamp) / 60000 } + fun isSameDay(timestamp1: Long, timestamp2: Long) = isSameDay(Date(timestamp1), Date(timestamp2)) + //Map:{DAYS=1, HOURS=3, MINUTES=46, SECONDS=40, MILLISECONDS=0, MICROSECONDS=0, NANOSECONDS=0} fun computeDiff(date1: Long, date2: Long): Map { val units: MutableList = ArrayList(EnumSet.allOf(TimeUnit::class.java))