From fa20af444043e34f98e4d2ed63db8fc92c7de763 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 13 Oct 2019 17:58:45 +0200 Subject: [PATCH 01/14] network status before time --- .../constraints/objectives/ObjectivesFragment.kt | 9 +++++---- .../objectives/activities/ObjectivesExamDialog.kt | 7 +++---- .../objectives/objectives/Objective.java | 2 +- .../objectives/objectives/Objective2.java | 5 +++++ .../general/nsclient/NsClientReceiverDelegate.java | 2 +- .../receivers/NetworkChangeReceiver.java | 14 +++++++++++++- .../main/res/layout/objectives_exam_fragment.xml | 2 +- app/src/main/res/values/exam.xml | 3 +++ app/src/main/res/values/objectives.xml | 2 +- 9 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index cd6e6dff4c..52f394285d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -51,7 +51,6 @@ class ObjectivesFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - objectives_recyclerview.layoutManager = LinearLayoutManager(view.context) objectives_recyclerview.adapter = objectivesAdapter objectives_fake.setOnClickListener { updateGUI() } @@ -208,15 +207,16 @@ class ObjectivesFragment : Fragment() { holder.accomplished.setTextColor(-0x3e3e3f) holder.verify.setOnClickListener { holder.verify.visibility = View.INVISIBLE + NetworkChangeReceiver.fetch() SntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { activity?.runOnUiThread { holder.verify.visibility = View.VISIBLE log.debug("NTP time: $time System time: ${DateUtil.now()}") - if (!networkConnected) { + if (!networkConnected && !objectives_fake.isChecked) { ToastUtils.showToastInUiThread(context, R.string.notconnected) } else if (success) { - if (objective.isCompleted(time)) { + if (objective.isCompleted(time) || objectives_fake.isChecked) { objective.accomplishedOn = time notifyDataSetChanged() scrollToCurrentObjective() @@ -233,12 +233,13 @@ class ObjectivesFragment : Fragment() { } holder.start.setOnClickListener { holder.start.visibility = View.INVISIBLE + NetworkChangeReceiver.fetch() SntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { activity?.runOnUiThread { holder.start.visibility = View.VISIBLE log.debug("NTP time: $time System time: ${DateUtil.now()}") - if (!networkConnected) { + if (!networkConnected && !objectives_fake.isChecked) { ToastUtils.showToastInUiThread(context, R.string.notconnected) } else if (success) { objective.startedOn = time diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt index 30ab4b500b..1428652be5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt @@ -57,12 +57,11 @@ class ObjectivesExamDialog : DialogFragment() { objectives_exam_question.setText(task.question) // Options objectives_exam_options.removeAllViews() - for (o in task.options) { - val option: Option = o as Option; - val cb = option.generate(context) + task.options.forEach { + val cb = it.generate(context) if (task.answered) { cb.isEnabled = false - if (option.isCorrect) + if (it.isCorrect) cb.isChecked = true } objectives_exam_options.addView(cb) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java index b126f93673..c882a921f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.java @@ -230,7 +230,7 @@ public abstract class Objective { return question; } - public List getOptions() { + public List getOptions() { return options; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.java index 58d27308a5..017ad33a8c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective2.java @@ -199,6 +199,11 @@ public class Objective2 extends Objective { .hint(new Hint(R.string.profileswitchtime_hint1)) ); + tasks.add(new ExamTask(R.string.other_medication_label, R.string.other_medication_text,"otherMedicationWarning") + .option(new Option(R.string.yes, true)) + .option(new Option(R.string.no, false)) + ); + for (Task task : tasks) Collections.shuffle(((ExamTask)task).options); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NsClientReceiverDelegate.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NsClientReceiverDelegate.java index 072ad6cd56..daeb646053 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NsClientReceiverDelegate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NsClientReceiverDelegate.java @@ -23,7 +23,7 @@ class NsClientReceiverDelegate { private final Context context; private final Bus bus; - private NetworkChangeReceiver networkChangeReceiver = new NetworkChangeReceiver(); + private NetworkChangeReceiver networkChangeReceiver = NetworkChangeReceiver.instance; private ChargingStateReceiver chargingStateReceiver = new ChargingStateReceiver(); private boolean allowedChargingState = true; diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java index 2695ad64f2..efe836cd28 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/receivers/NetworkChangeReceiver.java @@ -8,6 +8,7 @@ import android.net.NetworkInfo; import android.net.wifi.SupplicantState; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; + import androidx.annotation.Nullable; import org.slf4j.Logger; @@ -23,6 +24,17 @@ public class NetworkChangeReceiver extends BroadcastReceiver { private static EventNetworkChange lastEvent = null; + public static final NetworkChangeReceiver instance = new NetworkChangeReceiver(); + + // TODO: Split NSClient into network state component that can be used by several plugins and logic for plugin + public static void fetch() { + NetworkChangeReceiver.instance.grabNetworkStatus(MainApp.instance().getApplicationContext()); + } + + private NetworkChangeReceiver() { + super(); + } + @Override public void onReceive(final Context context, final Intent intent) { EventNetworkChange event = grabNetworkStatus(context); @@ -71,7 +83,7 @@ public class NetworkChangeReceiver extends BroadcastReceiver { return lastEvent != null && lastEvent.wifiConnected; } - public static boolean isConnected() { + public static boolean isConnected() { return lastEvent != null && (lastEvent.wifiConnected || lastEvent.mobileConnected); } diff --git a/app/src/main/res/layout/objectives_exam_fragment.xml b/app/src/main/res/layout/objectives_exam_fragment.xml index ff906d036d..2fe02877bd 100644 --- a/app/src/main/res/layout/objectives_exam_fragment.xml +++ b/app/src/main/res/layout/objectives_exam_fragment.xml @@ -105,7 +105,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" - android:text="Disabled to:" + android:text="Disabled until:" android:textColor="#FF5722" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/app/src/main/res/values/exam.xml b/app/src/main/res/values/exam.xml index ae4fa99587..1303038828 100644 --- a/app/src/main/res/values/exam.xml +++ b/app/src/main/res/values/exam.xml @@ -162,5 +162,8 @@ Your diabetes team Google Facebook + Other Medication + AAPS reduces BR to raise blood sugar. Drugs from the group of SGLT2 inhibitors (gliflozins) can prevent the expected increase and thus may produce a dangerous insulin deficiency (DKA). +\nCommon brand names are: Invokana®, Forxiga®, Jardiance®, Steglatro®, Suglat®, Apleway®, Deberza®, Synjardy®, Vokanamet®, Xigduo®.\n\nI hereby confirm that I will not take such drugs when using AAPS or will deactivate the loop before using these drugs. diff --git a/app/src/main/res/values/objectives.xml b/app/src/main/res/values/objectives.xml index 8464c4d947..469db88006 100644 --- a/app/src/main/res/values/objectives.xml +++ b/app/src/main/res/values/objectives.xml @@ -52,7 +52,7 @@ Code invalid Prove your knowledge Study and answer questions correctly - Answering disabled to: %1$s + Answering disabled until: %1$s Wrong answer! Next unfinished Request code: %1$s From 78fe46d33ea643dfb07a67295fd4c0f3222745f1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 13 Oct 2019 18:08:24 +0200 Subject: [PATCH 02/14] fix string --- app/src/main/res/values/exam.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/exam.xml b/app/src/main/res/values/exam.xml index 1303038828..e5b5e19633 100644 --- a/app/src/main/res/values/exam.xml +++ b/app/src/main/res/values/exam.xml @@ -163,7 +163,7 @@ Google Facebook Other Medication - AAPS reduces BR to raise blood sugar. Drugs from the group of SGLT2 inhibitors (gliflozins) can prevent the expected increase and thus may produce a dangerous insulin deficiency (DKA). + AAPS reduces BR to raise blood sugar. Drugs from the group of SGLT2 inhibitors (gliflozins) can prevent the expected increase in BG and thus may produce a dangerous insulin deficiency (DKA). \nCommon brand names are: Invokana®, Forxiga®, Jardiance®, Steglatro®, Suglat®, Apleway®, Deberza®, Synjardy®, Vokanamet®, Xigduo®.\n\nI hereby confirm that I will not take such drugs when using AAPS or will deactivate the loop before using these drugs. From 2c5597c5bf20e1dbd1db16bc38a8d0ea9e7ae219 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 13 Oct 2019 18:12:32 +0200 Subject: [PATCH 03/14] nicer string --- app/src/main/res/values/exam.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/exam.xml b/app/src/main/res/values/exam.xml index e5b5e19633..e9063fd2b1 100644 --- a/app/src/main/res/values/exam.xml +++ b/app/src/main/res/values/exam.xml @@ -164,6 +164,6 @@ Facebook Other Medication AAPS reduces BR to raise blood sugar. Drugs from the group of SGLT2 inhibitors (gliflozins) can prevent the expected increase in BG and thus may produce a dangerous insulin deficiency (DKA). -\nCommon brand names are: Invokana®, Forxiga®, Jardiance®, Steglatro®, Suglat®, Apleway®, Deberza®, Synjardy®, Vokanamet®, Xigduo®.\n\nI hereby confirm that I will not take such drugs when using AAPS or will deactivate the loop before using these drugs. +\nCommon brand names are: Invokana®, Forxiga®, Jardiance®, Steglatro®, Suglat®, Apleway®, Deberza®, Synjardy®, Vokanamet®, Xigduo®.\n\nI hereby promise that I will not take such drugs when using AAPS or will deactivate the loop before using these drugs. From 0fcad5646ebfa29ef3c731d17cd176b380c59de5 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 17 Oct 2019 13:23:29 +0100 Subject: [PATCH 04/14] Added processing of Prime records from Pump - it only processes if record is less than 30 minutes old and if it was not processed already (we store last PrimeRecord) --- .../pump/common/utils/DateTimeUtil.java | 25 +++++++ .../medtronic/data/MedtronicHistoryData.java | 72 +++++++++++++++++-- .../pump/medtronic/util/MedtronicConst.java | 1 + 3 files changed, 94 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/DateTimeUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/DateTimeUtil.java index e4f097e7db..783553f431 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/DateTimeUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/DateTimeUtil.java @@ -250,4 +250,29 @@ public class DateTimeUtil { return minutes.getMinutes(); } + + + public static long getMillisFromATDWithAddedMinutes(long atd, int minutesDiff) { + GregorianCalendar oldestEntryTime = DateTimeUtil.toGregorianCalendar(atd); + oldestEntryTime.add(Calendar.MINUTE, minutesDiff); + + return oldestEntryTime.getTimeInMillis(); + } + + + public static long getATDWithAddedMinutes(long atd, int minutesDiff) { + GregorianCalendar oldestEntryTime = DateTimeUtil.toGregorianCalendar(atd); + oldestEntryTime.add(Calendar.MINUTE, minutesDiff); + + return oldestEntryTime.getTimeInMillis(); + } + + + public static long getATDWithAddedMinutes(GregorianCalendar oldestEntryTime, int minutesDiff) { + oldestEntryTime.add(Calendar.MINUTE, minutesDiff); + + return toATechDate(oldestEntryTime); + } + + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java index 00cda7feca..208512ab1d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java @@ -6,6 +6,8 @@ import com.google.gson.GsonBuilder; import org.apache.commons.lang3.StringUtils; import org.joda.time.LocalDateTime; import org.joda.time.Minutes; +import org.json.JSONException; +import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,6 +22,7 @@ import java.util.Map; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.DetailedBolusInfo; +import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DbObjectBase; import info.nightscout.androidaps.db.ExtendedBolus; @@ -27,6 +30,7 @@ import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TDD; import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.logging.L; +import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil; @@ -46,6 +50,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; import info.nightscout.androidaps.plugins.treatments.Treatment; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.SP; @@ -59,6 +64,7 @@ import info.nightscout.androidaps.utils.SP; // all times that time changed (TZ, DST, etc.). Data needs to be returned in batches (time_changed batches, so that we can // handle it. It would help to assign sort_ids to items (from oldest (1) to newest (x) +// All things marked with "TODO: Fix db code" needs to be updated in new 2.5 database code public class MedtronicHistoryData { @@ -382,6 +388,22 @@ public class MedtronicHistoryData { */ public void processNewHistoryData() { + // TODO: Fix db code + // Prime (for reseting autosense) + List primeRecords = getFilteredItems(PumpHistoryEntryType.Prime); + + if (isLogEnabled()) + LOG.debug("ProcessHistoryData: Prime [count={}, items={}]", primeRecords.size(), gson.toJson(primeRecords)); + + if (isCollectionNotEmpty(primeRecords)) { + try { + processPrime(primeRecords); + } catch (Exception ex) { + LOG.error("ProcessHistoryData: Error processing Prime entries: " + ex.getMessage(), ex); + throw ex; + } + } + // TDD List tdds = getFilteredItems(PumpHistoryEntryType.EndResultTotals, getTDDType()); @@ -454,6 +476,49 @@ public class MedtronicHistoryData { } + private void processPrime(List primeRecords) { + + long maxAllowedTimeInPast = DateTimeUtil.getATDWithAddedMinutes(new GregorianCalendar(), -30); + + long lastPrimeRecord = 0L; + + for (PumpHistoryEntry primeRecord : primeRecords) { + + if (primeRecord.atechDateTime > maxAllowedTimeInPast) { + if (lastPrimeRecord < primeRecord.atechDateTime) { + lastPrimeRecord = primeRecord.atechDateTime; + } + } + } + + if (lastPrimeRecord != 0L) { + long lastPrimeFromAAPS = SP.getLong(MedtronicConst.Statistics.LastPrime, 0L); + + if (lastPrimeRecord != lastPrimeFromAAPS) { + uploadCareportalEvent(DateTimeUtil.toMillisFromATD(lastPrimeRecord), CareportalEvent.SITECHANGE); + + SP.putLong(MedtronicConst.Statistics.LastPrime, lastPrimeRecord); + } + } + } + + + private void uploadCareportalEvent(long date, String event) { + if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date) != null) + return; + try { + JSONObject data = new JSONObject(); + String enteredBy = SP.getString("careportal_enteredby", ""); + if (!enteredBy.equals("")) data.put("enteredBy", enteredBy); + data.put("created_at", DateUtil.toISOString(date)); + data.put("eventType", event); + NSUpload.uploadCareportalEntryToNS(data); + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private void processTDDs(List tddsIn) { List tdds = filterTDDs(tddsIn); @@ -681,12 +746,11 @@ public class MedtronicHistoryData { /** * findDbEntry - finds Db entries in database, while theoretically this should have same dateTime they - * don't. Entry on pump is few seconds before treatment in AAPS, and on manual boluses on pump there - * is no treatment at all. For now we look fro tratment that was from 0s - 1m59s within pump entry. + * don't. Entry on pump is few seconds before treatment in AAPS, and on manual boluses on pump there + * is no treatment at all. For now we look fro tratment that was from 0s - 1m59s within pump entry. * - * @param treatment Pump Entry + * @param treatment Pump Entry * @param entriesFromHistory entries from history - * * @return DbObject from AAPS (if found) */ private DbObjectBase findDbEntry(PumpHistoryEntry treatment, List entriesFromHistory) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.java index b5bd2f1f64..cd39ba53bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.java @@ -42,6 +42,7 @@ public class MedtronicConst { public static final String StandardBoluses = StatsPrefix + "std_boluses_delivered"; public static final String SMBBoluses = StatsPrefix + "smb_boluses_delivered"; public static final String LastPumpHistoryEntry = StatsPrefix + "pump_history_entry"; + public static final String LastPrime = StatsPrefix + "last_sent_prime"; } } From c867ae110485800c0c21f17497c9e60db9664eec Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 23 Oct 2019 22:55:49 +0200 Subject: [PATCH 05/14] VirtualPumpFragment -> kotlin --- .../general/automation/AutomationFragment.kt | 9 +- .../pump/virtual/VirtualPumpFragment.java | 122 ------------------ .../pump/virtual/VirtualPumpFragment.kt | 85 ++++++++++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 89 insertions(+), 128 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt index 728480323c..d1135c21ed 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt @@ -74,14 +74,11 @@ class AutomationFragment : Fragment() { @Synchronized private fun updateGui() { - if (eventListAdapter == null) return eventListAdapter?.notifyDataSetChanged() val sb = StringBuilder() - for (l in AutomationPlugin.executionLog.reversed()) { - sb.append(l) - sb.append("\n") - } - automation_logView.text = sb.toString() + for (l in AutomationPlugin.executionLog.reversed()) + sb.append(l).append("\n") + automation_logView?.text = sb.toString() } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.java deleted file mode 100644 index 35e95d66b7..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.java +++ /dev/null @@ -1,122 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.virtual; - - -import android.app.Activity; -import android.os.Bundle; -import android.os.Handler; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.db.ExtendedBolus; -import info.nightscout.androidaps.db.TemporaryBasal; -import info.nightscout.androidaps.plugins.bus.RxBus; -import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; -import info.nightscout.androidaps.plugins.pump.virtual.events.EventVirtualPumpUpdateGui; -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; -import info.nightscout.androidaps.utils.FabricPrivacy; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; - - -public class VirtualPumpFragment extends Fragment { - private static Logger log = LoggerFactory.getLogger(VirtualPumpFragment.class); - private CompositeDisposable disposable = new CompositeDisposable(); - - TextView basaBasalRateView; - TextView tempBasalView; - TextView extendedBolusView; - TextView batteryView; - TextView reservoirView; - TextView pumpTypeView; - TextView pumpSettingsView; - - - private static Handler sLoopHandler = new Handler(); - private static Runnable sRefreshLoop = null; - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (sRefreshLoop == null) { - sRefreshLoop = () -> { - Activity activity = getActivity(); - if (activity != null) - activity.runOnUiThread(this::updateGui); - sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L); - }; - sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.virtualpump_fragment, container, false); - basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate); - tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal); - extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus); - batteryView = (TextView) view.findViewById(R.id.virtualpump_battery); - reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir); - pumpTypeView = (TextView) view.findViewById(R.id.virtualpump_type); - pumpSettingsView = (TextView) view.findViewById(R.id.virtualpump_type_def); - - return view; - } - - @Override - public synchronized void onResume() { - super.onResume(); - disposable.add(RxBus.INSTANCE - .toObservable(EventVirtualPumpUpdateGui.class) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(event -> updateGui(), FabricPrivacy::logException) - ); - updateGui(); - } - - @Override - public synchronized void onPause() { - super.onPause(); - disposable.clear(); - } - - protected void updateGui() { - VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getPlugin(); - basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U"); - TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()); - if (activeTemp != null) { - tempBasalView.setText(activeTemp.toStringFull()); - } else { - tempBasalView.setText(""); - } - ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis()); - if (activeExtendedBolus != null) { - extendedBolusView.setText(activeExtendedBolus.toString()); - } else { - extendedBolusView.setText(""); - } - batteryView.setText(virtualPump.batteryPercent + "%"); - reservoirView.setText(virtualPump.reservoirInUnits + "U"); - - virtualPump.refreshConfiguration(); - - PumpType pumpType = virtualPump.getPumpType(); - - pumpTypeView.setText(pumpType.getDescription()); - - String template = MainApp.gs(R.string.virtualpump_pump_def); - - - pumpSettingsView.setText(pumpType.getFullDescription(template, pumpType.hasExtendedBasals())); - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt new file mode 100644 index 0000000000..08402520c2 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt @@ -0,0 +1,85 @@ +package info.nightscout.androidaps.plugins.pump.virtual + +import android.os.Bundle +import android.os.Handler +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.R +import info.nightscout.androidaps.events.EventExtendedBolusChange +import info.nightscout.androidaps.events.EventTempBasalChange +import info.nightscout.androidaps.plugins.bus.RxBus +import info.nightscout.androidaps.plugins.pump.virtual.events.EventVirtualPumpUpdateGui +import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.T +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.CompositeDisposable +import kotlinx.android.synthetic.main.virtualpump_fragment.* +import org.slf4j.LoggerFactory + +class VirtualPumpFragment : Fragment() { + private val disposable = CompositeDisposable() + + private val loopHandler = Handler() + private lateinit var refreshLoop: Runnable + + init { + refreshLoop = Runnable { + activity?.runOnUiThread { updateGui() } + loopHandler.postDelayed(refreshLoop, T.mins(1).msecs()) + } + } + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.virtualpump_fragment, container, false) + } + + @Synchronized + override fun onResume() { + super.onResume() + disposable.add(RxBus + .toObservable(EventVirtualPumpUpdateGui::class.java) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe({ updateGui() }, { FabricPrivacy.logException(it) }) + ) + disposable.add(RxBus + .toObservable(EventTempBasalChange::class.java) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe({ updateGui() }, { FabricPrivacy.logException(it) }) + ) + disposable.add(RxBus + .toObservable(EventExtendedBolusChange::class.java) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe({ updateGui() }, { FabricPrivacy.logException(it) }) + ) + loopHandler.postDelayed(refreshLoop, T.mins(1).msecs()) + updateGui() + } + + @Synchronized + override fun onPause() { + super.onPause() + disposable.clear() + loopHandler.removeCallbacks(refreshLoop) + } + + @Synchronized + private fun updateGui() { + val virtualPump = VirtualPumpPlugin.getPlugin() + virtualpump_basabasalrate?.text = MainApp.gs(R.string.pump_basebasalrate, virtualPump.baseBasalRate) + virtualpump_tempbasal?.text = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() + ?: "" + virtualpump_extendedbolus?.text = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis())?.toString() ?: "" + virtualpump_battery?.text = MainApp.gs(R.string.format_percent, virtualPump.batteryPercent) + virtualpump_reservoir?.text = MainApp.gs(R.string.formatinsulinunits, virtualPump.reservoirInUnits.toDouble()) + + virtualPump.refreshConfiguration() + val pumpType = virtualPump.pumpType + + virtualpump_type?.text = pumpType.description + virtualpump_type_def?.text = pumpType.getFullDescription(MainApp.gs(R.string.virtualpump_pump_def), pumpType.hasExtendedBasals()) + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3139b71a38..ebabd0df15 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1602,6 +1602,7 @@ %1$s ISF: %2$.1f %1$.0fg IC: %2$.1f %1$.1fg IC: %2$.1f + %1$d%% Bolus wizard min From e2abdce146c170fc30781aafbd91f816ecfe68a8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 24 Oct 2019 10:28:50 +0200 Subject: [PATCH 06/14] New Crowdin translations (#2128) * New translations objectives.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations strings.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations objectives.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations objectives.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations objectives.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations objectives.xml (Portuguese) * New translations exam.xml (Portuguese) * New translations strings.xml (German) * New translations strings.xml (Lithuanian) * New translations strings.xml (Lithuanian) * New translations strings.xml (French) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (French) * New translations strings.xml (Russian) * New translations strings.xml (Portuguese) * New translations strings.xml (German) * New translations strings.xml (Afrikaans) * New translations strings.xml (Lithuanian) * New translations strings.xml (Bulgarian) * New translations strings.xml (Czech) --- app/src/main/res/values-af-rZA/strings.xml | 22 +++++++++++ app/src/main/res/values-bg-rBG/strings.xml | 1 + app/src/main/res/values-cs-rCZ/strings.xml | 1 + app/src/main/res/values-de-rDE/strings.xml | 3 +- app/src/main/res/values-fr-rFR/strings.xml | 7 ++-- app/src/main/res/values-lt-rLT/strings.xml | 13 ++++--- app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-pt-rPT/exam.xml | 39 +++++++++++++++++++ app/src/main/res/values-pt-rPT/objectives.xml | 17 ++++++++ app/src/main/res/values-pt-rPT/strings.xml | 3 +- app/src/main/res/values-ru-rRU/strings.xml | 1 + 11 files changed, 97 insertions(+), 11 deletions(-) diff --git a/app/src/main/res/values-af-rZA/strings.xml b/app/src/main/res/values-af-rZA/strings.xml index 1df78ea55f..0739b28283 100644 --- a/app/src/main/res/values-af-rZA/strings.xml +++ b/app/src/main/res/values-af-rZA/strings.xml @@ -33,6 +33,7 @@ Mees onlangse algoritme vir gevorderde gebruikers Wys die huidige staat van jou lus en knoppies vir mees algemene optrede Toon \'n voortgesette kennisgewing met \'n kort oorsig van wat jou lus besig is om te doen + Definieer\'n profiel wat beskikbaar is aflyn. Bied die profiel wat jy het beskryf het in Nightscout Definieer \'n profiel met net een tydblok. Pomp Integrasie met Accu-Chek Combo pompe, vereis dat ruffy geïnstalleer is @@ -1336,6 +1337,27 @@ Verkry Tydelike Basale Stel Tydelike Basale Stel Bolus + Verander profiel na + Verander profiel na %1$s + Laaste konneksie na pomp + Laaste konneksie na pomp [minute gelede] + Vorige konneksie na pomp %1$s %2$s min terug + Stuur\'n SMS: %1$s + Stuur SMS na alle fone in voorkeure + Stuur\'n SMS met die teks Bolus beperking aangewend: %2$.2fU to %3$.2fU]]> %1$.0f / %2$d U + Laai tans... + Sluimer + Tyd reeks + Tyd is tussen %1$s en %2$s + Tussen + Maak toe + Ongeldig boodskap teks + %1$s ISF: %2$.1f + %1$.0fg IC: %2$.1f + %1$.1fg IC: %2$.1f + %1$d%% + Bolus slimjan + min diff --git a/app/src/main/res/values-bg-rBG/strings.xml b/app/src/main/res/values-bg-rBG/strings.xml index 7d66bad159..f6e3ded8df 100644 --- a/app/src/main/res/values-bg-rBG/strings.xml +++ b/app/src/main/res/values-bg-rBG/strings.xml @@ -1368,6 +1368,7 @@ %1$s ISF: %2$.1f %1$.0fгр Чувств: %2$.1f %1$.1fгр Чувств: %2$.1f + %1$d %% Болус калкулатор мин diff --git a/app/src/main/res/values-cs-rCZ/strings.xml b/app/src/main/res/values-cs-rCZ/strings.xml index 13c65531e5..2a8edebc99 100644 --- a/app/src/main/res/values-cs-rCZ/strings.xml +++ b/app/src/main/res/values-cs-rCZ/strings.xml @@ -1369,6 +1369,7 @@ %1$s ISF: %2$.1f %1$.0fg IC: %2$.1f %1$.1fg IC: %2$.1f + %1$d%% Bolusová kalkulačka min diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index df441a07d4..261255b57e 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -478,7 +478,7 @@ Passwort für die Einstellungen Einstellungen freischalten Tagesinsulin-Limit wird bald erreicht - Nighscout-Client + Nightscout-Client NSCl URL: Auto-Scrollen @@ -1370,6 +1370,7 @@ Unerwartetes Verhalten. %1$s ISF: %2$.1f %1$.0fg IC: %2$.1f %1$.1fg IC: %2$.1f + %1$d%% Bolus-Rechner Min. diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 8811098fbd..f7a7be126a 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -426,13 +426,13 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S ACT CONF BOUCLE - SP + P.S. OAPS - LP + P.L. DANA ACCUEIL POMPEV - PROFIL NS + P.NS TRAIT CP OBJ @@ -1370,6 +1370,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S %1$s SI: %2$.1f %1$.0fg G/I: %2$.1f %1$.1fg G/I: %2$.1f + %1$d%% Assistant Bolus min diff --git a/app/src/main/res/values-lt-rLT/strings.xml b/app/src/main/res/values-lt-rLT/strings.xml index 8b47cc4a76..b2c3122929 100644 --- a/app/src/main/res/values-lt-rLT/strings.xml +++ b/app/src/main/res/values-lt-rLT/strings.xml @@ -65,7 +65,7 @@ Tikslas Nenustatytas profilis Insulinas: - Angliavandeniai: + AV: AIO: AIO: Visas AIO: @@ -76,10 +76,10 @@ AIO: Visas AIO: Insulinas - Angliavandeniai + AV KG LT - Angliavandeniai + AV Korekcija vv Bolusų AIO @@ -158,7 +158,7 @@ Bolusas: Valandinė bazė Valandinė bazė: - Angliavandeniai + AV Pakeiskite įvestus duomenis! Nustatyti naują ištęstą bolusą: KG šaltinis @@ -341,7 +341,7 @@ Greitasis patarėjas Greitojo patarėjo nustatymai Mygtuko tekstas: - Angliavandeniai: + AV: Galioja: Pridėti Redaguoti @@ -787,7 +787,7 @@ Paleisti laikinąją bazę Nutildyti Insulinas - Angliavandeniai + AV Mygtukai Siunčia kalibravimą į xDrip+ arba atidaro G5 kalibravimo dialogą Atidaro xDrip+, o mygtukas ATGAL gražina į AAPS @@ -1369,6 +1369,7 @@ %1$s JIF: %2$.1f %1$.0fg IA: %2$.1f %1$.1fg IA: %2$.1f + %1$d%% Boluso patarėjas min. diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 5068a68e02..48ad20eda6 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1348,6 +1348,7 @@ Alterar perfil para %1$s Última ligação à bomba Última ligação à bomba [minutos atrás] + Última ligação à bomba %1$s %2$s min atrás Enviar SMS: %1$s Enviar SMS para todos os números nas preferências Enviar SMS com texto diff --git a/app/src/main/res/values-pt-rPT/exam.xml b/app/src/main/res/values-pt-rPT/exam.xml index 8e944c54a6..ab9ad540be 100644 --- a/app/src/main/res/values-pt-rPT/exam.xml +++ b/app/src/main/res/values-pt-rPT/exam.xml @@ -7,14 +7,21 @@ O valor mínimo é de 5 horas. https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html?#insulin O significado é igual ao parâmetro DIA usado na bomba. + É necessário determinar o seu valor individual (mas não menos de 5 horas). Tópico: Alvo-Temp. Hipo O que é a razão principal para definir TT hipoglicemia? + Para evitar que a Glic fique baixa se já estiver em funcionamento um temp zero. + Para evitar o AAPS dosear demasiada insulina após uma subida rápida causada por hidratos de actuação rápida para tratar hipoglicemia. https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html + Qual perfil pode ser usado e configurado offline? Tópico: Perfil Offline Perfil NS pode ser usado, mas não configurado. https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#profile Tópico: Desligar a Bomba + O que deve ser feito ao desligar a bomba? Clique em \'Desligar bomba\' para que o AAPS saiba que nenhuma insulina está a ser entregue. + Clique em \'Suspender loop\' para que AAPS pare o looping enquanto a bomba estiver desconectada. + Não altere nada no AAPS, apenas desconecte a bomba. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#other-settings Tópico: Definições do AndroidAPS Quais são as práticas recomendadas para fazer cópia de segurança das configurações? @@ -35,19 +42,27 @@ https://androidaps.readthedocs.io/en/latest/EN/Usage/Smoothing-Blood-Glucose-Data-in-xDrip.html#smoothing-blood-glucose-data Verifique que a app do CGM suaviza os dados da Glicose. Tópico: Exercício + Como você pode ajudar o sistema a lidar com exercícios? Usando o recurso de alvo-temp. Fazer uma mudança de perfil inferior a 100%. Fazer uma mudança de perfil acima de 100%. Parar o loop. + Definir um alvo-temp de actividade antes de iniciar o exercício. + Definir um alvo-temp de actividade após iniciar o exercício leva a resultados piores do que se iniciado antes. https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html#activity-temp-target Tópico: Loop Desactivado/Suspenso + Eu recebo insulina quando o loop estiver desactivado/suspenso? + Sim, a insulina basal continua a ser entregue. + Não, a entrega da insulina está parada. Topic: Testar Basal, FSI e IC + Quando devo validar valores das basais, FSI e de IC? Antes de começar com o looping. Quando ocorrer frequentemente Glic baixa. Quando ocorrer frequentemente Glic alta. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#androidaps-settings Tópico: Pré-requisitos O que preciso? + Informações do perfil validadas (Basal, IC, FSI, DIA). Um computador para criar um APK. Um telefone compatível. Um Carro. @@ -79,40 +94,64 @@ https://www.facebook.com/groups/AndroidAPSUsers/ https://gitter.im/MilosKozak/AndroidAPS Tópico: Plugins de Insulina + Qual marca de insulina pode ser usada com o plugin \'Ultra-Rapid-Oref\'? Fiasp® NovoRapid ® Humalog ® Actrapid ® https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#insulin Tópico: Plugins de Sensibilidade + Qual algoritmo de sensibilidade tem um intervalo de tempo configurável? https://androidaps.readthedocs.io/en/latest/EN/Configuration/Sensitivity-detection-and-COB.html + Qual plugin de sensibilidade deve ser usado para o recurso UAM? Tópico: Erros de Entrada de Hidratos + O que deve fazer se tiver feito uma entrada incorrecta de hidratos? + Em Tratamentos, excluir a entrada incorrecta de hidratos. Insira novos hidratos. + Como adicionar insulina falsa utilizando a função Recarregar Tópico: Alimentos com Gordura e Proteína + O que fazer se a comida contém uma grande quantidade de gordura e/ou proteínas? + Recalcular gordura e proteínas em hidratos e usar recurso de \"Hidratos Estendidos\". + Recalcular gordura e proteínas em hidratos e adicionar ao cálculo de bólus. + Use o bólus estendido para cobrir gordura e proteínas. https://androidaps.readthedocs.io/en/latest/EN/Usage/Extended-Carbs.html Tópico: Monitorização Remota + Como pode monitorizar AAPS do seu filho remotamente? Usando um site Nightscout. + App Dex om Follow se estiver a usar a app original Dexcom (Glic apenas). + Dexcom Follow se estiver a usar a app xDrip. xDrip a correr no modo seguidor. App de Loop no iPhone. App Spike no iPhone. https://androidaps.readthedocs.io/en/latest/EN/Children/Children.html Tópico: Factor de Sensibilidade de Insulina + Valores elevados de FSI levam a uma entrega de menos insulina quando o AAPS corrige Glic alta. + Valores baixos de FSI levam a uma entrega de menos insulina quando o AAPS corrige Glic alta. + Alterar os valores FSI não tem efeito sobre a quantidade de insulina entregue quando a AAPS corrige Glic alta. É necessário inserir FSI nas Preferências. A alteração do valor do FSI no seu perfil é suficiente para aplicar a mudança. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-sensitivity-factor-isf-mmol-l-u-or-mg-dl-u https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html Tópico: Rácio IC + Rácios IC mais altos levam a menos insulina entregue para uma dada quantidade de hidratos. + Rácios IC mais baixos levam a menos insulina entregue para uma dada quantidade de hidratos. + Se tiver 0 COB, alterar o rácio IC irá levar a uma quantidade diferente de insulina para corrigir um determinado valor da Glic. + IC será diferente se contar a unidade de pão como 10g ou 12g. + O significado do IC é: Quantas unidades de pão são cobertas por 1U de insulina. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#carbohydrate-to-insulin-ratio-cr-g-u Tópico: Mudança De Perfil + Ao especificar 90% na mudança de perfil… Basais são 10% superiores. Basais serão 10% inferiores. Valor IC será 10% superior. Valor IC será 10% inferior. O valor FSI será 10% mais alto. O valor FSI será 10% mais baixo. + Você receberá aproximadamente 10% menos insulina no total. Alvo será 10% superior. Alvo será 10% inferior. Só alvo inferior será 10% menor. https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#profile-switch + Se acordar 1h mais cedo do que o normal, como deve notificar a AAPS da mudança no seu horário? Iniciar uma mudança de perfil com uma alteração de turno de 1 Iniciar uma mudança de perfil com uma alteração de turno de -1 https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#timeshift diff --git a/app/src/main/res/values-pt-rPT/objectives.xml b/app/src/main/res/values-pt-rPT/objectives.xml index b08cb82a54..00bc0b8c77 100644 --- a/app/src/main/res/values-pt-rPT/objectives.xml +++ b/app/src/main/res/values-pt-rPT/objectives.xml @@ -7,7 +7,21 @@ %1$d. Objectivo Objetivo %1$d não iniciado Objetivo %1$d não terminado + A configurar visualização e monitorização, e análise de rácios e basais + Verificar se a Glic está disponível no Nightscout, e se os dados da bomba de insulina estão a ser carregados A iniciar em Open Loop + Utilizar em modo de Open Loop por alguns dias e dar manualmente muitas basais temporárias. Configurar e usar alvos temporários e alvos padrão temporários (por exemplo, para actividade ou tratamentos de hipo com hidratos) + Compreender o seu open loop, incluindo as recomendações de basais temporárias + Com base nessa experiência, decidir qual deve ser a basal máxima e configurá-la na bomba e nas preferências + Começar o close loop com Suspensão por Glicose Baixa + Utilizar em close loop com IOB máx = 0 por alguns dias sem muitas situações de Suspensão por Baixa Glicose + Ajustar o close loop, aumentar IOB máxima acima de 0 e reduzir gradualmente os alvos de Glic + Utilizar por alguns dias e pelo menos uma noite sem alarmes de Glic baixa, antes de baixar Glic + Ajuste as basais e os rácios, se necessário, e, em seguida, active o auto-sens + 1 semana de looping durante o dia com sucesso com entrada regular de hidratos de carbono + A activar recursos adicionais para uso durante o dia, como assistente avançado de refeição + Activando recursos adicionais para uso durante o dia, como SMB + Deverá ler a wiki e aumentar a IOB máx para que os SMBs funcionem devidamente! Inicialmente poderá considerar maxIOB=média dos bólus + 3 x a basal máxima Glic disponível no NS Estado da Bomba disponível no NS Execução manual @@ -16,6 +30,9 @@ Executar diferentes acções no AndroidAPS Definir perfil de 90% por 10 min (pressione longo no nome de perfil na Visão Geral) Simular chuveiro. Desligar a bomba de 1h (Pressione longo em Open Loop) + ... e volte a ligar de volta da mesma forma + Crie um alvo temporário personalizado com 10 min de duração (pressione longo no seu alvo actual) + No Configurador active o plugiin de Acções, torne-o visível e exiba o seu conteúdo no menu superior Mostrar conteúdo do plugin Loop Utilizar a função de escala premindo longamente gráfico Glic Inserir diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index fc2b1e0ddb..350c707033 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -296,7 +296,7 @@ Insulina diária Erros Glicose - Reabastecimento + Recarregar Suspender A ligar durante %1$d s Senha da bomba @@ -1369,6 +1369,7 @@ %1$s FSI: %2$.1f %1$.0fg IC: %2$.1f %1$.1fg IC: %2$.1f + %1$d%% Assistente de Bólus min diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index a01225fd0f..0a4d317757 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -1371,6 +1371,7 @@ Context | Edit Context %1$s ISF: %2$.1f %1$.0fg IC: %2$.1f %1$.1fg IC: %2$.1f + %1$d%% Мастер Болюса мин From 414695c5e3e8d94b30f180f6d8c9254610fdb077 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 24 Oct 2019 11:34:22 +0200 Subject: [PATCH 07/14] preserve show calculation checkbox state, make wizard better translatable" --- .../general/overview/dialogs/WizardDialog.kt | 76 ++++++++++--------- .../res/layout/overview_wizard_dialog.xml | 8 +- app/src/main/res/values/strings.xml | 5 +- 3 files changed, 48 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/WizardDialog.kt index 9471747d7c..552ab502e7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/dialogs/WizardDialog.kt @@ -30,6 +30,7 @@ import kotlinx.android.synthetic.main.overview_wizard_dialog.* import org.slf4j.LoggerFactory import java.text.DecimalFormat import java.util.* +import kotlin.math.abs class WizardDialog : DialogFragment() { private val log = LoggerFactory.getLogger(WizardDialog::class.java) @@ -69,10 +70,10 @@ class WizardDialog : DialogFragment() { override fun onSaveInstanceState(savedInstanceState: Bundle) { super.onSaveInstanceState(savedInstanceState) - savedInstanceState.putDouble("treatments_wizard_bginput", treatments_wizard_bginput.value) - savedInstanceState.putDouble("treatments_wizard_carbsinput", treatments_wizard_carbsinput.value) - savedInstanceState.putDouble("treatments_wizard_correctioninput", treatments_wizard_correctioninput.value) - savedInstanceState.putDouble("treatments_wizard_carbtimeinput", treatments_wizard_carbtimeinput.value) + savedInstanceState.putDouble("treatments_wizard_bg_input", treatments_wizard_bg_input.value) + savedInstanceState.putDouble("treatments_wizard_carbs_input", treatments_wizard_carbs_input.value) + savedInstanceState.putDouble("treatments_wizard_correction_input", treatments_wizard_correction_input.value) + savedInstanceState.putDouble("treatments_wizard_carb_time_input", treatments_wizard_carb_time_input.value) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, @@ -94,19 +95,19 @@ class WizardDialog : DialogFragment() { val maxCarbs = MainApp.getConstraintChecker().maxCarbsAllowed.value() val maxCorrection = MainApp.getConstraintChecker().maxBolusAllowed.value() - treatments_wizard_bginput.setParams(savedInstanceState?.getDouble("treatments_wizard_bginput") + treatments_wizard_bg_input.setParams(savedInstanceState?.getDouble("treatments_wizard_bg_input") ?: 0.0, 0.0, 500.0, 0.1, DecimalFormat("0.0"), false, ok, textWatcher) - treatments_wizard_carbsinput.setParams(savedInstanceState?.getDouble("treatments_wizard_carbsinput") + treatments_wizard_carbs_input.setParams(savedInstanceState?.getDouble("treatments_wizard_carbs_input") ?: 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, ok, textWatcher) - val bolusstep = ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.bolusStep + val bolusStep = ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.bolusStep ?: 0.1 - treatments_wizard_correctioninput.setParams(savedInstanceState?.getDouble("treatments_wizard_correctioninput") - ?: 0.0, -maxCorrection, maxCorrection, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, ok, textWatcher) - treatments_wizard_carbtimeinput.setParams(savedInstanceState?.getDouble("treatments_wizard_carbtimeinput") + treatments_wizard_correction_input.setParams(savedInstanceState?.getDouble("treatments_wizard_correction_input") + ?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, ok, textWatcher) + treatments_wizard_carb_time_input.setParams(savedInstanceState?.getDouble("treatments_wizard_carb_time_input") ?: 0.0, -60.0, 60.0, 5.0, DecimalFormat("0"), false, ok, textWatcher) initDialog() - treatments_wizard_percent_used.text = SP.getInt(R.string.key_boluswizard_percentage, 100).toString() + "%" + treatments_wizard_percent_used.text = MainApp.gs(R.string.format_percent, SP.getInt(R.string.key_boluswizard_percentage, 100)) // ok button ok.setOnClickListener { if (okClicked) { @@ -130,10 +131,13 @@ class WizardDialog : DialogFragment() { treatments_wizard_bgtrendcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) } treatments_wizard_sbcheckbox.setOnCheckedChangeListener { buttonView, _ -> onCheckedChanged(buttonView) } - treatments_wizard_delimiter.visibility = View.GONE - treatments_wizard_resulttable.visibility = View.GONE + val showCalc = SP.getBoolean(MainApp.gs(R.string.key_wizard_calculation_visible), false) + treatments_wizard_delimiter.visibility = if (showCalc) View.VISIBLE else View.GONE + treatments_wizard_resulttable.visibility = if (showCalc) View.VISIBLE else View.GONE + treatments_wizard_calculationcheckbox.isChecked = showCalc treatments_wizard_calculationcheckbox.setOnCheckedChangeListener { _, isChecked -> run { + SP.putBoolean(MainApp.gs(R.string.key_wizard_calculation_visible), isChecked) treatments_wizard_delimiter.visibility = if (isChecked) View.VISIBLE else View.GONE treatments_wizard_resulttable.visibility = if (isChecked) View.VISIBLE else View.GONE } @@ -168,7 +172,7 @@ class WizardDialog : DialogFragment() { disposable.clear() } - fun onCheckedChanged(buttonView: CompoundButton) { + private fun onCheckedChanged(buttonView: CompoundButton) { saveCheckedStates() treatments_wizard_ttcheckbox.isEnabled = treatments_wizard_bgcheckbox.isChecked && TreatmentsPlugin.getPlugin().tempTargetFromHistory != null if (buttonView.id == treatments_wizard_cobcheckbox.id) @@ -220,17 +224,17 @@ class WizardDialog : DialogFragment() { val units = profile.units treatments_wizard_bgunits.text = units if (units == Constants.MGDL) - treatments_wizard_bginput.setStep(1.0) + treatments_wizard_bg_input.setStep(1.0) else - treatments_wizard_bginput.setStep(0.1) + treatments_wizard_bg_input.setStep(0.1) // Set BG if not old val lastBg = DatabaseHelper.actualBg() if (lastBg != null) { - treatments_wizard_bginput.value = lastBg.valueToUnits(units) + treatments_wizard_bg_input.value = lastBg.valueToUnits(units) } else { - treatments_wizard_bginput.value = 0.0 + treatments_wizard_bg_input.value = 0.0 } treatments_wizard_ttcheckbox.isEnabled = TreatmentsPlugin.getPlugin().tempTargetFromHistory != null @@ -263,29 +267,29 @@ class WizardDialog : DialogFragment() { if (specificProfile == null) return // Entered values - var c_bg = SafeParse.stringToDouble(treatments_wizard_bginput.text) - val c_carbs = SafeParse.stringToInt(treatments_wizard_carbsinput.text) - val c_correction = SafeParse.stringToDouble(treatments_wizard_correctioninput.text) - val carbsAfterConstraint = MainApp.getConstraintChecker().applyCarbsConstraints(Constraint(c_carbs)).value() - if (Math.abs(c_carbs - carbsAfterConstraint) > 0.01) { - treatments_wizard_carbsinput.value = 0.0 + var bg = SafeParse.stringToDouble(treatments_wizard_bg_input.text) + val carbs = SafeParse.stringToInt(treatments_wizard_carbs_input.text) + val correction = SafeParse.stringToDouble(treatments_wizard_correction_input.text) + val carbsAfterConstraint = MainApp.getConstraintChecker().applyCarbsConstraints(Constraint(carbs)).value() + if (abs(carbs - carbsAfterConstraint) > 0.01) { + treatments_wizard_carbs_input.value = 0.0 ToastUtils.showToastInUiThread(MainApp.instance().applicationContext, MainApp.gs(R.string.carbsconstraintapplied)) return } - c_bg = if (treatments_wizard_bgcheckbox.isChecked) c_bg else 0.0 + bg = if (treatments_wizard_bgcheckbox.isChecked) bg else 0.0 val tempTarget = if (treatments_wizard_ttcheckbox.isChecked) TreatmentsPlugin.getPlugin().tempTargetFromHistory else null // COB - var c_cob = 0.0 + var cob = 0.0 if (treatments_wizard_cobcheckbox.isChecked) { val cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "Wizard COB") - cobInfo.displayCob?.let { c_cob = it } + cobInfo.displayCob?.let { cob = it } } - val carbTime = SafeParse.stringToInt(treatments_wizard_carbtimeinput.text) + val carbTime = SafeParse.stringToInt(treatments_wizard_carb_time_input.text) - wizard = BolusWizard(specificProfile, profileName, tempTarget, carbsAfterConstraint, c_cob, c_bg, c_correction, + wizard = BolusWizard(specificProfile, profileName, tempTarget, carbsAfterConstraint, cob, bg, correction, SP.getInt(R.string.key_boluswizard_percentage, 100).toDouble(), treatments_wizard_bgcheckbox.isChecked, treatments_wizard_cobcheckbox.isChecked, @@ -297,10 +301,10 @@ class WizardDialog : DialogFragment() { treatment_wizard_notes.text.toString(), carbTime) wizard?.let { wizard -> - treatments_wizard_bg.text = String.format(MainApp.gs(R.string.format_bg_isf), BgReading().value(Profile.toMgdl(c_bg, specificProfile.units)).valueToUnitsToString(specificProfile.units), wizard.sens) + treatments_wizard_bg.text = String.format(MainApp.gs(R.string.format_bg_isf), BgReading().value(Profile.toMgdl(bg, specificProfile.units)).valueToUnitsToString(specificProfile.units), wizard.sens) treatments_wizard_bginsulin.text = StringUtils.formatInsulin(wizard.insulinFromBG) - treatments_wizard_carbs.text = String.format(MainApp.gs(R.string.format_carbs_ic), c_carbs.toDouble(), wizard.ic) + treatments_wizard_carbs.text = String.format(MainApp.gs(R.string.format_carbs_ic), carbs.toDouble(), wizard.ic) treatments_wizard_carbsinsulin.text = StringUtils.formatInsulin(wizard.insulinFromCarbs) treatments_wizard_bolusiobinsulin.text = StringUtils.formatInsulin(wizard.insulinFromBolusIOB) @@ -324,7 +328,7 @@ class WizardDialog : DialogFragment() { // COB if (treatments_wizard_cobcheckbox.isChecked) { - treatments_wizard_cob.text = String.format(MainApp.gs(R.string.format_cob_ic), c_cob, wizard.ic) + treatments_wizard_cob.text = String.format(MainApp.gs(R.string.format_cob_ic), cob, wizard.ic) treatments_wizard_cobinsulin.text = StringUtils.formatInsulin(wizard.insulinFromCOB) } else { treatments_wizard_cob.text = "" @@ -332,12 +336,12 @@ class WizardDialog : DialogFragment() { } if (wizard.calculatedTotalInsulin > 0.0 || carbsAfterConstraint > 0.0) { - val insulinText = if (wizard.calculatedTotalInsulin > 0.0) DecimalFormatter.toPumpSupportedBolus(wizard.calculatedTotalInsulin) + "U" else "" - val carbsText = if (carbsAfterConstraint > 0.0) DecimalFormatter.to0Decimal(carbsAfterConstraint.toDouble()) + "g" else "" - treatments_wizard_total.text = MainApp.gs(R.string.result) + ": " + insulinText + " " + carbsText + val insulinText = if (wizard.calculatedTotalInsulin > 0.0) MainApp.gs(R.string.formatinsulinunits, wizard.calculatedTotalInsulin) else "" + val carbsText = if (carbsAfterConstraint > 0.0) MainApp.gs(R.string.format_carbs, carbsAfterConstraint) else "" + treatments_wizard_total.text = MainApp.gs(R.string.result_insulin_carbs, insulinText, carbsText) ok.visibility = View.VISIBLE } else { - treatments_wizard_total.text = MainApp.gs(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.carbsEquivalent) + "g" + treatments_wizard_total.text = MainApp.gs(R.string.missing_carbs, wizard.carbsEquivalent.toInt()) ok.visibility = View.INVISIBLE } } diff --git a/app/src/main/res/layout/overview_wizard_dialog.xml b/app/src/main/res/layout/overview_wizard_dialog.xml index c8add6e2b5..a56efc38fd 100644 --- a/app/src/main/res/layout/overview_wizard_dialog.xml +++ b/app/src/main/res/layout/overview_wizard_dialog.xml @@ -55,7 +55,7 @@ android:textStyle="bold" /> @@ -85,7 +85,7 @@ android:textStyle="bold" /> @@ -116,7 +116,7 @@ android:textStyle="bold" /> @@ -146,7 +146,7 @@ android:textStyle="bold" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ebabd0df15..22cc2ff15f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -121,6 +121,7 @@ Profile Meal data Result + Result: %1$s $2$s No glucose data available No change requested Request @@ -245,7 +246,7 @@ TempBasal Extended Bolus Nightscout version: - Missing + Missing %1$dg Preferences exported Export settings to Import settings from @@ -1605,5 +1606,7 @@ %1$d%% Bolus wizard min + wizard_calculation_visible + %1$dg From 1d7b3e10e48b31a2994f24bf67f0777422d6abac Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 24 Oct 2019 14:14:51 +0200 Subject: [PATCH 08/14] typo --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 22cc2ff15f..5efe97baab 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -121,7 +121,7 @@ Profile Meal data Result - Result: %1$s $2$s + Result: %1$s %2$s No glucose data available No change requested Request From e84e59b4ca0b8d61a04547809f7ea9b495418dd0 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 24 Oct 2019 21:36:44 +0200 Subject: [PATCH 09/14] fix objectives fragment --- .../objectives/ObjectivesFragment.kt | 74 +++++++++++-------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 52f394285d..56f046055b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -208,48 +208,60 @@ class ObjectivesFragment : Fragment() { holder.verify.setOnClickListener { holder.verify.visibility = View.INVISIBLE NetworkChangeReceiver.fetch() - SntpClient.ntpTime(object : SntpClient.Callback() { - override fun run() { - activity?.runOnUiThread { - holder.verify.visibility = View.VISIBLE - log.debug("NTP time: $time System time: ${DateUtil.now()}") - if (!networkConnected && !objectives_fake.isChecked) { - ToastUtils.showToastInUiThread(context, R.string.notconnected) - } else if (success) { - if (objective.isCompleted(time) || objectives_fake.isChecked) { - objective.accomplishedOn = time - notifyDataSetChanged() - scrollToCurrentObjective() - startUpdateTimer() + if (objectives_fake.isChecked) { + objective.accomplishedOn = DateUtil.now() + notifyDataSetChanged() + scrollToCurrentObjective() + startUpdateTimer() + } else + SntpClient.ntpTime(object : SntpClient.Callback() { + override fun run() { + activity?.runOnUiThread { + holder.verify.visibility = View.VISIBLE + log.debug("NTP time: $time System time: ${DateUtil.now()}") + if (!networkConnected) { + ToastUtils.showToastInUiThread(context, R.string.notconnected) + } else if (success) { + if (objective.isCompleted(time)) { + objective.accomplishedOn = time + notifyDataSetChanged() + scrollToCurrentObjective() + startUpdateTimer() + } else { + ToastUtils.showToastInUiThread(context, R.string.requirementnotmet) + } } else { - ToastUtils.showToastInUiThread(context, R.string.requirementnotmet) + ToastUtils.showToastInUiThread(context, R.string.failedretrievetime) } - } else { - ToastUtils.showToastInUiThread(context, R.string.failedretrievetime) } } - } - }, NetworkChangeReceiver.isConnected()) + }, NetworkChangeReceiver.isConnected()) } holder.start.setOnClickListener { holder.start.visibility = View.INVISIBLE NetworkChangeReceiver.fetch() SntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { - activity?.runOnUiThread { - holder.start.visibility = View.VISIBLE - log.debug("NTP time: $time System time: ${DateUtil.now()}") - if (!networkConnected && !objectives_fake.isChecked) { - ToastUtils.showToastInUiThread(context, R.string.notconnected) - } else if (success) { - objective.startedOn = time - notifyDataSetChanged() - scrollToCurrentObjective() - startUpdateTimer() - } else { - ToastUtils.showToastInUiThread(context, R.string.failedretrievetime) + if (objectives_fake.isChecked) { + objective.startedOn = time + notifyDataSetChanged() + scrollToCurrentObjective() + startUpdateTimer() + } else + activity?.runOnUiThread { + holder.start.visibility = View.VISIBLE + log.debug("NTP time: $time System time: ${DateUtil.now()}") + if (!networkConnected) { + ToastUtils.showToastInUiThread(context, R.string.notconnected) + } else if (success) { + objective.startedOn = time + notifyDataSetChanged() + scrollToCurrentObjective() + startUpdateTimer() + } else { + ToastUtils.showToastInUiThread(context, R.string.failedretrievetime) + } } - } } }, NetworkChangeReceiver.isConnected()) } From 830f59b2fabf7acc9cfde801580f3d3d92387186 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 24 Oct 2019 23:06:43 +0200 Subject: [PATCH 10/14] fix pluging list --- app/src/main/java/info/nightscout/androidaps/MainApp.java | 6 +++--- .../plugins/constraints/objectives/ObjectivesPlugin.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 049f07dccb..3231fc7e01 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -191,9 +191,9 @@ public class MainApp extends Application { pluginsList.add(TreatmentsPlugin.getPlugin()); if (!Config.NSCLIENT) pluginsList.add(SafetyPlugin.getPlugin()); if (!Config.NSCLIENT) pluginsList.add(VersionCheckerPlugin.INSTANCE); - if (!Config.NSCLIENT) pluginsList.add(StorageConstraintPlugin.getPlugin()); - if (!Config.NSCLIENT) pluginsList.add(SignatureVerifierPlugin.getPlugin()); - if (!Config.APS) pluginsList.add(ObjectivesPlugin.INSTANCE); + if (Config.APS) pluginsList.add(StorageConstraintPlugin.getPlugin()); + if (Config.APS) pluginsList.add(SignatureVerifierPlugin.getPlugin()); + if (Config.APS) pluginsList.add(ObjectivesPlugin.INSTANCE); pluginsList.add(SourceXdripPlugin.getPlugin()); pluginsList.add(SourceNSClientPlugin.getPlugin()); pluginsList.add(SourceMM640gPlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index 7913e73426..ca3e1d3126 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -21,8 +21,8 @@ import java.util.* object ObjectivesPlugin : PluginBase(PluginDescription() .mainType(PluginType.CONSTRAINTS) .fragmentClass(ObjectivesFragment::class.qualifiedName) - .alwaysEnabled(!Config.NSCLIENT) - .showInList(!Config.NSCLIENT) + .alwaysEnabled(Config.APS) + .showInList(Config.APS) .pluginName(R.string.objectives) .shortName(R.string.objectives_shortname) .description(R.string.description_objectives)), ConstraintsInterface { From a18f5523b98139581206047fece36d669092f2fc Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 24 Oct 2019 23:54:59 +0200 Subject: [PATCH 11/14] better update objectives gui --- .../constraints/objectives/ObjectivesFragment.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 56f046055b..5ae8b0ed67 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -210,9 +210,9 @@ class ObjectivesFragment : Fragment() { NetworkChangeReceiver.fetch() if (objectives_fake.isChecked) { objective.accomplishedOn = DateUtil.now() - notifyDataSetChanged() scrollToCurrentObjective() startUpdateTimer() + RxBus.send(EventObjectivesUpdateGui()) } else SntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { @@ -224,9 +224,9 @@ class ObjectivesFragment : Fragment() { } else if (success) { if (objective.isCompleted(time)) { objective.accomplishedOn = time - notifyDataSetChanged() scrollToCurrentObjective() startUpdateTimer() + RxBus.send(EventObjectivesUpdateGui()) } else { ToastUtils.showToastInUiThread(context, R.string.requirementnotmet) } @@ -244,9 +244,9 @@ class ObjectivesFragment : Fragment() { override fun run() { if (objectives_fake.isChecked) { objective.startedOn = time - notifyDataSetChanged() scrollToCurrentObjective() startUpdateTimer() + RxBus.send(EventObjectivesUpdateGui()) } else activity?.runOnUiThread { holder.start.visibility = View.VISIBLE @@ -255,9 +255,9 @@ class ObjectivesFragment : Fragment() { ToastUtils.showToastInUiThread(context, R.string.notconnected) } else if (success) { objective.startedOn = time - notifyDataSetChanged() scrollToCurrentObjective() startUpdateTimer() + RxBus.send(EventObjectivesUpdateGui()) } else { ToastUtils.showToastInUiThread(context, R.string.failedretrievetime) } @@ -272,8 +272,8 @@ class ObjectivesFragment : Fragment() { val prevObj = ObjectivesPlugin.objectives[position - 1] prevObj.accomplishedOn = 0 } - notifyDataSetChanged() scrollToCurrentObjective() + RxBus.send(EventObjectivesUpdateGui()) } if (objective.hasSpecialInput && !objective.isAccomplished && objective.isStarted) { // generate random request code if none exists @@ -287,7 +287,7 @@ class ObjectivesFragment : Fragment() { holder.enterButton.setOnClickListener { val input = holder.input.text.toString() objective.specialAction(activity, input) - notifyDataSetChanged() + RxBus.send(EventObjectivesUpdateGui()) } } else { holder.enterButton.visibility = View.GONE From 776e1361dfe5742704282808b02332ec11ad5ff2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 25 Oct 2019 00:14:55 +0200 Subject: [PATCH 12/14] format icon --- app/src/main/res/layout/overview_wizard_dialog.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/layout/overview_wizard_dialog.xml b/app/src/main/res/layout/overview_wizard_dialog.xml index a56efc38fd..71ce0e31e9 100644 --- a/app/src/main/res/layout/overview_wizard_dialog.xml +++ b/app/src/main/res/layout/overview_wizard_dialog.xml @@ -18,11 +18,12 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" + android:layout_marginBottom="5dp" android:orientation="horizontal"> + android:textColor="@color/colorCalculatorButton" /> From e02b5746a0f70fe4d4049cad316a97949b985e44 Mon Sep 17 00:00:00 2001 From: Rob Kresha Date: Thu, 24 Oct 2019 23:05:07 -0500 Subject: [PATCH 13/14] Threshold battery % in Overview Plugin > Advanced Settings Change from two %'s to one --- app/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5efe97baab..450522ae4f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -612,9 +612,9 @@ key_statuslights_res_critical Threshold critical reservoir level [U] key_statuslights_bat_warning - Threshold warning battery level [%%] + Threshold warning battery level [%] key_statuslights_bat_critical - Threshold critical battery level [%%] + Threshold critical battery level [%] IOB COB Firmware From f399f8bb1f850ff585ace26d91410b08986c3779 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 25 Oct 2019 11:38:23 +0200 Subject: [PATCH 14/14] Brasil language, better working Locale setting --- .../nightscout/androidaps/MainActivity.java | 40 +++++------ .../info/nightscout/androidaps/MainApp.java | 6 +- .../activities/PreferencesActivity.java | 2 - .../tidepool/events/EventTidepoolStatus.kt | 2 +- .../androidaps/setupwizard/SWDefinition.java | 3 +- .../setupwizard/SetupWizardActivity.java | 2 +- .../androidaps/utils/FabricPrivacy.java | 2 +- .../androidaps/utils/LocaleHelper.java | 69 ------------------- .../androidaps/utils/LocaleHelper.kt | 32 +++++++++ app/src/main/res/values/arrays.xml | 2 + app/src/main/res/values/strings.xml | 2 +- 11 files changed, 60 insertions(+), 102 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.java create mode 100644 app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.kt diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index f250df0580..64c2656086 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -78,7 +78,7 @@ public class MainActivity extends NoSplashAppCompatActivity { super.onCreate(savedInstanceState); Iconify.with(new FontAwesomeModule()); - LocaleHelper.onCreate(this, "en"); + LocaleHelper.INSTANCE.update(getApplicationContext()); setContentView(R.layout.activity_main); setSupportActionBar(findViewById(R.id.toolbar)); @@ -117,24 +117,6 @@ public class MainActivity extends NoSplashAppCompatActivity { VersionCheckerUtilsKt.triggerCheckVersion(); FabricPrivacy.setUserStats(); - } - - private void checkPluginPreferences(ViewPager viewPager) { - if (pluginPreferencesMenuItem == null) return; - if (((TabPageAdapter) viewPager.getAdapter()).getPluginAt(viewPager.getCurrentItem()).getPreferencesId() != -1) - pluginPreferencesMenuItem.setEnabled(true); - else pluginPreferencesMenuItem.setEnabled(false); - } - - @Override - public void onPostCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) { - super.onPostCreate(savedInstanceState, persistentState); - actionBarDrawerToggle.syncState(); - } - - @Override - protected void onResume() { - super.onResume(); setupTabs(); setupViews(); @@ -143,8 +125,7 @@ public class MainActivity extends NoSplashAppCompatActivity { .toObservable(EventRebuildTabs.class) .observeOn(AndroidSchedulers.mainThread()) .subscribe(event -> { - String lang = SP.getString(R.string.key_language, "en"); - LocaleHelper.setLocale(getApplicationContext(), lang); + LocaleHelper.INSTANCE.update(getApplicationContext()); if (event.getRecreate()) { recreate(); } else { @@ -175,9 +156,22 @@ public class MainActivity extends NoSplashAppCompatActivity { } } + private void checkPluginPreferences(ViewPager viewPager) { + if (pluginPreferencesMenuItem == null) return; + if (((TabPageAdapter) viewPager.getAdapter()).getPluginAt(viewPager.getCurrentItem()).getPreferencesId() != -1) + pluginPreferencesMenuItem.setEnabled(true); + else pluginPreferencesMenuItem.setEnabled(false); + } + @Override - public void onPause() { - super.onPause(); + public void onPostCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) { + super.onPostCreate(savedInstanceState, persistentState); + actionBarDrawerToggle.syncState(); + } + + @Override + public void onDestroy() { + super.onDestroy(); disposable.clear(); } diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 3231fc7e01..379afabddf 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -35,7 +35,9 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.constraints.dstHelper.DstHelperPlugin; import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin; import info.nightscout.androidaps.plugins.constraints.safety.SafetyPlugin; +import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin; import info.nightscout.androidaps.plugins.constraints.storage.StorageConstraintPlugin; +import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin; import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin; import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin; import info.nightscout.androidaps.plugins.general.careportal.CareportalPlugin; @@ -48,9 +50,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.receivers.AckAlarmRec import info.nightscout.androidaps.plugins.general.nsclient.receivers.DBAccessReceiver; import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin; import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin; -import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin; import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin; -import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin; import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin; @@ -88,6 +88,7 @@ import info.nightscout.androidaps.receivers.NSAlarmReceiver; import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.utils.FabricPrivacy; +import info.nightscout.androidaps.utils.LocaleHelper; import io.fabric.sdk.android.Fabric; import static info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion; @@ -124,6 +125,7 @@ public class MainApp extends Application { log.debug("onCreate"); sInstance = this; sResources = getResources(); + LocaleHelper.INSTANCE.update(this); sConstraintsChecker = new ConstraintChecker(); sDatabaseHelper = OpenHelperManager.getHelper(sInstance, DatabaseHelper.class); diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java index cf347cd2b0..367429dbbf 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java @@ -70,8 +70,6 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { RxBus.INSTANCE.send(new EventPreferenceChange(key)); if (key.equals("language")) { - String lang = sharedPreferences.getString("language", "en"); - LocaleHelper.setLocale(getApplicationContext(), lang); RxBus.INSTANCE.send(new EventRebuildTabs(true)); //recreate() does not update language so better close settings finish(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/events/EventTidepoolStatus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/events/EventTidepoolStatus.kt index aa69c11e95..e7854f8ff2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/events/EventTidepoolStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/events/EventTidepoolStatus.kt @@ -17,7 +17,7 @@ class EventTidepoolStatus(val status: String) : Event() { log.debug("New status: $status") } - private var timeFormat = SimpleDateFormat("HH:mm:ss", LocaleHelper.getLocale()) + private var timeFormat = SimpleDateFormat("HH:mm:ss", LocaleHelper.currentLocale()) fun toPreparedHtml(): StringBuilder { val stringBuilder = StringBuilder() diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java index a8b09e7428..2c9e1ea51b 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java @@ -91,8 +91,7 @@ public class SWDefinition { .preferenceId(R.string.key_language).label(R.string.language) .comment(R.string.setupwizard_language_prompt)) .validator(() -> { - String lang = SP.getString("language", "en"); - LocaleHelper.setLocale(MainApp.instance().getApplicationContext(), lang); + LocaleHelper.INSTANCE.update(MainApp.instance().getApplicationContext()); return SP.contains(R.string.key_language); }); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java index 721978b291..e6a4831693 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java @@ -51,7 +51,7 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - LocaleHelper.onCreate(this, "en"); + LocaleHelper.INSTANCE.update(getApplicationContext()); setContentView(R.layout.activity_setupwizard); scrollView = (ScrollView) findViewById(R.id.sw_scrollview); diff --git a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java index 07a31a3b05..355623f38d 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java @@ -124,7 +124,7 @@ public class FabricPrivacy { .replace(".net/", ":"); MainApp.getFirebaseAnalytics().setUserProperty("Mode", BuildConfig.APPLICATION_ID + "-" + closedLoopEnabled); - MainApp.getFirebaseAnalytics().setUserProperty("Language", LocaleHelper.getLanguage()); + MainApp.getFirebaseAnalytics().setUserProperty("Language", LocaleHelper.INSTANCE.currentLanguage()); MainApp.getFirebaseAnalytics().setUserProperty("Version", BuildConfig.VERSION); MainApp.getFirebaseAnalytics().setUserProperty("HEAD", BuildConfig.HEAD); MainApp.getFirebaseAnalytics().setUserProperty("Remote", remote); diff --git a/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.java b/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.java deleted file mode 100644 index d2e4c0622b..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.java +++ /dev/null @@ -1,69 +0,0 @@ -package info.nightscout.androidaps.utils; - -import android.content.Context; -import android.content.SharedPreferences; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.preference.PreferenceManager; - -import java.util.Locale; - -/** - * This class is used to change your application locale and persist this change for the next time - * that your app is going to be used. - *

- * You can also change the locale of your application on the fly by using the setLocale method. - *

- * Created by gunhansancar on 07/10/15. - */ -public class LocaleHelper { - - private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language"; - - public static void onCreate(Context context) { - String lang = getPersistedData(Locale.getDefault().getLanguage()); - setLocale(context, lang); - } - - public static void onCreate(Context context, String defaultLanguage) { - String lang = getPersistedData(defaultLanguage); - setLocale(context, lang); - } - - public static String getLanguage() { - return getPersistedData(Locale.getDefault().getLanguage()); - } - - public static void setLocale(Context context, String language) { - persist(context, language); - updateResources(context, language); - } - - private static String getPersistedData(String defaultLanguage) { - return SP.getString(SELECTED_LANGUAGE, defaultLanguage); - } - - private static void persist(Context context, String language) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - SharedPreferences.Editor editor = preferences.edit(); - - editor.putString(SELECTED_LANGUAGE, language); - editor.apply(); - } - - private static void updateResources(Context context, String language) { - Locale locale = new Locale(language); - Locale.setDefault(locale); - - Resources resources = context.getResources(); - - Configuration configuration = resources.getConfiguration(); - configuration.locale = locale; - - resources.updateConfiguration(configuration, resources.getDisplayMetrics()); - } - - public static Locale getLocale() { - return new Locale(getPersistedData("en")); - } -} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.kt b/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.kt new file mode 100644 index 0000000000..6052c5699a --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.kt @@ -0,0 +1,32 @@ +package info.nightscout.androidaps.utils + +import android.content.Context +import info.nightscout.androidaps.R +import java.util.* + +object LocaleHelper { + fun update(context: Context) = + updateResources(context, currentLanguage()) + + fun currentLanguage(): String = + SP.getString(R.string.key_language, Locale.getDefault().language) + + fun currentLocale(): Locale = + Locale(SP.getString(R.string.key_language, Locale.getDefault().language)) + + @Suppress("DEPRECATION") + private fun updateResources(context: Context, language: String) { + var locale = Locale(language) + if (language.contains("_")) { + // language with country like pt_BR defined in arrays.xml + val lang = language.substring(0, 2) + val country = language.substring(3, 5) + locale = Locale(lang, country) + } + + Locale.setDefault(locale) + val resources = context.resources + resources.configuration.setLocale(locale) + resources.updateConfiguration(resources.configuration, resources.displayMetrics) + } +} \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 864835bd87..0ad824ddea 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -24,6 +24,7 @@ @string/ko_lang @string/lt_lang @string/pt_lang + @string/pt_BR_lang @string/ro_lang @string/ru_lang @string/sk_lang @@ -46,6 +47,7 @@ ko lt pt + pt_BR ro ru sk diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5efe97baab..059491910d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,7 +17,7 @@ Lithuanian Polish Portuguese - + Portuguese, Brazilian Romanian Russian Slovak