From df3a595ef41e2f691247d884787f0bfc842b11ff Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 20 Nov 2021 20:57:30 +0100 Subject: [PATCH] Create strings for ReadStatus reason translation --- .../smsCommunicator/SmsCommunicatorPlugin.kt | 4 ++-- .../queue/commands/CommandReadStatus.kt | 3 ++- .../androidaps/receivers/KeepAliveReceiver.kt | 7 +++++-- .../androidaps/setupwizard/SWDefinition.kt | 2 +- .../plugins/pump/combo/ComboFragment.java | 2 +- .../androidaps/interfaces/PumpPluginBase.kt | 3 ++- core/src/main/res/values/strings.xml | 18 ++++++++++++++++++ .../nightscout/androidaps/dana/DanaFragment.kt | 2 +- .../comm/MsgInitConnStatusTime_k.kt | 2 +- .../services/DanaRKoreanExecutionService.java | 2 +- .../danaRv2/comm/MsgCheckValue_v2.kt | 4 ++-- .../androidaps/danar/AbstractDanaRPlugin.java | 3 ++- .../danar/comm/MsgInitConnStatusTime.kt | 2 +- .../danar/services/DanaRExecutionService.java | 2 +- .../androidaps/danars/DanaRSPlugin.kt | 2 +- .../androidaps/diaconn/DiaconnG8Fragment.kt | 2 +- .../androidaps/diaconn/DiaconnG8Plugin.kt | 2 +- .../pump/insight/LocalInsightPlugin.java | 2 +- .../pump/medtronic/MedtronicFragment.kt | 2 +- .../pump/medtronic/MedtronicPumpPlugin.kt | 2 +- .../pump/omnipod/dash/OmnipodDashPumpPlugin.kt | 2 +- .../dash/ui/OmnipodDashOverviewFragment.kt | 2 +- 22 files changed, 48 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index bf6d2816b8..1ca68a21c6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -499,7 +499,7 @@ class SmsCommunicatorPlugin @Inject constructor( private fun processPUMP(divided: Array, receivedSms: Sms) { if (divided.size == 1) { - commandQueue.readStatus("SMS", object : Callback() { + commandQueue.readStatus(rh.gs(R.string.sms), object : Callback() { override fun run() { val pump = activePlugin.activePump if (result.success) { @@ -828,7 +828,7 @@ class SmsCommunicatorPlugin @Inject constructor( override fun run() { val resultSuccess = result.success val resultBolusDelivered = result.bolusDelivered - commandQueue.readStatus("SMS", object : Callback() { + commandQueue.readStatus(rh.gs(R.string.sms), object : Callback() { override fun run() { if (resultSuccess) { var replyText = if (isMeal) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt index 096178b06e..78b8e80168 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.queue.commands import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.logging.LTag @@ -29,5 +30,5 @@ class CommandReadStatus( callback?.result(result)?.run() } - override fun status(): String = "READSTATUS $reason" + override fun status(): String = rh.gs(R.string.read_status, reason) } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt index 47460541f0..03e65fbc5a 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt @@ -12,6 +12,7 @@ import com.google.common.util.concurrent.ListenableFuture import dagger.android.DaggerBroadcastReceiver import dagger.android.HasAndroidInjector import info.nightscout.androidaps.BuildConfig +import info.nightscout.androidaps.R import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.database.AppRepository @@ -32,6 +33,7 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.LocalAlertUtils import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject import kotlin.math.abs @@ -72,6 +74,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { @Inject lateinit var commandQueue: CommandQueue @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var maintenancePlugin: MaintenancePlugin + @Inject lateinit var rh: ResourceHelper init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) @@ -152,10 +155,10 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { rxBus.send(EventProfileSwitchChanged()) } else if (isStatusOutdated && !pump.isBusy()) { lastReadStatus = System.currentTimeMillis() - commandQueue.readStatus("KeepAlive. Status outdated.", null) + commandQueue.readStatus(rh.gs(R.string.keepalive_status_outdated), null) } else if (isBasalOutdated && !pump.isBusy()) { lastReadStatus = System.currentTimeMillis() - commandQueue.readStatus("KeepAlive. Basal outdated.", null) + commandQueue.readStatus(rh.gs(R.string.keepalive_basal_outdated), null) } if (lastRun != 0L && System.currentTimeMillis() - lastRun > T.mins(10).msecs()) { aapsLogger.error(LTag.CORE, "KeepAlive fail") diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index e79221c2c5..96e757bc3e 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -292,7 +292,7 @@ class SWDefinition @Inject constructor( .visibility { activePlugin.activePump is OmnipodErosPumpPlugin }) .add(SWButton(injector) .text(R.string.readstatus) - .action { commandQueue.readStatus("Clicked connect to pump", null) } + .action { commandQueue.readStatus(rh.gs(R.string.clicked_connect_to_pump), null) } .visibility { // Hide for Omnipod, because as we don't require a Pod to be paired in the setup wizard, // Getting the status might not be possible diff --git a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboFragment.java b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboFragment.java index 9e10c4701f..30ca0686c8 100644 --- a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboFragment.java +++ b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboFragment.java @@ -74,7 +74,7 @@ public class ComboFragment extends DaggerFragment { refreshButton = view.findViewById(R.id.combo_refresh_button); refreshButton.setOnClickListener(v -> { refreshButton.setEnabled(false); - commandQueue.readStatus("User request", new Callback() { + commandQueue.readStatus(rh.gs(R.string.user_request), new Callback() { @Override public void run() { runOnUiThread(() -> refreshButton.setEnabled(true)); diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt index 0c324bc0fe..9ecb129a44 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpPluginBase.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.interfaces import android.os.SystemClock import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.core.R import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -18,7 +19,7 @@ abstract class PumpPluginBase( if (getType() == PluginType.PUMP) { Thread { SystemClock.sleep(3000) - commandQueue.readStatus("Pump driver changed.", null) + commandQueue.readStatus(rh.gs(R.string.pump_driver_changed), null) }.start() } } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 3ac720e134..8b517b63b4 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -504,6 +504,24 @@ Basal value NSClient version doesn\'t match to AndroidAPS. Please update. + + KeepAlive. Status outdated. + KeepAlive. Basal outdated. + SMS + Clicked connect to pump + Pump driver changed. + Pump driver change. + Device changed + Clicked refresh + Scheduled Status Refresh + Unconfirmed command + Requested by user + User request + Bolus OK + Pump paired + Insight Refresh Button + READSTATUS %1$s + %1$d day %1$d days diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt index 4e8f941197..4e69657231 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt @@ -112,7 +112,7 @@ class DanaFragment : DaggerFragment() { binding.btConnectionLayout.setOnClickListener { aapsLogger.debug(LTag.PUMP, "Clicked connect to pump") danaPump.reset() - commandQueue.readStatus("Clicked connect to pump", null) + commandQueue.readStatus(rh.gs(R.string.clicked_connect_to_pump), null) } if (activePlugin.activePump.pumpDescription.pumpType == PumpType.DANA_RS || activePlugin.activePump.pumpDescription.pumpType == PumpType.DANA_I diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRKorean/comm/MsgInitConnStatusTime_k.kt b/danar/src/main/java/info/nightscout/androidaps/danaRKorean/comm/MsgInitConnStatusTime_k.kt index a15f694783..0bf840dccc 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRKorean/comm/MsgInitConnStatusTime_k.kt +++ b/danar/src/main/java/info/nightscout/androidaps/danaRKorean/comm/MsgInitConnStatusTime_k.kt @@ -33,7 +33,7 @@ class MsgInitConnStatusTime_k( //If profile coming from pump, switch it as well configBuilder.storeSettings("ChangingKoreanDanaDriver") rxBus.send(EventRebuildTabs()) - commandQueue.readStatus("PumpDriverChange", null) // force new connection + commandQueue.readStatus(rh.gs(R.string.pump_driver_change), null) // force new connection return } val time = dateTimeSecFromBuff(bytes, 0) diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRKorean/services/DanaRKoreanExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danaRKorean/services/DanaRKoreanExecutionService.java index 9e22bbd4eb..f594994e37 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRKorean/services/DanaRKoreanExecutionService.java +++ b/danar/src/main/java/info/nightscout/androidaps/danaRKorean/services/DanaRKoreanExecutionService.java @@ -291,7 +291,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { SystemClock.sleep(300); danaPump.setBolusingTreatment(null); - commandQueue.readStatus("bolusOK", null); + commandQueue.readStatus(rh.gs(R.string.bolus_ok), null); } return !start.failed; diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRv2/comm/MsgCheckValue_v2.kt b/danar/src/main/java/info/nightscout/androidaps/danaRv2/comm/MsgCheckValue_v2.kt index 08c73eb232..526b816e9a 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRv2/comm/MsgCheckValue_v2.kt +++ b/danar/src/main/java/info/nightscout/androidaps/danaRv2/comm/MsgCheckValue_v2.kt @@ -40,7 +40,7 @@ class MsgCheckValue_v2( //If profile coming from pump, switch it as well configBuilder.storeSettings("ChangingDanaRv2Driver") rxBus.send(EventRebuildTabs()) - commandQueue.readStatus("PumpDriverChange", null) // force new connection + commandQueue.readStatus(rh.gs(R.string.pump_driver_change), null) // force new connection return } if (danaPump.protocol != 2) { @@ -57,7 +57,7 @@ class MsgCheckValue_v2( //If profile coming from pump, switch it as well configBuilder.storeSettings("ChangingDanaRv2Driver") rxBus.send(EventRebuildTabs()) - commandQueue.readStatus("PumpDriverChange", null) // force new connection + commandQueue.readStatus(rh.gs(R.string.pump_driver_change), null) // force new connection return } aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaPump.hwModel)) diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java index 2ed03b933c..898299d258 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java @@ -62,6 +62,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump protected DateUtil dateUtil; protected AapsSchedulers aapsSchedulers; protected PumpSync pumpSync; + protected ResourceHelper rh; protected AbstractDanaRPlugin( HasAndroidInjector injector, @@ -111,7 +112,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump if (event.isChanged(getRh(), R.string.key_danar_bt_name)) { danaPump.reset(); pumpSync.connectNewPump(); - getCommandQueue().readStatus("DeviceChanged", null); + getCommandQueue().readStatus(rh.gs(R.string.device_changed), null); } }) ); diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgInitConnStatusTime.kt b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgInitConnStatusTime.kt index 6d1f38ac8f..6bcd50dcfd 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgInitConnStatusTime.kt +++ b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgInitConnStatusTime.kt @@ -32,7 +32,7 @@ class MsgInitConnStatusTime( //If profile coming from pump, switch it as well configBuilder.storeSettings("ChangingDanaDriver") rxBus.send(EventRebuildTabs()) - commandQueue.readStatus("PumpDriverChange", null) // force new connection + commandQueue.readStatus(rh.gs(R.string.pump_driver_change), null) // force new connection failed = false return } else { diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/services/DanaRExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danar/services/DanaRExecutionService.java index e88e137eee..9d7b39e60e 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/services/DanaRExecutionService.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/services/DanaRExecutionService.java @@ -356,7 +356,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { } } } else { - commandQueue.readStatus("bolusOK", null); + commandQueue.readStatus(rh.gs(R.string.bolus_ok), null); } } return !start.failed; diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt index 0cc5babb4b..8d0e824830 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt @@ -139,7 +139,7 @@ class DanaRSPlugin @Inject constructor( mDeviceAddress = sp.getString(R.string.key_danars_address, "") mDeviceName = sp.getString(R.string.key_danars_name, "") danaPump.reset() - commandQueue.readStatus("DeviceChanged", null) + commandQueue.readStatus(rh.gs(R.string.device_changed), null) } override fun connect(reason: String) { diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Fragment.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Fragment.kt index 84ba98e25b..6cbe74c213 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Fragment.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Fragment.kt @@ -82,7 +82,7 @@ class DiaconnG8Fragment : DaggerFragment() { binding.btconnection.setOnClickListener { aapsLogger.debug(LTag.PUMP, "Clicked connect to pump") diaconnG8Pump.lastConnection = 0 - commandQueue.readStatus("Clicked connect to pump", null) + commandQueue.readStatus(rh.gs(R.string.clicked_connect_to_pump), null) } } diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Plugin.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Plugin.kt index 277f723dac..98c907f320 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Plugin.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/DiaconnG8Plugin.kt @@ -123,7 +123,7 @@ class DiaconnG8Plugin @Inject constructor( mDeviceAddress = sp.getString(R.string.key_diaconn_g8_address, "") mDeviceName = sp.getString(R.string.key_diaconn_g8_name, "") diaconnG8Pump.reset() - commandQueue.readStatus("DeviceChanged", null) + commandQueue.readStatus(rh.gs(R.string.device_changed), null) } override fun connect(reason: String) { diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 83956aaeea..d0ffdadb35 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -1628,7 +1628,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai @Override public void onPumpPaired() { - commandQueue.readStatus("Pump paired", null); + commandQueue.readStatus(rh.gs(R.string.pump_paired), null); } @Override diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt index 5d24a8c03e..12eb22cf7b 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt @@ -110,7 +110,7 @@ class MedtronicFragment : DaggerFragment() { } else { binding.refresh.isEnabled = false medtronicPumpPlugin.resetStatusState() - commandQueue.readStatus("Clicked refresh", object : Callback() { + commandQueue.readStatus(rh.gs(R.string.clicked_refresh), object : Callback() { override fun run() { activity?.runOnUiThread { if (_binding != null) binding.refresh.isEnabled = true } } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt index 3f6bb023a7..bf93716ace 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.kt @@ -203,7 +203,7 @@ class MedtronicPumpPlugin @Inject constructor( )!! if (doWeHaveAnyStatusNeededRefreshing(statusRefresh)) { if (!commandQueue.statusInQueue()) { - commandQueue.readStatus("Scheduled Status Refresh", null) + commandQueue.readStatus(rh.gs(R.string.scheduled_status_refresh), null) } } clearBusyQueue() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index f304c32757..1baa37737e 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -197,7 +197,7 @@ class OmnipodDashPumpPlugin @Inject constructor( commandQueue.size() == 0 && commandQueue.performing() == null ) { - commandQueue.readStatus("Unconfirmed command", null) + commandQueue.readStatus(rh.gs(R.string.unconfirmed_command), null) } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt index 5c2902ab91..e7c5917015 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt @@ -129,7 +129,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() { buttonBinding.buttonRefreshStatus.setOnClickListener { disablePodActionButtons() commandQueue.readStatus( - "REQUESTED BY USER", + rh.gs(R.string.requested_by_user), DisplayResultDialogCallback( rh.gs(R.string.omnipod_common_error_failed_to_refresh_status), false