Remove UserEntryExt file and move UserEntryPresentationHelper.kt in utils folder
This commit is contained in:
parent
09349fddd4
commit
9d4a1d5944
7 changed files with 48 additions and 72 deletions
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.treatments.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.renderscript.Sampler
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -25,8 +24,8 @@ import info.nightscout.androidaps.utils.DateUtil
|
|||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.Translator
|
||||
import info.nightscout.androidaps.utils.UserEntryPresentationHelper
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.extensions.*
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -166,11 +165,9 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
|||
else -> valuesWithUnitString += if (v.iValue != 0 || v.sValue != "") { v.value().toString() + separator } else ""
|
||||
}
|
||||
}
|
||||
if (source.iconId() > 0) {
|
||||
holder.binding.iconSource.setImageResource(source.iconId())
|
||||
|
||||
holder.binding.iconSource.setImageResource(userEntryPresentationHelper.iconId(source))
|
||||
holder.binding.iconSource.visibility = View.VISIBLE
|
||||
} else
|
||||
holder.binding.iconSource.visibility = View.INVISIBLE
|
||||
holder.binding.values.text = valuesWithUnitString.trim()
|
||||
holder.binding.values.visibility = if (holder.binding.values.text != "") View.VISIBLE else View.GONE
|
||||
holder.binding.action.text = translator.translate(current.action)
|
||||
|
|
|
@ -162,6 +162,6 @@ class Translator @Inject internal constructor(
|
|||
Sources.Wear -> resourceHelper.gs(R.string.wear)
|
||||
Sources.Unknown -> resourceHelper.gs(R.string.unknown)
|
||||
|
||||
else -> resourceHelper.gs(R.string.unknown)
|
||||
else -> source.name
|
||||
}
|
||||
}
|
|
@ -1,17 +1,13 @@
|
|||
package info.nightscout.androidaps.utils.extensions
|
||||
package info.nightscout.androidaps.utils
|
||||
|
||||
import dagger.Reusable
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.database.entities.UserEntry
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.ColorGroup
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.Translator
|
||||
import javax.inject.Inject
|
||||
|
||||
@Reusable
|
||||
|
@ -34,6 +30,40 @@ class UserEntryPresentationHelper @Inject constructor(
|
|||
else -> R.color.defaulttext
|
||||
}
|
||||
|
||||
fun iconId(source: Sources): Int = when (source) {
|
||||
Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs
|
||||
Sources.InsulinDialog -> R.drawable.ic_bolus
|
||||
Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs
|
||||
Sources.WizardDialog -> R.drawable.ic_calculator
|
||||
Sources.QuickWizard -> R.drawable.ic_quick_wizard
|
||||
Sources.ExtendedBolusDialog -> R.drawable.ic_actions_startextbolus
|
||||
Sources.TTDialog -> R.drawable.ic_temptarget_high
|
||||
Sources.ProfileSwitchDialog -> R.drawable.ic_actions_profileswitch
|
||||
Sources.LoopDialog -> R.drawable.ic_loop_closed
|
||||
Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal
|
||||
Sources.CalibrationDialog -> R.drawable.ic_calibration
|
||||
Sources.FillDialog -> R.drawable.ic_cp_pump_canula
|
||||
Sources.BgCheck -> R.drawable.ic_cp_bgcheck
|
||||
Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert
|
||||
Sources.BatteryChange -> R.drawable.ic_cp_pump_battery
|
||||
Sources.Note -> R.drawable.ic_cp_note
|
||||
Sources.Exercise -> R.drawable.ic_cp_exercise
|
||||
Sources.Question -> R.drawable.ic_cp_question
|
||||
Sources.Announcement -> R.drawable.ic_cp_announcement
|
||||
Sources.Actions -> R.drawable.ic_action
|
||||
Sources.Automation -> R.drawable.ic_automation
|
||||
Sources.LocalProfile -> R.drawable.ic_local_profile
|
||||
Sources.Loop -> R.drawable.ic_loop_closed_white
|
||||
Sources.Maintenance -> R.drawable.ic_maintenance
|
||||
Sources.NSClient -> R.drawable.ic_nightscout_syncs
|
||||
Sources.Pump -> R.drawable.ic_generic_icon
|
||||
Sources.SMS -> R.drawable.ic_sms
|
||||
Sources.Treatments -> R.drawable.ic_treatments
|
||||
Sources.Wear -> R.drawable.ic_watch
|
||||
Sources.Food -> R.drawable.ic_food
|
||||
Sources.Unknown -> R.drawable.ic_generic_icon
|
||||
}
|
||||
|
||||
fun listToPresentationString(list: List<XXXValueWithUnit>) =
|
||||
list.joinToString(separator = " ", transform = this::toPresentationString)
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
package info.nightscout.androidaps.utils.extensions
|
||||
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||
|
||||
fun ColorGroup.colorId(): Int {
|
||||
return when (this) {
|
||||
ColorGroup.InsulinTreatment -> R.color.basal
|
||||
ColorGroup.CarbTreatment -> R.color.carbs
|
||||
ColorGroup.TT -> R.color.tempTargetConfirmation
|
||||
ColorGroup.Profile -> R.color.white
|
||||
ColorGroup.Loop -> R.color.loopClosed
|
||||
ColorGroup.Careportal -> R.color.high
|
||||
ColorGroup.Pump -> R.color.iob
|
||||
ColorGroup.Aaps -> R.color.defaulttext
|
||||
else -> R.color.defaulttext
|
||||
}
|
||||
}
|
||||
|
||||
fun Sources.iconId(): Int {
|
||||
return when (this) {
|
||||
Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs
|
||||
Sources.InsulinDialog -> R.drawable.ic_bolus
|
||||
Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs
|
||||
Sources.WizardDialog -> R.drawable.ic_calculator
|
||||
Sources.QuickWizard -> R.drawable.ic_quick_wizard
|
||||
Sources.ExtendedBolusDialog -> R.drawable.ic_actions_startextbolus
|
||||
Sources.TTDialog -> R.drawable.ic_temptarget_high
|
||||
Sources.ProfileSwitchDialog -> R.drawable.ic_actions_profileswitch
|
||||
Sources.LoopDialog -> R.drawable.ic_loop_closed
|
||||
Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal
|
||||
Sources.CalibrationDialog -> R.drawable.ic_calibration
|
||||
Sources.FillDialog -> R.drawable.ic_cp_pump_canula
|
||||
Sources.BgCheck -> R.drawable.ic_cp_bgcheck
|
||||
Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert
|
||||
Sources.BatteryChange -> R.drawable.ic_cp_pump_battery
|
||||
Sources.Note -> R.drawable.ic_cp_note
|
||||
Sources.Exercise -> R.drawable.ic_cp_exercise
|
||||
Sources.Question -> R.drawable.ic_cp_question
|
||||
Sources.Announcement -> R.drawable.ic_cp_announcement
|
||||
Sources.Maintenance -> R.drawable.ic_maintenance
|
||||
Sources.Treatments -> R.drawable.ic_treatments
|
||||
Sources.LocalProfile -> R.drawable.ic_local_profile
|
||||
Sources.Actions -> R.drawable.ic_action
|
||||
Sources.Automation -> R.drawable.ic_automation
|
||||
Sources.Loop -> R.drawable.ic_loop_closed_white
|
||||
Sources.NSClient -> R.drawable.ic_nightscout_syncs
|
||||
Sources.Wear -> R.drawable.ic_watch
|
||||
else -> -1
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue