Move Pulse Log and RL stats from Omnipod tab to Pod Management menu
This commit is contained in:
parent
df6e607fd0
commit
0acfa506c3
|
@ -19,7 +19,6 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
|||
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.R
|
||||
|
@ -126,14 +125,6 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_play_test_beep), false))
|
||||
}
|
||||
|
||||
omnipod_overview_button_rileylink_stats.setOnClickListener {
|
||||
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
||||
startActivity(Intent(context, RileyLinkStatusActivity::class.java))
|
||||
} else {
|
||||
displayNotConfiguredDialog()
|
||||
}
|
||||
}
|
||||
|
||||
omnipod_overview_button_acknowledge_active_alerts.setOnClickListener {
|
||||
disablePodActionButtons()
|
||||
commandQueue.customCommand(CommandAcknowledgeAlerts(),
|
||||
|
@ -154,12 +145,6 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_set_time), true)
|
||||
.messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_time_on_pod_updated)))
|
||||
}
|
||||
|
||||
omnipod_overview_button_pulse_log.setOnClickListener {
|
||||
disablePodActionButtons()
|
||||
commandQueue.customCommand(CommandReadPulseLog(),
|
||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_read_pulse_log), false))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -454,19 +439,15 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
updateAcknowledgeAlertsButton()
|
||||
updateSuspendDeliveryButton()
|
||||
updateSetTimeButton()
|
||||
updatePulseLogButton()
|
||||
updateTestBeepButton()
|
||||
updateRileylinkStatsButton()
|
||||
}
|
||||
|
||||
|
||||
private fun disablePodActionButtons() {
|
||||
omnipod_overview_button_acknowledge_active_alerts.isEnabled = false
|
||||
omnipod_overview_button_resume_delivery.isEnabled = false
|
||||
omnipod_overview_button_suspend_delivery.isEnabled = false
|
||||
omnipod_overview_button_set_time.isEnabled = false
|
||||
omnipod_overview_button_refresh_status.isEnabled = false
|
||||
omnipod_overview_button_pulse_log.isEnabled = false
|
||||
omnipod_overview_button_test_beep.isEnabled = false
|
||||
}
|
||||
|
||||
|
@ -512,24 +493,6 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updatePulseLogButton() {
|
||||
if (omnipodManager.isPulseLogButtonEnabled) {
|
||||
omnipod_overview_button_pulse_log.visibility = View.VISIBLE
|
||||
omnipod_overview_button_pulse_log.isEnabled = podStateManager.isPodActivationCompleted && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
} else {
|
||||
omnipod_overview_button_pulse_log.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateRileylinkStatsButton() {
|
||||
if (omnipodManager.isRileylinkStatsButtonEnabled) {
|
||||
omnipod_overview_button_rileylink_stats.visibility = View.VISIBLE
|
||||
omnipod_overview_button_rileylink_stats.isEnabled = true
|
||||
} else {
|
||||
omnipod_overview_button_rileylink_stats.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTestBeepButton() {
|
||||
if (omnipodManager.isTestBeepButtonEnabled) {
|
||||
omnipod_overview_button_test_beep.visibility = View.VISIBLE
|
||||
|
|
|
@ -1,25 +1,33 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.R
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandReadPulseLog
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.activation.PodActivationWizardActivity
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.ui.wizard.deactivation.PodDeactivationWizardActivity
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.queue.events.EventQueueChanged
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||
import info.nightscout.androidaps.utils.extensions.toVisibility
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.omnipod_pod_management.*
|
||||
|
@ -38,6 +46,8 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var injector: HasAndroidInjector
|
||||
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
|
||||
@Inject lateinit var aapsOmnipodManager: AapsOmnipodManager
|
||||
@Inject lateinit var context: Context
|
||||
@Inject lateinit var omnipodPumpPlugin: OmnipodPumpPlugin
|
||||
|
||||
private var disposables: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -55,11 +65,32 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
omnipod_pod_management_button_discard_pod.setOnClickListener {
|
||||
OKDialog.showConfirmation(this,
|
||||
resourceHelper.gs(R.string.omnipod_pod_management_discard_pod_state_confirmation), Thread {
|
||||
resourceHelper.gs(R.string.omnipod_pod_management_discard_pod_confirmation), Thread {
|
||||
aapsOmnipodManager.discardPodState()
|
||||
})
|
||||
}
|
||||
|
||||
omnipod_pod_management_button_rileylink_stats.setOnClickListener {
|
||||
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
||||
startActivity(Intent(context, RileyLinkStatusActivity::class.java))
|
||||
} else {
|
||||
displayNotConfiguredDialog()
|
||||
}
|
||||
}
|
||||
|
||||
omnipod_pod_management_button_pulse_log.setOnClickListener {
|
||||
omnipod_pod_management_button_pulse_log.isEnabled = false
|
||||
omnipod_pod_management_button_pulse_log.setText(R.string.omnipod_pod_management_button_reading_pulse_log)
|
||||
|
||||
commandQueue.customCommand(CommandReadPulseLog(), object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
displayErrorDialog(resourceHelper.gs(R.string.omnipod_warning), resourceHelper.gs(R.string.omnipod_two_strings_concatenated_by_colon, resourceHelper.gs(R.string.omnipod_error_failed_to_read_pulse_log), result.comment), false)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
omnipod_pod_management_button_pod_history.setOnClickListener {
|
||||
startActivity(Intent(this, PodHistoryActivity::class.java))
|
||||
}
|
||||
|
@ -75,6 +106,10 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
.toObservable(EventOmnipodPumpValuesChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ refreshButtons() }, { fabricPrivacy.logException(it) })
|
||||
disposables += rxBus
|
||||
.toObservable(EventQueueChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ refreshButtons() }, { fabricPrivacy.logException(it) })
|
||||
|
||||
refreshButtons()
|
||||
}
|
||||
|
@ -88,9 +123,13 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
// Only show the discard button to reset a cached Pod address before the Pod has actually been initialized
|
||||
// Otherwise, users should use the Deactivate Pod Wizard. In case proper deactivation fails,
|
||||
// they will get an option to discard the Pod state there
|
||||
// TODO maybe rename this button and the confirmation dialog text (see onCreate)
|
||||
val discardButtonEnabled = podStateManager.hasPodState() && !podStateManager.isPodInitialized
|
||||
omnipod_pod_management_button_discard_pod.visibility = discardButtonEnabled.toVisibility()
|
||||
|
||||
val pulseLogButtonEnabled = aapsOmnipodManager.isPulseLogButtonEnabled
|
||||
omnipod_pod_management_button_pulse_log.visibility = pulseLogButtonEnabled.toVisibility()
|
||||
|
||||
omnipod_pod_management_button_rileylink_stats.visibility = aapsOmnipodManager.isRileylinkStatsButtonEnabled.toVisibility()
|
||||
omnipod_pod_management_waiting_for_rl_layout.visibility = (!rileyLinkServiceData.rileyLinkServiceState.isReady).toVisibility()
|
||||
|
||||
if (rileyLinkServiceData.rileyLinkServiceState.isReady) {
|
||||
|
@ -99,13 +138,45 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
if (discardButtonEnabled) {
|
||||
omnipod_pod_management_button_discard_pod.isEnabled = true
|
||||
}
|
||||
if (pulseLogButtonEnabled) {
|
||||
if (commandQueue.isCustomCommandInQueue(CommandReadPulseLog::class.java)) {
|
||||
omnipod_pod_management_button_pulse_log.isEnabled = false
|
||||
omnipod_pod_management_button_pulse_log.setText(R.string.omnipod_pod_management_button_reading_pulse_log)
|
||||
} else {
|
||||
omnipod_pod_management_button_pulse_log.isEnabled = true
|
||||
omnipod_pod_management_button_pulse_log.setText(R.string.omnipod_pod_management_button_read_pulse_log)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
omnipod_pod_management_button_activate_pod.isEnabled = false
|
||||
omnipod_pod_management_button_deactivate_pod.isEnabled = false
|
||||
if (discardButtonEnabled) {
|
||||
omnipod_pod_management_button_discard_pod.isEnabled = false
|
||||
}
|
||||
if (pulseLogButtonEnabled) {
|
||||
omnipod_pod_management_button_pulse_log.isEnabled = false
|
||||
omnipod_pod_management_button_pulse_log.setText(R.string.omnipod_pod_management_button_read_pulse_log)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun displayErrorDialog(title: String, message: String, withSound: Boolean) {
|
||||
context.let {
|
||||
val i = Intent(it, ErrorHelperActivity::class.java)
|
||||
i.putExtra("soundid", if (withSound) R.raw.boluserror else 0)
|
||||
i.putExtra("status", message)
|
||||
i.putExtra("title", title)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
it.startActivity(i)
|
||||
}
|
||||
}
|
||||
|
||||
private fun displayNotConfiguredDialog() {
|
||||
context?.let {
|
||||
UIRunnable(Runnable {
|
||||
OKDialog.show(it, resourceHelper.gs(R.string.omnipod_warning),
|
||||
resourceHelper.gs(R.string.omnipod_error_operation_not_possible_no_configuration), null)
|
||||
}).run()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
30
omnipod/src/main/res/drawable/ic_rl_stats.xml
Normal file
30
omnipod/src/main/res/drawable/ic_rl_stats.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M5.719,19.125L5.719,11.828"
|
||||
android:strokeWidth="2.2677"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#FEAF05"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M9.792,19.125L9.792,8.01"
|
||||
android:strokeWidth="2.2677"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#FEAF05"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M13.865,19.125L13.865,9.51"
|
||||
android:strokeWidth="2.2677"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#FEAF05"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M17.938,19.125L17.938,4.594"
|
||||
android:strokeWidth="2.2677"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#FEAF05"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
|
@ -821,30 +821,6 @@
|
|||
android:paddingRight="0dp"
|
||||
android:text="@string/omnipod_overview_button_test_beep" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/omnipod_overview_button_pulse_log"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="@drawable/ic_pulse_log"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:text="@string/omnipod_overview_button_read_pulse_log"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/omnipod_overview_button_rileylink_stats"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="@drawable/ic_danarstats"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:text="@string/omnipod_overview_button_riley_link_stats"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -92,6 +92,20 @@
|
|||
android:text="@string/omnipod_pod_management_button_discard_pod"
|
||||
android:textAllCaps="false" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/omnipod_pod_management_button_pulse_log"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="40dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginRight="40dp"
|
||||
android:layout_weight="0.5"
|
||||
android:drawableTop="@drawable/ic_pulse_log"
|
||||
android:text="@string/omnipod_pod_management_button_read_pulse_log"
|
||||
android:textAllCaps="false"
|
||||
android:visibility="gone" />
|
||||
|
||||
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
||||
android:id="@+id/omnipod_pod_management_button_pod_history"
|
||||
style="?android:attr/buttonStyle"
|
||||
|
@ -105,6 +119,19 @@
|
|||
android:text="@string/omnipod_pod_management_button_pod_history"
|
||||
android:textAllCaps="false" />
|
||||
|
||||
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
||||
android:id="@+id/omnipod_pod_management_button_rileylink_stats"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="40dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginRight="40dp"
|
||||
android:layout_weight="0.5"
|
||||
android:drawableTop="@drawable/ic_rl_stats"
|
||||
android:text="@string/omnipod_pod_management_button_riley_link_stats"
|
||||
android:textAllCaps="false" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
<string name="omnipod_config_basal_beeps_enabled">Basal beeps enabled</string>
|
||||
<string name="omnipod_config_smb_beeps_enabled">SMB beeps enabled</string>
|
||||
<string name="omnipod_config_tbr_beeps_enabled">TBR beeps enabled</string>
|
||||
<string name="omnipod_config_suspend_delivery_button_enabled">Suspend Delivery button enabled</string>
|
||||
<string name="omnipod_config_pulse_log_button_enabled">Pulse Log button enabled</string>
|
||||
<string name="omnipod_config_test_beep_button_enabled">Test beep button enabled</string>
|
||||
<string name="omnipod_config_rileylink_stats_button_enabled">RileyLink Stats button enabled</string>
|
||||
<string name="omnipod_config_suspend_delivery_button_enabled">Show Suspend Delivery button in Omnipod tab</string>
|
||||
<string name="omnipod_config_pulse_log_button_enabled">Show Pulse Log button in Pod Management menu</string>
|
||||
<string name="omnipod_config_test_beep_button_enabled">Show Test Beep button in Omnipod tab</string>
|
||||
<string name="omnipod_config_rileylink_stats_button_enabled">Show RileyLink Stats button in Pod Management menu</string>
|
||||
<string name="omnipod_config_time_change_enabled">DST/Time zone detection enabled</string>
|
||||
<string name="omnipod_config_expiration_reminder_enabled">Expiration reminder enabled</string>
|
||||
<string name="omnipod_config_expiration_reminder_hours_before_shutdown">Hours before shutdown</string>
|
||||
|
@ -182,7 +182,10 @@
|
|||
<string name="omnipod_pod_management_button_deactivate_pod">Deactivate Pod</string>
|
||||
<string name="omnipod_pod_management_button_discard_pod">Discard Pod</string>
|
||||
<string name="omnipod_pod_management_button_pod_history">Pod history</string>
|
||||
<string name="omnipod_pod_management_discard_pod_state_confirmation">If you discard the Pod, you will not be able to communicate with it anymore. You should only do this when all communication with the Pod persistently fails. If you can still communicate with the Pod, please use the <b>Deactivate Pod</b> option.\n\nIf you wish to proceed, please make sure to remove the Pod from your body!</string>
|
||||
<string name="omnipod_pod_management_button_riley_link_stats">RileyLink stats</string>
|
||||
<string name="omnipod_pod_management_button_read_pulse_log">Read pulse log</string>
|
||||
<string name="omnipod_pod_management_button_reading_pulse_log">Reading pulse log…</string>
|
||||
<string name="omnipod_pod_management_discard_pod_confirmation">If you discard the Pod, you will not be able to communicate with it anymore. You should only do this when all communication with the Pod persistently fails. If you can still communicate with the Pod, please use the <b>Deactivate Pod</b> option.\n\nIf you wish to proceed, please make sure to remove the Pod from your body!</string>
|
||||
|
||||
<!-- Omnipod - Wizard common -->
|
||||
<string name="omnipod_wizard_button_cancel">Cancel</string>
|
||||
|
@ -222,8 +225,6 @@
|
|||
<!-- Omnipod - Overview -->
|
||||
<string name="omnipod_overview_button_set_time">Set time</string>
|
||||
<string name="omnipod_overview_button_suspend_delivery">Suspend</string>
|
||||
<string name="omnipod_overview_button_riley_link_stats">RL stats</string>
|
||||
<string name="omnipod_overview_button_read_pulse_log">Pulse log</string>
|
||||
<string name="omnipod_overview_button_refresh">Refresh</string>
|
||||
<string name="omnipod_overview_button_resume_delivery">Resume delivery</string>
|
||||
<string name="omnipod_overview_button_pod_management">Pod mgmt</string>
|
||||
|
|
Loading…
Reference in a new issue