Merge remote-tracking branch 'Nightscout/dev' into LoopDialog
This commit is contained in:
commit
b4710b4936
47 changed files with 717 additions and 711 deletions
|
@ -10,7 +10,7 @@ import info.nightscout.androidaps.plugins.general.maintenance.activities.PrefImp
|
|||
import info.nightscout.androidaps.plugins.general.openhumans.OpenHumansLoginActivity
|
||||
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity
|
||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEScanActivity
|
||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RileyLinkBLEConfigActivity
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightAlertActivity
|
||||
import info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingActivity
|
||||
|
@ -33,7 +33,7 @@ abstract class ActivitiesModule {
|
|||
@ContributesAndroidInjector abstract fun contributesQuickWizardListActivity(): QuickWizardListActivity
|
||||
@ContributesAndroidInjector abstract fun contributesRequestDexcomPermissionActivity(): RequestDexcomPermissionActivity
|
||||
@ContributesAndroidInjector abstract fun contributesRileyLinkStatusActivity(): RileyLinkStatusActivity
|
||||
@ContributesAndroidInjector abstract fun contributesRileyLinkBLEScanActivity(): RileyLinkBLEScanActivity
|
||||
@ContributesAndroidInjector abstract fun contributesRileyLinkBLEConfigActivity(): RileyLinkBLEConfigActivity
|
||||
@ContributesAndroidInjector abstract fun contributesSetupWizardActivity(): SetupWizardActivity
|
||||
@ContributesAndroidInjector abstract fun contributesSingleFragmentActivity(): SingleFragmentActivity
|
||||
@ContributesAndroidInjector abstract fun contributesSmsCommunicatorOtpActivity(): SmsCommunicatorOtpActivity
|
||||
|
|
|
@ -146,7 +146,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
treatments_wizard_bgtrendcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
treatments_wizard_sbcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
|
||||
|
||||
val showCalc = sp.getBoolean(resourceHelper.gs(R.string.key_wizard_calculation_visible), false)
|
||||
val showCalc = sp.getBoolean(R.string.key_wizard_calculation_visible, false)
|
||||
treatments_wizard_delimiter.visibility = showCalc.toVisibility()
|
||||
treatments_wizard_resulttable.visibility = showCalc.toVisibility()
|
||||
treatments_wizard_calculationcheckbox.isChecked = showCalc
|
||||
|
@ -211,8 +211,8 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
}
|
||||
|
||||
private fun loadCheckedStates() {
|
||||
treatments_wizard_bgtrendcheckbox.isChecked = sp.getBoolean(resourceHelper.gs(R.string.key_wizard_include_trend_bg), false)
|
||||
treatments_wizard_cobcheckbox.isChecked = sp.getBoolean(resourceHelper.gs(R.string.key_wizard_include_cob), false)
|
||||
treatments_wizard_bgtrendcheckbox.isChecked = sp.getBoolean(R.string.key_wizard_include_trend_bg, false)
|
||||
treatments_wizard_cobcheckbox.isChecked = sp.getBoolean(R.string.key_wizard_include_cob, false)
|
||||
}
|
||||
|
||||
private fun initDialog() {
|
||||
|
|
|
@ -267,8 +267,8 @@ public class DetermineBasalAdapterSMBJS {
|
|||
mProfile.put("low_temptarget_lowers_sensitivity", false);
|
||||
|
||||
|
||||
mProfile.put("sensitivity_raises_target", sp.getBoolean(resourceHelper.gs(R.string.key_sensitivity_raises_target),SMBDefaults.sensitivity_raises_target));
|
||||
mProfile.put("resistance_lowers_target", sp.getBoolean(resourceHelper.gs(R.string.key_resistance_lowers_target),SMBDefaults.resistance_lowers_target));
|
||||
mProfile.put("sensitivity_raises_target", sp.getBoolean(R.string.key_sensitivity_raises_target,SMBDefaults.sensitivity_raises_target));
|
||||
mProfile.put("resistance_lowers_target", sp.getBoolean(R.string.key_resistance_lowers_target,SMBDefaults.resistance_lowers_target));
|
||||
mProfile.put("adv_target_adjustments", SMBDefaults.adv_target_adjustments);
|
||||
mProfile.put("exercise_mode", SMBDefaults.exercise_mode);
|
||||
mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target);
|
||||
|
@ -284,7 +284,7 @@ public class DetermineBasalAdapterSMBJS {
|
|||
mProfile.put("enableUAM", uamAllowed);
|
||||
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
||||
|
||||
boolean smbEnabled = sp.getBoolean(resourceHelper.gs(R.string.key_use_smb), false);
|
||||
boolean smbEnabled = sp.getBoolean(R.string.key_use_smb, false);
|
||||
mProfile.put("SMBInterval", sp.getInt(R.string.key_smbinterval, SMBDefaults.SMBInterval));
|
||||
mProfile.put("enableSMB_with_COB", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_COB, false));
|
||||
mProfile.put("enableSMB_with_temptarget", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_temptarget, false));
|
||||
|
|
|
@ -123,7 +123,7 @@ class ImportExportPrefs @Inject constructor(
|
|||
}
|
||||
|
||||
private fun prefsEncryptionIsDisabled() =
|
||||
buildHelper.isEngineeringMode() && !sp.getBoolean(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs), true)
|
||||
buildHelper.isEngineeringMode() && !sp.getBoolean(R.string.key_maintenance_encrypt_exported_prefs, true)
|
||||
|
||||
private fun askForMasterPass(activity: FragmentActivity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
|
||||
passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { password ->
|
||||
|
|
|
@ -77,7 +77,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
|
|||
aapsLogger.debug(LTag.CORE, "KeepAlive scheduled")
|
||||
SystemClock.sleep(5000) // wait for app initialization
|
||||
localAlertUtils.shortenSnoozeInterval()
|
||||
localAlertUtils.presnoozeAlarms()
|
||||
localAlertUtils.preSnoozeAlarms()
|
||||
val am = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||
val i = Intent(context, KeepAliveReceiver::class.java)
|
||||
val pi = PendingIntent.getBroadcast(context, 0, i, 0)
|
||||
|
|
|
@ -5,19 +5,21 @@ import info.nightscout.androidaps.Constants
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* Created by adrian on 17/12/17.
|
||||
|
@ -31,48 +33,49 @@ class LocalAlertUtils @Inject constructor(
|
|||
private val activePlugin: ActivePluginProvider,
|
||||
private val profileFunction: ProfileFunction,
|
||||
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin,
|
||||
private val smsCommunicatorPlugin: SmsCommunicatorPlugin,
|
||||
private val config: Config,
|
||||
private val nsUpload: NSUpload,
|
||||
private val dateUtil: DateUtil
|
||||
) {
|
||||
|
||||
fun missedReadingsThreshold(): Long {
|
||||
return T.mins(sp.getInt(resourceHelper.gs(R.string.key_missed_bg_readings_threshold_minutes), Constants.DEFAULT_MISSED_BG_READINGS_THRESHOLD_MINUTES).toLong()).msecs()
|
||||
private fun missedReadingsThreshold(): Long {
|
||||
return T.mins(sp.getInt(R.string.key_missed_bg_readings_threshold_minutes, Constants.DEFAULT_MISSED_BG_READINGS_THRESHOLD_MINUTES).toLong()).msecs()
|
||||
}
|
||||
|
||||
fun pumpUnreachableThreshold(): Long {
|
||||
return T.mins(sp.getInt(resourceHelper.gs(R.string.key_pump_unreachable_threshold_minutes), Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong()).msecs()
|
||||
private fun pumpUnreachableThreshold(): Long {
|
||||
return T.mins(sp.getInt(R.string.key_pump_unreachable_threshold_minutes, Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong()).msecs()
|
||||
}
|
||||
|
||||
fun checkPumpUnreachableAlarm(lastConnection: Long, isStatusOutdated: Boolean, isDisconnected: Boolean) {
|
||||
val alarmTimeoutExpired = isAlarmTimeoutExpired(lastConnection, pumpUnreachableThreshold())
|
||||
val nextAlarmOccurrenceReached = sp.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis()
|
||||
if (config.APS && sp.getBoolean(resourceHelper.gs(R.string.key_enable_pump_unreachable_alert), true)
|
||||
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !isDisconnected) {
|
||||
if (config.APS && isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !isDisconnected) {
|
||||
if (sp.getBoolean(R.string.key_enable_pump_unreachable_alert, true)) {
|
||||
aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + dateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated)
|
||||
val n = Notification(Notification.PUMP_UNREACHABLE, resourceHelper.gs(R.string.pump_unreachable), Notification.URGENT)
|
||||
n.soundId = R.raw.alarm
|
||||
sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold())
|
||||
rxBus.send(EventNewNotification(n))
|
||||
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
|
||||
nsUpload.uploadError(n.text)
|
||||
rxBus.send(EventNewNotification(Notification(Notification.PUMP_UNREACHABLE, resourceHelper.gs(R.string.pump_unreachable), Notification.URGENT).also { it.soundId - R.raw.alarm }))
|
||||
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true))
|
||||
nsUpload.uploadError(resourceHelper.gs(R.string.pump_unreachable))
|
||||
}
|
||||
if (sp.getBoolean(R.string.key_smscommunicator_report_pump_ureachable, true))
|
||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(resourceHelper.gs(R.string.pump_unreachable))
|
||||
}
|
||||
if (!isStatusOutdated && !alarmTimeoutExpired) rxBus.send(EventDismissNotification(Notification.PUMP_UNREACHABLE))
|
||||
}
|
||||
|
||||
private fun isAlarmTimeoutExpired(lastConnection: Long, unreachableThreshold: Long): Boolean {
|
||||
if (activePlugin.activePump.pumpDescription.hasCustomUnreachableAlertCheck) {
|
||||
return activePlugin.activePump.isUnreachableAlertTimeoutExceeded(unreachableThreshold)
|
||||
return if (activePlugin.activePump.pumpDescription.hasCustomUnreachableAlertCheck) {
|
||||
activePlugin.activePump.isUnreachableAlertTimeoutExceeded(unreachableThreshold)
|
||||
} else {
|
||||
return lastConnection + pumpUnreachableThreshold() < System.currentTimeMillis()
|
||||
lastConnection + pumpUnreachableThreshold() < System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
/*Presnoozes the alarms with 5 minutes if no snooze exists.
|
||||
/*Pre-snoozes the alarms with 5 minutes if no snooze exists.
|
||||
* Call only at startup!
|
||||
*/
|
||||
fun presnoozeAlarms() {
|
||||
fun preSnoozeAlarms() {
|
||||
if (sp.getLong("nextMissedReadingsAlarm", 0L) < System.currentTimeMillis()) {
|
||||
sp.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + 5 * 60 * 1000)
|
||||
}
|
||||
|
@ -83,10 +86,10 @@ class LocalAlertUtils @Inject constructor(
|
|||
|
||||
fun shortenSnoozeInterval() { //shortens alarm times in case of setting changes or future data
|
||||
var nextMissedReadingsAlarm = sp.getLong("nextMissedReadingsAlarm", 0L)
|
||||
nextMissedReadingsAlarm = Math.min(System.currentTimeMillis() + missedReadingsThreshold(), nextMissedReadingsAlarm)
|
||||
nextMissedReadingsAlarm = min(System.currentTimeMillis() + missedReadingsThreshold(), nextMissedReadingsAlarm)
|
||||
sp.putLong("nextMissedReadingsAlarm", nextMissedReadingsAlarm)
|
||||
var nextPumpDisconnectedAlarm = sp.getLong("nextPumpDisconnectedAlarm", 0L)
|
||||
nextPumpDisconnectedAlarm = Math.min(System.currentTimeMillis() + pumpUnreachableThreshold(), nextPumpDisconnectedAlarm)
|
||||
nextPumpDisconnectedAlarm = min(System.currentTimeMillis() + pumpUnreachableThreshold(), nextPumpDisconnectedAlarm)
|
||||
sp.putLong("nextPumpDisconnectedAlarm", nextPumpDisconnectedAlarm)
|
||||
}
|
||||
|
||||
|
@ -104,7 +107,7 @@ class LocalAlertUtils @Inject constructor(
|
|||
|
||||
fun checkStaleBGAlert() {
|
||||
val bgReading: BgReading? = iobCobCalculatorPlugin.lastBg()
|
||||
if (sp.getBoolean(resourceHelper.gs(R.string.key_enable_missed_bg_readings_alert), false)
|
||||
if (sp.getBoolean(R.string.key_enable_missed_bg_readings_alert, false)
|
||||
&& bgReading != null && bgReading.date + missedReadingsThreshold() < System.currentTimeMillis() && sp.getLong("nextMissedReadingsAlarm", 0L) < System.currentTimeMillis()) {
|
||||
val n = Notification(Notification.BG_READINGS_MISSED, resourceHelper.gs(R.string.missed_bg_readings), Notification.URGENT)
|
||||
n.soundId = R.raw.alarm
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
||||
android:id="@+id/profilehelper_compareprofile"
|
||||
style="@style/ButtonMediumFontStyle"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableStart="@drawable/ic_compare_profiles"
|
||||
|
@ -50,8 +50,8 @@
|
|||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:id="@+id/profilehelper_profiletype_title"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/profiletype"
|
||||
|
@ -173,11 +173,11 @@
|
|||
android:layout_marginStart="10dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
|
||||
|
||||
<Button
|
||||
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
||||
android:id="@+id/profilehelper_copytolocalprofile"
|
||||
style="@style/ButtonMediumFontStyle"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableStart="@drawable/ic_clone_48"
|
||||
android:text="@string/clone_label" />
|
||||
|
||||
|
|
|
@ -83,9 +83,10 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/time_offset"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
@ -116,9 +117,10 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/careportal_newnstreatment_duration_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
@ -149,9 +151,10 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/overview_carbs_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
|
|
@ -81,9 +81,10 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text=""
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
@ -115,9 +116,10 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/careportal_newnstreatment_duration_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
@ -148,9 +150,10 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/careportal_newnstreatment_percentage_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
@ -181,9 +184,10 @@
|
|||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:width="120dp"
|
||||
android:padding="10dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/careportal_newnstreatment_timeshift_label"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="bold" />
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
android:layout_marginEnd="5dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:text="Profile"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
|||
android:layout_gravity="end"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:text="TempTarget"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/mdtp_white" />
|
||||
|
@ -53,8 +53,8 @@
|
|||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:text="@string/initializing"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
|
|
|
@ -925,8 +925,8 @@
|
|||
<string name="diawarning">Please remember: new insulin profiles require DIA at least 5h. DIA 5–6h on new profile is equal to DIA 3h on old insulin profiles.</string>
|
||||
<string name="setupwizard_profile_description">Please select source of profile. If patient is a child you should use NS profile. If there is nobody following you on Nightscout you will probably prefer Local profile. Please remember that you are only selecting the profile source. To use it you must activate it by executing \"Profile switch\"</string>
|
||||
<string name="setupwizard_aps_description">Select one from availables algorithms. They are sorted from oldest to newest. Newer algorithm is usually more powerful and more aggressive. Thus if you are new looper you may probably start with AMA and not with latest one. Do not forget to read the OpenAPS documentation and configure it before use.</string>
|
||||
<string name="setupwizard_pump_waiting_for_riley_link_connection">Waiting for RileyLink connection…\n</string>
|
||||
<string name="setupwizard_pump_pump_not_initialized"><b>Note:</b> You can continue setup once the pump has been initialized.\n</string>
|
||||
<string name="setupwizard_pump_waiting_for_riley_link_connection">Please configure your RileyLink below. After selecting a RileyLink, it will be possible to continue setup once the RileyLink status is \"Connected\". This might take a minute.\n</string>
|
||||
<string name="setupwizard_pump_pump_not_initialized"><b>Note:</b> You can continue setup once the pump has been set up.\n</string>
|
||||
<string name="startobjective">Start your first objective</string>
|
||||
<string name="permission">Permission</string>
|
||||
<string name="askforpermission">Ask for permission</string>
|
||||
|
@ -1422,5 +1422,8 @@
|
|||
<string name="copytolocalprofile_invalid">Unable to create local profile. Profile is invalid.</string>
|
||||
<string name="cta_dont_kill_my_app_info">Don\'t kill my app?</string>
|
||||
<string name="alarm">Alarm</string>
|
||||
<string name="key_smscommunicator_report_pump_ureachable" translatable="false">smscommunicator_report_pump_ureachable</string>
|
||||
<string name="smscommunicator_report_pump_ureachable_summary">Send SMS if unreachable pump event is triggered</string>
|
||||
<string name="smscommunicator_pump_ureachable">Report pump ureachable</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -52,5 +52,5 @@
|
|||
<item name="android:textColor">#ff0000</item>
|
||||
</style>
|
||||
|
||||
<style name="ProfileHelperAppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"/>
|
||||
<style name="ProfileHelperAppTheme" parent="Theme.MaterialComponents.NoActionBar"/>
|
||||
</resources>
|
||||
|
|
|
@ -49,6 +49,12 @@
|
|||
<intent android:action="info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity" />
|
||||
</Preference>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_smscommunicator_report_pump_ureachable"
|
||||
android:summary="@string/smscommunicator_report_pump_ureachable_summary"
|
||||
android:title="@string/smscommunicator_pump_ureachable" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
|
@ -30,7 +30,7 @@ public class Constants {
|
|||
|
||||
// Circadian Percentage Profile
|
||||
public static final int CPP_MIN_PERCENTAGE = 30;
|
||||
public static final int CPP_MAX_PERCENTAGE = 200;
|
||||
public static final int CPP_MAX_PERCENTAGE = 250;
|
||||
public static final int CPP_MIN_TIMESHIFT = -6;
|
||||
public static final int CPP_MAX_TIMESHIFT = 23;
|
||||
|
||||
|
|
|
@ -132,12 +132,10 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
setTextWatcher(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,11 +151,10 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
}
|
||||
});
|
||||
|
||||
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
|
||||
@Override public void onFocusChange(View v, boolean hasFocus) {
|
||||
editText.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
focused = hasFocus;
|
||||
if (!focused) getValue(); // check min/max
|
||||
updateEditText();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -204,12 +201,12 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
editText.addTextChangedListener(textWatcher);
|
||||
}
|
||||
|
||||
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, Button okButton) {
|
||||
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formatter, boolean allowZero, Button okButton) {
|
||||
this.value = initValue;
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
this.step = step;
|
||||
this.formatter = formater;
|
||||
this.formatter = formatter;
|
||||
this.allowZero = allowZero;
|
||||
callValueChangedListener();
|
||||
this.okButton = okButton;
|
||||
|
@ -234,6 +231,14 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
}
|
||||
|
||||
public Double getValue() {
|
||||
if (value > maxValue) {
|
||||
value = maxValue;
|
||||
ToastUtils.showToastInUiThread(getContext(), getContext().getString(R.string.youareonallowedlimit));
|
||||
}
|
||||
if (value < minValue) {
|
||||
value = minValue;
|
||||
ToastUtils.showToastInUiThread(getContext(), getContext().getString(R.string.youareonallowedlimit));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="compact_height">30dp</dimen>
|
||||
<dimen name="compact_height">42dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
<dimen name="appbar_padding_top">8dp</dimen>
|
||||
</resources>
|
||||
|
|
|
@ -184,7 +184,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
|||
}
|
||||
|
||||
protected void getBTSocketForSelectedPump() {
|
||||
mDevName = sp.getString(resourceHelper.gs(R.string.key_danar_bt_name), "");
|
||||
mDevName = sp.getString(R.string.key_danar_bt_name, "");
|
||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
if (bluetoothAdapter != null) {
|
||||
|
|
|
@ -96,8 +96,9 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
|
||||
setPumpIDString(sp.getString(MedtronicConst.Prefs.PumpSerial, "000000"));
|
||||
|
||||
// get most recently used RileyLink address
|
||||
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||
// get most recently used RileyLink address and name
|
||||
rileyLinkServiceData.rileyLinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||
rileyLinkServiceData.rileyLinkName = sp.getString(RileyLinkConst.Prefs.RileyLinkName, "");
|
||||
|
||||
rfspy.startReader();
|
||||
|
||||
|
@ -180,7 +181,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
}
|
||||
|
||||
|
||||
public boolean verifyConfiguration() {
|
||||
public boolean verifyConfiguration(boolean forceRileyLinkAddressRenewal) {
|
||||
try {
|
||||
String regexSN = "[0-9]{6}";
|
||||
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||
|
@ -316,7 +317,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
//boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(resourceHelper.gs(R.string.common_on));
|
||||
//MedtronicHistoryData.doubleBolusDebug = bolusDebug;
|
||||
|
||||
reconfigureService();
|
||||
reconfigureService(forceRileyLinkAddressRenewal);
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -327,7 +328,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean reconfigureService() {
|
||||
private boolean reconfigureService(boolean forceRileyLinkAddressRenewal) {
|
||||
|
||||
if (!inPreInit) {
|
||||
|
||||
|
@ -336,7 +337,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
serialChanged = false;
|
||||
}
|
||||
|
||||
if (rileyLinkAddressChanged) {
|
||||
if (rileyLinkAddressChanged || forceRileyLinkAddressRenewal) {
|
||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this);
|
||||
rileyLinkAddressChanged = false;
|
||||
}
|
||||
|
@ -380,6 +381,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
public boolean setNotInPreInit() {
|
||||
this.inPreInit = false;
|
||||
|
||||
return reconfigureService();
|
||||
return reconfigureService(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
<string name="medtronic_notification_check_time_date">Pump clock update needed</string> <!-- combo_notification_check_time_date -->
|
||||
<string name="common_on">On</string>
|
||||
<string name="common_off">Off</string>
|
||||
<string name="mdt_last_bolus" translatable="false">%1$.1f %2$s (%3$s)</string>
|
||||
<string name="pump_time_updated">Pump time updated</string>
|
||||
<string name="key_set_neutral_temps" translatable="false">set_neutral_temps</string>
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
android:key="@string/key_rileylink_mac_address"
|
||||
android:summary=""
|
||||
android:title="RileyLink Configuration">
|
||||
<intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
|
||||
<intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEConfigActivity" />
|
||||
</Preference>
|
||||
|
||||
<SwitchPreference
|
||||
|
|
|
@ -72,7 +72,8 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
rileyLinkServiceData.targetDevice = RileyLinkTargetDevice.Omnipod;
|
||||
rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod;
|
||||
|
||||
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||
rileyLinkServiceData.rileyLinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||
rileyLinkServiceData.rileyLinkName = sp.getString(RileyLinkConst.Prefs.RileyLinkName, "");
|
||||
|
||||
rfspy.startReader();
|
||||
|
||||
|
@ -109,7 +110,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyConfiguration() {
|
||||
public boolean verifyConfiguration(boolean forceRileyLinkAddressRenewal) {
|
||||
try {
|
||||
errorDescription = null;
|
||||
|
||||
|
@ -133,7 +134,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
|
||||
rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod;
|
||||
|
||||
reconfigureService();
|
||||
reconfigureService(forceRileyLinkAddressRenewal);
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -144,9 +145,9 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean reconfigureService() {
|
||||
private boolean reconfigureService(boolean forceRileyLinkAddressRenewal) {
|
||||
if (!inPreInit) {
|
||||
if (rileyLinkAddressChanged) {
|
||||
if (rileyLinkAddressChanged || forceRileyLinkAddressRenewal) {
|
||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this);
|
||||
rileyLinkAddressChanged = false;
|
||||
}
|
||||
|
@ -158,6 +159,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
public boolean setNotInPreInit() {
|
||||
this.inPreInit = false;
|
||||
|
||||
return reconfigureService();
|
||||
return reconfigureService(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -596,7 +596,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
|
||||
// FIXME ideally we should just have access to LocalAlertUtils here
|
||||
private fun getPumpUnreachableTimeout(): Duration {
|
||||
return Duration.standardMinutes(sp.getInt(resourceHelper.gs(R.string.key_pump_unreachable_threshold_minutes), Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong())
|
||||
return Duration.standardMinutes(sp.getInt(R.string.key_pump_unreachable_threshold_minutes, Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong())
|
||||
}
|
||||
|
||||
inner class DisplayResultDialogCallback(private val errorMessagePrefix: String, private val withSoundOnError: Boolean) : Callback() {
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
<string name="omnipod_overview_last_bolus_value" translatable="false">%1$.2f %2$s (%3$s)</string>
|
||||
|
||||
<!-- Omnipod - Preferences -->
|
||||
<string name="omnipod_config_riley_link_configuration">RileyLink Configuration</string>
|
||||
<string name="omnipod_config_bolus_beeps_enabled">Bolus beeps enabled</string>
|
||||
<string name="omnipod_config_basal_beeps_enabled">Basal beeps enabled</string>
|
||||
<string name="omnipod_config_smb_beeps_enabled">SMB beeps enabled</string>
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
<Preference
|
||||
android:enabled="true"
|
||||
android:key="@string/key_rileylink_mac_address"
|
||||
android:summary=""
|
||||
android:title="RileyLink Configuration">
|
||||
<intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
|
||||
android:title="@string/omnipod_config_riley_link_configuration">
|
||||
<intent android:action="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEConfigActivity" />
|
||||
</Preference>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
<application>
|
||||
<activity android:name=".dialog.RileyLinkBLEScanActivity">
|
||||
<activity android:name=".dialog.RileyLinkBLEConfigActivity">
|
||||
<intent-filter>
|
||||
<action android:name="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />
|
||||
<action android:name="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEConfigActivity" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".hw.rileylink.dialog.RileyLinkStatusActivity"
|
||||
android:label="@string/title_activity_rileylink_settings"
|
||||
|
|
|
@ -0,0 +1,359 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.dialog;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.le.BluetoothLeScanner;
|
||||
import android.bluetooth.le.ScanCallback;
|
||||
import android.bluetooth.le.ScanFilter;
|
||||
import android.bluetooth.le.ScanResult;
|
||||
import android.bluetooth.le.ScanSettings;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.ParcelUuid;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.common.R;
|
||||
import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
// IMPORTANT: This activity needs to be called from RileyLinkSelectPreference (see pref_medtronic.xml as example)
|
||||
public class RileyLinkBLEConfigActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject SP sp;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject BlePreCheck blePrecheck;
|
||||
@Inject RileyLinkUtil rileyLinkUtil;
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
|
||||
private static final String TAG = "RileyLinkBLEConfigActivity";
|
||||
private static final long SCAN_PERIOD_MILLIS = 15_000;
|
||||
|
||||
private ScanSettings settings;
|
||||
private List<ScanFilter> filters;
|
||||
private TextView currentlySelectedRileyLinkName;
|
||||
private TextView currentlySelectedRileyLinkAddress;
|
||||
private Button buttonRemoveRileyLink;
|
||||
private Button buttonStartScan;
|
||||
private Button buttonStopScan;
|
||||
private BluetoothAdapter bluetoothAdapter;
|
||||
private BluetoothLeScanner bleScanner;
|
||||
private LeDeviceListAdapter deviceListAdapter;
|
||||
private Handler handler;
|
||||
public boolean scanning;
|
||||
|
||||
private final Runnable stopScanAfterTimeoutRunnable = () -> {
|
||||
if (scanning) {
|
||||
stopLeDeviceScan();
|
||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this); // Reconnect current RL
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.riley_link_ble_config_activity);
|
||||
|
||||
// Initializes Bluetooth adapter.
|
||||
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
deviceListAdapter = new LeDeviceListAdapter();
|
||||
handler = new Handler();
|
||||
currentlySelectedRileyLinkName = findViewById(R.id.riley_link_ble_config_currently_selected_riley_link_name);
|
||||
currentlySelectedRileyLinkAddress = findViewById(R.id.riley_link_ble_config_currently_selected_riley_link_address);
|
||||
buttonRemoveRileyLink = findViewById(R.id.riley_link_ble_config_button_remove_riley_link);
|
||||
buttonStartScan = findViewById(R.id.riley_link_ble_config_scan_start);
|
||||
buttonStopScan = findViewById(R.id.riley_link_ble_config_button_scan_stop);
|
||||
ListView deviceList = findViewById(R.id.riley_link_ble_config_scan_device_list);
|
||||
deviceList.setAdapter(deviceListAdapter);
|
||||
deviceList.setOnItemClickListener((parent, view, position, id) -> {
|
||||
// stop scanning if still active
|
||||
if (scanning) {
|
||||
stopLeDeviceScan();
|
||||
}
|
||||
|
||||
String bleAddress = ((TextView) view.findViewById(R.id.riley_link_ble_config_scan_item_device_address)).getText().toString();
|
||||
String deviceName = ((TextView) view.findViewById(R.id.riley_link_ble_config_scan_item_device_name)).getText().toString();
|
||||
|
||||
sp.putString(RileyLinkConst.Prefs.RileyLinkAddress, bleAddress);
|
||||
sp.putString(RileyLinkConst.Prefs.RileyLinkName, deviceName);
|
||||
|
||||
RileyLinkPumpDevice rileyLinkPump = (RileyLinkPumpDevice) activePlugin.getActivePump();
|
||||
rileyLinkPump.getRileyLinkService().verifyConfiguration(true); // force reloading of address to assure that the RL gets reconnected (even if the address didn't change)
|
||||
rileyLinkPump.triggerPumpConfigurationChangedEvent();
|
||||
|
||||
finish();
|
||||
});
|
||||
|
||||
buttonStartScan.setOnClickListener(view -> {
|
||||
// disable currently selected RL, so that we can discover it
|
||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect, this);
|
||||
startLeDeviceScan();
|
||||
});
|
||||
|
||||
buttonStopScan.setOnClickListener(view -> {
|
||||
if (scanning) {
|
||||
stopLeDeviceScan();
|
||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this); // Reconnect current RL
|
||||
}
|
||||
});
|
||||
|
||||
buttonRemoveRileyLink.setOnClickListener(view -> new AlertDialog.Builder(this)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.setTitle(getString(R.string.riley_link_ble_config_remove_riley_link_confirmation_title))
|
||||
.setMessage(getString(R.string.riley_link_ble_config_remove_riley_link_confirmation))
|
||||
.setPositiveButton(getString(R.string.riley_link_common_yes), (dialog, which) -> {
|
||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect, RileyLinkBLEConfigActivity.this);
|
||||
sp.remove(RileyLinkConst.Prefs.RileyLinkAddress);
|
||||
sp.remove(RileyLinkConst.Prefs.RileyLinkName);
|
||||
updateCurrentlySelectedRileyLink();
|
||||
})
|
||||
.setNegativeButton(getString(R.string.riley_link_common_no), null)
|
||||
.show());
|
||||
}
|
||||
|
||||
private void updateCurrentlySelectedRileyLink() {
|
||||
String address = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||
if (StringUtils.isEmpty(address)) {
|
||||
currentlySelectedRileyLinkName.setText(R.string.riley_link_ble_config_no_riley_link_selected);
|
||||
currentlySelectedRileyLinkAddress.setVisibility(View.GONE);
|
||||
buttonRemoveRileyLink.setVisibility(View.GONE);
|
||||
} else {
|
||||
currentlySelectedRileyLinkAddress.setVisibility(View.VISIBLE);
|
||||
buttonRemoveRileyLink.setVisibility(View.VISIBLE);
|
||||
|
||||
currentlySelectedRileyLinkName.setText(sp.getString(RileyLinkConst.Prefs.RileyLinkName, "RileyLink (?)"));
|
||||
currentlySelectedRileyLinkAddress.setText(address);
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected void onResume() {
|
||||
super.onResume();
|
||||
prepareForScanning();
|
||||
|
||||
updateCurrentlySelectedRileyLink();
|
||||
}
|
||||
|
||||
@Override protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (scanning) {
|
||||
stopLeDeviceScan();
|
||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this); // Reconnect current RL
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareForScanning() {
|
||||
boolean checkOK = blePrecheck.prerequisitesCheck(this);
|
||||
|
||||
if (checkOK) {
|
||||
bleScanner = bluetoothAdapter.getBluetoothLeScanner();
|
||||
settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
|
||||
filters = Collections.singletonList(new ScanFilter.Builder().setServiceUuid(
|
||||
ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build());
|
||||
}
|
||||
}
|
||||
|
||||
private final ScanCallback bleScanCallback = new ScanCallback() {
|
||||
@Override
|
||||
public void onScanResult(int callbackType, final ScanResult scanRecord) {
|
||||
Log.d(TAG, scanRecord.toString());
|
||||
|
||||
runOnUiThread(() -> {
|
||||
if (addDevice(scanRecord))
|
||||
deviceListAdapter.notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatchScanResults(final List<ScanResult> results) {
|
||||
runOnUiThread(() -> {
|
||||
boolean added = false;
|
||||
|
||||
for (ScanResult result : results) {
|
||||
if (addDevice(result))
|
||||
added = true;
|
||||
}
|
||||
|
||||
if (added)
|
||||
deviceListAdapter.notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
private boolean addDevice(ScanResult result) {
|
||||
BluetoothDevice device = result.getDevice();
|
||||
|
||||
List<ParcelUuid> serviceUuids = result.getScanRecord().getServiceUuids();
|
||||
|
||||
if (serviceUuids == null || serviceUuids.size() == 0) {
|
||||
Log.v(TAG, "Device " + device.getAddress() + " has no serviceUuids (Not RileyLink).");
|
||||
} else if (serviceUuids.size() > 1) {
|
||||
Log.v(TAG, "Device " + device.getAddress() + " has too many serviceUuids (Not RileyLink).");
|
||||
} else {
|
||||
String uuid = serviceUuids.get(0).getUuid().toString().toLowerCase();
|
||||
|
||||
if (uuid.equals(GattAttributes.SERVICE_RADIO)) {
|
||||
Log.i(TAG, "Found RileyLink with address: " + device.getAddress());
|
||||
deviceListAdapter.addDevice(result);
|
||||
return true;
|
||||
} else {
|
||||
Log.v(TAG, "Device " + device.getAddress() + " has incorrect uuid (Not RileyLink).");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanFailed(int errorCode) {
|
||||
Log.e("Scan Failed", "Error Code: " + errorCode);
|
||||
Toast.makeText(RileyLinkBLEConfigActivity.this, resourceHelper.gs(R.string.riley_link_ble_config_scan_error, errorCode),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private void startLeDeviceScan() {
|
||||
if (bleScanner == null) {
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "startLeDeviceScan failed: bleScanner is null");
|
||||
return;
|
||||
}
|
||||
|
||||
deviceListAdapter.clear();
|
||||
deviceListAdapter.notifyDataSetChanged();
|
||||
|
||||
handler.postDelayed(stopScanAfterTimeoutRunnable, SCAN_PERIOD_MILLIS);
|
||||
|
||||
buttonStartScan.setEnabled(false);
|
||||
buttonStopScan.setVisibility(View.VISIBLE);
|
||||
|
||||
scanning = true;
|
||||
bleScanner.startScan(filters, settings, bleScanCallback);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "startLeDeviceScan: Scanning Start");
|
||||
Toast.makeText(RileyLinkBLEConfigActivity.this, R.string.riley_link_ble_config_scan_scanning, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private void stopLeDeviceScan() {
|
||||
if (scanning) {
|
||||
scanning = false;
|
||||
|
||||
bleScanner.stopScan(bleScanCallback);
|
||||
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "stopLeDeviceScan: Scanning Stop");
|
||||
Toast.makeText(this, R.string.riley_link_ble_config_scan_finished, Toast.LENGTH_SHORT).show();
|
||||
handler.removeCallbacks(stopScanAfterTimeoutRunnable);
|
||||
}
|
||||
|
||||
buttonStartScan.setEnabled(true);
|
||||
buttonStopScan.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private class LeDeviceListAdapter extends BaseAdapter {
|
||||
private final ArrayList<BluetoothDevice> mLeDevices;
|
||||
private final Map<BluetoothDevice, Integer> rileyLinkDevices;
|
||||
private final LayoutInflater mInflator;
|
||||
|
||||
public LeDeviceListAdapter() {
|
||||
super();
|
||||
mLeDevices = new ArrayList<>();
|
||||
rileyLinkDevices = new HashMap<>();
|
||||
mInflator = RileyLinkBLEConfigActivity.this.getLayoutInflater();
|
||||
}
|
||||
|
||||
public void addDevice(ScanResult result) {
|
||||
if (!mLeDevices.contains(result.getDevice())) {
|
||||
mLeDevices.add(result.getDevice());
|
||||
}
|
||||
rileyLinkDevices.put(result.getDevice(), result.getRssi());
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
mLeDevices.clear();
|
||||
rileyLinkDevices.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mLeDevices.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return mLeDevices.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
ViewHolder viewHolder;
|
||||
// General ListView optimization code.
|
||||
if (view == null) {
|
||||
view = mInflator.inflate(R.layout.riley_link_ble_config_scan_item, null);
|
||||
viewHolder = new ViewHolder();
|
||||
viewHolder.deviceAddress = view.findViewById(R.id.riley_link_ble_config_scan_item_device_address);
|
||||
viewHolder.deviceName = view.findViewById(R.id.riley_link_ble_config_scan_item_device_name);
|
||||
view.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) view.getTag();
|
||||
}
|
||||
|
||||
BluetoothDevice device = mLeDevices.get(i);
|
||||
String deviceName = device.getName();
|
||||
|
||||
if (StringUtils.isBlank(deviceName)) {
|
||||
deviceName = "RileyLink (?)";
|
||||
}
|
||||
|
||||
deviceName += " [" + rileyLinkDevices.get(device) + "]";
|
||||
|
||||
String currentlySelectedAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||
|
||||
if (currentlySelectedAddress.equals(device.getAddress())) {
|
||||
deviceName += " (" + getResources().getString(R.string.riley_link_ble_config_scan_selected) + ")";
|
||||
}
|
||||
|
||||
viewHolder.deviceName.setText(deviceName);
|
||||
viewHolder.deviceAddress.setText(device.getAddress());
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
static class ViewHolder {
|
||||
TextView deviceName;
|
||||
TextView deviceAddress;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,380 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.dialog;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.le.BluetoothLeScanner;
|
||||
import android.bluetooth.le.ScanCallback;
|
||||
import android.bluetooth.le.ScanFilter;
|
||||
import android.bluetooth.le.ScanResult;
|
||||
import android.bluetooth.le.ScanSettings;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.ParcelUuid;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.common.R;
|
||||
import info.nightscout.androidaps.plugins.pump.common.ble.BlePreCheck;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
// IMPORTANT: This activity needs to be called from RileyLinkSelectPreference (see pref_medtronic.xml as example)
|
||||
public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject SP sp;
|
||||
@Inject RxBusWrapper rxBus;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject BlePreCheck blePrecheck;
|
||||
@Inject RileyLinkUtil rileyLinkUtil;
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
|
||||
private static final int PERMISSION_REQUEST_COARSE_LOCATION = 30241; // arbitrary.
|
||||
private static final int REQUEST_ENABLE_BT = 30242; // arbitrary
|
||||
|
||||
private static final String TAG = "RileyLinkBLEScanActivity";
|
||||
|
||||
// Stops scanning after 30 seconds.
|
||||
private static final long SCAN_PERIOD = 30000;
|
||||
public boolean mScanning;
|
||||
public ScanSettings settings;
|
||||
public List<ScanFilter> filters;
|
||||
public ListView listBTScan;
|
||||
public Toolbar toolbarBTScan;
|
||||
public Context mContext = this;
|
||||
private BluetoothAdapter mBluetoothAdapter;
|
||||
private BluetoothLeScanner mLEScanner;
|
||||
private LeDeviceListAdapter mLeDeviceListAdapter;
|
||||
private Handler mHandler;
|
||||
|
||||
private String actionTitleStart, actionTitleStop;
|
||||
private MenuItem menuItem;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.rileylink_scan_activity);
|
||||
|
||||
// Initializes Bluetooth adapter.
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
mHandler = new Handler();
|
||||
|
||||
mLeDeviceListAdapter = new LeDeviceListAdapter();
|
||||
listBTScan = findViewById(R.id.rileylink_listBTScan);
|
||||
listBTScan.setAdapter(mLeDeviceListAdapter);
|
||||
listBTScan.setOnItemClickListener((parent, view, position, id) -> {
|
||||
|
||||
// stop scanning if still active
|
||||
if (mScanning) {
|
||||
mScanning = false;
|
||||
mLEScanner.stopScan(mScanCallback2);
|
||||
}
|
||||
|
||||
TextView textview = view.findViewById(R.id.rileylink_device_address);
|
||||
String bleAddress = textview.getText().toString();
|
||||
|
||||
sp.putString(RileyLinkConst.Prefs.RileyLinkAddress, bleAddress);
|
||||
|
||||
RileyLinkPumpDevice rileyLinkPump = (RileyLinkPumpDevice) activePlugin.getActivePump();
|
||||
rileyLinkPump.getRileyLinkService().verifyConfiguration(); // force reloading of address
|
||||
rileyLinkPump.triggerPumpConfigurationChangedEvent();
|
||||
|
||||
finish();
|
||||
});
|
||||
|
||||
toolbarBTScan = findViewById(R.id.rileylink_toolbarBTScan);
|
||||
toolbarBTScan.setTitle(R.string.rileylink_scanner_title);
|
||||
setSupportActionBar(toolbarBTScan);
|
||||
|
||||
prepareForScanning();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_rileylink_ble_scan, menu);
|
||||
|
||||
actionTitleStart = resourceHelper.gs(R.string.rileylink_scanner_scan_scan);
|
||||
actionTitleStop = resourceHelper.gs(R.string.rileylink_scanner_scan_stop);
|
||||
|
||||
menuItem = menu.getItem(0);
|
||||
|
||||
menuItem.setTitle(actionTitleStart);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getTitle().equals(actionTitleStart)) {
|
||||
scanLeDevice(true);
|
||||
return true;
|
||||
} else if (item.getTitle().equals(actionTitleStop)) {
|
||||
scanLeDevice(false);
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void prepareForScanning() {
|
||||
boolean checkOK = blePrecheck.prerequisitesCheck(this);
|
||||
|
||||
if (checkOK) {
|
||||
mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
|
||||
settings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
|
||||
filters = Collections.singletonList(new ScanFilter.Builder().setServiceUuid(
|
||||
ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build());
|
||||
}
|
||||
|
||||
// disable currently selected RL, so that we can discover it
|
||||
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect, this);
|
||||
}
|
||||
|
||||
|
||||
private final ScanCallback mScanCallback2 = new ScanCallback() {
|
||||
|
||||
@Override
|
||||
public void onScanResult(int callbackType, final ScanResult scanRecord) {
|
||||
|
||||
Log.d(TAG, scanRecord.toString());
|
||||
|
||||
runOnUiThread(() -> {
|
||||
if (addDevice(scanRecord))
|
||||
mLeDeviceListAdapter.notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBatchScanResults(final List<ScanResult> results) {
|
||||
|
||||
runOnUiThread(() -> {
|
||||
|
||||
boolean added = false;
|
||||
|
||||
for (ScanResult result : results) {
|
||||
if (addDevice(result))
|
||||
added = true;
|
||||
}
|
||||
|
||||
if (added)
|
||||
mLeDeviceListAdapter.notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private boolean addDevice(ScanResult result) {
|
||||
|
||||
BluetoothDevice device = result.getDevice();
|
||||
|
||||
List<ParcelUuid> serviceUuids = result.getScanRecord().getServiceUuids();
|
||||
|
||||
if (serviceUuids == null || serviceUuids.size() == 0) {
|
||||
Log.v(TAG, "Device " + device.getAddress() + " has no serviceUuids (Not RileyLink).");
|
||||
} else if (serviceUuids.size() > 1) {
|
||||
Log.v(TAG, "Device " + device.getAddress() + " has too many serviceUuids (Not RileyLink).");
|
||||
} else {
|
||||
|
||||
String uuid = serviceUuids.get(0).getUuid().toString().toLowerCase();
|
||||
|
||||
if (uuid.equals(GattAttributes.SERVICE_RADIO)) {
|
||||
Log.i(TAG, "Found RileyLink with address: " + device.getAddress());
|
||||
mLeDeviceListAdapter.addDevice(result);
|
||||
return true;
|
||||
} else {
|
||||
Log.v(TAG, "Device " + device.getAddress() + " has incorrect uuid (Not RileyLink).");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private String getDeviceDebug(BluetoothDevice device) {
|
||||
return "BluetoothDevice [name=" + device.getName() + ", address=" + device.getAddress() + //
|
||||
", type=" + device.getType(); // + ", alias=" + device.getAlias();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onScanFailed(int errorCode) {
|
||||
Log.e("Scan Failed", "Error Code: " + errorCode);
|
||||
Toast.makeText(mContext, resourceHelper.gs(R.string.rileylink_scanner_scanning_error, errorCode),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
private void scanLeDevice(final boolean enable) {
|
||||
|
||||
if (mLEScanner == null)
|
||||
return;
|
||||
|
||||
if (enable) {
|
||||
|
||||
mLeDeviceListAdapter.clear();
|
||||
mLeDeviceListAdapter.notifyDataSetChanged();
|
||||
|
||||
// Stops scanning after a pre-defined scan period.
|
||||
mHandler.postDelayed(() -> {
|
||||
|
||||
if (mScanning) {
|
||||
mScanning = false;
|
||||
mLEScanner.stopScan(mScanCallback2);
|
||||
aapsLogger.debug("scanLeDevice: Scanning Stop");
|
||||
Toast.makeText(mContext, R.string.rileylink_scanner_scanning_finished, Toast.LENGTH_SHORT).show();
|
||||
menuItem.setTitle(actionTitleStart);
|
||||
}
|
||||
}, SCAN_PERIOD);
|
||||
|
||||
mScanning = true;
|
||||
mLEScanner.startScan(filters, settings, mScanCallback2);
|
||||
aapsLogger.debug("scanLeDevice: Scanning Start");
|
||||
Toast.makeText(this, R.string.rileylink_scanner_scanning, Toast.LENGTH_SHORT).show();
|
||||
|
||||
menuItem.setTitle(actionTitleStop);
|
||||
|
||||
} else {
|
||||
if (mScanning) {
|
||||
mScanning = false;
|
||||
mLEScanner.stopScan(mScanCallback2);
|
||||
|
||||
aapsLogger.debug("scanLeDevice: Scanning Stop");
|
||||
Toast.makeText(this, R.string.rileylink_scanner_scanning_finished, Toast.LENGTH_SHORT).show();
|
||||
|
||||
menuItem.setTitle(actionTitleStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class LeDeviceListAdapter extends BaseAdapter {
|
||||
|
||||
private final ArrayList<BluetoothDevice> mLeDevices;
|
||||
private final Map<BluetoothDevice, Integer> rileyLinkDevices;
|
||||
private final LayoutInflater mInflator;
|
||||
String currentlySelectedAddress;
|
||||
|
||||
|
||||
public LeDeviceListAdapter() {
|
||||
super();
|
||||
mLeDevices = new ArrayList<>();
|
||||
rileyLinkDevices = new HashMap<>();
|
||||
mInflator = RileyLinkBLEScanActivity.this.getLayoutInflater();
|
||||
currentlySelectedAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||
}
|
||||
|
||||
|
||||
public void addDevice(ScanResult result) {
|
||||
|
||||
if (!mLeDevices.contains(result.getDevice())) {
|
||||
mLeDevices.add(result.getDevice());
|
||||
}
|
||||
rileyLinkDevices.put(result.getDevice(), result.getRssi());
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
mLeDevices.clear();
|
||||
rileyLinkDevices.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mLeDevices.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return mLeDevices.get(i);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
|
||||
ViewHolder viewHolder;
|
||||
// General ListView optimization code.
|
||||
if (view == null) {
|
||||
view = mInflator.inflate(R.layout.rileylink_scan_item, null);
|
||||
viewHolder = new ViewHolder();
|
||||
viewHolder.deviceAddress = view.findViewById(R.id.rileylink_device_address);
|
||||
viewHolder.deviceName = view.findViewById(R.id.rileylink_device_name);
|
||||
view.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) view.getTag();
|
||||
}
|
||||
|
||||
BluetoothDevice device = mLeDevices.get(i);
|
||||
String deviceName = device.getName();
|
||||
|
||||
if (StringUtils.isBlank(deviceName)) {
|
||||
deviceName = "RileyLink";
|
||||
}
|
||||
|
||||
deviceName += " [" + rileyLinkDevices.get(device).intValue() + "]";
|
||||
|
||||
if (currentlySelectedAddress.equals(device.getAddress())) {
|
||||
// viewHolder.deviceName.setTextColor(getColor(R.color.secondary_text_light));
|
||||
// viewHolder.deviceAddress.setTextColor(getColor(R.color.secondary_text_light));
|
||||
deviceName += " (" + getResources().getString(R.string.rileylink_scanner_selected_device) + ")";
|
||||
}
|
||||
|
||||
viewHolder.deviceName.setText(deviceName);
|
||||
viewHolder.deviceAddress.setText(device.getAddress());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class ViewHolder {
|
||||
|
||||
TextView deviceName;
|
||||
TextView deviceAddress;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,6 +33,7 @@ public class RileyLinkConst {
|
|||
//public static final String PrefPrefix = "pref_rileylink_";
|
||||
//public static final String RileyLinkAddress = PrefPrefix + "mac_address"; // pref_rileylink_mac_address
|
||||
public static final int RileyLinkAddress = R.string.key_rileylink_mac_address;
|
||||
public static final int RileyLinkName = R.string.key_rileylink_name;
|
||||
public static final String LastGoodDeviceCommunicationTime = Prefix + "lastGoodDeviceCommunicationTime";
|
||||
public static final String LastGoodDeviceFrequency = Prefix + "LastGoodDeviceFrequency";
|
||||
public static final int Encoding = R.string.key_medtronic_encoding;
|
||||
|
|
|
@ -112,7 +112,6 @@ public class RFSpy {
|
|||
reader.newDataIsAvailable();
|
||||
}
|
||||
|
||||
|
||||
public Integer getBatteryLevel() {
|
||||
BLECommOperationResult result = rileyLinkBle.readCharacteristic_blocking(batteryServiceUUID, batteryLevelUUID);
|
||||
if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) {
|
||||
|
|
|
@ -35,6 +35,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
|||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ThreadUtil;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
/**
|
||||
* Created by geoff on 5/26/16.
|
||||
|
@ -46,6 +47,7 @@ public class RileyLinkBLE {
|
|||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||
@Inject RileyLinkUtil rileyLinkUtil;
|
||||
@Inject SP sp;
|
||||
|
||||
private final Context context;
|
||||
private final boolean gattDebugEnabled = true;
|
||||
|
@ -392,6 +394,17 @@ public class RileyLinkBLE {
|
|||
if (gattDebugEnabled) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Gatt Connected.");
|
||||
}
|
||||
|
||||
String deviceName = bluetoothConnectionGatt.getDevice().getName();
|
||||
if (StringUtils.isNotEmpty(deviceName)) {
|
||||
// Update stored name upon connecting (also for backwards compatibility for device where a name was not yet stored)
|
||||
sp.putString(RileyLinkConst.Prefs.RileyLinkName, deviceName);
|
||||
} else {
|
||||
sp.remove(RileyLinkConst.Prefs.RileyLinkName);
|
||||
}
|
||||
|
||||
rileyLinkServiceData.rileyLinkName = deviceName;
|
||||
rileyLinkServiceData.rileyLinkAddress = bluetoothConnectionGatt.getDevice().getAddress();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ public abstract class Encoding4b6bAbstract implements Encoding4b6b {
|
|||
|
||||
// 21, 49, 50, 35, 52, 37, 38, 22, 26, 25, 42, 11, 44, 13, 14, 28
|
||||
|
||||
public abstract byte[] encode4b6b(byte[] data);
|
||||
@Override public abstract byte[] encode4b6b(byte[] data);
|
||||
|
||||
|
||||
public abstract byte[] decode4b6b(byte[] data) throws RileyLinkCommunicationException;
|
||||
@Override public abstract byte[] decode4b6b(byte[] data) throws RileyLinkCommunicationException;
|
||||
|
||||
|
||||
protected short convertUnsigned(byte x) {
|
||||
|
|
|
@ -19,7 +19,7 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract {
|
|||
public static final Logger LOG = StacktraceLoggerWrapper.getLogger(Encoding4b6bGeoff.class);
|
||||
|
||||
|
||||
public byte[] encode4b6b(byte[] data) {
|
||||
@Override public byte[] encode4b6b(byte[] data) {
|
||||
// if ((data.length % 2) != 0) {
|
||||
// LOG.error("Warning: data is odd number of bytes");
|
||||
// }
|
||||
|
@ -77,7 +77,7 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract {
|
|||
* @return
|
||||
* @throws NumberFormatException
|
||||
*/
|
||||
public byte[] decode4b6b(byte[] raw) throws RileyLinkCommunicationException {
|
||||
@Override public byte[] decode4b6b(byte[] raw) throws RileyLinkCommunicationException {
|
||||
|
||||
StringBuilder errorMessageBuilder = new StringBuilder();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public class Encoding4b6bGo extends Encoding4b6bAbstract {
|
|||
private static Map<Short, Short> decodeGoMap;
|
||||
|
||||
|
||||
public byte[] encode4b6b(byte[] src) {
|
||||
@Override public byte[] encode4b6b(byte[] src) {
|
||||
// 2 input bytes produce 3 output bytes.
|
||||
// Odd final input byte, if any, produces 2 output bytes.
|
||||
int n = src.length;
|
||||
|
@ -54,7 +54,7 @@ public class Encoding4b6bGo extends Encoding4b6bAbstract {
|
|||
* @param src
|
||||
* @return
|
||||
*/
|
||||
public byte[] decode4b6b(byte[] src) throws RileyLinkCommunicationException {
|
||||
@Override public byte[] decode4b6b(byte[] src) throws RileyLinkCommunicationException {
|
||||
int n = src.length;
|
||||
|
||||
if (decodeGoMap == null)
|
||||
|
|
|
@ -33,7 +33,7 @@ public class Encoding4b6bLoop extends Encoding4b6bAbstract {
|
|||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public byte[] encode4b6b(byte[] data) {
|
||||
@Override public byte[] encode4b6b(byte[] data) {
|
||||
|
||||
List<Byte> buffer = new ArrayList<Byte>();
|
||||
int bitAccumulator = 0x0;
|
||||
|
@ -78,7 +78,7 @@ public class Encoding4b6bLoop extends Encoding4b6bAbstract {
|
|||
* @return
|
||||
* @throws RileyLinkCommunicationException
|
||||
*/
|
||||
public byte[] decode4b6b(byte[] data) throws RileyLinkCommunicationException {
|
||||
@Override public byte[] decode4b6b(byte[] data) throws RileyLinkCommunicationException {
|
||||
List<Byte> buffer = new ArrayList<Byte>();
|
||||
int availBits = 0;
|
||||
int bitAccumulator = 0;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
@ -16,33 +15,21 @@ import java.util.List;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.common.R;
|
||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
|
||||
public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject RileyLinkUtil rileyLinkUtil;
|
||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||
|
||||
TextView connectionStatus;
|
||||
TextView configuredAddress;
|
||||
TextView connectedDevice;
|
||||
TextView connectionError;
|
||||
|
||||
private SectionsPagerAdapter mSectionsPagerAdapter;
|
||||
private FloatingActionButton floatingActionButton;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private TabLayout tabLayout;
|
||||
/**
|
||||
* The {@link ViewPager} that will host the section contents.
|
||||
*/
|
||||
private ViewPager mViewPager;
|
||||
|
||||
private ViewPager viewPager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -53,72 +40,28 @@ public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
|||
// primary sections of the activity.
|
||||
|
||||
// Set up the ViewPager with the sections adapter.
|
||||
mViewPager = findViewById(R.id.rileylink_settings_container);
|
||||
viewPager = findViewById(R.id.rileylink_settings_container);
|
||||
// mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
setupViewPager(mViewPager);
|
||||
setupViewPager();
|
||||
|
||||
tabLayout = findViewById(R.id.rileylink_settings_tabs);
|
||||
tabLayout.setupWithViewPager(mViewPager);
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
|
||||
floatingActionButton = findViewById(R.id.rileylink_settings_fab);
|
||||
FloatingActionButton floatingActionButton = findViewById(R.id.rileylink_settings_fab);
|
||||
floatingActionButton.setOnClickListener(v -> {
|
||||
|
||||
RefreshableInterface selectableInterface = (RefreshableInterface) mSectionsPagerAdapter
|
||||
RefreshableInterface selectableInterface = (RefreshableInterface) sectionsPagerAdapter
|
||||
.getItem(tabLayout.getSelectedTabPosition());
|
||||
selectableInterface.refreshData();
|
||||
|
||||
// refreshData(tabLayout.getSelectedTabPosition());
|
||||
|
||||
// Toast.makeText(getApplicationContext(), "Test pos: " + tabLayout.getSelectedTabPosition(),
|
||||
// Toast.LENGTH_LONG);
|
||||
});
|
||||
|
||||
this.connectionStatus = findViewById(R.id.rls_t1_connection_status);
|
||||
this.configuredAddress = findViewById(R.id.rls_t1_configured_address);
|
||||
this.connectedDevice = findViewById(R.id.rls_t1_connected_device);
|
||||
this.connectionError = findViewById(R.id.rls_t1_connection_error);
|
||||
|
||||
// // 7-12
|
||||
// int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
|
||||
// R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12};
|
||||
//
|
||||
// for (int id : ids) {
|
||||
//
|
||||
// TextView tv = (TextView) findViewById(id);
|
||||
// tv.setText(tv.getText() + ":");
|
||||
// }
|
||||
|
||||
// refreshData(0);
|
||||
// refreshData(1);
|
||||
|
||||
}
|
||||
|
||||
public void setupViewPager() {
|
||||
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
|
||||
public void refreshData(int position) {
|
||||
if (position == 0) {
|
||||
// FIXME i18n
|
||||
this.connectionStatus.setText(rileyLinkServiceData.rileyLinkServiceState.name());
|
||||
this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
|
||||
// FIXME
|
||||
this.connectedDevice.setText("???");
|
||||
// FIXME i18n
|
||||
this.connectionError.setText(rileyLinkServiceData.rileyLinkError.name());
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setupViewPager(ViewPager pager) {
|
||||
|
||||
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
|
||||
mSectionsPagerAdapter.addFragment(new RileyLinkStatusGeneralFragment(), resourceHelper.gs(R.string.rileylink_settings_tab1));
|
||||
mSectionsPagerAdapter.addFragment(new RileyLinkStatusHistoryFragment(), resourceHelper.gs(R.string.rileylink_settings_tab2));
|
||||
//mSectionsPagerAdapter.addFragment(new RileyLinkStatusDevice(), "Medtronic");
|
||||
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
sectionsPagerAdapter.addFragment(new RileyLinkStatusGeneralFragment(), resourceHelper.gs(R.string.rileylink_settings_tab1));
|
||||
sectionsPagerAdapter.addFragment(new RileyLinkStatusHistoryFragment(), resourceHelper.gs(R.string.rileylink_settings_tab2));
|
||||
viewPager.setAdapter(sectionsPagerAdapter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,32 +74,27 @@ public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
|||
List<String> fragmentTitle = new ArrayList<>();
|
||||
int lastSelectedPosition = 0;
|
||||
|
||||
|
||||
public SectionsPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
this.lastSelectedPosition = position;
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// Show 3 total pages.
|
||||
return fragmentList.size();
|
||||
}
|
||||
|
||||
|
||||
public void addFragment(Fragment fragment, String title) {
|
||||
this.fragmentList.add(fragment);
|
||||
this.fragmentTitle.add(title);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
return fragmentTitle.get(position);
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.joda.time.LocalDateTime;
|
||||
|
||||
import java.util.Locale;
|
||||
|
@ -31,40 +32,39 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|||
|
||||
public class RileyLinkStatusGeneralFragment extends DaggerFragment implements RefreshableInterface {
|
||||
|
||||
private static final String PLACEHOLDER = "-";
|
||||
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||
@Inject DateUtil dateUtil;
|
||||
|
||||
TextView connectionStatus;
|
||||
TextView configuredAddress;
|
||||
TextView connectedDevice;
|
||||
TextView connectionError;
|
||||
TextView deviceType;
|
||||
TextView deviceModel;
|
||||
TextView serialNumber;
|
||||
TextView pumpFrequency;
|
||||
TextView lastUsedFrequency;
|
||||
TextView lastDeviceContact;
|
||||
TextView firmwareVersion;
|
||||
|
||||
boolean first = false;
|
||||
private TextView connectionStatus;
|
||||
private TextView configuredRileyLinkAddress;
|
||||
private TextView configuredRileyLinkName;
|
||||
private TextView connectedDevice;
|
||||
private TextView connectionError;
|
||||
private TextView deviceType;
|
||||
private TextView deviceModel;
|
||||
private TextView serialNumber;
|
||||
private TextView pumpFrequency;
|
||||
private TextView lastUsedFrequency;
|
||||
private TextView lastDeviceContact;
|
||||
private TextView firmwareVersion;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.rileylink_status_general, container, false);
|
||||
|
||||
return rootView;
|
||||
return inflater.inflate(R.layout.rileylink_status_general, container, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
|
||||
this.configuredAddress = getActivity().findViewById(R.id.rls_t1_configured_address);
|
||||
this.configuredRileyLinkAddress = getActivity().findViewById(R.id.rls_t1_configured_riley_link_address);
|
||||
this.configuredRileyLinkName = getActivity().findViewById(R.id.rls_t1_configured_riley_link_name);
|
||||
this.connectedDevice = getActivity().findViewById(R.id.rls_t1_connected_device);
|
||||
this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
|
||||
this.deviceType = getActivity().findViewById(R.id.rls_t1_device_type);
|
||||
|
@ -75,39 +75,24 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
|||
this.lastDeviceContact = getActivity().findViewById(R.id.rls_t1_last_device_contact);
|
||||
this.firmwareVersion = getActivity().findViewById(R.id.rls_t1_firmware_version);
|
||||
|
||||
if (!first) {
|
||||
|
||||
// 7-14
|
||||
int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
|
||||
R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12, R.id.rls_t1_tv13};
|
||||
|
||||
for (int id : ids) {
|
||||
|
||||
TextView tv = getActivity().findViewById(id);
|
||||
tv.setText(tv.getText() + ":");
|
||||
}
|
||||
|
||||
first = true;
|
||||
}
|
||||
|
||||
refreshData();
|
||||
}
|
||||
|
||||
|
||||
public void refreshData() {
|
||||
|
||||
@Override public void refreshData() {
|
||||
RileyLinkTargetDevice targetDevice = rileyLinkServiceData.targetDevice;
|
||||
|
||||
this.connectionStatus.setText(resourceHelper.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId()));
|
||||
|
||||
// BS FIXME rileyLinkServiceData is injected so I suppose it cannot be null?
|
||||
if (rileyLinkServiceData != null) {
|
||||
this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
|
||||
this.configuredRileyLinkAddress.setText(StringUtils.isEmpty(rileyLinkServiceData.rileyLinkAddress) ? PLACEHOLDER : rileyLinkServiceData.rileyLinkAddress);
|
||||
this.configuredRileyLinkName.setText(StringUtils.isEmpty(rileyLinkServiceData.rileyLinkName) ? PLACEHOLDER : rileyLinkServiceData.rileyLinkName);
|
||||
this.connectionError.setText(rileyLinkServiceData.rileyLinkError == null ? //
|
||||
"-"
|
||||
PLACEHOLDER
|
||||
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
|
||||
|
||||
if (firmwareVersion == null) {
|
||||
this.firmwareVersion.setText("BLE113: -\nCC110: -");
|
||||
this.firmwareVersion.setText("BLE113: " + PLACEHOLDER + "\nCC110: " + PLACEHOLDER);
|
||||
} else {
|
||||
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 +
|
||||
"\nCC110: " + rileyLinkServiceData.versionCC110);
|
||||
|
@ -129,7 +114,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
|||
|
||||
long lastConnectionTimeMillis = pumpPlugin.getLastConnectionTimeMillis();
|
||||
if (lastConnectionTimeMillis == 0) {
|
||||
this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never));
|
||||
this.lastDeviceContact.setText(resourceHelper.gs(R.string.riley_link_ble_config_connected_never));
|
||||
} else {
|
||||
this.lastDeviceContact.setText(StringUtil.toDateTimeString(dateUtil, new LocalDateTime(lastConnectionTimeMillis)));
|
||||
}
|
||||
|
|
|
@ -142,7 +142,6 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
|||
|
||||
return true;
|
||||
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
|
||||
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLinkConst.Intents.RileyLinkReady");
|
||||
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
|
||||
|
||||
|
@ -153,7 +152,6 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
|||
String bleVersion = rileyLinkService.rfspy.getBLEVersionCached();
|
||||
RileyLinkFirmwareVersion rlVersion = rileyLinkServiceData.firmwareVersion;
|
||||
|
||||
// if (isLoggingEnabled())
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy version (BLE113): " + bleVersion);
|
||||
rileyLinkService.rileyLinkServiceData.versionBLE113 = bleVersion;
|
||||
|
||||
|
@ -180,7 +178,6 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
|||
return true;
|
||||
} else if (action.equals(RileyLinkConst.Intents.RileyLinkDisconnect)) {
|
||||
rileyLinkService.disconnectRileyLink();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -154,19 +154,19 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.RileyLinkInitializing);
|
||||
|
||||
if (rileyLinkBLE.isConnected()) {
|
||||
if (deviceAddress.equals(rileyLinkServiceData.rileylinkAddress)) {
|
||||
if (deviceAddress.equals(rileyLinkServiceData.rileyLinkAddress)) {
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "No change to RL address. Not reconnecting.");
|
||||
return false;
|
||||
} else {
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Disconnecting from old RL (" + rileyLinkServiceData.rileyLinkAddress
|
||||
+ "), reconnecting to new: " + deviceAddress);
|
||||
|
||||
rileyLinkBLE.disconnect();
|
||||
// prolly need to shut down listening thread too?
|
||||
// SP.putString(MedtronicConst.Prefs.RileyLinkAddress, deviceAddress);
|
||||
|
||||
rileyLinkServiceData.rileylinkAddress = deviceAddress;
|
||||
rileyLinkBLE.findRileyLink(rileyLinkServiceData.rileylinkAddress);
|
||||
rileyLinkServiceData.rileyLinkAddress = deviceAddress;
|
||||
rileyLinkBLE.findRileyLink(rileyLinkServiceData.rileyLinkAddress);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
@ -229,7 +229,8 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
|
||||
if (rileyLinkBLE.isConnected()) {
|
||||
rileyLinkBLE.disconnect();
|
||||
rileyLinkServiceData.rileylinkAddress = null;
|
||||
rileyLinkServiceData.rileyLinkAddress = null;
|
||||
rileyLinkServiceData.rileyLinkName = null;
|
||||
}
|
||||
|
||||
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.BluetoothReady);
|
||||
|
@ -260,5 +261,9 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public abstract boolean verifyConfiguration();
|
||||
public boolean verifyConfiguration() {
|
||||
return verifyConfiguration(false);
|
||||
}
|
||||
|
||||
public abstract boolean verifyConfiguration(boolean forceRileyLinkAddressRenewal);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ public class RileyLinkServiceData {
|
|||
private long lastServiceStateChange = 0L;
|
||||
public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
|
||||
public RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
||||
public String rileylinkAddress;
|
||||
public String rileyLinkAddress;
|
||||
public String rileyLinkName;
|
||||
long lastTuneUpTime = 0L;
|
||||
public Double lastGoodFrequency;
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public class ServiceTransport extends ServiceMessage {
|
|||
}
|
||||
|
||||
|
||||
public ServiceTransport clone() {
|
||||
@Override public ServiceTransport clone() {
|
||||
Parcel p = Parcel.obtain();
|
||||
Parcel p2 = Parcel.obtain();
|
||||
getMap().writeToParcel(p, 0);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ServiceTaskExecutor extends ThreadPoolExecutor {
|
|||
}
|
||||
|
||||
// FIXME
|
||||
protected void beforeExecute(Thread t, Runnable r) {
|
||||
@Override protected void beforeExecute(Thread t, Runnable r) {
|
||||
// This is run on either caller UI thread or Service UI thread.
|
||||
ServiceTask task = (ServiceTask) r;
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "About to run task " + task.getClass().getSimpleName());
|
||||
|
@ -43,7 +43,7 @@ public class ServiceTaskExecutor extends ThreadPoolExecutor {
|
|||
|
||||
|
||||
// FIXME
|
||||
protected void afterExecute(Runnable r, Throwable t) {
|
||||
@Override protected void afterExecute(Runnable r, Throwable t) {
|
||||
// This is run on either caller UI thread or Service UI thread.
|
||||
ServiceTask task = (ServiceTask) r;
|
||||
task.postOp();
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp">
|
||||
|
||||
<!-- Currently selected RileyLink -->
|
||||
<TextView
|
||||
style="@style/TextAppearance.AppCompat.Title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/riley_link_ble_config_scan_currently_selected_riley_link" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/riley_link_ble_config_currently_selected_riley_link_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="10dp"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/riley_link_ble_config_currently_selected_riley_link_address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="10dp"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/riley_link_ble_config_button_remove_riley_link"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/riley_link_ble_config_remove_riley_link"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- RileyLink scan -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.AppCompat.Title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/riley_link_ble_config_scan_title" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/riley_link_ble_config_scan_start"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/riley_link_ble_config_button_scan_start" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/riley_link_ble_config_button_scan_stop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/riley_link_ble_config_scan_stop"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- RileyLink scan results -->
|
||||
<ListView
|
||||
android:id="@+id/riley_link_ble_config_scan_device_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="32dp">
|
||||
android:paddingStart="10dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rileylink_device_name"
|
||||
android:id="@+id/riley_link_ble_config_scan_item_device_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="24dp"
|
||||
|
||||
android:text="name" />
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rileylink_device_address"
|
||||
android:id="@+id/riley_link_ble_config_scan_item_device_address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="12dp" />
|
||||
android:textSize="12sp" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,43 +0,0 @@
|
|||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.gxwtech.roundtrip2.RileyLinkScan">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:elevation="0dp">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/rileylink_toolbarBTScan"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"></androidx.appcompat.widget.Toolbar>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="?attr/actionBarSize">
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/rileylink_listBTScan"
|
||||
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
|
@ -37,16 +37,42 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv02"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_weight="35"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/rileylink_configured_address" />
|
||||
android:text="@string/rileylink_configured_riley_link_address" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_configured_address"
|
||||
android:id="@+id/rls_t1_configured_riley_link_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_weight="65"
|
||||
android:gravity="center_vertical"
|
||||
android:text=" "
|
||||
android:textAlignment="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_weight="35"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/rileylink_configured_riley_link_name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_configured_riley_link_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
|
@ -65,7 +91,6 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv03"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
@ -94,7 +119,6 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv04"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
@ -123,7 +147,6 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv05"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
@ -151,7 +174,6 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv13"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
@ -194,7 +216,6 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv07"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
@ -223,7 +244,6 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv08"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
@ -252,13 +272,12 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv09"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_weight="35"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/medtronic_serial_number" />
|
||||
android:text="@string/rileylink_pump_serial_number" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_serial_number"
|
||||
|
@ -281,13 +300,12 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv10"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_weight="35"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/medtronic_pump_frequency" />
|
||||
android:text="@string/rileylink_pump_frequency" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_pump_frequency"
|
||||
|
@ -309,7 +327,6 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv11"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
@ -338,7 +355,6 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rls_t1_tv12"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
<item
|
||||
android:id="@+id/rileylink_miScan"
|
||||
app:showAsAction="ifRoom"
|
||||
android:title="@string/rileylink_scanner_scan_scan"></item>
|
||||
android:title="@string/riley_link_ble_config_button_scan_start"></item>
|
||||
</menu>
|
|
@ -1,17 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- RL BLE Scanning -->
|
||||
<string name="rileylink_scanner_scan_scan">SCAN</string>
|
||||
<string name="rileylink_scanner_scan_stop">STOP</string>
|
||||
<string name="rileylink_scanner_selected_device">Selected</string>
|
||||
<string name="rileylink_scanner_title">RileyLink Scan</string>
|
||||
<string name="location_yes">Enable</string>
|
||||
<string name="location_no">No</string>
|
||||
<string name="rileylink_scanner_scanning">Scanning</string>
|
||||
<string name="rileylink_scanner_scanning_finished">Scanning finished</string>
|
||||
<string name="rileylink_scanner_scanning_error">Scanning error: %1$d</string>
|
||||
<string name="common_never">Never</string>
|
||||
<!-- RL keys -->
|
||||
<string name="key_medtronic_pump_encoding_4b6b_local" translatable="false">medtronic_pump_encoding_4b6b_local</string>
|
||||
<string name="key_medtronic_pump_encoding_4b6b_rileylink" translatable="false">medtronic_pump_encoding_4b6b_rileylink</string>
|
||||
<string name="key_rileylink_mac_address" translatable="false">pref_rileylink_mac_address</string>
|
||||
<string name="key_rileylink_name" translatable="false">pref_rileylink_name</string>
|
||||
<string name="key_medtronic_encoding" translatable="false">pref_medtronic_encoding</string>
|
||||
|
||||
<!-- RL BLE Config -->
|
||||
<string name="riley_link_ble_config_button_scan_start">Scan</string>
|
||||
<string name="riley_link_ble_config_scan_stop">Stop</string>
|
||||
<string name="riley_link_ble_config_scan_selected">Selected</string>
|
||||
<string name="riley_link_ble_config_scan_title">RileyLink Scan</string>
|
||||
<string name="riley_link_ble_config_scan_scanning">Scanning</string>
|
||||
<string name="riley_link_ble_config_scan_finished">Scanning finished</string>
|
||||
<string name="riley_link_ble_config_scan_error">Scanning error: %1$d</string>
|
||||
<string name="riley_link_ble_config_connected_never">Never</string>
|
||||
<string name="riley_link_ble_config_scan_currently_selected_riley_link">Currently Selected RileyLink</string>
|
||||
<string name="riley_link_ble_config_remove_riley_link">Remove</string>
|
||||
<string name="riley_link_ble_config_remove_riley_link_confirmation">Are you sure that you want to remove your RileyLink?</string>
|
||||
<string name="riley_link_ble_config_remove_riley_link_confirmation_title">Remove RileyLink</string>
|
||||
<string name="riley_link_ble_config_no_riley_link_selected">No RileyLink selected</string>
|
||||
|
||||
<!-- RL Status Page -->
|
||||
<string name="rileylink_settings_tab1">Settings</string>
|
||||
|
@ -20,17 +30,19 @@
|
|||
<string name="medtronic_pump_status">Pump Status</string>
|
||||
<string name="title_activity_rileylink_settings">RileyLink Settings</string>
|
||||
<string name="rileylink_title">RileyLink</string>
|
||||
<string name="rileylink_configured_address">Configured Address</string>
|
||||
<string name="rileylink_connected_device">Connected Device</string>
|
||||
<string name="rileylink_connection_status">Connection Status</string>
|
||||
<string name="rileylink_connection_error">Connection Error</string>
|
||||
<string name="rileylink_configured_riley_link_address">Configured RileyLink Address:</string>
|
||||
<string name="rileylink_configured_riley_link_name">Configured RileyLink Name:</string>
|
||||
<string name="rileylink_connected_device">Connected Device:</string>
|
||||
<string name="rileylink_connection_status">Connection Status:</string>
|
||||
<string name="rileylink_connection_error">Connection Error:</string>
|
||||
<string name="rileylink_device">Device</string>
|
||||
<string name="rileylink_device_type">Device Type</string>
|
||||
<string name="rileylink_device_model">Device Model</string>
|
||||
<string name="rileylink_last_used_frequency">Last used frequency</string>
|
||||
<string name="rileylink_last_device_contact">Last device contact</string>
|
||||
<string name="rileylink_firmware_version">Firmware</string>
|
||||
|
||||
<string name="rileylink_device_type">Device Type:</string>
|
||||
<string name="rileylink_device_model">Device Model:</string>
|
||||
<string name="rileylink_last_used_frequency">Last Used Frequency:</string>
|
||||
<string name="rileylink_last_device_contact">Last Device Contact:</string>
|
||||
<string name="rileylink_firmware_version">Firmware Version:</string>
|
||||
<string name="rileylink_pump_serial_number">Pump Serial Number:</string>
|
||||
<string name="rileylink_pump_frequency">Pump Frequency:</string>
|
||||
|
||||
<!-- RL State -->
|
||||
<string name="rileylink_state_bt_init">Bluetooth Initializing…</string>
|
||||
|
@ -53,17 +65,11 @@
|
|||
<string name="rileylink_error_pump_unreachable">Pump unreachable</string>
|
||||
<string name="rileylink_error_pod_unreachable">Pod unreachable</string>
|
||||
|
||||
<!-- RL Target Device -->
|
||||
<!-- RileyLink - Common -->
|
||||
<string name="rileylink_target_device_medtronic">Medtronic Pump</string>
|
||||
<string name="rileylink_target_device_omnipod">Omnipod</string>
|
||||
|
||||
<string name="key_medtronic_pump_encoding_4b6b_local" translatable="false">medtronic_pump_encoding_4b6b_local</string>
|
||||
<string name="key_medtronic_pump_encoding_4b6b_rileylink" translatable="false">medtronic_pump_encoding_4b6b_rileylink</string>
|
||||
|
||||
<string name="key_rileylink_mac_address" translatable="false">pref_rileylink_mac_address</string>
|
||||
<string name="key_medtronic_encoding" translatable="false">pref_medtronic_encoding</string>
|
||||
|
||||
<string name="mdt_last_bolus" translatable="false">%1$.1f %2$s (%3$s)</string>
|
||||
<string name="riley_link_common_yes">Yes</string>
|
||||
<string name="riley_link_common_no">No</string>
|
||||
|
||||
<plurals name="duration_days">
|
||||
<item quantity="one">%1$d day</item>
|
||||
|
@ -74,5 +80,4 @@
|
|||
<item quantity="other">%1$d hours</item>
|
||||
</plurals>
|
||||
|
||||
|
||||
</resources>
|
Loading…
Reference in a new issue