Combo i18n.

This commit is contained in:
Johannes Mockenhaupt 2017-10-27 11:52:35 +02:00
parent b47559647f
commit eed3773b49
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
18 changed files with 87 additions and 61 deletions

View file

@ -20,12 +20,10 @@ import java.util.List;
import de.jotomo.ruffy.spi.CommandResult;
import de.jotomo.ruffy.spi.PumpState;
import de.jotomo.ruffy.spi.history.Bolus;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
public class ComboFragment extends SubscriberFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(ComboFragment.class);
@ -97,12 +95,13 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
// activity
String activity = plugin.getPump().activity;
activityView.setText(activity != null ? activity : "Idle");
activityView.setText(activity != null ? activity : "");
if (plugin.isInitialized()) {
// status
// state
stateView.setText(plugin.getStateSummary());
PumpState ps = plugin.getPump().state;
stateView.setText(plugin.getPump().state.getStateSummary());
if (plugin.getPump().state.errorMsg != null
|| ps.insulinState == PumpState.EMPTY
|| ps.batteryState == PumpState.EMPTY) {
@ -144,14 +143,14 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
// TODO must not be within if (lastCmdResult) so we can complain if NO command ever worked; also move from completionTime to new times
// TODO check all access to completionTime. useful anymore?
if (plugin.getPump().lastSuccessfulConnection < System.currentTimeMillis() + 30 * 60 * 1000) {
lastConnectionView.setText("No connection for " + minAgo + " min");
lastConnectionView.setText(getString(R.string.combo_no_pump_connection, minAgo));
lastConnectionView.setTextColor(Color.RED);
}
if (plugin.getPump().lastConnectionAttempt > plugin.getPump().lastSuccessfulConnection) {
lastConnectionView.setText("Last connect attempt failed");
lastConnectionView.setText(R.string.combo_connect_attempt_failed);
lastConnectionView.setTextColor(Color.YELLOW);
} else {
lastConnectionView.setText("" + minAgo + " (" + time + ")");
lastConnectionView.setText(getString(R.string.combo_last_connection_time, minAgo, time));
lastConnectionView.setTextColor(Color.WHITE);
}
@ -161,9 +160,11 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
Bolus bolus = history.get(0);
long agoMsc = System.currentTimeMillis() - bolus.timestamp;
double agoHours = agoMsc / 60d / 60d / 1000d;
lastBolusView.setText(DecimalFormatter.to2Decimal(bolus.amount) + " U " +
"(" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ", "
+ DateUtil.timeString(bolus.timestamp) + ") ");
lastBolusView.setText(getString(R.string.combo_last_bolus,
bolus.amount,
agoHours,
getString(R.string.hoursago),
DateUtil.timeString(bolus.timestamp)));
} else {
lastBolusView.setText("");
}
@ -175,7 +176,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
long minSinceRead = (System.currentTimeMillis() - lastCmdResult.completionTime) / 1000 / 60;
long remaining = ps.tbrRemainingDuration - minSinceRead;
if (remaining >= 0) {
tbrStr = ps.tbrPercent + "% (" + remaining + " min remaining)";
tbrStr = getString(R.string.combo_tbr_remaining, ps.tbrPercent, remaining);
}
}
tempBasalText.setText(tbrStr);

View file

