Create strings for ReadStatus reason translation

This commit is contained in:
Philoul 2021-11-20 20:57:30 +01:00
parent ecf0a779c0
commit df3a595ef4
22 changed files with 48 additions and 24 deletions

View file

@ -499,7 +499,7 @@ class SmsCommunicatorPlugin @Inject constructor(
private fun processPUMP(divided: Array<String>, receivedSms: Sms) { private fun processPUMP(divided: Array<String>, receivedSms: Sms) {
if (divided.size == 1) { if (divided.size == 1) {
commandQueue.readStatus("SMS", object : Callback() { commandQueue.readStatus(rh.gs(R.string.sms), object : Callback() {
override fun run() { override fun run() {
val pump = activePlugin.activePump val pump = activePlugin.activePump
if (result.success) { if (result.success) {
@ -828,7 +828,7 @@ class SmsCommunicatorPlugin @Inject constructor(
override fun run() { override fun run() {
val resultSuccess = result.success val resultSuccess = result.success
val resultBolusDelivered = result.bolusDelivered val resultBolusDelivered = result.bolusDelivered
commandQueue.readStatus("SMS", object : Callback() { commandQueue.readStatus(rh.gs(R.string.sms), object : Callback() {
override fun run() { override fun run() {
if (resultSuccess) { if (resultSuccess) {
var replyText = if (isMeal) var replyText = if (isMeal)

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.queue.commands package info.nightscout.androidaps.queue.commands
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
@ -29,5 +30,5 @@ class CommandReadStatus(
callback?.result(result)?.run() callback?.result(result)?.run()
} }
override fun status(): String = "READSTATUS $reason" override fun status(): String = rh.gs(R.string.read_status, reason)
} }

View file

@ -12,6 +12,7 @@ import com.google.common.util.concurrent.ListenableFuture
import dagger.android.DaggerBroadcastReceiver import dagger.android.DaggerBroadcastReceiver
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.database.AppRepository 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.FabricPrivacy
import info.nightscout.androidaps.utils.LocalAlertUtils import info.nightscout.androidaps.utils.LocalAlertUtils
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.abs import kotlin.math.abs
@ -72,6 +74,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
@Inject lateinit var commandQueue: CommandQueue @Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var maintenancePlugin: MaintenancePlugin @Inject lateinit var maintenancePlugin: MaintenancePlugin
@Inject lateinit var rh: ResourceHelper
init { init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
@ -152,10 +155,10 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
rxBus.send(EventProfileSwitchChanged()) rxBus.send(EventProfileSwitchChanged())
} else if (isStatusOutdated && !pump.isBusy()) { } else if (isStatusOutdated && !pump.isBusy()) {
lastReadStatus = System.currentTimeMillis() lastReadStatus = System.currentTimeMillis()
commandQueue.readStatus("KeepAlive. Status outdated.", null) commandQueue.readStatus(rh.gs(R.string.keepalive_status_outdated), null)
} else if (isBasalOutdated && !pump.isBusy()) { } else if (isBasalOutdated && !pump.isBusy()) {
lastReadStatus = System.currentTimeMillis() 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()) { if (lastRun != 0L && System.currentTimeMillis() - lastRun > T.mins(10).msecs()) {
aapsLogger.error(LTag.CORE, "KeepAlive fail") aapsLogger.error(LTag.CORE, "KeepAlive fail")

View file

@ -292,7 +292,7 @@ class SWDefinition @Inject constructor(
.visibility { activePlugin.activePump is OmnipodErosPumpPlugin }) .visibility { activePlugin.activePump is OmnipodErosPumpPlugin })
.add(SWButton(injector) .add(SWButton(injector)
.text(R.string.readstatus) .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 { .visibility {
// Hide for Omnipod, because as we don't require a Pod to be paired in the setup wizard, // 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 // Getting the status might not be possible

View file

@ -74,7 +74,7 @@ public class ComboFragment extends DaggerFragment {
refreshButton = view.findViewById(R.id.combo_refresh_button); refreshButton = view.findViewById(R.id.combo_refresh_button);
refreshButton.setOnClickListener(v -> { refreshButton.setOnClickListener(v -> {
refreshButton.setEnabled(false); refreshButton.setEnabled(false);
commandQueue.readStatus("User request", new Callback() { commandQueue.readStatus(rh.gs(R.string.user_request), new Callback() {
@Override @Override
public void run() { public void run() {
runOnUiThread(() -> refreshButton.setEnabled(true)); runOnUiThread(() -> refreshButton.setEnabled(true));

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.interfaces
import android.os.SystemClock import android.os.SystemClock
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -18,7 +19,7 @@ abstract class PumpPluginBase(
if (getType() == PluginType.PUMP) { if (getType() == PluginType.PUMP) {
Thread { Thread {
SystemClock.sleep(3000) SystemClock.sleep(3000)
commandQueue.readStatus("Pump driver changed.", null) commandQueue.readStatus(rh.gs(R.string.pump_driver_changed), null)
}.start() }.start()
} }
} }

View file

@ -504,6 +504,24 @@
<string name="basal_value">Basal value</string> <string name="basal_value">Basal value</string>
<string name="nsclient_version_does_not_match">NSClient version doesn\'t match to AndroidAPS. Please update.</string> <string name="nsclient_version_does_not_match">NSClient version doesn\'t match to AndroidAPS. Please update.</string>
<!-- readStatus reasons -->
<string name="keepalive_status_outdated" comment="26 characters max for translation">KeepAlive. Status outdated.</string>
<string name="keepalive_basal_outdated" comment="26 characters max for translation">KeepAlive. Basal outdated.</string>
<string name="sms" comment="26 characters max for translation">SMS</string>
<string name="clicked_connect_to_pump" comment="26 characters max for translation">Clicked connect to pump</string>
<string name="pump_driver_changed" comment="26 characters max for translation">Pump driver changed.</string>
<string name="pump_driver_change" comment="26 characters max for translation">Pump driver change.</string>
<string name="device_changed" comment="26 characters max for translation">Device changed</string>
<string name="clicked_refresh" comment="26 characters max for translation">Clicked refresh</string>
<string name="scheduled_status_refresh" comment="26 characters max for translation">Scheduled Status Refresh</string>
<string name="unconfirmed_command" comment="26 characters max for translation">Unconfirmed command</string>
<string name="requested_by_user" comment="26 characters max for translation">Requested by user</string>
<string name="user_request" comment="26 characters max for translation">User request</string>
<string name="bolus_ok" comment="26 characters max for translation">Bolus OK</string>
<string name="pump_paired" comment="26 characters max for translation">Pump paired</string>
<string name="InsightRefreshButton" comment="26 characters max for translation">Insight Refresh Button</string>
<string name="read_status" comment="10 characters max for READSTATUS translation">READSTATUS %1$s</string>
<plurals name="days"> <plurals name="days">
<item quantity="one">%1$d day</item> <item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item> <item quantity="other">%1$d days</item>

View file

@ -112,7 +112,7 @@ class DanaFragment : DaggerFragment() {
binding.btConnectionLayout.setOnClickListener { binding.btConnectionLayout.setOnClickListener {
aapsLogger.debug(LTag.PUMP, "Clicked connect to pump") aapsLogger.debug(LTag.PUMP, "Clicked connect to pump")
danaPump.reset() 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 || if (activePlugin.activePump.pumpDescription.pumpType == PumpType.DANA_RS ||
activePlugin.activePump.pumpDescription.pumpType == PumpType.DANA_I activePlugin.activePump.pumpDescription.pumpType == PumpType.DANA_I

View file

@ -33,7 +33,7 @@ class MsgInitConnStatusTime_k(
//If profile coming from pump, switch it as well //If profile coming from pump, switch it as well
configBuilder.storeSettings("ChangingKoreanDanaDriver") configBuilder.storeSettings("ChangingKoreanDanaDriver")
rxBus.send(EventRebuildTabs()) rxBus.send(EventRebuildTabs())
commandQueue.readStatus("PumpDriverChange", null) // force new connection commandQueue.readStatus(rh.gs(R.string.pump_driver_change), null) // force new connection
return return
} }
val time = dateTimeSecFromBuff(bytes, 0) val time = dateTimeSecFromBuff(bytes, 0)

View file

@ -291,7 +291,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
SystemClock.sleep(300); SystemClock.sleep(300);
danaPump.setBolusingTreatment(null); danaPump.setBolusingTreatment(null);
commandQueue.readStatus("bolusOK", null); commandQueue.readStatus(rh.gs(R.string.bolus_ok), null);
} }
return !start.failed; return !start.failed;

View file

@ -40,7 +40,7 @@ class MsgCheckValue_v2(
//If profile coming from pump, switch it as well //If profile coming from pump, switch it as well
configBuilder.storeSettings("ChangingDanaRv2Driver") configBuilder.storeSettings("ChangingDanaRv2Driver")
rxBus.send(EventRebuildTabs()) rxBus.send(EventRebuildTabs())
commandQueue.readStatus("PumpDriverChange", null) // force new connection commandQueue.readStatus(rh.gs(R.string.pump_driver_change), null) // force new connection
return return
} }
if (danaPump.protocol != 2) { if (danaPump.protocol != 2) {
@ -57,7 +57,7 @@ class MsgCheckValue_v2(
//If profile coming from pump, switch it as well //If profile coming from pump, switch it as well
configBuilder.storeSettings("ChangingDanaRv2Driver") configBuilder.storeSettings("ChangingDanaRv2Driver")
rxBus.send(EventRebuildTabs()) rxBus.send(EventRebuildTabs())
commandQueue.readStatus("PumpDriverChange", null) // force new connection commandQueue.readStatus(rh.gs(R.string.pump_driver_change), null) // force new connection
return return
} }
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaPump.hwModel))

View file

@ -62,6 +62,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
protected DateUtil dateUtil; protected DateUtil dateUtil;
protected AapsSchedulers aapsSchedulers; protected AapsSchedulers aapsSchedulers;
protected PumpSync pumpSync; protected PumpSync pumpSync;
protected ResourceHelper rh;
protected AbstractDanaRPlugin( protected AbstractDanaRPlugin(
HasAndroidInjector injector, HasAndroidInjector injector,
@ -111,7 +112,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
if (event.isChanged(getRh(), R.string.key_danar_bt_name)) { if (event.isChanged(getRh(), R.string.key_danar_bt_name)) {
danaPump.reset(); danaPump.reset();
pumpSync.connectNewPump(); pumpSync.connectNewPump();
getCommandQueue().readStatus("DeviceChanged", null); getCommandQueue().readStatus(rh.gs(R.string.device_changed), null);
} }
}) })
); );

View file

@ -32,7 +32,7 @@ class MsgInitConnStatusTime(
//If profile coming from pump, switch it as well //If profile coming from pump, switch it as well
configBuilder.storeSettings("ChangingDanaDriver") configBuilder.storeSettings("ChangingDanaDriver")
rxBus.send(EventRebuildTabs()) 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 failed = false
return return
} else { } else {

View file

@ -356,7 +356,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
} }
} }
} else { } else {
commandQueue.readStatus("bolusOK", null); commandQueue.readStatus(rh.gs(R.string.bolus_ok), null);
} }
} }
return !start.failed; return !start.failed;

View file

@ -139,7 +139,7 @@ class DanaRSPlugin @Inject constructor(
mDeviceAddress = sp.getString(R.string.key_danars_address, "") mDeviceAddress = sp.getString(R.string.key_danars_address, "")
mDeviceName = sp.getString(R.string.key_danars_name, "") mDeviceName = sp.getString(R.string.key_danars_name, "")
danaPump.reset() danaPump.reset()
commandQueue.readStatus("DeviceChanged", null) commandQueue.readStatus(rh.gs(R.string.device_changed), null)
} }
override fun connect(reason: String) { override fun connect(reason: String) {

View file

@ -82,7 +82,7 @@ class DiaconnG8Fragment : DaggerFragment() {
binding.btconnection.setOnClickListener { binding.btconnection.setOnClickListener {
aapsLogger.debug(LTag.PUMP, "Clicked connect to pump") aapsLogger.debug(LTag.PUMP, "Clicked connect to pump")
diaconnG8Pump.lastConnection = 0 diaconnG8Pump.lastConnection = 0
commandQueue.readStatus("Clicked connect to pump", null) commandQueue.readStatus(rh.gs(R.string.clicked_connect_to_pump), null)
} }
} }

View file

@ -123,7 +123,7 @@ class DiaconnG8Plugin @Inject constructor(
mDeviceAddress = sp.getString(R.string.key_diaconn_g8_address, "") mDeviceAddress = sp.getString(R.string.key_diaconn_g8_address, "")
mDeviceName = sp.getString(R.string.key_diaconn_g8_name, "") mDeviceName = sp.getString(R.string.key_diaconn_g8_name, "")
diaconnG8Pump.reset() diaconnG8Pump.reset()
commandQueue.readStatus("DeviceChanged", null) commandQueue.readStatus(rh.gs(R.string.device_changed), null)
} }
override fun connect(reason: String) { override fun connect(reason: String) {

View file

@ -1628,7 +1628,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
@Override @Override
public void onPumpPaired() { public void onPumpPaired() {
commandQueue.readStatus("Pump paired", null); commandQueue.readStatus(rh.gs(R.string.pump_paired), null);
} }
@Override @Override

View file

@ -110,7 +110,7 @@ class MedtronicFragment : DaggerFragment() {
} else { } else {
binding.refresh.isEnabled = false binding.refresh.isEnabled = false
medtronicPumpPlugin.resetStatusState() medtronicPumpPlugin.resetStatusState()
commandQueue.readStatus("Clicked refresh", object : Callback() { commandQueue.readStatus(rh.gs(R.string.clicked_refresh), object : Callback() {
override fun run() { override fun run() {
activity?.runOnUiThread { if (_binding != null) binding.refresh.isEnabled = true } activity?.runOnUiThread { if (_binding != null) binding.refresh.isEnabled = true }
} }

View file

@ -203,7 +203,7 @@ class MedtronicPumpPlugin @Inject constructor(
)!! )!!
if (doWeHaveAnyStatusNeededRefreshing(statusRefresh)) { if (doWeHaveAnyStatusNeededRefreshing(statusRefresh)) {
if (!commandQueue.statusInQueue()) { if (!commandQueue.statusInQueue()) {
commandQueue.readStatus("Scheduled Status Refresh", null) commandQueue.readStatus(rh.gs(R.string.scheduled_status_refresh), null)
} }
} }
clearBusyQueue() clearBusyQueue()

View file

@ -197,7 +197,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
commandQueue.size() == 0 && commandQueue.size() == 0 &&
commandQueue.performing() == null commandQueue.performing() == null
) { ) {
commandQueue.readStatus("Unconfirmed command", null) commandQueue.readStatus(rh.gs(R.string.unconfirmed_command), null)
} }
} }

View file

@ -129,7 +129,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
buttonBinding.buttonRefreshStatus.setOnClickListener { buttonBinding.buttonRefreshStatus.setOnClickListener {
disablePodActionButtons() disablePodActionButtons()
commandQueue.readStatus( commandQueue.readStatus(
"REQUESTED BY USER", rh.gs(R.string.requested_by_user),
DisplayResultDialogCallback( DisplayResultDialogCallback(
rh.gs(R.string.omnipod_common_error_failed_to_refresh_status), rh.gs(R.string.omnipod_common_error_failed_to_refresh_status),
false false