From e16d6611838f74cf640c293c7be0f740a9fba0ed Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 4 Feb 2021 12:03:34 +0100 Subject: [PATCH] OverviewFragment -> jetpack --- app/build.gradle | 1 - .../historyBrowser/HistoryBrowseActivity.kt | 2 +- .../general/overview/OverviewFragment.kt | 340 +++++++-------- .../androidaps/skins/SkinInterface.kt | 53 ++- ...p_age_canula.xml => ic_cp_age_cannula.xml} | 0 ...ic_quickwizard.xml => ic_quick_wizard.xml} | 0 .../res/layout/activity_historybrowse.xml | 2 +- .../res/layout/automation_dialog_event.xml | 2 +- .../res/layout/careportal_stats_fragment.xml | 12 +- .../careportal_stats_fragment_lowres.xml | 395 +++++++++--------- .../main/res/layout/combopump_fragment.xml | 20 +- app/src/main/res/layout/dialog_loop.xml | 6 +- app/src/main/res/layout/dialog_wizard.xml | 2 +- .../local_insight_status_delimitter.xml | 2 +- app/src/main/res/layout/loop_fragment.xml | 22 +- .../main/res/layout/openapsama_fragment.xml | 24 +- .../res/layout/overview_buttons_layout.xml | 42 +- .../overview_editquickwizard_dialog.xml | 2 +- app/src/main/res/layout/overview_fragment.xml | 39 +- .../res/layout/overview_graphs_layout.xml | 15 +- .../main/res/layout/overview_info_layout.xml | 200 +++++---- .../overview_loop_pumpstatus_layout.xml | 17 +- .../layout/overview_quickwizardlist_item.xml | 2 +- .../layout/overview_statuslights_layout.xml | 26 +- .../res/layout/profileviewer_fragment.xml | 16 +- .../main/res/layout/treatments_bolus_item.xml | 2 +- .../res/layout/treatments_careportal_item.xml | 2 +- .../layout/treatments_extendedbolus_item.xml | 2 +- .../layout/treatments_profileswitch_item.xml | 2 +- .../res/layout/treatments_tempbasals_item.xml | 2 +- .../res/layout/treatments_temptarget_item.xml | 2 +- .../main/res/layout/virtualpump_fragment.xml | 12 +- app/src/main/res/values/strings.xml | 3 +- .../main/res/layout/dialog_profileviewer.xml | 12 +- .../layout/maintenance_import_list_item.xml | 2 +- core/src/main/res/values/colors.xml | 2 +- dana/src/main/res/layout/danar_fragment.xml | 28 +- .../layout/danar_user_options_activity.xml | 16 +- .../main/res/layout/medtronic_fragment.xml | 20 +- .../src/main/res/layout/omnipod_overview.xml | 22 +- 40 files changed, 718 insertions(+), 653 deletions(-) rename app/src/main/res/drawable/{ic_cp_age_canula.xml => ic_cp_age_cannula.xml} (100%) rename app/src/main/res/drawable/{ic_quickwizard.xml => ic_quick_wizard.xml} (100%) diff --git a/app/build.gradle b/app/build.gradle index f7caa59867..481375c476 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,6 @@ buildscript { } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'com.google.gms.google-services' //apply plugin: 'jacoco-android' diff --git a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt index e4b37130e4..0c3db46994 100644 --- a/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/historyBrowser/HistoryBrowseActivity.kt @@ -148,7 +148,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { binding.bggraph.gridLabelRenderer?.reloadStyles() binding.bggraph.gridLabelRenderer?.labelVerticalWidth = axisWidth - overviewMenus.setupChartMenu(binding.overviewChartMenuButton) + overviewMenus.setupChartMenu(binding.chartMenuButton) prepareGraphsIfNeeded(overviewMenus.setting.size) savedInstanceState?.let { bundle -> rangeToDisplay = bundle.getInt("rangeToDisplay", 0) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index a8c0b10866..a06fe3fdd0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -28,6 +28,7 @@ import info.nightscout.androidaps.Config import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.databinding.OverviewFragmentBinding import info.nightscout.androidaps.dialogs.* import info.nightscout.androidaps.events.* import info.nightscout.androidaps.interfaces.* @@ -64,12 +65,6 @@ import info.nightscout.androidaps.utils.wizard.QuickWizard import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers -import kotlinx.android.synthetic.main.overview_buttons_layout.* -import kotlinx.android.synthetic.main.overview_fragment.* -import kotlinx.android.synthetic.main.overview_graphs_layout.* -import kotlinx.android.synthetic.main.overview_info_layout.* -import kotlinx.android.synthetic.main.overview_loop_pumpstatus_layout.* -import kotlinx.android.synthetic.main.overview_statuslights_layout.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -130,15 +125,19 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList private val graphLock = Object() - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle?): View? { + private var _binding: OverviewFragmentBinding? = null - //check screen width - dm = DisplayMetrics() - activity?.windowManager?.defaultDisplay?.getMetrics(dm) + // This property is only valid between onCreateView and + // onDestroyView. + private val binding get() = _binding!! - return inflater.inflate(R.layout.overview_fragment, container, false) - } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View = + OverviewFragmentBinding.inflate(inflater, container, false).also { + _binding = it + //check screen width + dm = DisplayMetrics() + activity?.windowManager?.defaultDisplay?.getMetrics(dm) + }.root override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -151,25 +150,25 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList val landscape = screenHeight < screenWidth skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, view, landscape, resourceHelper.gb(R.bool.isTablet), smallHeight) - nsclient_layout?.visibility = config.NSCLIENT.toVisibility() + binding.nsclientLayout.visibility = config.NSCLIENT.toVisibility() - overview_pumpstatus?.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder)) + binding.loopPumpStatusLayout.pumpStatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder)) - overview_notifications?.setHasFixedSize(false) - overview_notifications?.layoutManager = LinearLayoutManager(view.context) + binding.notifications.setHasFixedSize(false) + binding.notifications.layoutManager = LinearLayoutManager(view.context) axisWidth = if (dm.densityDpi <= 120) 3 else if (dm.densityDpi <= 160) 10 else if (dm.densityDpi <= 320) 35 else if (dm.densityDpi <= 420) 50 else if (dm.densityDpi <= 560) 70 else 80 - overview_bggraph?.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid) - overview_bggraph?.gridLabelRenderer?.reloadStyles() - overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth - overview_bggraph?.layoutParams?.height = resourceHelper.dpToPx(skinProvider.activeSkin().mainGraphHeight) + binding.graphsLayout.bgGraph.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid) + binding.graphsLayout.bgGraph.gridLabelRenderer?.reloadStyles() + binding.graphsLayout.bgGraph.gridLabelRenderer?.labelVerticalWidth = axisWidth + binding.graphsLayout.bgGraph.layoutParams?.height = resourceHelper.dpToPx(skinProvider.activeSkin().mainGraphHeight) - carbAnimation = overview_carbs_icon?.background as AnimationDrawable? + carbAnimation = binding.infoLayout.carbsIcon.background as AnimationDrawable? carbAnimation?.setEnterFadeDuration(1200) carbAnimation?.setExitFadeDuration(1200) rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6) - overview_bggraph?.setOnLongClickListener { + binding.graphsLayout.bgGraph.setOnLongClickListener { rangeToDisplay += 6 rangeToDisplay = if (rangeToDisplay > 24) 6 else rangeToDisplay sp.putInt(R.string.key_rangetodisplay, rangeToDisplay) @@ -178,32 +177,34 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList false } prepareGraphsIfNeeded(overviewMenus.setting.size) - overviewMenus.setupChartMenu(overview_chartMenuButton) + overviewMenus.setupChartMenu(binding.graphsLayout.chartMenuButton) - overview_activeprofile?.setOnClickListener(this) - overview_activeprofile?.setOnLongClickListener(this) - overview_temptarget?.setOnClickListener(this) - overview_temptarget?.setOnLongClickListener(this) - overview_accepttempbutton?.setOnClickListener(this) - overview_treatmentbutton?.setOnClickListener(this) - overview_wizardbutton?.setOnClickListener(this) - overview_calibrationbutton?.setOnClickListener(this) - overview_cgmbutton?.setOnClickListener(this) - overview_insulinbutton?.setOnClickListener(this) - overview_carbsbutton?.setOnClickListener(this) - overview_quickwizardbutton?.setOnClickListener(this) - overview_quickwizardbutton?.setOnLongClickListener(this) - overview_apsmode?.setOnClickListener(this) - overview_apsmode?.setOnLongClickListener(this) - overview_activeprofile?.setOnLongClickListener(this) + binding.loopPumpStatusLayout.activeProfile.setOnClickListener(this) + binding.loopPumpStatusLayout.activeProfile.setOnLongClickListener(this) + binding.loopPumpStatusLayout.tempTarget.setOnClickListener(this) + binding.loopPumpStatusLayout.tempTarget.setOnLongClickListener(this) + binding.buttonsLayout.acceptTempButton.setOnClickListener(this) + binding.buttonsLayout.treatmentButton.setOnClickListener(this) + binding.buttonsLayout.wizardButton.setOnClickListener(this) + binding.buttonsLayout.calibrationButton.setOnClickListener(this) + binding.buttonsLayout.cgmButton.setOnClickListener(this) + binding.buttonsLayout.insulinButton.setOnClickListener(this) + binding.buttonsLayout.carbsButton.setOnClickListener(this) + binding.buttonsLayout.quickWizardButton.setOnClickListener(this) + binding.buttonsLayout.quickWizardButton.setOnLongClickListener(this) + binding.infoLayout.apsMode.setOnClickListener(this) + binding.infoLayout.apsMode.setOnLongClickListener(this) + binding.loopPumpStatusLayout.activeProfile.setOnLongClickListener(this) } + @Synchronized override fun onPause() { super.onPause() disposable.clear() loopHandler.removeCallbacksAndMessages(null) } + @Synchronized override fun onResume() { super.onResume() disposable.add(rxBus @@ -264,7 +265,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList disposable.add(rxBus .toObservable(EventIobCalculationProgress::class.java) .observeOn(AndroidSchedulers.mainThread()) - .subscribe({ overview_iobcalculationprogess?.text = it.progress }) { fabricPrivacy.logException(it) }) + .subscribe({ binding.graphsLayout.iobCalculationProgress.text = it.progress }) { fabricPrivacy.logException(it) }) refreshLoop = Runnable { scheduleUpdateGUI("refreshLoop") @@ -275,20 +276,26 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList updateGUI("onResume") } + @Synchronized + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } + override fun onClick(v: View) { // try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days // https://stackoverflow.com/questions/14860239/checking-if-state-is-saved-before-committing-a-fragmenttransaction if (childFragmentManager.isStateSaved) return activity?.let { activity -> when (v.id) { - R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if(isAdded) TreatmentDialog().show(childFragmentManager, "Overview") }) - R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if(isAdded) WizardDialog().show(childFragmentManager, "Overview") }) - R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if(isAdded) InsulinDialog().show(childFragmentManager, "Overview") }) - R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if(isAdded) onClickQuickWizard() }) - R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if(isAdded) CarbsDialog().show(childFragmentManager, "Overview") }) - R.id.overview_temptarget -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if(isAdded) TempTargetDialog().show(childFragmentManager, "Overview") }) + R.id.treatment_button -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) TreatmentDialog().show(childFragmentManager, "Overview") }) + R.id.wizard_button -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) WizardDialog().show(childFragmentManager, "Overview") }) + R.id.insulin_button -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) InsulinDialog().show(childFragmentManager, "Overview") }) + R.id.quick_wizard_button -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) onClickQuickWizard() }) + R.id.carbs_button -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) CarbsDialog().show(childFragmentManager, "Overview") }) + R.id.temp_target -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { if (isAdded) TempTargetDialog().show(childFragmentManager, "Overview") }) - R.id.overview_activeprofile -> { + R.id.active_profile -> { ProfileViewerDialog().also { pvd -> pvd.arguments = Bundle().also { it.putLong("time", DateUtil.now()) @@ -297,7 +304,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList }.show(childFragmentManager, "ProfileViewDialog") } - R.id.overview_cgmbutton -> { + R.id.cgm_button -> { if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) openCgmApp("com.eveningoutpost.dexdrip") else if (dexcomPlugin.isEnabled(PluginType.BGSOURCE)) { @@ -308,7 +315,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } } - R.id.overview_calibrationbutton -> { + R.id.calibration_button -> { if (xdripPlugin.isEnabled(PluginType.BGSOURCE)) { CalibrationDialog().show(childFragmentManager, "CalibrationDialog") } else if (dexcomPlugin.isEnabled(PluginType.BGSOURCE)) { @@ -323,7 +330,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } } - R.id.overview_accepttempbutton -> { + R.id.accept_temp_button -> { profileFunction.getProfile() ?: return if (loopPlugin.isEnabled(PluginType.LOOP)) { val lastRun = loopPlugin.lastRun @@ -333,7 +340,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned() ?: "".toSpanned(), { aapsLogger.debug("USER ENTRY: ACCEPT TEMP BASAL") - overview_accepttempbutton?.visibility = View.GONE + binding.buttonsLayout.acceptTempButton.visibility = View.GONE (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) actionStringHandler.handleInitiate("cancelChangeRequest") loopPlugin.acceptChangeRequest() @@ -343,9 +350,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } } - R.id.overview_apsmode -> { + R.id.aps_mode -> { protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { - if(isAdded) LoopDialog().also { dialog -> + if (isAdded) LoopDialog().also { dialog -> dialog.arguments = Bundle().also { it.putInt("showOkCancel", 1) } }.show(childFragmentManager, "Overview") }) @@ -370,12 +377,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList override fun onLongClick(v: View): Boolean { when (v.id) { - R.id.overview_quickwizardbutton -> { + R.id.quick_wizard_button -> { startActivity(Intent(v.context, QuickWizardListActivity::class.java)) return true } - R.id.overview_apsmode -> { + R.id.aps_mode -> { activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { LoopDialog().also { dialog -> @@ -385,8 +392,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } } - R.id.overview_temptarget -> v.performClick() - R.id.overview_activeprofile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") }) } + R.id.temp_target -> v.performClick() + R.id.active_profile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") }) } } return false @@ -399,7 +406,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList val pump = activePlugin.activePump val quickWizardEntry = quickWizard.getActive() if (quickWizardEntry != null && actualBg != null && profile != null) { - overview_quickwizardbutton?.visibility = View.VISIBLE + binding.buttonsLayout.quickWizardButton.visibility = View.VISIBLE val wizard = quickWizardEntry.doCalc(profile, profileName, actualBg, true) if (wizard.calculatedTotalInsulin > 0.0 && quickWizardEntry.carbs() > 0.0) { val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(quickWizardEntry.carbs())).value() @@ -417,12 +424,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList private fun updatePumpStatus(event: EventPumpStatusChanged) { val status = event.getStatus(resourceHelper) if (status != "") { - overview_pumpstatus?.text = status - overview_pumpstatuslayout?.visibility = View.VISIBLE - overview_looplayout?.visibility = View.GONE + binding.loopPumpStatusLayout.pumpStatus.text = status + binding.loopPumpStatusLayout.pumpStatusLayout.visibility = View.VISIBLE + binding.loopPumpStatusLayout.loopLayout.visibility = View.GONE } else { - overview_pumpstatuslayout?.visibility = View.GONE - overview_looplayout?.visibility = View.VISIBLE + binding.loopPumpStatusLayout.pumpStatusLayout.visibility = View.GONE + binding.loopPumpStatusLayout.loopLayout.visibility = View.VISIBLE } } @@ -437,12 +444,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList // QuickWizard button val quickWizardEntry = quickWizard.getActive() if (quickWizardEntry != null && lastBG != null && profile != null && pump.isInitialized && !pump.isSuspended) { - overview_quickwizardbutton?.visibility = View.VISIBLE + binding.buttonsLayout.quickWizardButton.visibility = View.VISIBLE val wizard = quickWizardEntry.doCalc(profile, profileName, lastBG, false) - overview_quickwizardbutton?.text = quickWizardEntry.buttonText() + "\n" + resourceHelper.gs(R.string.format_carbs, quickWizardEntry.carbs()) + + binding.buttonsLayout.quickWizardButton.text = quickWizardEntry.buttonText() + "\n" + resourceHelper.gs(R.string.format_carbs, quickWizardEntry.carbs()) + " " + resourceHelper.gs(R.string.formatinsulinunits, wizard.calculatedTotalInsulin) - if (wizard.calculatedTotalInsulin <= 0) overview_quickwizardbutton?.visibility = View.GONE - } else overview_quickwizardbutton?.visibility = View.GONE + if (wizard.calculatedTotalInsulin <= 0) binding.buttonsLayout.quickWizardButton.visibility = View.GONE + } else binding.buttonsLayout.quickWizardButton.visibility = View.GONE // **** Temp button **** val lastRun = loopPlugin.lastRun @@ -454,23 +461,23 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList lastRun.constraintsProcessed?.isChangeRequested == true // change is requested if (showAcceptButton && pump.isInitialized && !pump.isSuspended && loopPlugin.isEnabled(PluginType.LOOP)) { - overview_accepttempbutton?.visibility = View.VISIBLE - overview_accepttempbutton?.text = "${resourceHelper.gs(R.string.setbasalquestion)}\n${lastRun!!.constraintsProcessed}" + binding.buttonsLayout.acceptTempButton.visibility = View.VISIBLE + binding.buttonsLayout.acceptTempButton.text = "${resourceHelper.gs(R.string.setbasalquestion)}\n${lastRun!!.constraintsProcessed}" } else { - overview_accepttempbutton?.visibility = View.GONE + binding.buttonsLayout.acceptTempButton.visibility = View.GONE } // **** Various treatment buttons **** - overview_carbsbutton?.visibility = ((!activePlugin.activePump.pumpDescription.storesCarbInfo || pump.isInitialized && !pump.isSuspended) && profile != null && sp.getBoolean(R.string.key_show_carbs_button, true)).toVisibility() - overview_treatmentbutton?.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_treatment_button, false)).toVisibility() - overview_wizardbutton?.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_wizard_button, true)).toVisibility() - overview_insulinbutton?.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility() + binding.buttonsLayout.carbsButton.visibility = ((!activePlugin.activePump.pumpDescription.storesCarbInfo || pump.isInitialized && !pump.isSuspended) && profile != null && sp.getBoolean(R.string.key_show_carbs_button, true)).toVisibility() + binding.buttonsLayout.treatmentButton.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_treatment_button, false)).toVisibility() + binding.buttonsLayout.wizardButton.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_wizard_button, true)).toVisibility() + binding.buttonsLayout.insulinButton.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility() // **** Calibration & CGM buttons **** val xDripIsBgSource = xdripPlugin.isEnabled(PluginType.BGSOURCE) val dexcomIsSource = dexcomPlugin.isEnabled(PluginType.BGSOURCE) - overview_calibrationbutton?.visibility = ((xDripIsBgSource || dexcomIsSource) && actualBG != null && sp.getBoolean(R.string.key_show_calibration_button, true)).toVisibility() - overview_cgmbutton?.visibility = (sp.getBoolean(R.string.key_show_cgm_button, false) && (xDripIsBgSource || dexcomIsSource)).toVisibility() + binding.buttonsLayout.calibrationButton.visibility = ((xDripIsBgSource || dexcomIsSource) && actualBG != null && sp.getBoolean(R.string.key_show_calibration_button, true)).toVisibility() + binding.buttonsLayout.cgmButton.visibility = (sp.getBoolean(R.string.key_show_cgm_button, false) && (xDripIsBgSource || dexcomIsSource)).toVisibility() } @@ -481,7 +488,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList // rebuild needed secondaryGraphs.clear() secondaryGraphsLabel.clear() - overview_iobgraph.removeAllViews() + binding.graphsLayout.iobGraph.removeAllViews() for (i in 1 until numOfGraphs) { val relativeLayout = RelativeLayout(context) relativeLayout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) @@ -504,7 +511,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList relativeLayout.addView(label) secondaryGraphsLabel.add(label) - overview_iobgraph.addView(relativeLayout) + binding.graphsLayout.iobGraph.addView(relativeLayout) secondaryGraphs.add(graph) } } @@ -528,19 +535,20 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList @SuppressLint("SetTextI18n") fun updateGUI(from: String) { + if (_binding == null) return aapsLogger.debug("UpdateGUI from $from") - overview_time?.text = dateUtil.timeString(Date()) + binding.infoLayout.time.text = dateUtil.timeString(Date()) if (!profileFunction.isProfileValid("Overview")) { - overview_pumpstatus?.setText(R.string.noprofileset) - overview_pumpstatuslayout?.visibility = View.VISIBLE - overview_looplayout?.visibility = View.GONE + binding.loopPumpStatusLayout.pumpStatus.setText(R.string.noprofileset) + binding.loopPumpStatusLayout.pumpStatusLayout.visibility = View.VISIBLE + binding.loopPumpStatusLayout.loopLayout.visibility = View.GONE return } - overview_notifications?.let { notificationStore.updateNotifications(it) } - overview_pumpstatuslayout?.visibility = View.GONE - overview_looplayout?.visibility = View.VISIBLE + binding.notifications.let { notificationStore.updateNotifications(it) } + binding.loopPumpStatusLayout.pumpStatusLayout.visibility = View.GONE + binding.loopPumpStatusLayout.loopLayout.visibility = View.VISIBLE val profile = profileFunction.getProfile() ?: return val actualBG = iobCobCalculatorPlugin.actualBg() @@ -567,126 +575,126 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList else -> resourceHelper.gc(R.color.inrange) } - overview_bg?.text = lastBG.valueToUnitsToString(units) - overview_bg?.setTextColor(color) - overview_arrow?.setImageResource(lastBG.directionToIcon(databaseHelper)) - overview_arrow?.setColorFilter(color) + binding.infoLayout.bg.text = lastBG.valueToUnitsToString(units) + binding.infoLayout.bg.setTextColor(color) + binding.infoLayout.arrow.setImageResource(lastBG.directionToIcon(databaseHelper)) + binding.infoLayout.arrow.setColorFilter(color) val glucoseStatus = GlucoseStatus(injector).glucoseStatusData if (glucoseStatus != null) { - overview_delta_large?.text = Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) - overview_delta_large?.setTextColor(color) - overview_delta?.text = Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) - overview_avgdelta?.text = "${Profile.toSignedUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units)}" - overview_long_avgdelta?.text = "${Profile.toSignedUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units)}" + binding.infoLayout.deltaLarge.text = Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + binding.infoLayout.deltaLarge.setTextColor(color) + binding.infoLayout.delta.text = Profile.toSignedUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + binding.infoLayout.avgDelta.text = Profile.toSignedUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) + binding.infoLayout.longAvgDelta.text = Profile.toSignedUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units) } else { - overview_delta?.text = "Δ " + resourceHelper.gs(R.string.notavailable) - overview_avgdelta?.text = "" - overview_long_avgdelta?.text = "" + binding.infoLayout.delta.text = "Δ " + resourceHelper.gs(R.string.notavailable) + binding.infoLayout.avgDelta.text = "" + binding.infoLayout.longAvgDelta.text = "" } // strike through if BG is old - overview_bg?.let { overview_bg -> + binding.infoLayout.bg.let { overview_bg -> var flag = overview_bg.paintFlags flag = if (actualBG == null) { flag or Paint.STRIKE_THRU_TEXT_FLAG } else flag and Paint.STRIKE_THRU_TEXT_FLAG.inv() overview_bg.paintFlags = flag } - overview_timeago?.text = DateUtil.minAgo(resourceHelper, lastBG.date) - overview_timeagoshort?.text = "(" + DateUtil.minAgoShort(lastBG.date) + ")" + binding.infoLayout.timeAgo.text = DateUtil.minAgo(resourceHelper, lastBG.date) + binding.infoLayout.timeAgoShort.text = "(" + DateUtil.minAgoShort(lastBG.date) + ")" } val closedLoopEnabled = constraintChecker.isClosedLoopAllowed() // aps mode if (config.APS && pump.pumpDescription.isTempBasalCapable) { - overview_apsmode?.visibility = View.VISIBLE - overview_time_llayout?.visibility = View.GONE + binding.infoLayout.apsMode.visibility = View.VISIBLE + binding.infoLayout.timeLayout.visibility = View.GONE when { loopPlugin.isEnabled() && loopPlugin.isSuperBolus -> { - overview_apsmode?.setImageResource(R.drawable.ic_loop_superbolus) - overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) - overview_apsmode_text?.visibility = View.VISIBLE + binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_superbolus) + binding.infoLayout.apsModeText.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) + binding.infoLayout.apsModeText.visibility = View.VISIBLE } loopPlugin.isDisconnected -> { - overview_apsmode?.setImageResource(R.drawable.ic_loop_disconnected) - overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) - overview_apsmode_text?.visibility = View.VISIBLE + binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_disconnected) + binding.infoLayout.apsModeText.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) + binding.infoLayout.apsModeText.visibility = View.VISIBLE } loopPlugin.isEnabled() && loopPlugin.isSuspended -> { - overview_apsmode?.setImageResource(R.drawable.ic_loop_paused) - overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) - overview_apsmode_text?.visibility = View.VISIBLE + binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_paused) + binding.infoLayout.apsModeText.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) + binding.infoLayout.apsModeText.visibility = View.VISIBLE } pump.isSuspended -> { - overview_apsmode?.setImageResource(if (pump.pumpDescription.pumpType == PumpType.Insulet_Omnipod) { + binding.infoLayout.apsMode.setImageResource(if (pump.pumpDescription.pumpType == PumpType.Insulet_Omnipod) { // For Omnipod, indicate the pump as disconnected when it's suspended. // The only way to 'reconnect' it, is through the Omnipod tab R.drawable.ic_loop_disconnected } else { R.drawable.ic_loop_paused }) - overview_apsmode_text?.visibility = View.GONE + binding.infoLayout.apsModeText.visibility = View.GONE } loopPlugin.isEnabled() && closedLoopEnabled.value() && loopPlugin.isLGS -> { - overview_apsmode?.setImageResource(R.drawable.ic_loop_lgs) - overview_apsmode_text?.visibility = View.GONE + binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_lgs) + binding.infoLayout.apsModeText.visibility = View.GONE } loopPlugin.isEnabled() && closedLoopEnabled.value() -> { - overview_apsmode?.setImageResource(R.drawable.ic_loop_closed) - overview_apsmode_text?.visibility = View.GONE + binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_closed) + binding.infoLayout.apsModeText.visibility = View.GONE } loopPlugin.isEnabled() && !closedLoopEnabled.value() -> { - overview_apsmode?.setImageResource(R.drawable.ic_loop_open) - overview_apsmode_text?.visibility = View.GONE + binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_open) + binding.infoLayout.apsModeText.visibility = View.GONE } else -> { - overview_apsmode?.setImageResource(R.drawable.ic_loop_disabled) - overview_apsmode_text?.visibility = View.GONE + binding.infoLayout.apsMode.setImageResource(R.drawable.ic_loop_disabled) + binding.infoLayout.apsModeText.visibility = View.GONE } } } else { //nsclient - overview_apsmode?.visibility = View.GONE - overview_apsmode_text?.visibility = View.GONE - overview_time_llayout?.visibility = View.VISIBLE + binding.infoLayout.apsMode.visibility = View.GONE + binding.infoLayout.apsModeText.visibility = View.GONE + binding.infoLayout.timeLayout.visibility = View.VISIBLE } // temp target val tempTarget = treatmentsPlugin.tempTargetFromHistory if (tempTarget != null) { - overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) - overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) - overview_temptarget?.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper) + binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) + binding.loopPumpStatusLayout.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) + binding.loopPumpStatusLayout.tempTarget.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper) } else { // If the target is not the same as set in the profile then oref has overridden it val targetUsed = lastRun?.constraintsProcessed?.targetBG ?: 0.0 if (targetUsed != 0.0 && abs(profile.targetMgdl - targetUsed) > 0.01) { aapsLogger.debug("Adjusted target. Profile: ${profile.targetMgdl} APS: $targetUsed") - overview_temptarget?.text = Profile.toTargetRangeString(targetUsed, targetUsed, Constants.MGDL, units) - overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) - overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) + binding.loopPumpStatusLayout.tempTarget.text = Profile.toTargetRangeString(targetUsed, targetUsed, Constants.MGDL, units) + binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) + binding.loopPumpStatusLayout.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) } else { - overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) - overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) - overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) + binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) + binding.loopPumpStatusLayout.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) + binding.loopPumpStatusLayout.tempTarget.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) } } // Basal, TBR val activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()) - overview_basebasal?.text = activeTemp?.let { "T:" + activeTemp.toStringVeryShort() } + binding.infoLayout.baseBasal.text = activeTemp?.let { "T:" + activeTemp.toStringVeryShort() } ?: resourceHelper.gs(R.string.pump_basebasalrate, profile.basal) - overview_basal_llayout?.setOnClickListener { + binding.infoLayout.basalLayout.setOnClickListener { var fullText = "${resourceHelper.gs(R.string.basebasalrate_label)}: ${resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)}" if (activeTemp != null) fullText += "\n" + resourceHelper.gs(R.string.tempbasal_label) + ": " + activeTemp.toStringFull() @@ -694,36 +702,36 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList OKDialog.show(it, resourceHelper.gs(R.string.basal), fullText) } } - overview_basebasal?.setTextColor(activeTemp?.let { resourceHelper.gc(R.color.basal) } + binding.infoLayout.baseBasal.setTextColor(activeTemp?.let { resourceHelper.gc(R.color.basal) } ?: resourceHelper.gc(R.color.defaulttextcolor)) - overview_basebasal_icon?.setImageResource(R.drawable.ic_cp_basal_no_tbr) + binding.infoLayout.baseBasalIcon.setImageResource(R.drawable.ic_cp_basal_no_tbr) val percentRate = activeTemp?.tempBasalConvertedToPercent(System.currentTimeMillis(), profile) ?: 100 - if (percentRate > 100) overview_basebasal_icon?.setImageResource(R.drawable.ic_cp_basal_tbr_high) - if (percentRate < 100) overview_basebasal_icon?.setImageResource(R.drawable.ic_cp_basal_tbr_low) + if (percentRate > 100) binding.infoLayout.baseBasalIcon.setImageResource(R.drawable.ic_cp_basal_tbr_high) + if (percentRate < 100) binding.infoLayout.baseBasalIcon.setImageResource(R.drawable.ic_cp_basal_tbr_low) // Extended bolus val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) - overview_extendedbolus?.text = + binding.infoLayout.extendedBolus.text = if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses) resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.absoluteRate()) else "" - overview_extendedbolus?.setOnClickListener { + binding.infoLayout.extendedBolus.setOnClickListener { if (extendedBolus != null) activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.extended_bolus), extendedBolus.toString()) } } - overview_extended_llayout?.visibility = (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses).toVisibility() + binding.infoLayout.extendedLayout.visibility = (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses).toVisibility() // Active profile - overview_activeprofile?.text = profileFunction.getProfileNameWithDuration() + binding.loopPumpStatusLayout.activeProfile.text = profileFunction.getProfileNameWithDuration() if (profile.percentage != 100 || profile.timeshift != 0) { - overview_activeprofile?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) - overview_activeprofile?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) + binding.loopPumpStatusLayout.activeProfile.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) + binding.loopPumpStatusLayout.activeProfile.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) } else { - overview_activeprofile?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) - overview_activeprofile?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) + binding.loopPumpStatusLayout.activeProfile.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) + binding.loopPumpStatusLayout.activeProfile.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) } processButtonsVisibility() @@ -733,9 +741,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList treatmentsPlugin.updateTotalIOBTempBasals() val bolusIob = treatmentsPlugin.lastCalculationTreatments.round() val basalIob = treatmentsPlugin.lastCalculationTempBasals.round() - overview_iob?.text = resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + binding.infoLayout.iob.text = resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) - overview_iob_llayout?.setOnClickListener { + binding.infoLayout.iobLayout.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.iob), resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + "\n" + @@ -746,8 +754,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } // Status lights - overview_statuslights?.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() - statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, careportal_reservoirlevel, careportal_sensorage, null, careportal_pbage, careportal_batterylevel) + binding.statusLightsLayout.statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() + statusLightHandler.updateStatusLights(binding.statusLightsLayout.cannulaAge, binding.statusLightsLayout.insulinAge, binding.statusLightsLayout.reservoirLevel, binding.statusLightsLayout.sensorAge, null, binding.statusLightsLayout.pbAge, binding.statusLightsLayout.batteryLevel) // cob var cobText: String = resourceHelper.gs(R.string.value_unavailable_short) @@ -763,36 +771,36 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (treatmentsPlugin.lastCarbTime < lastRun.lastAPSRun) { cobText = cobText + " | " + lastRun.constraintsProcessed!!.carbsReq + " " + resourceHelper.gs(R.string.required) } - overview_cob?.text = cobText + binding.infoLayout.cob.text = cobText if (carbAnimation?.isRunning == false) carbAnimation?.start() } else { - overview_cob?.text = cobText + binding.infoLayout.cob.text = cobText carbAnimation?.stop() carbAnimation?.selectDrawable(0) } - } else overview_cob?.text = cobText + } else binding.infoLayout.cob.text = cobText // pump status from ns - overview_pump?.text = nsDeviceStatus.pumpStatus - overview_pump?.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.pump), nsDeviceStatus.extendedPumpStatus) } } + binding.pump.text = nsDeviceStatus.pumpStatus + binding.pump.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.pump), nsDeviceStatus.extendedPumpStatus) } } // OpenAPS status from ns - overview_openaps?.text = nsDeviceStatus.openApsStatus - overview_openaps?.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.openaps), nsDeviceStatus.extendedOpenApsStatus) } } + binding.openaps.text = nsDeviceStatus.openApsStatus + binding.openaps.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.openaps), nsDeviceStatus.extendedOpenApsStatus) } } // Uploader status from ns - overview_uploader?.text = nsDeviceStatus.uploaderStatusSpanned - overview_uploader?.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.uploader), nsDeviceStatus.extendedUploaderStatus) } } + binding.uploader.text = nsDeviceStatus.uploaderStatusSpanned + binding.uploader.setOnClickListener { activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.uploader), nsDeviceStatus.extendedUploaderStatus) } } // Sensitivity if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) { - overview_sensitivity_icon?.setImageResource(R.drawable.ic_swap_vert_black_48dp_green) + binding.infoLayout.sensitivityIcon.setImageResource(R.drawable.ic_swap_vert_black_48dp_green) } else { - overview_sensitivity_icon?.setImageResource(R.drawable.ic_x_swap_vert) + binding.infoLayout.sensitivityIcon.setImageResource(R.drawable.ic_x_swap_vert) } - overview_sensitivity?.text = + binding.infoLayout.sensitivity.text = iobCobCalculatorPlugin.getLastAutosensData("Overview")?.let { autosensData -> String.format(Locale.ENGLISH, "%.0f%%", autosensData.autosensResult.ratio * 100) } ?: "" @@ -800,10 +808,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList private fun updateGraph(lastRun: LoopInterface.LastRun?, predictionsAvailable: Boolean, lowLine: Double, highLine: Double, pump: PumpInterface, profile: Profile) { viewLifecycleOwner.lifecycleScope.launch(Dispatchers.Main) { - overview_bggraph ?: return@launch + if (_binding == null) return@launch val menuChartSettings = overviewMenus.setting prepareGraphsIfNeeded(menuChartSettings.size) - val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin, treatmentsPlugin) + val graphData = GraphData(injector, binding.graphsLayout.bgGraph, iobCobCalculatorPlugin, treatmentsPlugin) val secondaryGraphsData: ArrayList = ArrayList() // do preparation in different thread diff --git a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt index 253b822988..85ab6791ac 100644 --- a/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt +++ b/app/src/main/java/info/nightscout/androidaps/skins/SkinInterface.kt @@ -27,9 +27,9 @@ interface SkinInterface { val landscape = screenHeight < screenWidth if (landscape) { - val iobLayout = view.findViewById(R.id.overview_iob_llayout) + val iobLayout = view.findViewById(R.id.iob_layout) val iobLayoutParams = iobLayout.layoutParams as ConstraintLayout.LayoutParams - val timeLayout = view.findViewById(R.id.overview_time_llayout) + val timeLayout = view.findViewById(R.id.time_layout) iobLayoutParams.startToStart = ConstraintLayout.LayoutParams.UNSET iobLayoutParams.startToEnd = timeLayout.id iobLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET @@ -37,44 +37,43 @@ interface SkinInterface { val timeLayoutParams = timeLayout.layoutParams as ConstraintLayout.LayoutParams timeLayoutParams.endToEnd = ConstraintLayout.LayoutParams.UNSET timeLayoutParams.endToStart = iobLayout.id - val cobLayoutParams = view.findViewById(R.id.overview_cob_llayout).layoutParams as ConstraintLayout.LayoutParams + val cobLayoutParams = view.findViewById(R.id.cob_layout).layoutParams as ConstraintLayout.LayoutParams cobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID - val basalLayoutParams = view.findViewById(R.id.overview_basal_llayout).layoutParams as ConstraintLayout.LayoutParams + val basalLayoutParams = view.findViewById(R.id.basal_layout).layoutParams as ConstraintLayout.LayoutParams basalLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID - val extendedLayoutParams = view.findViewById(R.id.overview_extended_llayout).layoutParams as ConstraintLayout.LayoutParams + val extendedLayoutParams = view.findViewById(R.id.extended_layout).layoutParams as ConstraintLayout.LayoutParams extendedLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID - val asLayoutParams = view.findViewById(R.id.overview_as_llayout).layoutParams as ConstraintLayout.LayoutParams + val asLayoutParams = view.findViewById(R.id.as_layout).layoutParams as ConstraintLayout.LayoutParams asLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID if (isTablet) { for (v in listOf( - view.findViewById(R.id.overview_bg), - view.findViewById(R.id.overview_time), - view.findViewById(R.id.overview_timeagoshort), - view.findViewById(R.id.overview_iob), - view.findViewById(R.id.overview_cob), - view.findViewById(R.id.overview_basebasal), - view.findViewById(R.id.overview_extendedbolus), - view.findViewById(R.id.overview_sensitivity) + view.findViewById(R.id.bg), + view.findViewById(R.id.time), + view.findViewById(R.id.time_ago_short), + view.findViewById(R.id.iob), + view.findViewById(R.id.cob), + view.findViewById(R.id.base_basal), + view.findViewById(R.id.extended_bolus), + view.findViewById(R.id.sensitivity) )) v?.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.5f) for (v in listOf( - view.findViewById(R.id.overview_pump), - view.findViewById(R.id.overview_openaps), - view.findViewById(R.id.overview_uploader), - view.findViewById(R.id.careportal_canulaage), - view.findViewById(R.id.careportal_insulinage), - view.findViewById(R.id.careportal_reservoirlevel), - view.findViewById(R.id.careportal_reservoirlevel), - view.findViewById(R.id.careportal_sensorage), - view.findViewById(R.id.careportal_pbage), - view.findViewById(R.id.careportal_batterylevel) + view.findViewById(R.id.pump), + view.findViewById(R.id.openaps), + view.findViewById(R.id.uploader), + view.findViewById(R.id.cannula_age), + view.findViewById(R.id.insulin_age), + view.findViewById(R.id.reservoir_level), + view.findViewById(R.id.sensor_age), + view.findViewById(R.id.pb_age), + view.findViewById(R.id.battery_level) )) v?.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f) timeLayout?.orientation = LinearLayout.HORIZONTAL - view.findViewById(R.id.overview_timeagoshort)?.setTextSize(COMPLEX_UNIT_PX, view.findViewById(R.id.overview_time).textSize) + view.findViewById(R.id.time_ago_short)?.setTextSize(COMPLEX_UNIT_PX, view.findViewById(R.id.time).textSize) - view.findViewById(R.id.overview_delta_large)?.visibility = View.VISIBLE + view.findViewById(R.id.delta_large)?.visibility = View.VISIBLE } else { - view.findViewById(R.id.overview_delta_large)?.visibility = View.GONE + view.findViewById(R.id.delta_large)?.visibility = View.GONE } } } diff --git a/app/src/main/res/drawable/ic_cp_age_canula.xml b/app/src/main/res/drawable/ic_cp_age_cannula.xml similarity index 100% rename from app/src/main/res/drawable/ic_cp_age_canula.xml rename to app/src/main/res/drawable/ic_cp_age_cannula.xml diff --git a/app/src/main/res/drawable/ic_quickwizard.xml b/app/src/main/res/drawable/ic_quick_wizard.xml similarity index 100% rename from app/src/main/res/drawable/ic_quickwizard.xml rename to app/src/main/res/drawable/ic_quick_wizard.xml diff --git a/app/src/main/res/layout/activity_historybrowse.xml b/app/src/main/res/layout/activity_historybrowse.xml index 7960795719..98ce50f0c4 100644 --- a/app/src/main/res/layout/activity_historybrowse.xml +++ b/app/src/main/res/layout/activity_historybrowse.xml @@ -77,7 +77,7 @@ android:layout_height="match_parent" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> @@ -152,7 +152,7 @@ android:layout_marginRight="20dp" android:layout_marginBottom="2dp" android:layout_span="5" - android:background="@color/listdelimiter" /> + android:background="@color/list_delimiter" /> @@ -166,9 +166,9 @@ android:gravity="center_vertical" android:paddingStart="15dp" android:paddingEnd="2dp" - android:text="@string/careportal_canula_label" + android:text="@string/cannula" android:textSize="14sp" - app:drawableStartCompat="@drawable/ic_cp_age_canula" /> + app:drawableStartCompat="@drawable/ic_cp_age_cannula" /> + android:background="@color/list_delimiter" /> @@ -298,7 +298,7 @@ android:layout_marginRight="20dp" android:layout_marginBottom="2dp" android:layout_span="5" - android:background="@color/listdelimiter" /> + android:background="@color/list_delimiter" /> diff --git a/app/src/main/res/layout/careportal_stats_fragment_lowres.xml b/app/src/main/res/layout/careportal_stats_fragment_lowres.xml index eb6a1dc8ed..121728bffc 100644 --- a/app/src/main/res/layout/careportal_stats_fragment_lowres.xml +++ b/app/src/main/res/layout/careportal_stats_fragment_lowres.xml @@ -1,228 +1,227 @@ - - + android:layout_height="wrap_content"> - + + + + + + + + + + + + + android:layout_height="2dip" + android:layout_marginLeft="20dp" + android:layout_marginTop="2dp" + android:layout_marginRight="20dp" + android:layout_marginBottom="2dp" + android:layout_span="3" + android:background="@color/list_delimiter" /> - + + + + + - + - + - + - + + + android:layout_height="2dip" + android:layout_marginLeft="20dp" + android:layout_marginTop="2dp" + android:layout_marginRight="20dp" + android:layout_marginBottom="2dp" + android:layout_span="3" + android:background="@color/list_delimiter" /> - + - + - + + + + + + + + + + + android:layout_height="2dip" + android:layout_marginLeft="20dp" + android:layout_marginTop="2dp" + android:layout_marginRight="20dp" + android:layout_marginBottom="2dp" + android:layout_span="3" + android:background="@color/list_delimiter" /> - + + + + + - + + - + - + - + android:layout_height="2dip" + android:layout_marginLeft="20dp" + android:layout_marginTop="2dp" + android:layout_marginRight="20dp" + android:layout_marginBottom="2dp" + android:layout_span="3" + android:background="@color/list_delimiter" /> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/app/src/main/res/layout/combopump_fragment.xml b/app/src/main/res/layout/combopump_fragment.xml index 8af1415688..8e13a5fb8f 100644 --- a/app/src/main/res/layout/combopump_fragment.xml +++ b/app/src/main/res/layout/combopump_fragment.xml @@ -62,7 +62,7 @@ android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="5dp" - android:background="@color/listdelimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> + android:background="@color/list_delimiter" /> @@ -269,7 +269,7 @@ android:layout_marginStart="5dp" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" - android:background="@color/listdelimiter" /> + android:background="@color/list_delimiter" /> @@ -391,7 +391,7 @@ android:layout_marginStart="5dp" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" - android:background="@color/listdelimiter" /> + android:background="@color/list_delimiter" />