@ -16,7 +16,6 @@ import de.jotomo.ruffy.spi.CommandResult;
import de.jotomo.ruffy.spi.PumpState;
import de.jotomo.ruffy.spi.RuffyCommands;
import de.jotomo.ruffy.spi.history.Bolus;
import de.jotomo.ruffy.spi.history.PumpError;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest;
import de.jotomo.ruffy.spi.history.Tbr;
import de.jotomo.ruffyscripter.RuffyCommandsV1Impl;
@ -33,8 +32,6 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI;
import info.nightscout.utils.DateUtil;
@ -128,6 +125,17 @@ public class ComboPlugin implements PluginBase, PumpInterface {
return getName();
}
String getStateSummary() {
PumpState ps = pump.state;
if (ps.menu == null)
return MainApp.sResources.getString(R.string.combo_pump_state_unreachable);
else if (ps.suspended && (ps.batteryState == PumpState.EMPTY || ps.insulinState == PumpState.EMPTY))
return MainApp.sResources.getString(R.string.combo_pump_state_suspended_due_to_error);
else if (ps.suspended)
return MainApp.sResources.getString(R.string.combo_pump_state_suspended_by_user);
return MainApp.sResources.getString(R.string.combo_pump_state_running);
}
@Override
public boolean isEnabled(int type) {
return type == PUMP && fragmentEnabled;
@ -736,7 +744,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
JSONObject pumpJson = new JSONObject();
JSONObject statusJson = new JSONObject();
JSONObject extendedJson = new JSONObject();
statusJson.put("status", pump.state.getStateSummary());
statusJson.put("status", getStateSummary());
extendedJson.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
try {
extendedJson.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
@ -785,7 +793,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override
public String shortStatus(boolean veryShort) {
// TODO trim for wear if veryShort==true
return pump.state.getStateSummary();
return getStateSummary();
}
@Override

View file

@ -3,10 +3,8 @@ package info.nightscout.androidaps.plugins.PumpCombo;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import de.jotomo.ruffy.spi.PumpState;
import de.jotomo.ruffy.spi.CommandResult;
import de.jotomo.ruffy.spi.history.Bolus;
import de.jotomo.ruffy.spi.history.PumpHistory;
class ComboPump {

View file

@ -36,7 +36,6 @@ public class PairingActivity extends AppCompatActivity {
private ListView listView = null;
private PairingActivity.ListAdapter mListAdapter = null;
private ArrayList<PairingActivity.BluetoothDeviceItem> mDevices = new ArrayList<>();
;
private BluetoothAdapter mBluetoothAdapter = null;
private BluetoothLeScanner mBluetoothLeScanner = null;

View file

@ -29,7 +29,7 @@
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="State"
android:text="@string/combo_pump_state_label"
android:textSize="14sp" />
<TextView
@ -74,7 +74,7 @@
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="Battery"
android:text="@string/pump_battery_label"
android:textSize="14sp" />
<TextView
@ -119,7 +119,7 @@
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="Reservoir"
android:text="@string/pump_reservoir_label"
android:textSize="14sp" />
<TextView
@ -164,7 +164,7 @@
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="Activity"
android:text="@string/combo_pump_activity"
android:textSize="14sp" />
<TextView
@ -360,6 +360,7 @@
android:paddingRight="0dp"
android:text="@string/combo_refresh" />
<!-- TODO v3-->
<Button
android:id="@+id/combo_stats"
style="@style/ButtonSmallFontStyle"

View file

@ -144,7 +144,7 @@
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/virtualpump_battery_label"
android:text="@string/pump_battery_label"
android:textSize="14sp" />
<TextView
@ -460,7 +460,7 @@
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/virtualpump_reservoir_label"
android:text="@string/pump_reservoir_label"
android:textSize="14sp" />
<TextView

View file

@ -165,7 +165,7 @@
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/virtualpump_battery_label"
android:text="@string/pump_battery_label"
android:textSize="14sp" />
<TextView
@ -209,7 +209,7 @@
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/virtualpump_reservoir_label"
android:text="@string/pump_reservoir_label"
android:textSize="14sp" />
<TextView

View file

@ -48,9 +48,9 @@
<string name="treatments_wizard_total_label">ОБШО</string>
<string name="openapsma_run">Старт сега</string>
<string name="pump_basebasalrate_label">Базова базална стойност</string>
<string name="virtualpump_battery_label">Батерия</string>
<string name="pump_battery_label">Батерия</string>
<string name="virtualpump_extendedbolus_label">Удължен болус</string>
<string name="virtualpump_reservoir_label">Резервоар</string>
<string name="pump_reservoir_label">Резервоар</string>
<string name="virtualpump_resultok">OK</string>
<string name="virtualpump_sqlerror">Грешка в базата данни</string>
<string name="pump_tempbasal_label">Временен базал</string>

View file

@ -154,9 +154,9 @@
<string name="unsupportedclientver">Nepodporovaná verze NSClient</string>
<string name="virtualpump">Virtualní pumpa</string>
<string name="pump_basebasalrate_label">Základní hodnota bazálu</string>
<string name="virtualpump_battery_label">Baterie</string>
<string name="pump_battery_label">Baterie</string>
<string name="virtualpump_extendedbolus_label">Prodloužený bolus</string>
<string name="virtualpump_reservoir_label">Zásobník</string>
<string name="pump_reservoir_label">Zásobník</string>
<string name="virtualpump_resultok">OK</string>
<string name="virtualpump_sqlerror">Chyba databáze</string>
<string name="pump_tempbasal_label">Dočasný bazál</string>

View file

@ -23,7 +23,7 @@
<string name="tempbasals_netratio_label_string">Ratio:</string>
<string name="tempbasals_realduration_label_string">Dur:</string>
<string name="treatmentdeliveryerror">Bolus Abgabefehler</string>
<string name="virtualpump_battery_label">Batterie</string>
<string name="pump_battery_label">Batterie</string>
<string name="virtualpump_resultok">OK</string>
<string name="basal">Basal</string>
<string name="bolus">Bolus</string>
@ -92,12 +92,12 @@
<string name="treatments_wizard_unit_label">E</string>
<string name="up">Up</string>
<string name="virtualpump">Virtuelle Pumpe</string>
<string name="virtualpump_reservoir_label">Reservoir</string>
<string name="pump_reservoir_label">Reservoir</string>
<string name="xdrip">xDrip</string>
<string name="vitualpump_label">VIRTUELLE PUMPE</string>
<string name="virtualpump_sqlerror">SQL Error</string>
<string name="virtualpump_extendedbolus_label">Extended bolus</string>
<string name="pump_tempbasal_label">Temp basal</string>
<string name="pump_tempbasal_label">Temporäre Basalrate</string>
<string name="visible">Sichtbar</string>
<string name="pump_basebasalrate_label">Basis Basalrate</string>
<string name="treatments_wizard_total_label">TOTAL</string>
@ -619,4 +619,22 @@
<string formatted="false" name="dia_too_short">DIA von %s ist zu kurz - aaps nutzt stattdessen %s!</string>
<string name="danar_stats_warning_Message">Möglicherweise ungenau, wenn zum Befüllen ein Bolus verwendet wurde!</string>
<string name="danar_stats_ratio">Verhältnis</string>
<string name="combo_refresh">Aktualisieren</string>
<string name="combo_pump_activity">Aktivität</string>
<string name="combo_tbr_remaining">%d%% (%d verbleibend)</string>
<string name="combopump_settings">Accu-Chek Combo settings Einstellungen</string>
<string name="combo_connect_attempt_failed">Verbindungsaufbau fehlgeschlagen</string>
<string name="combo_no_pump_connection">Keine Verbindung zur Pumpe seit %s</string>
<string name="bolusstopped">Bolusabgabe gestopped</string>
<string name="bolusstopping">Bolusabgabe wird abgebrochen</string>
<string name="pump_errors_history">Fehlerprotokol</string>
<string name="treatments_wizard_tt_label">TZ</string>
<string name="combo_pump_state_label">Status</string>
<string name="combo_pump_state_unreachable">Keine Verbindung zur Pumpe</string>
<string name="combo_pump_state_suspended_by_user">Durch Benuzter gestoppt</string>
<string name="combo_pump_state_suspended_due_to_error">Wegen Fehler gestoppt</string>
<string name="combo_pump_state_running">Normaler Betrieb</string>
<string name="combo_last_bolus">Letzter Bolus</string>
<string name="combo_last_connection_time">Letzte Verbindung</string>
<string name="combo_stats">Statistiken</string>
</resources>

View file

@ -49,8 +49,8 @@
<string name="pump_basebasalrate_label">Dosis Basal Base</string>
<string name="pump_tempbasal_label">Basal Temporal</string>
<string name="virtualpump_extendedbolus_label">Bolo extendido</string>
<string name="virtualpump_battery_label">Batería</string>
<string name="virtualpump_reservoir_label">Depósito:</string>
<string name="pump_battery_label">Batería</string>
<string name="pump_reservoir_label">Depósito:</string>
<string name="virtualpump_resultok">OK</string>
<string name="virtualpump_sqlerror">Error de SQL</string>
<string name="openapsma_lastrun_label">Última ejecución</string>

View file

@ -439,11 +439,11 @@
<string name="virtualpump_shortname">VPUMP</string>
<string name="virtualpump_settings">Impostazioni del Micro virtuale</string>
<string name="virtualpump_resultok">ok</string>
<string name="virtualpump_reservoir_label">Serbatoio</string>
<string name="pump_reservoir_label">Serbatoio</string>
<string name="pump_lastconnection_label">Ultima conessione</string>
<string name="virtualpump_firmware_label">Firmware</string>
<string name="virtualpump_extendedbolus_label">Bolo Esteso</string>
<string name="virtualpump_battery_label">Batteria</string>
<string name="pump_battery_label">Batteria</string>
<string name="pump_basebasalrate_label">Base basale</string>
<string name="virtualpump">Micro Virtuale</string>
<string name="uploading">UpLoading</string>

View file

@ -51,8 +51,8 @@
<string name="pump_basebasalrate_label">기본 기초주입량</string>
<string name="pump_tempbasal_label">임시기초주입</string>
<string name="virtualpump_extendedbolus_label">확장식사주입</string>
<string name="virtualpump_battery_label">배터리</string>
<string name="virtualpump_reservoir_label">인슐린 잔량</string>
<string name="pump_battery_label">배터리</string>
<string name="pump_reservoir_label">인슐린 잔량</string>
<string name="virtualpump_resultok">OK</string>
<string name="virtualpump_sqlerror">SQL 에러</string>
<string name="openapsma_lastrun_label">최근 실행</string>

View file

@ -46,12 +46,12 @@
<string name="virtualpump_shortname">VP</string>
<string name="virtualpump_settings">Virtuele pomp instellingen</string>
<string name="virtualpump_resultok">OK</string>
<string name="virtualpump_reservoir_label">Reservoir</string>
<string name="pump_reservoir_label">Reservoir</string>
<string name="pump_lastconnection_label">Laatste verbinding</string>
<string name="virtualpump_firmware_label">Firmware</string>
<string name="virtualpump_extendedbolus_label_short">EXT</string>
<string name="virtualpump_extendedbolus_label">Vertraagde bolus</string>
<string name="virtualpump_battery_label">Batterij</string>
<string name="pump_battery_label">Batterij</string>
<string name="virtualpump">Virtuele Pomp</string>
<string name="uploading">Uploaden</string>
<string name="uploader_short">UPLD</string>

View file

@ -529,11 +529,11 @@
<string name="uploading">передача данных</string>
<string name="virtualpump">виртуальная помпа</string>
<string name="pump_basebasalrate_label">базовая величина базала</string>
<string name="virtualpump_battery_label">батарея</string>
<string name="pump_battery_label">батарея</string>
<string name="virtualpump_extendedbolus_label">продленный болюс</string>
<string name="virtualpump_firmware_label">прошивка</string>
<string name="pump_lastconnection_label">прошлое соединение</string>
<string name="virtualpump_reservoir_label">резервуар</string>
<string name="pump_reservoir_label">резервуар</string>
<string name="virtualpump_resultok">OK</string>
<string name="virtualpump_settings">настройки вирт помпы</string>
<string name="virtualpump_shortname">ВиртПомпа</string>

View file

@ -313,11 +313,11 @@
<string name="virtualpump_shortname">VPUMP</string>
<string name="virtualpump_settings">Virtuell pump inställningar</string>
<string name="virtualpump_resultok">OK</string>
<string name="virtualpump_reservoir_label">Reservoir</string>
<string name="pump_reservoir_label">Reservoir</string>
<string name="pump_lastconnection_label">Sista kontakt</string>
<string name="virtualpump_firmware_label">Programversion</string>
<string name="virtualpump_extendedbolus_label">Förlängd bolus</string>
<string name="virtualpump_battery_label">Batteri</string>
<string name="pump_battery_label">Batteri</string>
<string name="pump_basebasalrate_label">Grund basal hastighet</string>
<string name="virtualpump">Virtuell Pump</string>
<string name="uploading">Uppladdning</string>

View file

@ -53,8 +53,8 @@
<string name="pump_basebasalrate_label">Base basal rate</string>
<string name="pump_tempbasal_label">Temp basal</string>
<string name="virtualpump_extendedbolus_label">Extended bolus</string>
<string name="virtualpump_battery_label">Battery</string>
<string name="virtualpump_reservoir_label">Reservoir</string>
<string name="pump_battery_label">Battery</string>
<string name="pump_reservoir_label">Reservoir</string>
<string name="virtualpump_resultok">OK</string>
<string name="virtualpump_sqlerror">SQL Error</string>
<string name="openapsma_lastrun_label">Last run</string>
@ -683,9 +683,9 @@
<string name="cpp_valuesnotstored">Values not stored!</string>
<string name="wear_overviewnotifications">Overview Notifications</string>
<string name="wear_overviewnotifications_summary">Pass the Overview Notifications through as wear confirmation messages.</string>
<string name="combopump">Accu-Chek Combo</string>
<string name="combopump" translatable="false">Accu-Chek Combo</string>
<string name="combopump_settings">Accu-Chek Combo settings</string>
<string name="combopump_shortname">COMBO</string>
<string name="combopump_shortname" translatable="false">COMBO</string>
<string name="ns_localbroadcasts">Enable broadcasts to other apps (like xDrip).</string>
<string name="ns_localbroadcasts_title">Enable local Broadcasts.</string>
<string name="careportal_activity_label">ACTIVITY &amp; FEEDBACK</string>
@ -754,5 +754,16 @@
<string name="bolusprogramming">Programming pump for bolusing</string>
<string name="combo_refresh">Refresh</string>
<string name="combo_stats">Stats</string>
<string name="combo_pump_state_label">State</string>
<string name="combo_pump_activity">Activity</string>
<string name="combo_no_pump_connection">No connection for %s</string>
<string name="combo_connect_attempt_failed">Last connect attempt failed</string>
<string name="combo_last_connection_time">%s (%s)</string>
<string name="combo_tbr_remaining">%d%% (%d remaining)</string>
<string name="combo_last_bolus">%.2f U (%.1f %s, %s)</string>
<string name="combo_pump_state_unreachable">Unreachable</string>
<string name="combo_pump_state_suspended_due_to_error">Suspended due to error</string>
<string name="combo_pump_state_suspended_by_user">Suspended by user</string>
<string name="combo_pump_state_running">Running</string>
</resources>

View file

@ -78,16 +78,6 @@ public class PumpState {
return this;
}
public String getStateSummary() {
if (menu == null)
return "Unreachable";
else if (suspended && (batteryState == EMPTY || insulinState == EMPTY))
return "Suspended due to error";
else if (suspended)
return "Suspended by user";
return "Running";
}
@Override
public String toString() {
return "PumpState{" +