ComboV2: UI improvements

This commit is contained in:
Milos Kozak 2022-11-25 17:40:28 +01:00
parent c6d01f10bd
commit 963016ef5d
9 changed files with 106 additions and 68 deletions

View file

@ -174,6 +174,12 @@ abstract class PluginsListModule {
@IntKey(140)
abstract fun bindComboPlugin(plugin: ComboPlugin): PluginBase
@Binds
@PumpDriver
@IntoMap
@IntKey(141)
abstract fun bindComboV2Plugin(plugin: ComboV2Plugin): PluginBase
@Binds
@PumpDriver
@IntoMap
@ -432,12 +438,6 @@ abstract class PluginsListModule {
@IntKey(500)
abstract fun bindThemeSwitcherPlugin(plugin: ThemeSwitcherPlugin): PluginBase
@Binds
@PumpDriver
@IntoMap
@IntKey(510)
abstract fun bindComboV2Plugin(plugin: ComboV2Plugin): PluginBase
@Qualifier
annotation class AllConfigs

View file

@ -7,6 +7,6 @@ import info.nightscout.core.ui.R
open class PluginNoSplashAppCompatActivity : DaggerAppCompatActivity() {
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setTheme(R.style.AppTheme_NoActionBar)
setTheme(R.style.AppTheme)
}
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="combopump" translatable="false">Accu-Chek Combo</string>
<string name="combopump" translatable="false">Accu-Chek Combo (Ruffy)</string>
<string name="combopump_shortname" translatable="false">COMBO</string>
<string name="description_pump_combo">Pump integration for Accu-Chek Combo pumps, requires having ruffy installed</string>
<string name="combo_programming_bolus">Programming pump for bolusing</string>

View file

@ -8,7 +8,7 @@
<application>
<activity
android:name="info.nightscout.pump.combov2.activities.ComboV2PairingActivity"
android:label="@string/combov2_pair_with_pump_title"
android:theme="@style/AppTheme" />
android:exported="false"
android:theme="@style/AppTheme.NoActionBar" />
</application>
</manifest>

View file

@ -175,7 +175,7 @@ class ComboV2Plugin @Inject constructor (
/*** Public functions and base class & interface overrides ***/
sealed class DriverState(val label: String) {
sealed class DriverState(@Suppress("unused") val label: String) {
// Initial state when the driver is created.
object NotInitialized : DriverState("notInitialized")
// Driver is disconnected from the pump, or no pump
@ -211,7 +211,7 @@ class ComboV2Plugin @Inject constructor (
object Error : DriverState("error")
}
val driverStateFlow = _driverStateFlow.asStateFlow()
private val driverStateFlow = _driverStateFlow.asStateFlow()
// Used by ComboV2PairingActivity to launch its own
// custom activities that have a result.
@ -228,30 +228,31 @@ class ComboV2Plugin @Inject constructor (
override fun onStart() {
super.onStart()
pumpCoroutineScope.launch {
aapsLogger.debug(LTag.PUMP, "Creating bluetooth interface")
bluetoothInterface = AndroidBluetoothInterface(context)
aapsLogger.debug(LTag.PUMP, "Creating bluetooth interface")
bluetoothInterface = AndroidBluetoothInterface(context)
aapsLogger.debug(LTag.PUMP, "Setting up bluetooth interface")
bluetoothInterface!!.setup()
aapsLogger.debug(LTag.PUMP, "Setting up bluetooth interface")
bluetoothInterface!!.setup()
aapsLogger.debug(LTag.PUMP, "Setting up pump manager")
pumpManager = ComboCtlPumpManager(bluetoothInterface!!, pumpStateStore)
pumpManager!!.setup {
_pairedStateUIFlow.value = false
}
aapsLogger.debug(LTag.PUMP, "Setting up pump manager")
pumpManager = ComboCtlPumpManager(bluetoothInterface!!, pumpStateStore)
pumpManager!!.setup {
_pairedStateUIFlow.value = false
// UI flows that must have defined values right
// at start are initialized here.
// The paired state UI flow is special in that it is also
// used as the backing store for the isPaired() function,
// so setting up that UI state flow equals updating that
// paired state.
val paired = pumpManager!!.getPairedPumpAddresses().isNotEmpty()
_pairedStateUIFlow.value = paired
setDriverState(DriverState.Disconnected)
}
// UI flows that must have defined values right
// at start are initialized here.
// The paired state UI flow is special in that it is also
// used as the backing store for the isPaired() function,
// so setting up that UI state flow equals updating that
// paired state.
val paired = pumpManager!!.getPairedPumpAddresses().isNotEmpty()
_pairedStateUIFlow.value = paired
setDriverState(DriverState.Disconnected)
}
override fun onStop() {

View file

@ -10,9 +10,9 @@ import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.comboctl.base.BasicProgressStage
import info.nightscout.comboctl.base.PairingPIN
import info.nightscout.core.ui.activities.PluginNoSplashAppCompatActivity
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.pump.combov2.ComboV2Plugin
import info.nightscout.pump.combov2.R
@ -26,7 +26,8 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import javax.inject.Inject
class ComboV2PairingActivity : PluginNoSplashAppCompatActivity() {
class ComboV2PairingActivity : DaggerAppCompatActivity() {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var combov2Plugin: ComboV2Plugin
@ -196,7 +197,7 @@ class ComboV2PairingActivity : PluginNoSplashAppCompatActivity() {
if (stage == BasicProgressStage.ComboPairingKeyAndPinRequested) {
binding.combov2PinEntryUi.visibility = View.VISIBLE
} else
binding.combov2PinEntryUi.visibility = View.INVISIBLE
binding.combov2PinEntryUi.visibility = View.GONE
// Scanning for the pump can take a long time and happens at the
// beginning, so set the progress bar to indeterminate during that
@ -211,7 +212,7 @@ class ComboV2PairingActivity : PluginNoSplashAppCompatActivity() {
combov2Plugin.previousPairingAttemptFailedFlow
.onEach { previousAttemptFailed ->
binding.combov2PinFailureIndicator.visibility =
if (previousAttemptFailed) View.VISIBLE else View.INVISIBLE
if (previousAttemptFailed) View.VISIBLE else View.GONE
}
.launchIn(this)
}

View file

@ -124,6 +124,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:layout_height="match_parent"
android:orientation="horizontal">

View file

@ -1,16 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<FrameLayout
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".plugins.pump.combov2.activities.ComboV2PairingActivity">
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="?attr/activity_title_backgroundColor"
android:orientation="horizontal"
android:padding="5dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="42dp"
android:layout_height="42dp"
android:importantForAccessibility="no"
android:scaleType="fitXY"
app:srcCompat="@drawable/ic_combo_128" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="@string/combov2_pair_with_pump_title"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
</androidx.appcompat.widget.LinearLayoutCompat>
<ScrollView
android:visibility="visible"
android:id="@+id/combov2_pairing_section_initial"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
@ -44,10 +79,10 @@
</ScrollView>
<ScrollView
android:visibility="gone"
android:id="@+id/combov2_pairing_section_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
@ -91,13 +126,13 @@
android:id="@+id/combov2_current_pairing_step_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="20dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="20dp"
android:background="@color/pumpStatusBackground"
android:gravity="center"
android:padding="16dp"
android:background="@color/pumpStatusBackground"
android:text=""
android:textSize="16sp" />
@ -106,27 +141,27 @@
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="20dp"
android:max="100"
android:maxHeight="5dp"
android:minHeight="3dp"
android:max="100" />
android:minHeight="3dp" />
<LinearLayout
android:id="@+id/combov2_pin_entry_ui"
android:visibility="invisible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center_horizontal"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
@ -140,12 +175,12 @@
android:id="@+id/combov2_pin_entry_edit"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:maxLength="12"
android:inputType="number"
android:digits="0123456789 "
android:minHeight="48dp"
android:hint="@string/combov2_pin_hint"
android:autofillHints="@string/combov2_pin_entry_hint"
android:digits="0123456789 "
android:hint="@string/combov2_pin_hint"
android:inputType="number"
android:maxLength="12"
android:minHeight="48dp"
android:text="" />
<Button
@ -158,14 +193,14 @@
<TextView
android:id="@+id/combov2_pin_failure_indicator"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:gravity="center"
android:text="@string/combov2_pairing_pin_failure"
android:textSize="16sp" />
android:textSize="16sp"
android:visibility="gone" />
</LinearLayout>
@ -188,18 +223,18 @@
</ScrollView>
<LinearLayout
android:visibility="gone"
android:id="@+id/combov2_pairing_section_finished"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:gravity="center"
android:padding="16dp"
android:text="@string/combov2_pairing_finished_successfully"
android:textSize="16sp" />
@ -220,19 +255,19 @@
</LinearLayout>
<LinearLayout
android:visibility="gone"
android:id="@+id/combov2_pairing_section_aborted"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/combov2_pairing_aborted_reason_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:gravity="center"
android:padding="16dp"
android:text=""
android:textSize="16sp" />
@ -252,5 +287,5 @@
</LinearLayout>
</FrameLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</layout>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="combov2_plugin_name">Accu-Chek Combo (new plugin)</string>
<string name="combov2_plugin_name">Accu-Chek Combo</string>
<string name="combov2_plugin_shortname" translatable="false">COMBOV2</string>
<string name="combov2_plugin_description">Pump integration for Accu-Chek Combo pumps, successor to Ruffy (EXPERIMENTAL)</string>
<string name="combov2_plugin_description">Native pump integration for Accu-Chek Combo pumps</string>
<string name="combov2_could_not_connect">Could not connect to the pump</string>
<string name="combov2_not_paired">Not paired to a pump</string>
<string name="combov2_pump_terminated_connection">Pump terminated connection</string>