From eed3773b49a3cd13327877d2d6c137b8fcd13911 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 27 Oct 2017 11:52:35 +0200 Subject: [PATCH] Combo i18n. --- .../plugins/PumpCombo/ComboFragment.java | 25 ++++++++++--------- .../plugins/PumpCombo/ComboPlugin.java | 18 +++++++++---- .../plugins/PumpCombo/ComboPump.java | 2 -- .../PumpCombo/activities/PairingActivity.java | 1 - .../main/res/layout/combopump_fragment.xml | 9 ++++--- app/src/main/res/layout/danar_fragment.xml | 4 +-- .../main/res/layout/vitualpump_fragment.xml | 4 +-- app/src/main/res/values-bg/strings.xml | 4 +-- app/src/main/res/values-cs/strings.xml | 4 +-- app/src/main/res/values-de/strings.xml | 24 +++++++++++++++--- app/src/main/res/values-es/strings.xml | 4 +-- app/src/main/res/values-it/strings.xml | 4 +-- app/src/main/res/values-ko/strings.xml | 4 +-- app/src/main/res/values-nl/strings.xml | 4 +-- app/src/main/res/values-ru/strings.xml | 4 +-- app/src/main/res/values-sv/strings.xml | 4 +-- app/src/main/res/values/strings.xml | 19 +++++++++++--- .../java/de/jotomo/ruffy/spi/PumpState.java | 10 -------- 18 files changed, 87 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index 3aa3930d08..7b7ea19c01 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -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); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index d53f4055d7..0217d71f2d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -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 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java index 202989a27a..27b064ef1c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java @@ -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 { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/activities/PairingActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/activities/PairingActivity.java index 3c368659dd..c4456d3c8c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/activities/PairingActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/activities/PairingActivity.java @@ -36,7 +36,6 @@ public class PairingActivity extends AppCompatActivity { private ListView listView = null; private PairingActivity.ListAdapter mListAdapter = null; private ArrayList mDevices = new ArrayList<>(); - ; private BluetoothAdapter mBluetoothAdapter = null; private BluetoothLeScanner mBluetoothLeScanner = null; diff --git a/app/src/main/res/layout/combopump_fragment.xml b/app/src/main/res/layout/combopump_fragment.xml index 7d208858ff..82bfca75d5 100644 --- a/app/src/main/res/layout/combopump_fragment.xml +++ b/app/src/main/res/layout/combopump_fragment.xml @@ -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" /> +