From 06c9920177ca5ba1dbf27a68fe42ebb64b5d9352 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 4 Jan 2022 10:48:57 +0100 Subject: [PATCH 01/14] wear: support simplify ui for ambient mode --- .../androidaps/watchfaces/BaseWatchFace.java | 36 +++++++++++---- wear/src/main/res/values/arrays.xml | 12 +++++ wear/src/main/res/values/strings.xml | 4 +- wear/src/main/res/xml/preferences.xml | 36 +++++++-------- wear/src/main/res/xml/watch_face.xml | 2 +- .../xml/watch_face_configuration_bigchart.xml | 5 ++- .../xml/watch_face_configuration_circle.xml | 12 ++--- .../xml/watch_face_configuration_cockpit.xml | 16 +++---- .../watch_face_configuration_digitalstyle.xml | 44 +++++++++---------- .../res/xml/watch_face_configuration_home.xml | 20 ++++----- .../xml/watch_face_configuration_home2.xml | 14 +++--- .../watch_face_configuration_largehome.xml | 20 ++++----- .../xml/watch_face_configuration_nochart.xml | 5 ++- .../watch_face_configuration_steampunk.xml | 16 +++---- 14 files changed, 135 insertions(+), 107 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index 0500786802..a1b195e29f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -130,7 +130,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } private void setupBatteryReceiver() { - if (sharedPrefs.getBoolean("simplify_ui_charging", false) && batteryReceiver == null) { + if (sharedPrefs.getString("simplify_ui", "off") == "charching" && batteryReceiver == null) { IntentFilter intentBatteryFilter = new IntentFilter(); intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING); intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING); @@ -306,7 +306,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public void setDataFields() { setDateAndTime(); - + if (setDataFieldsSimpleUi()) { + return; + } if (mSgv != null) { if (sharedPrefs.getBoolean("showBG", true)) { mSgv.setText(rawData.sSgv); @@ -485,11 +487,11 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mLoop.setVisibility(View.GONE); } } - setDataFieldsSimpleUi(); + } - void setDataFieldsSimpleUi() { - if (sharedPrefs.getBoolean("simplify_ui_charging", false) && isCharging()) { + boolean setDataFieldsSimpleUi() { + if (isSimpleUi()) { mSimpleUi.setVisibility(View.VISIBLE); mSimpleSvg.setText(rawData.sSgv); @@ -513,9 +515,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this); mSimpleTime.setText(timeFormat.format(System.currentTimeMillis())); - } else { - mSimpleUi.setVisibility(View.GONE); + return true; } + mSimpleUi.setVisibility(View.GONE); + return false; } @Override @@ -598,7 +601,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } protected void onWatchModeChanged(WatchMode watchMode) { - + setDataFields(); if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode lowResMode = isLowRes(watchMode); setColor(); @@ -612,6 +615,20 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN); // || (watchMode == WatchMode.LOW_BIT_BURN_IN); } + private boolean isSimpleUi() { + String simplify = sharedPrefs.getString("simplify_ui", "off"); + if (simplify.equals("off")) { + return false; + } + if (simplify.equals("ambient") && getCurrentWatchMode() == WatchMode.AMBIENT) { + return true; + } + if (simplify.equals("charging") && isCharging()) { + return true; + } + return false; + } + @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { setupBatteryReceiver(); @@ -640,6 +657,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } public void setupCharts() { + if (isSimpleUi()) { + return; + } if (rawData.bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); if (lowResMode) { diff --git a/wear/src/main/res/values/arrays.xml b/wear/src/main/res/values/arrays.xml index b3f80eb126..75f5479ef3 100644 --- a/wear/src/main/res/values/arrays.xml +++ b/wear/src/main/res/values/arrays.xml @@ -65,4 +65,16 @@ none + + Off + During Charging + Always On Mode + + + + off + charging + ambient + + diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index cf78cc7339..a83cb9bacd 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -136,8 +136,8 @@ white black multicolor - Simplify Charging UI - Only show time and BG when charging + Simplify UI + Only show time and BG Vibrate hourly diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index 528d8bf00a..919787dec7 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -5,16 +5,16 @@ @@ -24,7 +24,7 @@ android:summary="Show BG." android:title="@string/pref_show_bg" app:wear_iconOff="@drawable/settings_off" - app:wear_iconOn="@drawable/settings_on"/> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> - - + app:wear_iconOn="@drawable/settings_on" /> - - @@ -128,7 +124,7 @@ android:summary="Wizard from watch possible" android:title="@string/pref_wizard_in_menu" app:wear_iconOff="@drawable/settings_off" - app:wear_iconOn="@drawable/settings_on"/> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> - - + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> - \ No newline at end of file + diff --git a/wear/src/main/res/xml/watch_face_configuration_bigchart.xml b/wear/src/main/res/xml/watch_face_configuration_bigchart.xml index 7953823134..a5f5010bdc 100644 --- a/wear/src/main/res/xml/watch_face_configuration_bigchart.xml +++ b/wear/src/main/res/xml/watch_face_configuration_bigchart.xml @@ -9,12 +9,13 @@ android:summary="Dark theme" android:title="@string/pref_dark" app:wear_iconOff="@drawable/settings_off" - app:wear_iconOn="@drawable/settings_on"/> + app:wear_iconOn="@drawable/settings_on" /> + diff --git a/wear/src/main/res/xml/watch_face_configuration_circle.xml b/wear/src/main/res/xml/watch_face_configuration_circle.xml index 440b527bfa..1943d72b0f 100644 --- a/wear/src/main/res/xml/watch_face_configuration_circle.xml +++ b/wear/src/main/res/xml/watch_face_configuration_circle.xml @@ -8,7 +8,7 @@ android:summary="Dark theme" android:title="@string/pref_dark" app:wear_iconOff="@drawable/settings_off" - app:wear_iconOn="@drawable/settings_on"/> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> - + app:wear_iconOn="@drawable/settings_on" /> + diff --git a/wear/src/main/res/xml/watch_face_configuration_cockpit.xml b/wear/src/main/res/xml/watch_face_configuration_cockpit.xml index 2e8ef3c100..bd87348acb 100644 --- a/wear/src/main/res/xml/watch_face_configuration_cockpit.xml +++ b/wear/src/main/res/xml/watch_face_configuration_cockpit.xml @@ -3,18 +3,18 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> - + diff --git a/wear/src/main/res/xml/watch_face_configuration_digitalstyle.xml b/wear/src/main/res/xml/watch_face_configuration_digitalstyle.xml index d03498d32b..6e33c5d610 100644 --- a/wear/src/main/res/xml/watch_face_configuration_digitalstyle.xml +++ b/wear/src/main/res/xml/watch_face_configuration_digitalstyle.xml @@ -4,59 +4,59 @@ + android:entryValues="@array/digitalstyle_styles_values" + android:key="digitalstyle_frameStyle" + android:title="@string/digitalstyle_pref_your_style" /> + android:entryValues="@array/digitalstyle_color_values" + android:key="digitalstyle_frameColor" + android:title="@string/digitalstyle_pref_your_color" /> + android:entryValues="@array/digitalstyle_color_saturation" + android:key="digitalstyle_frameColorSaturation" + android:title="@string/digitalstyle_pref_your_color_saturation" /> + android:entryValues="@array/digitalstyle_color_opacity_value" + android:key="digitalstyle_frameColorOpacity" + android:title="@string/digitalstyle_pref_your_color_opacity" /> - + diff --git a/wear/src/main/res/xml/watch_face_configuration_home.xml b/wear/src/main/res/xml/watch_face_configuration_home.xml index fbe3015eab..a471c8a816 100644 --- a/wear/src/main/res/xml/watch_face_configuration_home.xml +++ b/wear/src/main/res/xml/watch_face_configuration_home.xml @@ -8,7 +8,7 @@ android:summary="Dark theme" android:title="@string/pref_dark" app:wear_iconOff="@drawable/settings_off" - app:wear_iconOn="@drawable/settings_on"/> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> - + diff --git a/wear/src/main/res/xml/watch_face_configuration_home2.xml b/wear/src/main/res/xml/watch_face_configuration_home2.xml index efc27df610..be883d2f76 100644 --- a/wear/src/main/res/xml/watch_face_configuration_home2.xml +++ b/wear/src/main/res/xml/watch_face_configuration_home2.xml @@ -32,12 +32,12 @@ app:wear_iconOff="@drawable/settings_off" app:wear_iconOn="@drawable/settings_on" /> - + diff --git a/wear/src/main/res/xml/watch_face_configuration_largehome.xml b/wear/src/main/res/xml/watch_face_configuration_largehome.xml index fbe3015eab..a471c8a816 100644 --- a/wear/src/main/res/xml/watch_face_configuration_largehome.xml +++ b/wear/src/main/res/xml/watch_face_configuration_largehome.xml @@ -8,7 +8,7 @@ android:summary="Dark theme" android:title="@string/pref_dark" app:wear_iconOff="@drawable/settings_off" - app:wear_iconOn="@drawable/settings_on"/> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> - + diff --git a/wear/src/main/res/xml/watch_face_configuration_nochart.xml b/wear/src/main/res/xml/watch_face_configuration_nochart.xml index dc5b99cf8c..a8d78f9d7c 100644 --- a/wear/src/main/res/xml/watch_face_configuration_nochart.xml +++ b/wear/src/main/res/xml/watch_face_configuration_nochart.xml @@ -8,13 +8,14 @@ android:summary="Dark theme" android:title="@string/pref_dark" app:wear_iconOff="@drawable/settings_off" - app:wear_iconOn="@drawable/settings_on"/> + app:wear_iconOn="@drawable/settings_on" /> + diff --git a/wear/src/main/res/xml/watch_face_configuration_steampunk.xml b/wear/src/main/res/xml/watch_face_configuration_steampunk.xml index 0b7358c1f6..e3933b6732 100644 --- a/wear/src/main/res/xml/watch_face_configuration_steampunk.xml +++ b/wear/src/main/res/xml/watch_face_configuration_steampunk.xml @@ -11,18 +11,18 @@ android:title="@string/pref_delta_granularity" /> - + From 4dd97e75ea06d5546f8e72683a0d164c31b31d14 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 5 Jan 2022 14:52:22 +0100 Subject: [PATCH 02/14] Wear: test optimisations always on --- .../androidaps/data/RawDisplayData.java | 8 +- .../androidaps/watchfaces/BaseWatchFace.java | 82 +++++++++++++++---- wear/src/main/res/values/arrays.xml | 2 + 3 files changed, 71 insertions(+), 21 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/data/RawDisplayData.java b/wear/src/main/java/info/nightscout/androidaps/data/RawDisplayData.java index 0eeead26bb..6560598227 100644 --- a/wear/src/main/java/info/nightscout/androidaps/data/RawDisplayData.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/RawDisplayData.java @@ -135,7 +135,7 @@ public class RawDisplayData { } private void updateData(DataMap dataMap) { - wearUtil.getWakeLock("readingPrefs", 50); + // wearUtil.getWakeLock("readingPrefs", 50); sgvLevel = dataMap.getLong("sgvLevel"); datetime = dataMap.getLong("timestamp"); sSgv = dataMap.getString("sgvString"); @@ -156,7 +156,7 @@ public class RawDisplayData { } private void updateStatus(DataMap dataMap) { - wearUtil.getWakeLock("readingPrefs", 50); + // wearUtil.getWakeLock("readingPrefs", 50); sBasalRate = dataMap.getString("currentBasal"); sUploaderBattery = dataMap.getString("battery"); sRigBattery = dataMap.getString("rigBattery"); @@ -183,7 +183,7 @@ public class RawDisplayData { } private void updateBasals(DataMap dataMap) { - wearUtil.getWakeLock("readingPrefs", 500); + // wearUtil.getWakeLock("readingPrefs", 500); loadBasalsAndTemps(dataMap); } @@ -194,7 +194,7 @@ public class RawDisplayData { for (DataMap temp : temps) { TempWatchData twd = new TempWatchData(); twd.startTime = temp.getLong("starttime"); - twd.startBasal = temp.getDouble("startBasal"); + twd.startBasal = temp.getDouble("startBasal"); twd.endTime = temp.getLong("endtime"); twd.endBasal = temp.getDouble("endbasal"); twd.amount = temp.getDouble("amount"); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index a1b195e29f..e79ef2c332 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -54,12 +54,15 @@ import lecho.lib.hellocharts.view.LineChartView; * Refactored by dlvoy on 2019-11-2019 */ + + public abstract class BaseWatchFace extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { @Inject WearUtil wearUtil; @Inject Persistence persistence; public final static IntentFilter INTENT_FILTER; + public final static String TAG = "ASTAG-perf"; static { INTENT_FILTER = new IntentFilter(); @@ -68,6 +71,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED); } + String mLastSvg = ""; + String mLastDirection = ""; + public final Point displaySize = new Point(); public TextView mTime, mHour, mMinute, mTimePeriod, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mDayName, mMonth, isAAPSv2, mHighLight, mLowLight; public TextView mSimpleSvg, mSimpleDirection, mSimpleTime; @@ -104,12 +110,23 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private MessageReceiver messageReceiver; private BroadcastReceiver batteryReceiver; protected boolean isCharging = false; + int colorDarkHigh; + int colorDarkMid; + int colorDarkLow; + java.text.DateFormat timeFormat; @Override public void onCreate() { + Log.i(TAG, "onCreate: "); // Not derived from DaggerService, do injection here AndroidInjection.inject(this); super.onCreate(); + + colorDarkHigh = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor); + colorDarkMid = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + colorDarkLow = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor); + timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this); + rawData = new RawDisplayData(wearUtil); Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); display.getSize(displaySize); @@ -130,13 +147,17 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } private void setupBatteryReceiver() { - if (sharedPrefs.getString("simplify_ui", "off") == "charching" && batteryReceiver == null) { + String setting = sharedPrefs.getString("simplify_ui", "off"); + Log.i(TAG, "setupBatteryReceiver: " + setting); + if (setting.equals("charging") || setting.equals("ambient_charging") && batteryReceiver == null) { + Log.i(TAG, "setupBatteryReceiver: DONE"); IntentFilter intentBatteryFilter = new IntentFilter(); intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING); intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING); batteryReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { + Log.i(TAG, "Battery BroadcastReceiver.onReceive: "); setDataFields(); invalidate(); } @@ -147,6 +168,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) { + Log.i(TAG, "onLayout: "); super.onLayout(shape, screenBounds, screenInsets); layoutView.onApplyWindowInsets(screenInsets); bIsRound = screenInsets.isRound(); @@ -160,6 +182,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc localBroadcastManager = LocalBroadcastManager.getInstance(this); localBroadcastManager.registerReceiver(messageReceiver, messageFilter); + final int colorDarkHigh = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor); + final int colorDarkMid = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + final int colorDarkDark = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor); + stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { @Override public void onLayoutInflated(WatchViewStub stub) { @@ -249,8 +275,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc super.onDestroy(); } + @Override + protected long getInteractiveModeUpdateRate() { + // Only call onTimeChanged every 1 + return 60 * 1000L; + } + @Override protected void onDraw(Canvas canvas) { + Log.i(TAG, "onDraw: "); if (layoutSet) { setupCharts(); @@ -267,8 +300,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) { + Log.i(TAG, "onTimeChanged: "); if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { - wakeLock.acquire(50); + Log.i(TAG, "onTimeChanged: time changed"); + // wakeLock.acquire(50); setDataFields(); setColor(); @@ -281,7 +316,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } else { mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); } - invalidate(); + // invalidate(); } } @@ -305,10 +340,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public void setDataFields() { - setDateAndTime(); if (setDataFieldsSimpleUi()) { return; } + setDateAndTime(); if (mSgv != null) { if (sharedPrefs.getBoolean("showBG", true)) { mSgv.setText(rawData.sSgv); @@ -500,20 +535,21 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } else { mSimpleSvg.setPaintFlags(mSimpleSvg.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); } + if (rawData.sgvLevel == 1) { - mSimpleSvg.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor)); - mSimpleDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor)); + mSimpleSvg.setTextColor(colorDarkHigh); + mSimpleDirection.setTextColor(colorDarkHigh); } else if (rawData.sgvLevel == 0) { - mSimpleSvg.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); - mSimpleDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mSimpleSvg.setTextColor(colorDarkMid); + mSimpleDirection.setTextColor(colorDarkMid); } else if (rawData.sgvLevel == -1) { - mSimpleSvg.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor)); - mSimpleDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor)); + mSimpleSvg.setTextColor(colorDarkLow); + mSimpleDirection.setTextColor(colorDarkLow); } mSimpleDirection.setText(rawData.sDirection+"\uFE0E"); - final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this); + mSimpleTime.setText(timeFormat.format(System.currentTimeMillis())); return true; } @@ -601,6 +637,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } protected void onWatchModeChanged(WatchMode watchMode) { + Log.i(TAG, "onWatchModeChanged: " + watchMode); setDataFields(); if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode lowResMode = isLowRes(watchMode); @@ -620,10 +657,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc if (simplify.equals("off")) { return false; } - if (simplify.equals("ambient") && getCurrentWatchMode() == WatchMode.AMBIENT) { + if ((simplify.equals("ambient") || simplify.equals("ambient_charging")) && getCurrentWatchMode() == WatchMode.AMBIENT) { return true; } - if (simplify.equals("charging") && isCharging()) { + if ((simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging()) { return true; } return false; @@ -631,6 +668,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { + Log.i(TAG, "onSharedPreferenceChanged: "); setupBatteryReceiver(); if ("delta_granularity".equals(key)) { ListenerService.requestData(this); @@ -677,6 +715,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public class MessageReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + Log.i(TAG, "Data MessageReceiver.onReceive: "); if (layoutSet) { final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock); @@ -685,15 +724,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc setupCharts(); } rawData.updateStatusFromMessage(intent, wakeLock); + rawData.updateBasalsFromMessage(intent, wakeLock); + } + if (!needUpdate()) { + return; } setDataFields(); setColor(); - if (layoutSet) { - rawData.updateBasalsFromMessage(intent, wakeLock); - } - mRelativeLayout.measure(specW, specH); if (forceSquareCanvas) { mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face. @@ -704,4 +743,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } } + private boolean needUpdate() { + if (isSimpleUi() && mLastSvg.equals(rawData.sSgv) && mLastDirection.equals(rawData.sDirection)) { + return false; + } + mLastSvg = rawData.sSgv; + mLastDirection = rawData.sDirection; + return true; + } + } diff --git a/wear/src/main/res/values/arrays.xml b/wear/src/main/res/values/arrays.xml index 75f5479ef3..6a753edec5 100644 --- a/wear/src/main/res/values/arrays.xml +++ b/wear/src/main/res/values/arrays.xml @@ -69,12 +69,14 @@ Off During Charging Always On Mode + Always On and Charging off charging ambient + ambient_charging From 6e5d14d47006955e72b180d2c04a4ddda14874ed Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 6 Jan 2022 08:31:12 +0100 Subject: [PATCH 03/14] Wear: re-enable wakelock --- .../info/nightscout/androidaps/data/RawDisplayData.java | 9 ++++++--- .../nightscout/androidaps/watchfaces/BaseWatchFace.java | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/data/RawDisplayData.java b/wear/src/main/java/info/nightscout/androidaps/data/RawDisplayData.java index 6560598227..024f72f676 100644 --- a/wear/src/main/java/info/nightscout/androidaps/data/RawDisplayData.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/RawDisplayData.java @@ -135,7 +135,7 @@ public class RawDisplayData { } private void updateData(DataMap dataMap) { - // wearUtil.getWakeLock("readingPrefs", 50); + PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); sgvLevel = dataMap.getLong("sgvLevel"); datetime = dataMap.getLong("timestamp"); sSgv = dataMap.getString("sgvString"); @@ -143,6 +143,7 @@ public class RawDisplayData { sDelta = dataMap.getString("delta"); sAvgDelta = dataMap.getString("avgDelta"); sUnits = dataMap.getString("glucoseUnits"); + wearUtil.releaseWakeLock(wl); } public DataMap updateStatusFromMessage(Intent intent, PowerManager.WakeLock wakeLock) { @@ -156,7 +157,7 @@ public class RawDisplayData { } private void updateStatus(DataMap dataMap) { - // wearUtil.getWakeLock("readingPrefs", 50); + PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); sBasalRate = dataMap.getString("currentBasal"); sUploaderBattery = dataMap.getString("battery"); sRigBattery = dataMap.getString("rigBattery"); @@ -170,6 +171,7 @@ public class RawDisplayData { externalStatusString = dataMap.getString("externalStatusString"); batteryLevel = dataMap.getInt("batteryLevel"); openApsStatus = dataMap.getLong("openApsStatus"); + wearUtil.releaseWakeLock(wl); } public DataMap updateBasalsFromMessage(Intent intent, PowerManager.WakeLock wakeLock) { @@ -183,8 +185,9 @@ public class RawDisplayData { } private void updateBasals(DataMap dataMap) { - // wearUtil.getWakeLock("readingPrefs", 500); + PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 500); loadBasalsAndTemps(dataMap); + wearUtil.releaseWakeLock(wl); } private void loadBasalsAndTemps(DataMap dataMap) { diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index e79ef2c332..fca56a9a64 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -303,7 +303,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc Log.i(TAG, "onTimeChanged: "); if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { Log.i(TAG, "onTimeChanged: time changed"); - // wakeLock.acquire(50); + PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); setDataFields(); setColor(); @@ -316,6 +316,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } else { mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); } + wearUtil.releaseWakeLock(wl); // invalidate(); } } From b8c2693d67fbb42739b7de58cb1d9539122e8c05 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 6 Jan 2022 21:11:42 +0100 Subject: [PATCH 04/14] Wear disable logs --- .../androidaps/watchfaces/BaseWatchFace.java | 138 ++++++++---------- 1 file changed, 63 insertions(+), 75 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index fca56a9a64..6011968480 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -62,7 +62,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Inject Persistence persistence; public final static IntentFilter INTENT_FILTER; - public final static String TAG = "ASTAG-perf"; static { INTENT_FILTER = new IntentFilter(); @@ -109,15 +108,14 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private LocalBroadcastManager localBroadcastManager; private MessageReceiver messageReceiver; private BroadcastReceiver batteryReceiver; - protected boolean isCharging = false; - int colorDarkHigh; - int colorDarkMid; - int colorDarkLow; - java.text.DateFormat timeFormat; + private int colorDarkHigh; + private int colorDarkMid; + private int colorDarkLow; + private java.text.DateFormat timeFormat; @Override public void onCreate() { - Log.i(TAG, "onCreate: "); + // Log.i(TAG, "onCreate: "); // Not derived from DaggerService, do injection here AndroidInjection.inject(this); super.onCreate(); @@ -148,16 +146,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private void setupBatteryReceiver() { String setting = sharedPrefs.getString("simplify_ui", "off"); - Log.i(TAG, "setupBatteryReceiver: " + setting); + //Log.i(TAG, "setupBatteryReceiver: " + setting); if (setting.equals("charging") || setting.equals("ambient_charging") && batteryReceiver == null) { - Log.i(TAG, "setupBatteryReceiver: DONE"); + //Log.i(TAG, "setupBatteryReceiver: DONE"); IntentFilter intentBatteryFilter = new IntentFilter(); intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING); intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING); batteryReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - Log.i(TAG, "Battery BroadcastReceiver.onReceive: "); + //Log.i(TAG, "Battery BroadcastReceiver.onReceive: "); setDataFields(); invalidate(); } @@ -168,82 +166,73 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) { - Log.i(TAG, "onLayout: "); + //Log.i(TAG, "onLayout: "); super.onLayout(shape, screenBounds, screenInsets); layoutView.onApplyWindowInsets(screenInsets); bIsRound = screenInsets.isRound(); } public void performViewSetup() { - final WatchViewStub stub = layoutView.findViewById(R.id.watch_view_stub); + final WatchViewStub layoutStub = layoutView.findViewById(R.id.watch_view_stub); IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND); messageReceiver = new MessageReceiver(); localBroadcastManager = LocalBroadcastManager.getInstance(this); localBroadcastManager.registerReceiver(messageReceiver, messageFilter); - final int colorDarkHigh = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor); - final int colorDarkMid = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); - final int colorDarkDark = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor); - - stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { - @Override - public void onLayoutInflated(WatchViewStub stub) { - mTime = stub.findViewById(R.id.watch_time); - mHour = stub.findViewById(R.id.hour); - mMinute = stub.findViewById(R.id.minute); - mTimePeriod = stub.findViewById(R.id.timePeriod); - mDay = stub.findViewById(R.id.day); - mDayName = stub.findViewById(R.id.dayname); - mMonth = stub.findViewById(R.id.month); - mDate = stub.findViewById(R.id.date_time); - mLoop = stub.findViewById(R.id.loop); - mSgv = stub.findViewById(R.id.sgv); - mDirection = stub.findViewById(R.id.direction); - mTimestamp = stub.findViewById(R.id.timestamp); - mIOB1 = stub.findViewById(R.id.iob_text); - mIOB2 = stub.findViewById(R.id.iobView); - mCOB1 = stub.findViewById(R.id.cob_text); - mCOB2 = stub.findViewById(R.id.cobView); - mBgi = stub.findViewById(R.id.bgiView); - mStatus = stub.findViewById(R.id.externaltstatus); - mBasalRate = stub.findViewById(R.id.tmpBasal); - mUploaderBattery = stub.findViewById(R.id.uploader_battery); - mRigBattery = stub.findViewById(R.id.rig_battery); - mDelta = stub.findViewById(R.id.delta); - mAvgDelta = stub.findViewById(R.id.avgdelta); - isAAPSv2 = stub.findViewById(R.id.AAPSv2); - mHighLight = stub.findViewById(R.id.highLight); - mLowLight = stub.findViewById(R.id.lowLight); - mRelativeLayout = stub.findViewById(R.id.main_layout); - mLinearLayout = stub.findViewById(R.id.secondary_layout); - mLinearLayout2 = stub.findViewById(R.id.tertiary_layout); - mGlucoseDial = stub.findViewById(R.id.glucose_dial); - mDeltaGauge = stub.findViewById(R.id.delta_pointer); - mHourHand = stub.findViewById(R.id.hour_hand); - mMinuteHand = stub.findViewById(R.id.minute_hand); - mChartTap = stub.findViewById(R.id.chart_zoom_tap); - mMainMenuTap = stub.findViewById(R.id.main_menu_tap); - chart = stub.findViewById(R.id.chart); - mSimpleUi = stub.findViewById(R.id.simple_ui); - mSimpleSvg = stub.findViewById(R.id.simple_sgv); - mSimpleDirection = stub.findViewById(R.id.simple_direction); - mSimpleTime = stub.findViewById(R.id.simple_watch_time); - layoutSet = true; - setDataFields(); - setColor(); - } - } - ); + layoutStub.setOnLayoutInflatedListener((WatchViewStub stub) -> { + mTime = stub.findViewById(R.id.watch_time); + mHour = stub.findViewById(R.id.hour); + mMinute = stub.findViewById(R.id.minute); + mTimePeriod = stub.findViewById(R.id.timePeriod); + mDay = stub.findViewById(R.id.day); + mDayName = stub.findViewById(R.id.dayname); + mMonth = stub.findViewById(R.id.month); + mDate = stub.findViewById(R.id.date_time); + mLoop = stub.findViewById(R.id.loop); + mSgv = stub.findViewById(R.id.sgv); + mDirection = stub.findViewById(R.id.direction); + mTimestamp = stub.findViewById(R.id.timestamp); + mIOB1 = stub.findViewById(R.id.iob_text); + mIOB2 = stub.findViewById(R.id.iobView); + mCOB1 = stub.findViewById(R.id.cob_text); + mCOB2 = stub.findViewById(R.id.cobView); + mBgi = stub.findViewById(R.id.bgiView); + mStatus = stub.findViewById(R.id.externaltstatus); + mBasalRate = stub.findViewById(R.id.tmpBasal); + mUploaderBattery = stub.findViewById(R.id.uploader_battery); + mRigBattery = stub.findViewById(R.id.rig_battery); + mDelta = stub.findViewById(R.id.delta); + mAvgDelta = stub.findViewById(R.id.avgdelta); + isAAPSv2 = stub.findViewById(R.id.AAPSv2); + mHighLight = stub.findViewById(R.id.highLight); + mLowLight = stub.findViewById(R.id.lowLight); + mRelativeLayout = stub.findViewById(R.id.main_layout); + mLinearLayout = stub.findViewById(R.id.secondary_layout); + mLinearLayout2 = stub.findViewById(R.id.tertiary_layout); + mGlucoseDial = stub.findViewById(R.id.glucose_dial); + mDeltaGauge = stub.findViewById(R.id.delta_pointer); + mHourHand = stub.findViewById(R.id.hour_hand); + mMinuteHand = stub.findViewById(R.id.minute_hand); + mChartTap = stub.findViewById(R.id.chart_zoom_tap); + mMainMenuTap = stub.findViewById(R.id.main_menu_tap); + chart = stub.findViewById(R.id.chart); + mSimpleUi = stub.findViewById(R.id.simple_ui); + mSimpleSvg = stub.findViewById(R.id.simple_sgv); + mSimpleDirection = stub.findViewById(R.id.simple_direction); + mSimpleTime = stub.findViewById(R.id.simple_watch_time); + layoutSet = true; + setDataFields(); + setColor(); + }); wakeLock.acquire(50); } public int ageLevel() { if (timeSince() <= (1000 * 60 * 12)) { return 1; - } else { - return 0; } + return 0; } public double timeSince() { @@ -283,7 +272,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onDraw(Canvas canvas) { - Log.i(TAG, "onDraw: "); + //Log.i(TAG, "onDraw: "); if (layoutSet) { setupCharts(); @@ -294,15 +283,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); } mRelativeLayout.draw(canvas); - Log.d("onDraw", "draw"); + //Log.d("onDraw", "draw"); } } @Override protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) { - Log.i(TAG, "onTimeChanged: "); + // Log.i(TAG, "onTimeChanged: "); if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { - Log.i(TAG, "onTimeChanged: time changed"); + //Log.i(TAG, "onTimeChanged: time changed"); PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); setDataFields(); @@ -550,7 +539,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mSimpleDirection.setText(rawData.sDirection+"\uFE0E"); - mSimpleTime.setText(timeFormat.format(System.currentTimeMillis())); return true; } @@ -638,7 +626,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } protected void onWatchModeChanged(WatchMode watchMode) { - Log.i(TAG, "onWatchModeChanged: " + watchMode); + //Log.i(TAG, "onWatchModeChanged: " + watchMode); setDataFields(); if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode lowResMode = isLowRes(watchMode); @@ -669,7 +657,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - Log.i(TAG, "onSharedPreferenceChanged: "); + //Log.i(TAG, "onSharedPreferenceChanged: "); setupBatteryReceiver(); if ("delta_granularity".equals(key)) { ListenerService.requestData(this); @@ -716,7 +704,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public class MessageReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - Log.i(TAG, "Data MessageReceiver.onReceive: "); + //Log.i(TAG, "Data MessageReceiver.onReceive: "); if (layoutSet) { final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock); From c01ff80bf61424662f6fe3d90f8b2fd365c7fb61 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Fri, 7 Jan 2022 19:44:27 +0100 Subject: [PATCH 05/14] Wear: use paint for simple UI drawing --- .../androidaps/watchfaces/BaseWatchFace.java | 406 ++++++++++-------- .../androidaps/watchfaces/Cockpit.java | 4 +- .../androidaps/watchfaces/Home2.java | 8 +- .../androidaps/watchfaces/Steampunk.java | 4 +- .../res/layout/rect_activity_digitalstyle.xml | 5 - .../main/res/layout/rect_activity_home.xml | 5 - .../main/res/layout/rect_activity_home_2.xml | 5 - .../res/layout/rect_activity_home_large.xml | 5 - wear/src/main/res/layout/rect_cockpit.xml | 5 - wear/src/main/res/layout/rect_steampunk.xml | 5 - .../layout/round_activity_digitalstyle.xml | 5 - .../main/res/layout/round_activity_home.xml | 5 - .../main/res/layout/round_activity_home_2.xml | 5 - .../res/layout/round_activity_home_large.xml | 5 - wear/src/main/res/layout/round_cockpit.xml | 7 +- wear/src/main/res/layout/round_steampunk.xml | 5 - wear/src/main/res/layout/simple_ui.xml | 81 ---- 17 files changed, 236 insertions(+), 329 deletions(-) delete mode 100644 wear/src/main/res/layout/simple_ui.xml diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index 6011968480..7b7068f94c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -10,13 +10,14 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; +import android.graphics.Typeface; import android.os.BatteryManager; import android.os.PowerManager; import android.os.Vibrator; import android.preference.PreferenceManager; import android.support.wearable.view.WatchViewStub; import android.text.format.DateFormat; -import android.util.Log; +//import android.util.Log; import android.view.Display; import android.view.View; import android.view.WindowInsets; @@ -37,6 +38,7 @@ import com.ustwo.clockwise.wearable.WatchFace; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Locale; import javax.inject.Inject; @@ -54,8 +56,6 @@ import lecho.lib.hellocharts.view.LineChartView; * Refactored by dlvoy on 2019-11-2019 */ - - public abstract class BaseWatchFace extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { @Inject WearUtil wearUtil; @@ -70,18 +70,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED); } - String mLastSvg = ""; - String mLastDirection = ""; - public final Point displaySize = new Point(); public TextView mTime, mHour, mMinute, mTimePeriod, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mDayName, mMonth, isAAPSv2, mHighLight, mLowLight; - public TextView mSimpleSvg, mSimpleDirection, mSimpleTime; public ImageView mGlucoseDial, mDeltaGauge, mHourHand, mMinuteHand; - public View mSimpleUi; public RelativeLayout mRelativeLayout; public LinearLayout mLinearLayout, mLinearLayout2, mDate, mChartTap, mMainMenuTap; public int ageLevel = 1; - public int loopLevel = 1; + public int loopLevel = -1; public int highColor = Color.YELLOW; public int lowColor = Color.RED; public int midColor = Color.WHITE; @@ -101,7 +96,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc // related endTime manual layout public View layoutView; public int specW, specH; - public boolean forceSquareCanvas = false; //set to true by the Steampunk watch face. + public boolean forceSquareCanvas = false; // Set to true by the Steampunk watch face. public String sMinute = "0"; public String sHour = "0"; protected SharedPreferences sharedPrefs; @@ -112,6 +107,12 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private int colorDarkMid; private int colorDarkLow; private java.text.DateFormat timeFormat; + private SimpleDateFormat sdfDay, sdfMonth, sdfHour, sdfPeriod, sdfDayName, sdfMinute; + // private final String TAG = "ASTAG"; + private Paint mBackgroundPaint, mTimePaint, mSvgPaint, mDirectionPaint; + private Date mDateTime; + private String mLastSvg = ""; + private String mLastDirection = ""; @Override public void onCreate() { @@ -123,7 +124,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc colorDarkHigh = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor); colorDarkMid = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); colorDarkLow = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor); - timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this); rawData = new RawDisplayData(wearUtil); Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); @@ -142,20 +142,22 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc persistence.turnOff(); setupBatteryReceiver(); + initFormats(); + setupSimpleUi(); } private void setupBatteryReceiver() { String setting = sharedPrefs.getString("simplify_ui", "off"); - //Log.i(TAG, "setupBatteryReceiver: " + setting); +// Log.i(TAG, "setupBatteryReceiver: " + setting); if (setting.equals("charging") || setting.equals("ambient_charging") && batteryReceiver == null) { - //Log.i(TAG, "setupBatteryReceiver: DONE"); +// Log.i(TAG, "setupBatteryReceiver: DONE"); IntentFilter intentBatteryFilter = new IntentFilter(); intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING); intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING); batteryReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - //Log.i(TAG, "Battery BroadcastReceiver.onReceive: "); +// Log.i(TAG, "Battery BroadcastReceiver.onReceive: "); setDataFields(); invalidate(); } @@ -164,9 +166,49 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } } + private void initFormats() { + Locale locale = Locale.getDefault(); + timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this); + sdfMinute = new SimpleDateFormat("mm", locale); + sdfHour = DateFormat.is24HourFormat(this) ? new SimpleDateFormat("HH", locale) : new SimpleDateFormat("hh", locale); + sdfPeriod = new SimpleDateFormat("a", locale); + sdfDay = new SimpleDateFormat("dd", locale); + sdfDayName = new SimpleDateFormat("E", locale); + sdfMonth = new SimpleDateFormat("MMM", locale); + } + + private void setupSimpleUi() { + mDateTime = new Date(); + + int black = ContextCompat.getColor(getApplicationContext(), R.color.black); + mBackgroundPaint = new Paint(); + mBackgroundPaint.setColor(black); + + final Typeface NORMAL_TYPEFACE = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL); + final Typeface BOLD_TYPEFACE = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD); + int white = ContextCompat.getColor(getApplicationContext(), R.color.white); + + float textSizeSvg = 75; + float textSizeDirection = 57; + float textSizeTime = 60; + + mSvgPaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeSvg); + mDirectionPaint = createTextPaint(BOLD_TYPEFACE, white, textSizeDirection); + mTimePaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeTime); + } + + private Paint createTextPaint(Typeface typeface, int colour, float textSize) { + Paint paint = new Paint(); + paint.setColor(colour); + paint.setTypeface(typeface); + paint.setAntiAlias(true); + paint.setTextSize(textSize); + return paint; + } + @Override protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) { - //Log.i(TAG, "onLayout: "); +// Log.i(TAG, "onLayout: "); super.onLayout(shape, screenBounds, screenInsets); layoutView.onApplyWindowInsets(screenInsets); bIsRound = screenInsets.isRound(); @@ -181,49 +223,46 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc localBroadcastManager.registerReceiver(messageReceiver, messageFilter); layoutStub.setOnLayoutInflatedListener((WatchViewStub stub) -> { - mTime = stub.findViewById(R.id.watch_time); - mHour = stub.findViewById(R.id.hour); - mMinute = stub.findViewById(R.id.minute); - mTimePeriod = stub.findViewById(R.id.timePeriod); - mDay = stub.findViewById(R.id.day); - mDayName = stub.findViewById(R.id.dayname); - mMonth = stub.findViewById(R.id.month); - mDate = stub.findViewById(R.id.date_time); - mLoop = stub.findViewById(R.id.loop); - mSgv = stub.findViewById(R.id.sgv); - mDirection = stub.findViewById(R.id.direction); - mTimestamp = stub.findViewById(R.id.timestamp); - mIOB1 = stub.findViewById(R.id.iob_text); - mIOB2 = stub.findViewById(R.id.iobView); - mCOB1 = stub.findViewById(R.id.cob_text); - mCOB2 = stub.findViewById(R.id.cobView); - mBgi = stub.findViewById(R.id.bgiView); - mStatus = stub.findViewById(R.id.externaltstatus); - mBasalRate = stub.findViewById(R.id.tmpBasal); - mUploaderBattery = stub.findViewById(R.id.uploader_battery); - mRigBattery = stub.findViewById(R.id.rig_battery); - mDelta = stub.findViewById(R.id.delta); - mAvgDelta = stub.findViewById(R.id.avgdelta); - isAAPSv2 = stub.findViewById(R.id.AAPSv2); - mHighLight = stub.findViewById(R.id.highLight); - mLowLight = stub.findViewById(R.id.lowLight); - mRelativeLayout = stub.findViewById(R.id.main_layout); - mLinearLayout = stub.findViewById(R.id.secondary_layout); - mLinearLayout2 = stub.findViewById(R.id.tertiary_layout); - mGlucoseDial = stub.findViewById(R.id.glucose_dial); - mDeltaGauge = stub.findViewById(R.id.delta_pointer); - mHourHand = stub.findViewById(R.id.hour_hand); - mMinuteHand = stub.findViewById(R.id.minute_hand); - mChartTap = stub.findViewById(R.id.chart_zoom_tap); - mMainMenuTap = stub.findViewById(R.id.main_menu_tap); - chart = stub.findViewById(R.id.chart); - mSimpleUi = stub.findViewById(R.id.simple_ui); - mSimpleSvg = stub.findViewById(R.id.simple_sgv); - mSimpleDirection = stub.findViewById(R.id.simple_direction); - mSimpleTime = stub.findViewById(R.id.simple_watch_time); - layoutSet = true; - setDataFields(); - setColor(); + mTime = stub.findViewById(R.id.watch_time); + mHour = stub.findViewById(R.id.hour); + mMinute = stub.findViewById(R.id.minute); + mTimePeriod = stub.findViewById(R.id.timePeriod); + mDay = stub.findViewById(R.id.day); + mDayName = stub.findViewById(R.id.dayname); + mMonth = stub.findViewById(R.id.month); + mDate = stub.findViewById(R.id.date_time); + mLoop = stub.findViewById(R.id.loop); + mSgv = stub.findViewById(R.id.sgv); + mDirection = stub.findViewById(R.id.direction); + mTimestamp = stub.findViewById(R.id.timestamp); + mIOB1 = stub.findViewById(R.id.iob_text); + mIOB2 = stub.findViewById(R.id.iobView); + mCOB1 = stub.findViewById(R.id.cob_text); + mCOB2 = stub.findViewById(R.id.cobView); + mBgi = stub.findViewById(R.id.bgiView); + mStatus = stub.findViewById(R.id.externaltstatus); + mBasalRate = stub.findViewById(R.id.tmpBasal); + mUploaderBattery = stub.findViewById(R.id.uploader_battery); + mRigBattery = stub.findViewById(R.id.rig_battery); + mDelta = stub.findViewById(R.id.delta); + mAvgDelta = stub.findViewById(R.id.avgdelta); + isAAPSv2 = stub.findViewById(R.id.AAPSv2); + mHighLight = stub.findViewById(R.id.highLight); + mLowLight = stub.findViewById(R.id.lowLight); + mRelativeLayout = stub.findViewById(R.id.main_layout); + mLinearLayout = stub.findViewById(R.id.secondary_layout); + mLinearLayout2 = stub.findViewById(R.id.tertiary_layout); + mGlucoseDial = stub.findViewById(R.id.glucose_dial); + mDeltaGauge = stub.findViewById(R.id.delta_pointer); + mHourHand = stub.findViewById(R.id.hour_hand); + mMinuteHand = stub.findViewById(R.id.minute_hand); + mChartTap = stub.findViewById(R.id.chart_zoom_tap); + mMainMenuTap = stub.findViewById(R.id.main_menu_tap); + chart = stub.findViewById(R.id.chart); + layoutSet = true; + setupCharts(); + setDataFields(); + missedReadingAlert(); }); wakeLock.acquire(50); } @@ -241,7 +280,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public String readingAge(boolean shortString) { if (rawData.datetime == 0) { - return shortString ? "--'" : "-- Minute ago"; + return shortString ? "--" : "-- Minute ago"; } int minutesAgo = (int) Math.floor(timeSince() / (1000 * 60)); if (minutesAgo == 1) { @@ -272,41 +311,84 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onDraw(Canvas canvas) { - //Log.i(TAG, "onDraw: "); - if (layoutSet) { - setupCharts(); + // Log.i(TAG, "onDraw: start "); + // Draw the background. + // long sTime = System.nanoTime(); + if (isSimpleUi()) { + onDrawSimpleUi(canvas); + } else { + if (layoutSet) { - mRelativeLayout.measure(specW, specH); - if (forceSquareCanvas) { - mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face. - } else { - mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); + mRelativeLayout.measure(specW, specH); + if (forceSquareCanvas) { + mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); // force a square for Steampunk watch face. + } else { + mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); + } + mRelativeLayout.draw(canvas); + //Log.d("onDraw", "draw"); } - mRelativeLayout.draw(canvas); - //Log.d("onDraw", "draw"); } + +// long fTime = System.nanoTime(); +// float elapsedTime = (float) (fTime - sTime) / (1000 * 1000); +// Log.i(TAG, "onDraw: end " + String.format("%.3f", elapsedTime) + "ms"); + } + + protected void onDrawSimpleUi(Canvas canvas) { + canvas.drawRect(0, 0, displaySize.x, displaySize.y, mBackgroundPaint); + float xHalf = displaySize.x / 2f; + float yThird = displaySize.y / 3f; + float yOffset = 25f; + + boolean isOutdated = rawData.datetime > 0 && ageLevel() <= 0; + mSvgPaint.setStrikeThruText(isOutdated); + + mSvgPaint.setColor(getBgColour(rawData.sgvLevel)); + mDirectionPaint.setColor(getBgColour(rawData.sgvLevel)); + + String sSvg = rawData.sSgv; + float svgWidth = mSvgPaint.measureText(sSvg); + + String sDirection = " " + rawData.sDirection + "\uFE0E"; + float directionWidth = mDirectionPaint.measureText(sDirection); + + float xSvg = xHalf - (svgWidth + directionWidth) / 2; + canvas.drawText(sSvg, xSvg, yThird + 50, mSvgPaint); + float xDirection = xSvg + svgWidth; + canvas.drawText(sDirection, xDirection, yThird + yOffset, mDirectionPaint); + + String sTime = timeFormat.format(mDateTime); + float xTime = xHalf - mTimePaint.measureText(sTime) / 2; + canvas.drawText(timeFormat.format(mDateTime), xTime, yThird * 2 + yOffset, mTimePaint); + + } + + int getBgColour(long level) { + if (rawData.sgvLevel == level) { + return colorDarkHigh; + + } if (rawData.sgvLevel == level) { + return colorDarkMid; + } + return colorDarkLow; } @Override protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) { - // Log.i(TAG, "onTimeChanged: "); +// Log.i(TAG, "onTimeChanged: called "); if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { - //Log.i(TAG, "onTimeChanged: time changed"); - PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); +// Log.i(TAG, "onTimeChanged: minute/hour changed"); + long now = System.currentTimeMillis(); + mDateTime.setTime(now); - setDataFields(); - setColor(); + PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); missedReadingAlert(); checkVibrateHourly(oldTime, newTime); - - mRelativeLayout.measure(specW, specH); - if (forceSquareCanvas) { - mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face. - } else { - mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); + if (!isSimpleUi()) { + setDataFields(); } wearUtil.releaseWakeLock(wl); - // invalidate(); } } @@ -321,7 +403,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private void checkVibrateHourly(WatchFaceTime oldTime, WatchFaceTime newTime) { boolean hourlyVibratePref = sharedPrefs.getBoolean("vibrate_Hourly", false); if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) { - Log.i("hourlyVibratePref", "true --> " + newTime.toString()); +// Log.i("hourlyVibratePref", "true --> " + newTime.toString()); Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); long[] vibrationPattern = {0, 150, 125, 100}; vibrator.vibrate(vibrationPattern, -1); @@ -330,16 +412,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public void setDataFields() { - if (setDataFieldsSimpleUi()) { - return; - } setDateAndTime(); if (mSgv != null) { if (sharedPrefs.getBoolean("showBG", true)) { mSgv.setText(rawData.sSgv); mSgv.setVisibility(View.VISIBLE); } else { - //leave the textview there but invisible, as a height holder for the empty space above the white line + // leave the textview there but invisible, as a height holder for the empty space above the white line mSgv.setVisibility(View.INVISIBLE); mSgv.setText(""); } @@ -349,7 +428,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc if (mDirection != null) { if (sharedPrefs.getBoolean("show_direction", true)) { - mDirection.setText(rawData.sDirection+"\uFE0E"); + mDirection.setText(rawData.sDirection + "\uFE0E"); mDirection.setVisibility(View.VISIBLE); } else { mDirection.setVisibility(View.GONE); @@ -383,7 +462,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mCOB1.setVisibility(View.GONE); mCOB2.setVisibility(View.GONE); } - //deal with cases where there is only the value shown for COB, and not the label + // Deal with cases where there is only the value shown for COB, and not the label } else if (mCOB2 != null) { mCOB2.setText(rawData.sCOB2); if (sharedPrefs.getBoolean("show_cob", true)) { @@ -421,7 +500,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mIOB2.setText(""); } } - if (mTimestamp != null) { if (sharedPrefs.getBoolean("showAgo", true)) { if (isAAPSv2 != null) { @@ -491,7 +569,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mStatus.setVisibility(View.GONE); } } - +// Log.i(TAG, +// "setDataFields: loop " + rawData.openApsStatus + " " + (System.currentTimeMillis() - rawData.openApsStatus)); if (mLoop != null) { if (sharedPrefs.getBoolean("showExternalStatus", true)) { mLoop.setVisibility(View.VISIBLE); @@ -506,79 +585,45 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mLoop.setBackgroundResource(R.drawable.loop_green_25); } } else { - mLoop.setText("-'"); + loopLevel = -1; + mLoop.setText("-"); + mLoop.setBackgroundResource(R.drawable.loop_grey_25); } } else { mLoop.setVisibility(View.GONE); } } - } - - boolean setDataFieldsSimpleUi() { - if (isSimpleUi()) { - mSimpleUi.setVisibility(View.VISIBLE); - - mSimpleSvg.setText(rawData.sSgv); - if (ageLevel() <= 0) { - mSimpleSvg.setPaintFlags(mSimpleSvg.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); - } else { - mSimpleSvg.setPaintFlags(mSimpleSvg.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); - } - - if (rawData.sgvLevel == 1) { - mSimpleSvg.setTextColor(colorDarkHigh); - mSimpleDirection.setTextColor(colorDarkHigh); - } else if (rawData.sgvLevel == 0) { - mSimpleSvg.setTextColor(colorDarkMid); - mSimpleDirection.setTextColor(colorDarkMid); - } else if (rawData.sgvLevel == -1) { - mSimpleSvg.setTextColor(colorDarkLow); - mSimpleDirection.setTextColor(colorDarkLow); - } - - mSimpleDirection.setText(rawData.sDirection+"\uFE0E"); - - mSimpleTime.setText(timeFormat.format(System.currentTimeMillis())); - return true; - } - mSimpleUi.setVisibility(View.GONE); - return false; + setColor(); } @Override protected void on24HourFormatChanged(boolean is24HourFormat) { - setDateAndTime(); +// Log.i(TAG, "on24HourFormatChanged: "); + initFormats(); + if (!isSimpleUi()) { + setDataFields(); + } + invalidate(); } public void setDateAndTime() { - final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this); if (mTime != null) { - mTime.setText(timeFormat.format(System.currentTimeMillis())); + mTime.setText(timeFormat.format(mDateTime)); } - Date now = new Date(); - SimpleDateFormat sdfHour; - SimpleDateFormat sdfMinute = new SimpleDateFormat("mm"); - if (DateFormat.is24HourFormat(this)) { - sdfHour = new SimpleDateFormat("HH"); - } else { - sdfHour = new SimpleDateFormat("hh"); - } - sHour = sdfHour.format(now); - sMinute = sdfMinute.format(now); - + sMinute = sdfMinute.format(mDateTime); + sHour = sdfHour.format(mDateTime); if (mHour != null && mMinute != null) { mHour.setText(sHour); mMinute.setText(sMinute); } - if(mTimePeriod != null) { + if (mTimePeriod != null) { if (!DateFormat.is24HourFormat(this)) { mTimePeriod.setVisibility(View.VISIBLE); - SimpleDateFormat sdfPeriod = new SimpleDateFormat("a"); - mTimePeriod.setText(sdfPeriod.format(now).toUpperCase()); + mTimePeriod.setText(sdfPeriod.format(mDateTime).toUpperCase()); } else { mTimePeriod.setVisibility(View.GONE); } @@ -587,14 +632,11 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc if (mDate != null && mDay != null && mMonth != null) { if (sharedPrefs.getBoolean("show_date", false)) { if (mDayName != null) { - SimpleDateFormat sdfDayName = new SimpleDateFormat("E"); - mDayName.setText(sdfDayName.format(now)); + mDayName.setText(sdfDayName.format(mDateTime)); } - SimpleDateFormat sdfDay = new SimpleDateFormat("dd"); - SimpleDateFormat sdfMonth = new SimpleDateFormat("MMM"); - mDay.setText(sdfDay.format(now)); - mMonth.setText(sdfMonth.format(now)); + mDay.setText(sdfDay.format(mDateTime)); + mMonth.setText(sdfMonth.format(mDateTime)); mDate.setVisibility(View.VISIBLE); } else { mDate.setVisibility(View.GONE); @@ -626,15 +668,21 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } protected void onWatchModeChanged(WatchMode watchMode) { - //Log.i(TAG, "onWatchModeChanged: " + watchMode); - setDataFields(); - if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode - lowResMode = isLowRes(watchMode); - setColor(); - } else if (!sharedPrefs.getBoolean("dark", true)) { - //in bright mode: different colours if active: - setColor(); +// Log.i(TAG, "onWatchModeChanged: " + watchMode); + lowResMode = isLowRes(watchMode); + if (isSimpleUi()) { + setSimpleUiAntiAlias(); + } else { + setDataFields(); } + invalidate(); + } + + void setSimpleUiAntiAlias() { + boolean antiAlias = getCurrentWatchMode() == WatchMode.AMBIENT; + mSvgPaint.setAntiAlias(antiAlias); + mDirectionPaint.setAntiAlias(antiAlias); + mTimePaint.setAntiAlias(antiAlias); } private boolean isLowRes(WatchMode watchMode) { @@ -649,15 +697,12 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc if ((simplify.equals("ambient") || simplify.equals("ambient_charging")) && getCurrentWatchMode() == WatchMode.AMBIENT) { return true; } - if ((simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging()) { - return true; - } - return false; + return (simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging(); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - //Log.i(TAG, "onSharedPreferenceChanged: "); +// Log.i(TAG, "onSharedPreferenceChanged: "); setupBatteryReceiver(); if ("delta_granularity".equals(key)) { ListenerService.requestData(this); @@ -665,7 +710,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc if (layoutSet) { setDataFields(); - setColor(); } invalidate(); } @@ -677,8 +721,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc protected abstract void setColorLowRes(); public void missedReadingAlert() { +// Log.i(TAG, "missedReadingAlert: check"); int minutes_since = (int) Math.floor(timeSince() / (1000 * 60)); - if (minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) { + if (rawData.datetime == 0 || minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) { +// Log.i(TAG, "missedReadingAlert: do"); ListenerService.requestData(this); // attempt endTime recover missing data } } @@ -704,36 +750,32 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public class MessageReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - //Log.i(TAG, "Data MessageReceiver.onReceive: "); +// Log.i(TAG, "Data MessageReceiver.onReceive: "); + PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); - if (layoutSet) { - final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock); - if (chart != null && dataMap != null) { - rawData.addToWatchSet(dataMap); - setupCharts(); + final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock); + if (chart != null && dataMap != null) { + rawData.addToWatchSet(dataMap); + setupCharts(); + } + rawData.updateStatusFromMessage(intent, wakeLock); + rawData.updateBasalsFromMessage(intent, wakeLock); + + if (isSimpleUi()) { + if (needUpdate()) { + invalidate(); } - rawData.updateStatusFromMessage(intent, wakeLock); - rawData.updateBasalsFromMessage(intent, wakeLock); - } - if (!needUpdate()) { - return; - } - - setDataFields(); - setColor(); - - mRelativeLayout.measure(specW, specH); - if (forceSquareCanvas) { - mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face. } else { - mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); + setupCharts(); + setDataFields(); + invalidate(); } - invalidate(); + wearUtil.releaseWakeLock(wl); } } private boolean needUpdate() { - if (isSimpleUi() && mLastSvg.equals(rawData.sSgv) && mLastDirection.equals(rawData.sDirection)) { + if (mLastSvg.equals(rawData.sSgv) && mLastDirection.equals(rawData.sDirection)) { return false; } mLastSvg = rawData.sSgv; diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Cockpit.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Cockpit.java index 31d293929a..3a68158109 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Cockpit.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Cockpit.java @@ -60,7 +60,9 @@ public class Cockpit extends BaseWatchFace { } } - if (loopLevel == 1) { + if (loopLevel == -1) { + mLoop.setBackgroundResource(R.drawable.loop_grey_25); + } else if (loopLevel == 1) { mLoop.setBackgroundResource(R.drawable.loop_green_25); } else { mLoop.setBackgroundResource(R.drawable.loop_red_25); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java index 74a36f914b..9f1cb75ddd 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java @@ -117,7 +117,9 @@ public class Home2 extends BaseWatchFace { mBasalRate.setTextColor(dividerTxtColor); mBgi.setTextColor(dividerTxtColor); - if (loopLevel == 1) { + if (loopLevel == -1) { + mLoop.setBackgroundResource(R.drawable.loop_grey_25); + } else if (loopLevel == 1) { mLoop.setBackgroundResource(R.drawable.loop_green_25); } else { mLoop.setBackgroundResource(R.drawable.loop_red_25); @@ -226,7 +228,9 @@ public class Home2 extends BaseWatchFace { mBasalRate.setTextColor(dividerTxtColor); mBgi.setTextColor(dividerTxtColor); - if (loopLevel == 1) { + if (loopLevel == -1) { + mLoop.setBackgroundResource(R.drawable.loop_grey_25); + } else if (loopLevel == 1) { mLoop.setBackgroundResource(R.drawable.loop_green_25); } else { mLoop.setBackgroundResource(R.drawable.loop_red_25); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java index 3451a3393f..b121f58f82 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java @@ -67,7 +67,7 @@ public class Steampunk extends BaseWatchFace { protected void setColorDark() { if (mLinearLayout2 != null) { - if (ageLevel() <= 0) { + if (ageLevel() <= 0 && rawData.datetime != 0) { mLinearLayout2.setBackgroundResource(R.drawable.redline); mTimestamp.setTextColor(getResources().getColor(R.color.red_600)); } else { @@ -267,4 +267,4 @@ public class Steampunk extends BaseWatchFace { setupCharts(); sharedPrefs.edit().putString("chart_timeframe", "" + timeframe).apply(); } -} \ No newline at end of file +} diff --git a/wear/src/main/res/layout/rect_activity_digitalstyle.xml b/wear/src/main/res/layout/rect_activity_digitalstyle.xml index 86c79196fc..ab31bb31ca 100644 --- a/wear/src/main/res/layout/rect_activity_digitalstyle.xml +++ b/wear/src/main/res/layout/rect_activity_digitalstyle.xml @@ -559,11 +559,6 @@ - - - - diff --git a/wear/src/main/res/layout/rect_activity_home_2.xml b/wear/src/main/res/layout/rect_activity_home_2.xml index f15bfa33bf..180ff9efdb 100644 --- a/wear/src/main/res/layout/rect_activity_home_2.xml +++ b/wear/src/main/res/layout/rect_activity_home_2.xml @@ -370,9 +370,4 @@ - - diff --git a/wear/src/main/res/layout/rect_activity_home_large.xml b/wear/src/main/res/layout/rect_activity_home_large.xml index e3fd3012e0..a6da174128 100644 --- a/wear/src/main/res/layout/rect_activity_home_large.xml +++ b/wear/src/main/res/layout/rect_activity_home_large.xml @@ -136,9 +136,4 @@ - - diff --git a/wear/src/main/res/layout/rect_cockpit.xml b/wear/src/main/res/layout/rect_cockpit.xml index 26b0e79d64..cf26712258 100644 --- a/wear/src/main/res/layout/rect_cockpit.xml +++ b/wear/src/main/res/layout/rect_cockpit.xml @@ -488,9 +488,4 @@ - - \ No newline at end of file diff --git a/wear/src/main/res/layout/rect_steampunk.xml b/wear/src/main/res/layout/rect_steampunk.xml index 91efff6d31..e88ab41c5c 100644 --- a/wear/src/main/res/layout/rect_steampunk.xml +++ b/wear/src/main/res/layout/rect_steampunk.xml @@ -378,9 +378,4 @@ android:layout_height="wrap_content" android:visibility="gone"/> - - diff --git a/wear/src/main/res/layout/round_activity_digitalstyle.xml b/wear/src/main/res/layout/round_activity_digitalstyle.xml index 193d727ca4..83a85b31fb 100644 --- a/wear/src/main/res/layout/round_activity_digitalstyle.xml +++ b/wear/src/main/res/layout/round_activity_digitalstyle.xml @@ -560,11 +560,6 @@ - - - - diff --git a/wear/src/main/res/layout/round_activity_home_2.xml b/wear/src/main/res/layout/round_activity_home_2.xml index 35c07352a2..d1ef61abe5 100644 --- a/wear/src/main/res/layout/round_activity_home_2.xml +++ b/wear/src/main/res/layout/round_activity_home_2.xml @@ -383,9 +383,4 @@ - - diff --git a/wear/src/main/res/layout/round_activity_home_large.xml b/wear/src/main/res/layout/round_activity_home_large.xml index 054584b842..9569d5d1ab 100644 --- a/wear/src/main/res/layout/round_activity_home_large.xml +++ b/wear/src/main/res/layout/round_activity_home_large.xml @@ -135,9 +135,4 @@ - - diff --git a/wear/src/main/res/layout/round_cockpit.xml b/wear/src/main/res/layout/round_cockpit.xml index 856f2ee6a3..c4f2f7d5d2 100644 --- a/wear/src/main/res/layout/round_cockpit.xml +++ b/wear/src/main/res/layout/round_cockpit.xml @@ -488,9 +488,4 @@ - - - \ No newline at end of file + diff --git a/wear/src/main/res/layout/round_steampunk.xml b/wear/src/main/res/layout/round_steampunk.xml index 2d66ada9cb..6e586a4251 100644 --- a/wear/src/main/res/layout/round_steampunk.xml +++ b/wear/src/main/res/layout/round_steampunk.xml @@ -378,9 +378,4 @@ android:layout_height="wrap_content" android:visibility="gone"/> - - diff --git a/wear/src/main/res/layout/simple_ui.xml b/wear/src/main/res/layout/simple_ui.xml deleted file mode 100644 index 0780f3e83b..0000000000 --- a/wear/src/main/res/layout/simple_ui.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - From 5760bbe708986778767228c7371014c212eef7f3 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Sat, 8 Jan 2022 17:32:29 +0100 Subject: [PATCH 06/14] Wear: simple ui use dimens --- .../androidaps/watchfaces/BaseWatchFace.java | 106 ++++++++++-------- .../androidaps/watchfaces/Steampunk.java | 1 + wear/src/main/res/values/dimens.xml | 8 ++ 3 files changed, 71 insertions(+), 44 deletions(-) create mode 100644 wear/src/main/res/values/dimens.xml diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index 7b7068f94c..8b560c0766 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; +import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; @@ -17,7 +18,7 @@ import android.os.Vibrator; import android.preference.PreferenceManager; import android.support.wearable.view.WatchViewStub; import android.text.format.DateFormat; -//import android.util.Log; +import android.util.Log; import android.view.Display; import android.view.View; import android.view.WindowInsets; @@ -108,15 +109,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private int colorDarkLow; private java.text.DateFormat timeFormat; private SimpleDateFormat sdfDay, sdfMonth, sdfHour, sdfPeriod, sdfDayName, sdfMinute; - // private final String TAG = "ASTAG"; + private final String TAG = "ASTAG"; private Paint mBackgroundPaint, mTimePaint, mSvgPaint, mDirectionPaint; private Date mDateTime; private String mLastSvg = ""; private String mLastDirection = ""; + private float mYOffset = 0; @Override public void onCreate() { - // Log.i(TAG, "onCreate: "); + Log.i(TAG, "onCreate: "); // Not derived from DaggerService, do injection here AndroidInjection.inject(this); super.onCreate(); @@ -148,16 +150,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private void setupBatteryReceiver() { String setting = sharedPrefs.getString("simplify_ui", "off"); -// Log.i(TAG, "setupBatteryReceiver: " + setting); + Log.i(TAG, "setupBatteryReceiver: " + setting); if (setting.equals("charging") || setting.equals("ambient_charging") && batteryReceiver == null) { -// Log.i(TAG, "setupBatteryReceiver: DONE"); + Log.i(TAG, "setupBatteryReceiver: DONE"); IntentFilter intentBatteryFilter = new IntentFilter(); intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING); intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING); batteryReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { -// Log.i(TAG, "Battery BroadcastReceiver.onReceive: "); + Log.i(TAG, "Battery BroadcastReceiver.onReceive: "); setDataFields(); invalidate(); } @@ -188,9 +190,11 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc final Typeface BOLD_TYPEFACE = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD); int white = ContextCompat.getColor(getApplicationContext(), R.color.white); - float textSizeSvg = 75; - float textSizeDirection = 57; - float textSizeTime = 60; + Resources resources = this.getResources(); + float textSizeSvg = resources.getDimension(R.dimen.simple_ui_svg_text_size); + float textSizeDirection = resources.getDimension(R.dimen.simple_ui_direction_text_size); + float textSizeTime = resources.getDimension(R.dimen.simple_ui_time_text_size); + mYOffset = resources.getDimension(R.dimen.simple_ui_y_offset); mSvgPaint = createTextPaint(NORMAL_TYPEFACE, white, textSizeSvg); mDirectionPaint = createTextPaint(BOLD_TYPEFACE, white, textSizeDirection); @@ -208,7 +212,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) { -// Log.i(TAG, "onLayout: "); + Log.i(TAG, "onLayout: "); super.onLayout(shape, screenBounds, screenInsets); layoutView.onApplyWindowInsets(screenInsets); bIsRound = screenInsets.isRound(); @@ -311,9 +315,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onDraw(Canvas canvas) { - // Log.i(TAG, "onDraw: start "); - // Draw the background. - // long sTime = System.nanoTime(); + Log.i(TAG, "onDraw: start "); + long sTime = System.nanoTime(); if (isSimpleUi()) { onDrawSimpleUi(canvas); } else { @@ -326,20 +329,19 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); } mRelativeLayout.draw(canvas); - //Log.d("onDraw", "draw"); } } -// long fTime = System.nanoTime(); -// float elapsedTime = (float) (fTime - sTime) / (1000 * 1000); -// Log.i(TAG, "onDraw: end " + String.format("%.3f", elapsedTime) + "ms"); + long fTime = System.nanoTime(); + float elapsedTime = (float) (fTime - sTime) / (1000 * 1000); + Log.i(TAG, "onDraw: end " + String.format("%.3f", elapsedTime) + "ms"); } protected void onDrawSimpleUi(Canvas canvas) { + Log.i(TAG, "onDrawSimpleUi: "); canvas.drawRect(0, 0, displaySize.x, displaySize.y, mBackgroundPaint); float xHalf = displaySize.x / 2f; float yThird = displaySize.y / 3f; - float yOffset = 25f; boolean isOutdated = rawData.datetime > 0 && ageLevel() <= 0; mSvgPaint.setStrikeThruText(isOutdated); @@ -350,25 +352,24 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc String sSvg = rawData.sSgv; float svgWidth = mSvgPaint.measureText(sSvg); - String sDirection = " " + rawData.sDirection + "\uFE0E"; + String sDirection = " " + rawData.sDirection + "\uFE0E"; float directionWidth = mDirectionPaint.measureText(sDirection); float xSvg = xHalf - (svgWidth + directionWidth) / 2; - canvas.drawText(sSvg, xSvg, yThird + 50, mSvgPaint); + canvas.drawText(sSvg, xSvg, yThird + mYOffset, mSvgPaint); float xDirection = xSvg + svgWidth; - canvas.drawText(sDirection, xDirection, yThird + yOffset, mDirectionPaint); + canvas.drawText(sDirection, xDirection, yThird + mYOffset, mDirectionPaint); String sTime = timeFormat.format(mDateTime); - float xTime = xHalf - mTimePaint.measureText(sTime) / 2; - canvas.drawText(timeFormat.format(mDateTime), xTime, yThird * 2 + yOffset, mTimePaint); - + float xTime = xHalf - mTimePaint.measureText(sTime) / 2f; + canvas.drawText(timeFormat.format(mDateTime), xTime, yThird * 2f + mYOffset, mTimePaint); } int getBgColour(long level) { - if (rawData.sgvLevel == level) { + if (level == 1) { return colorDarkHigh; - } if (rawData.sgvLevel == level) { + } if (level == 0) { return colorDarkMid; } return colorDarkLow; @@ -376,9 +377,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) { -// Log.i(TAG, "onTimeChanged: called "); + Log.i(TAG, "onTimeChanged: called "); if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { -// Log.i(TAG, "onTimeChanged: minute/hour changed"); + Log.i(TAG, "onTimeChanged: minute/hour changed"); long now = System.currentTimeMillis(); mDateTime.setTime(now); @@ -403,7 +404,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private void checkVibrateHourly(WatchFaceTime oldTime, WatchFaceTime newTime) { boolean hourlyVibratePref = sharedPrefs.getBoolean("vibrate_Hourly", false); if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) { -// Log.i("hourlyVibratePref", "true --> " + newTime.toString()); + Log.i("hourlyVibratePref", "true --> " + newTime.toString()); Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); long[] vibrationPattern = {0, 150, 125, 100}; vibrator.vibrate(vibrationPattern, -1); @@ -411,7 +412,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } public void setDataFields() { - + Log.i(TAG, "setDataFields: "); setDateAndTime(); if (mSgv != null) { if (sharedPrefs.getBoolean("showBG", true)) { @@ -487,7 +488,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mIOB1.setVisibility(View.GONE); mIOB2.setVisibility(View.GONE); } - //deal with cases where there is only the value shown for IOB, and not the label + // deal with cases where there is only the value shown for IOB, and not the label } else if (mIOB2 != null) { if (sharedPrefs.getBoolean("show_iob", true)) { mIOB2.setVisibility(View.VISIBLE); @@ -569,8 +570,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mStatus.setVisibility(View.GONE); } } -// Log.i(TAG, -// "setDataFields: loop " + rawData.openApsStatus + " " + (System.currentTimeMillis() - rawData.openApsStatus)); + Log.i(TAG, + "setDataFields: loop " + rawData.openApsStatus + " " + (System.currentTimeMillis() - rawData.openApsStatus)); if (mLoop != null) { if (sharedPrefs.getBoolean("showExternalStatus", true)) { mLoop.setVisibility(View.VISIBLE); @@ -599,7 +600,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void on24HourFormatChanged(boolean is24HourFormat) { -// Log.i(TAG, "on24HourFormatChanged: "); + Log.i(TAG, "on24HourFormatChanged: "); initFormats(); if (!isSimpleUi()) { setDataFields(); @@ -608,7 +609,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } public void setDateAndTime() { - + Log.i(TAG, "setDateAndTime: "); if (mTime != null) { mTime.setText(timeFormat.format(mDateTime)); } @@ -645,6 +646,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } public void setColor() { + Log.i(TAG, "setColor: "); dividerMatchesBg = sharedPrefs.getBoolean("match_divider", false); if (lowResMode) { setColorLowRes(); @@ -658,7 +660,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public void strikeThroughSgvIfNeeded() { if (mSgv != null) { if (sharedPrefs.getBoolean("showBG", true)) { - if (ageLevel() <= 0) { + if (ageLevel() <= 0 && rawData.datetime > 0) { mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); @@ -668,7 +670,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } protected void onWatchModeChanged(WatchMode watchMode) { -// Log.i(TAG, "onWatchModeChanged: " + watchMode); + Log.i(TAG, "onWatchModeChanged: " + watchMode); lowResMode = isLowRes(watchMode); if (isSimpleUi()) { setSimpleUiAntiAlias(); @@ -691,18 +693,25 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private boolean isSimpleUi() { String simplify = sharedPrefs.getString("simplify_ui", "off"); + Log.i(TAG, "isSimpleUi: " + simplify); if (simplify.equals("off")) { + Log.i(TAG, "isSimpleUi: off"); return false; } if ((simplify.equals("ambient") || simplify.equals("ambient_charging")) && getCurrentWatchMode() == WatchMode.AMBIENT) { + Log.i(TAG, "isSimpleUi: abient"); return true; } - return (simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging(); + if((simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging()){ + Log.i(TAG, "isSimpleUi: charging"); + return true; + } + return false; } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { -// Log.i(TAG, "onSharedPreferenceChanged: "); + Log.i(TAG, "onSharedPreferenceChanged: "); setupBatteryReceiver(); if ("delta_granularity".equals(key)) { ListenerService.requestData(this); @@ -721,10 +730,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc protected abstract void setColorLowRes(); public void missedReadingAlert() { -// Log.i(TAG, "missedReadingAlert: check"); + Log.i(TAG, "missedReadingAlert: check"); int minutes_since = (int) Math.floor(timeSince() / (1000 * 60)); if (rawData.datetime == 0 || minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) { -// Log.i(TAG, "missedReadingAlert: do"); + Log.i(TAG, "missedReadingAlert: do"); ListenerService.requestData(this); // attempt endTime recover missing data } } @@ -733,7 +742,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc if (isSimpleUi()) { return; } - if (rawData.bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things + Log.i(TAG, "setupCharts: "); + if (rawData.bgDataList.size() > 0) { // Dont crash things just because we dont have values, people dont like crashy things int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); if (lowResMode) { bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), rawData, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, Color.GREEN, timeframe); @@ -750,17 +760,21 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public class MessageReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { -// Log.i(TAG, "Data MessageReceiver.onReceive: "); + Log.i(TAG, "Data MessageReceiver.onReceive: "); + long sTime = System.nanoTime(); + PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock); + Log.i(TAG, "onReceive: data " + intent.getBundleExtra("data")); if (chart != null && dataMap != null) { rawData.addToWatchSet(dataMap); setupCharts(); } rawData.updateStatusFromMessage(intent, wakeLock); rawData.updateBasalsFromMessage(intent, wakeLock); - + Log.i(TAG, "onReceive: status " + intent.getBundleExtra("status")); + Log.i(TAG, "onReceive: " + rawData.sSgv + " " + rawData.sDirection); if (isSimpleUi()) { if (needUpdate()) { invalidate(); @@ -771,6 +785,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc invalidate(); } wearUtil.releaseWakeLock(wl); + long fTime = System.nanoTime(); + float elapsedTime = (float) (fTime - sTime) / (1000 * 1000); + Log.i(TAG, "onReceive: end " + String.format("%.3f", elapsedTime) + "ms"); } } @@ -780,6 +797,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } mLastSvg = rawData.sSgv; mLastDirection = rawData.sDirection; + Log.i(TAG, "needUpdate: "); return true; } diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java index b121f58f82..644c17668d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java @@ -108,6 +108,7 @@ public class Steampunk extends BaseWatchFace { if (rotationAngle > 330) rotationAngle = 330; //if the glucose value is higher than 330 then show "HIGH" on the dial. ("HIGH" is at 330 degrees on the dial) if (rotationAngle != 0 && rotationAngle < 30) rotationAngle = 30; //if the glucose value is lower than 30 show "LOW" on the dial. ("LOW" is at 30 degrees on the dial) + if (lastEndDegrees == 0) lastEndDegrees = rotationAngle; //rotate glucose dial RotateAnimation rotate = new RotateAnimation( diff --git a/wear/src/main/res/values/dimens.xml b/wear/src/main/res/values/dimens.xml new file mode 100644 index 0000000000..0eaedf5064 --- /dev/null +++ b/wear/src/main/res/values/dimens.xml @@ -0,0 +1,8 @@ + + + + 50sp + 35sp + 35sp + 5dp + From 311f648258073eb3361a80010b7c7be5af6e39bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jan 2022 08:08:39 +0000 Subject: [PATCH 07/14] Bump sqlite-jdbc from 3.34.0 to 3.36.0.3 Bumps [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.34.0 to 3.36.0.3. - [Release notes](https://github.com/xerial/sqlite-jdbc/releases) - [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG) - [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.34.0...3.36.0.3) --- updated-dependencies: - dependency-name: org.xerial:sqlite-jdbc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8add55d5c2..8a77250674 100644 --- a/build.gradle +++ b/build.gradle @@ -81,7 +81,7 @@ allprojects { // Source: https://issuetracker.google.com/issues/174695268 configurations.configureEach { resolutionStrategy { - force 'org.xerial:sqlite-jdbc:3.34.0' + force 'org.xerial:sqlite-jdbc:3.36.0.3' } } } From 6fd15940113b7bdedca37c03c8ad131c72e69af1 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Mon, 10 Jan 2022 09:28:57 +0100 Subject: [PATCH 08/14] Wear: remove debug log --- .../androidaps/watchfaces/BaseWatchFace.java | 93 +++++-------------- 1 file changed, 21 insertions(+), 72 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index 8b560c0766..b35aee5ade 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -97,28 +97,24 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc // related endTime manual layout public View layoutView; public int specW, specH; - public boolean forceSquareCanvas = false; // Set to true by the Steampunk watch face. + public boolean forceSquareCanvas = false; // Set to true by the Steampunk watch face. public String sMinute = "0"; public String sHour = "0"; protected SharedPreferences sharedPrefs; private LocalBroadcastManager localBroadcastManager; private MessageReceiver messageReceiver; private BroadcastReceiver batteryReceiver; - private int colorDarkHigh; - private int colorDarkMid; - private int colorDarkLow; + private int colorDarkHigh, colorDarkMid, colorDarkLow; private java.text.DateFormat timeFormat; private SimpleDateFormat sdfDay, sdfMonth, sdfHour, sdfPeriod, sdfDayName, sdfMinute; - private final String TAG = "ASTAG"; private Paint mBackgroundPaint, mTimePaint, mSvgPaint, mDirectionPaint; private Date mDateTime; - private String mLastSvg = ""; - private String mLastDirection = ""; + private String mLastSvg = "", mLastDirection = ""; private float mYOffset = 0; + private Intent mBatteryStatus; @Override public void onCreate() { - Log.i(TAG, "onCreate: "); // Not derived from DaggerService, do injection here AndroidInjection.inject(this); super.onCreate(); @@ -149,17 +145,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } private void setupBatteryReceiver() { + IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); + mBatteryStatus = this.registerReceiver(null, iFilter); String setting = sharedPrefs.getString("simplify_ui", "off"); - Log.i(TAG, "setupBatteryReceiver: " + setting); if (setting.equals("charging") || setting.equals("ambient_charging") && batteryReceiver == null) { - Log.i(TAG, "setupBatteryReceiver: DONE"); IntentFilter intentBatteryFilter = new IntentFilter(); intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING); intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING); batteryReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - Log.i(TAG, "Battery BroadcastReceiver.onReceive: "); setDataFields(); invalidate(); } @@ -212,7 +207,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) { - Log.i(TAG, "onLayout: "); super.onLayout(shape, screenBounds, screenInsets); layoutView.onApplyWindowInsets(screenInsets); bIsRound = screenInsets.isRound(); @@ -309,36 +303,24 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected long getInteractiveModeUpdateRate() { - // Only call onTimeChanged every 1 - return 60 * 1000L; + return 60 * 1000L; // Only call onTimeChanged every 60 seconds } @Override protected void onDraw(Canvas canvas) { - Log.i(TAG, "onDraw: start "); - long sTime = System.nanoTime(); if (isSimpleUi()) { onDrawSimpleUi(canvas); } else { if (layoutSet) { - mRelativeLayout.measure(specW, specH); - if (forceSquareCanvas) { - mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); // force a square for Steampunk watch face. - } else { - mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); - } + int y = forceSquareCanvas ? displaySize.x : displaySize.y; // Square Steampunk + mRelativeLayout.layout(0, 0, displaySize.x, y); mRelativeLayout.draw(canvas); } } - - long fTime = System.nanoTime(); - float elapsedTime = (float) (fTime - sTime) / (1000 * 1000); - Log.i(TAG, "onDraw: end " + String.format("%.3f", elapsedTime) + "ms"); } protected void onDrawSimpleUi(Canvas canvas) { - Log.i(TAG, "onDrawSimpleUi: "); canvas.drawRect(0, 0, displaySize.x, displaySize.y, mBackgroundPaint); float xHalf = displaySize.x / 2f; float yThird = displaySize.y / 3f; @@ -368,8 +350,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc int getBgColour(long level) { if (level == 1) { return colorDarkHigh; - - } if (level == 0) { + } + if (level == 0) { return colorDarkMid; } return colorDarkLow; @@ -377,9 +359,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) { - Log.i(TAG, "onTimeChanged: called "); if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { - Log.i(TAG, "onTimeChanged: minute/hour changed"); long now = System.currentTimeMillis(); mDateTime.setTime(now); @@ -394,9 +374,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } private boolean isCharging() { - IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); - Intent batteryStatus = this.registerReceiver(null, iFilter); - int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); + int status = mBatteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL; } @@ -412,14 +390,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } public void setDataFields() { - Log.i(TAG, "setDataFields: "); setDateAndTime(); if (mSgv != null) { if (sharedPrefs.getBoolean("showBG", true)) { mSgv.setText(rawData.sSgv); mSgv.setVisibility(View.VISIBLE); } else { - // leave the textview there but invisible, as a height holder for the empty space above the white line + // Leave the textview there but invisible, as a height holder for the empty space above the white line mSgv.setVisibility(View.INVISIBLE); mSgv.setText(""); } @@ -488,7 +465,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mIOB1.setVisibility(View.GONE); mIOB2.setVisibility(View.GONE); } - // deal with cases where there is only the value shown for IOB, and not the label + // Deal with cases where there is only the value shown for IOB, and not the label } else if (mIOB2 != null) { if (sharedPrefs.getBoolean("show_iob", true)) { mIOB2.setVisibility(View.VISIBLE); @@ -501,16 +478,14 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mIOB2.setText(""); } } + if (mTimestamp != null) { if (sharedPrefs.getBoolean("showAgo", true)) { if (isAAPSv2 != null) { mTimestamp.setText(readingAge(true)); } else { - if (sharedPrefs.getBoolean("showExternalStatus", true)) { - mTimestamp.setText(readingAge(true)); - } else { - mTimestamp.setText(readingAge(false)); - } + boolean shortString = sharedPrefs.getBoolean("showExternalStatus", true); + mTimestamp.setText(readingAge(shortString)); } mTimestamp.setVisibility(View.VISIBLE); } else { @@ -570,8 +545,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mStatus.setVisibility(View.GONE); } } - Log.i(TAG, - "setDataFields: loop " + rawData.openApsStatus + " " + (System.currentTimeMillis() - rawData.openApsStatus)); + if (mLoop != null) { if (sharedPrefs.getBoolean("showExternalStatus", true)) { mLoop.setVisibility(View.VISIBLE); @@ -600,7 +574,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc @Override protected void on24HourFormatChanged(boolean is24HourFormat) { - Log.i(TAG, "on24HourFormatChanged: "); initFormats(); if (!isSimpleUi()) { setDataFields(); @@ -609,7 +582,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } public void setDateAndTime() { - Log.i(TAG, "setDateAndTime: "); if (mTime != null) { mTime.setText(timeFormat.format(mDateTime)); } @@ -646,7 +618,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } public void setColor() { - Log.i(TAG, "setColor: "); dividerMatchesBg = sharedPrefs.getBoolean("match_divider", false); if (lowResMode) { setColorLowRes(); @@ -670,7 +641,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } protected void onWatchModeChanged(WatchMode watchMode) { - Log.i(TAG, "onWatchModeChanged: " + watchMode); lowResMode = isLowRes(watchMode); if (isSimpleUi()) { setSimpleUiAntiAlias(); @@ -693,30 +663,21 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc private boolean isSimpleUi() { String simplify = sharedPrefs.getString("simplify_ui", "off"); - Log.i(TAG, "isSimpleUi: " + simplify); if (simplify.equals("off")) { - Log.i(TAG, "isSimpleUi: off"); return false; } if ((simplify.equals("ambient") || simplify.equals("ambient_charging")) && getCurrentWatchMode() == WatchMode.AMBIENT) { - Log.i(TAG, "isSimpleUi: abient"); return true; } - if((simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging()){ - Log.i(TAG, "isSimpleUi: charging"); - return true; - } - return false; + return (simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging(); } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - Log.i(TAG, "onSharedPreferenceChanged: "); setupBatteryReceiver(); if ("delta_granularity".equals(key)) { ListenerService.requestData(this); } - if (layoutSet) { setDataFields(); } @@ -730,11 +691,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc protected abstract void setColorLowRes(); public void missedReadingAlert() { - Log.i(TAG, "missedReadingAlert: check"); int minutes_since = (int) Math.floor(timeSince() / (1000 * 60)); if (rawData.datetime == 0 || minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) { - Log.i(TAG, "missedReadingAlert: do"); - ListenerService.requestData(this); // attempt endTime recover missing data + ListenerService.requestData(this); // Attempt endTime recover missing data } } @@ -742,7 +701,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc if (isSimpleUi()) { return; } - Log.i(TAG, "setupCharts: "); if (rawData.bgDataList.size() > 0) { // Dont crash things just because we dont have values, people dont like crashy things int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); if (lowResMode) { @@ -760,21 +718,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc public class MessageReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - Log.i(TAG, "Data MessageReceiver.onReceive: "); - long sTime = System.nanoTime(); - PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock); - Log.i(TAG, "onReceive: data " + intent.getBundleExtra("data")); if (chart != null && dataMap != null) { rawData.addToWatchSet(dataMap); setupCharts(); } rawData.updateStatusFromMessage(intent, wakeLock); rawData.updateBasalsFromMessage(intent, wakeLock); - Log.i(TAG, "onReceive: status " + intent.getBundleExtra("status")); - Log.i(TAG, "onReceive: " + rawData.sSgv + " " + rawData.sDirection); + if (isSimpleUi()) { if (needUpdate()) { invalidate(); @@ -785,9 +738,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc invalidate(); } wearUtil.releaseWakeLock(wl); - long fTime = System.nanoTime(); - float elapsedTime = (float) (fTime - sTime) / (1000 * 1000); - Log.i(TAG, "onReceive: end " + String.format("%.3f", elapsedTime) + "ms"); } } @@ -797,7 +747,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc } mLastSvg = rawData.sSgv; mLastDirection = rawData.sDirection; - Log.i(TAG, "needUpdate: "); return true; } From 47d0663cf75c6cc85379b6a20bc81ad328fecfd4 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Mon, 10 Jan 2022 22:46:15 +0000 Subject: [PATCH 09/14] - added two special cases when processing list - createTBRProcessList: - if changed duration is 0 or less, we remove the entry - if previously added item makes duration longer than original one, then we use the original duration --- .../medtronic/data/MedtronicHistoryData.kt | 18 + .../medtronic/data/dto/TempBasalProcessDTO.kt | 6 +- .../data/MedtronicHistoryDataUTest.kt | 43 + .../src/test/resources/tbr_data_special.json | 1090 +++++++++++++++++ 4 files changed, 1156 insertions(+), 1 deletion(-) create mode 100644 medtronic/src/test/resources/tbr_data_special.json diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt index 6759efae81..7ea4b694d2 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt @@ -759,6 +759,7 @@ class MedtronicHistoryData @Inject constructor( } var previousItem: TempBasalProcessDTO? = null + val removalList : MutableList = arrayListOf() // fix for Zero TBRs for (tempBasalProcessDTO in processList) { @@ -768,8 +769,18 @@ class MedtronicHistoryData @Inject constructor( pheEnd.atechDateTime = DateTimeUtil.getATDWithAddedSeconds(tempBasalProcessDTO.itemOne.atechDateTime, -2) pheEnd.addDecodedData("Object", TempBasalPair(0.0, false, 0)) + var initialDuration = previousItem.durationAsSeconds + previousItem.itemTwo = pheEnd + if (previousItem.durationAsSeconds <=0) { + // if we have duration of 0 or less, then we have invalid entry which needs to be removed + removalList.add(previousItem) + } else if (previousItem.durationAsSeconds > initialDuration) { + // if duration with last item is longer than planned TBR duration we remove previous item and leave original duration + previousItem.itemTwo = null + } + previousItem = null } if (tempBasalProcessDTO.itemOneTbr!!.isZeroTBR) { @@ -777,6 +788,13 @@ class MedtronicHistoryData @Inject constructor( } } + // removing previously tagged item + if (removalList.isNotEmpty()) { + for (tempBasalProcessDTO in removalList) { + processList.remove(tempBasalProcessDTO) + } + } + return processList } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalProcessDTO.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalProcessDTO.kt index c53d793a43..b784699bfa 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalProcessDTO.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalProcessDTO.kt @@ -12,7 +12,11 @@ class TempBasalProcessDTO constructor(var itemOne: PumpHistoryEntry, set(value) { field = value if (objectType == ObjectType.TemporaryBasal) { - itemTwoTbr = value!!.getDecodedDataEntry("Object") as TempBasalPair + if (value!=null) { + itemTwoTbr = value.getDecodedDataEntry("Object") as TempBasalPair + } else { + itemTwoTbr = null + } } } diff --git a/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryDataUTest.kt b/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryDataUTest.kt index b5864a22e1..71c991a928 100644 --- a/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryDataUTest.kt +++ b/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryDataUTest.kt @@ -86,4 +86,47 @@ class MedtronicHistoryDataUTest : TestBase() { } + @Test + fun createTBRProcessList_SpecialCase() { + + var unitToTest = MedtronicHistoryData(packetInjector, aapsLogger, sp, rh, rxBus, activePlugin, + medtronicUtil, medtronicPumpHistoryDecoder, + medtronicPumpStatus, + pumpSync, + pumpSyncStorage) + + + val gson = Gson() + + val fileText = ClassLoader.getSystemResource("tbr_data_special.json").readText() + + val listType: Type = object : TypeToken?>() {}.getType() + val yourClassList: MutableList = gson.fromJson(fileText, listType) + + for (pumpHistoryEntry in yourClassList) { + val stringObject = pumpHistoryEntry.decodedData["Object"] as LinkedTreeMap + + val rate : Double = stringObject.get("insulinRate") as Double + val durationMinutes: Double = stringObject.get("durationMinutes") as Double + val durationMinutesInt : Int = durationMinutes.toInt() + + var tmbPair = TempBasalPair(rate, false, durationMinutesInt) + + pumpHistoryEntry.decodedData.remove("Object") + pumpHistoryEntry.addDecodedData("Object", tmbPair) + } + + System.out.println("TBR Pre-Process List (Special): " + gson.toJson(yourClassList)) + + val createTBRProcessList = unitToTest.createTBRProcessList(yourClassList) + + System.out.println("TBR Process List (Special): " + createTBRProcessList.size) + + for (tempBasalProcessDTO in createTBRProcessList) { + System.out.println(tempBasalProcessDTO.toTreatmentString()) + } + + } + + } \ No newline at end of file diff --git a/medtronic/src/test/resources/tbr_data_special.json b/medtronic/src/test/resources/tbr_data_special.json new file mode 100644 index 0000000000..301600ed9e --- /dev/null +++ b/medtronic/src/test/resources/tbr_data_special.json @@ -0,0 +1,1090 @@ +[{ + "entryType": "TempBasalCombined", + "DT": "19.12.2021 13:15:34", + "atechDateTime": 20211219131534, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.7000000000000002, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 13:20:19", + "atechDateTime": 20211219132019, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 13:20:20", + "atechDateTime": 20211219132020, + "decodedData": { + "Object": { + "durationMinutes": 60, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 13:30:29", + "atechDateTime": 20211219133029, + "decodedData": { + "Object": { + "durationMinutes": 90, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 13:50:33", + "atechDateTime": 20211219135033, + "decodedData": { + "Object": { + "durationMinutes": 120, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 14:20:21", + "atechDateTime": 20211219142021, + "decodedData": { + "Object": { + "durationMinutes": 120, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 14:50:16", + "atechDateTime": 20211219145016, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.85, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 14:55:55", + "atechDateTime": 20211219145555, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 14:55:57", + "atechDateTime": 20211219145557, + "decodedData": { + "Object": { + "durationMinutes": 60, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:00:33", + "atechDateTime": 20211219150033, + "decodedData": { + "Object": { + "durationMinutes": 60, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:15:41", + "atechDateTime": 20211219151541, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.55, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:20:32", + "atechDateTime": 20211219152032, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:20:34", + "atechDateTime": 20211219152034, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:30:39", + "atechDateTime": 20211219153039, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.8500000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:31:15", + "atechDateTime": 20211219153115, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:31:16", + "atechDateTime": 20211219153116, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 2.5, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:35:34", + "atechDateTime": 20211219153534, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:35:35", + "atechDateTime": 20211219153535, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.05, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:40:47", + "atechDateTime": 20211219154047, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:40:49", + "atechDateTime": 20211219154049, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.30000000000000004, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:45:16", + "atechDateTime": 20211219154516, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:45:17", + "atechDateTime": 20211219154517, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.6000000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:50:12", + "atechDateTime": 20211219155012, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:50:13", + "atechDateTime": 20211219155013, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.9500000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:55:23", + "atechDateTime": 20211219155523, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 15:55:25", + "atechDateTime": 20211219155525, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.1, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 16:00:27", + "atechDateTime": 20211219160027, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 16:00:29", + "atechDateTime": 20211219160029, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.55, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 16:05:37", + "atechDateTime": 20211219160537, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 16:05:38", + "atechDateTime": 20211219160538, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.1, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 16:10:04", + "atechDateTime": 20211219161004, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 16:10:06", + "atechDateTime": 20211219161006, + "decodedData": { + "Object": { + "durationMinutes": 120, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 17:25:36", + "atechDateTime": 20211219172536, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.75, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 17:30:36", + "atechDateTime": 20211219173036, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 17:30:37", + "atechDateTime": 20211219173037, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.1500000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 17:35:34", + "atechDateTime": 20211219173534, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 17:35:35", + "atechDateTime": 20211219173535, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 17:40:20", + "atechDateTime": 20211219174020, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.1500000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 17:55:36", + "atechDateTime": 20211219175536, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 17:55:38", + "atechDateTime": 20211219175538, + "decodedData": { + "Object": { + "durationMinutes": 120, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 18:25:30", + "atechDateTime": 20211219182530, + "decodedData": { + "Object": { + "durationMinutes": 120, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 19:25:50", + "atechDateTime": 20211219192550, + "decodedData": { + "Object": { + "durationMinutes": 120, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 20:51:09", + "atechDateTime": 20211219205109, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.2000000000000002, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 20:55:40", + "atechDateTime": 20211219205540, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 20:55:42", + "atechDateTime": 20211219205542, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.8, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:00:34", + "atechDateTime": 20211219210034, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:00:36", + "atechDateTime": 20211219210036, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.30000000000000004, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:05:12", + "atechDateTime": 20211219210512, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:05:13", + "atechDateTime": 20211219210513, + "decodedData": { + "Object": { + "durationMinutes": 60, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:10:23", + "atechDateTime": 20211219211023, + "decodedData": { + "Object": { + "durationMinutes": 60, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:25:24", + "atechDateTime": 20211219212524, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.9, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:30:54", + "atechDateTime": 20211219213054, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:30:56", + "atechDateTime": 20211219213056, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.4, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:35:58", + "atechDateTime": 20211219213558, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:36:00", + "atechDateTime": 20211219213600, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.55, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:40:34", + "atechDateTime": 20211219214034, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:40:36", + "atechDateTime": 20211219214036, + "decodedData": { + "Object": { + "durationMinutes": 60, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:50:04", + "atechDateTime": 20211219215004, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.55, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:55:52", + "atechDateTime": 20211219215552, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 21:55:54", + "atechDateTime": 20211219215554, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.3, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:00:34", + "atechDateTime": 20211219220034, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:00:35", + "atechDateTime": 20211219220035, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 2.45, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:10:37", + "atechDateTime": 20211219221037, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:15:26", + "atechDateTime": 20211219221526, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.5, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:20:51", + "atechDateTime": 20211219222051, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:20:52", + "atechDateTime": 20211219222052, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.1, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:25:52", + "atechDateTime": 20211219222552, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:25:53", + "atechDateTime": 20211219222553, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.7000000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:30:23", + "atechDateTime": 20211219223023, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:30:25", + "atechDateTime": 20211219223025, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:35:25", + "atechDateTime": 20211219223525, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:35:27", + "atechDateTime": 20211219223527, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.2000000000000002, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 22:45:57", + "atechDateTime": 20211219224557, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:05:38", + "atechDateTime": 20211219230538, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.05, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:10:34", + "atechDateTime": 20211219231034, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:10:36", + "atechDateTime": 20211219231036, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.35000000000000003, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:15:30", + "atechDateTime": 20211219231530, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:21:01", + "atechDateTime": 20211219232101, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.8500000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:30:08", + "atechDateTime": 20211219233008, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:30:10", + "atechDateTime": 20211219233010, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.05, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:35:53", + "atechDateTime": 20211219233553, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:35:54", + "atechDateTime": 20211219233554, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.8500000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:40:20", + "atechDateTime": 20211219234020, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:40:22", + "atechDateTime": 20211219234022, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 1.05, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:50:49", + "atechDateTime": 20211219235049, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:50:50", + "atechDateTime": 20211219235050, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.8500000000000001, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:55:04", + "atechDateTime": 20211219235504, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "19.12.2021 23:55:06", + "atechDateTime": 20211219235506, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.5, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:00:12", + "atechDateTime": 20211220000012, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:00:13", + "atechDateTime": 20211220000013, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.05, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:05:34", + "atechDateTime": 20211220000534, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:05:35", + "atechDateTime": 20211220000535, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.30000000000000004, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:15:05", + "atechDateTime": 20211220001505, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:15:06", + "atechDateTime": 20211220001506, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.1, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:21:26", + "atechDateTime": 20211220002126, + "decodedData": { + "Object": { + "durationMinutes": 0, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:21:27", + "atechDateTime": 20211220002127, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:50:49", + "atechDateTime": 20211220005049, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 00:50:50", + "atechDateTime": 20211220005050, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.0, + "isPercent": false + } + } +}, { + "entryType": "TempBasalCombined", + "DT": "20.12.2021 01:05:24", + "atechDateTime": 20211220010524, + "decodedData": { + "Object": { + "durationMinutes": 30, + "insulinRate": 0.0, + "isPercent": false + } + } +}] \ No newline at end of file From 95360dd6bc4ed535e8b34e79a8f795ba9e2c2ff9 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Mon, 10 Jan 2022 23:18:52 +0000 Subject: [PATCH 10/14] - small change --- .../plugins/pump/medtronic/data/MedtronicHistoryData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt index 7ea4b694d2..8a866c9516 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt @@ -769,7 +769,7 @@ class MedtronicHistoryData @Inject constructor( pheEnd.atechDateTime = DateTimeUtil.getATDWithAddedSeconds(tempBasalProcessDTO.itemOne.atechDateTime, -2) pheEnd.addDecodedData("Object", TempBasalPair(0.0, false, 0)) - var initialDuration = previousItem.durationAsSeconds + val initialDuration = previousItem.durationAsSeconds previousItem.itemTwo = pheEnd From 36cb37d9ac0e29e86ad1c213a26f8aa1b9f68031 Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 11 Jan 2022 21:04:43 +0100 Subject: [PATCH 11/14] Allow click on new wizard icons --- .../java/info/nightscout/androidaps/dialogs/WizardDialog.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt index 7d12c71687..06263b2a64 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -175,6 +175,10 @@ class WizardDialog : DaggerDialogFragment() { } dismiss() } + binding.bgEnabledIcon.setOnClickListener { binding.bgCheckbox.isChecked = !binding.bgCheckbox.isChecked } + binding.trendEnabledIcon.setOnClickListener { binding.bgTrendCheckbox.isChecked = !binding.bgTrendCheckbox.isChecked } + binding.cobEnabledIcon.setOnClickListener { binding.cobCheckbox.isChecked = !binding.cobCheckbox.isChecked } + binding.iobEnabledIcon.setOnClickListener { binding.iobCheckbox.isChecked = !binding.iobCheckbox.isChecked } // cancel button binding.cancel.setOnClickListener { aapsLogger.debug(LTag.APS, "Dialog canceled: ${this.javaClass.name}") From eb5a9aca550e73adde22d348904e76dc5e264cca Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 11 Jan 2022 21:20:48 +0100 Subject: [PATCH 12/14] Process Cob Click --- .../java/info/nightscout/androidaps/dialogs/WizardDialog.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt index 06263b2a64..c6624bb3d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -177,8 +177,8 @@ class WizardDialog : DaggerDialogFragment() { } binding.bgEnabledIcon.setOnClickListener { binding.bgCheckbox.isChecked = !binding.bgCheckbox.isChecked } binding.trendEnabledIcon.setOnClickListener { binding.bgTrendCheckbox.isChecked = !binding.bgTrendCheckbox.isChecked } - binding.cobEnabledIcon.setOnClickListener { binding.cobCheckbox.isChecked = !binding.cobCheckbox.isChecked } - binding.iobEnabledIcon.setOnClickListener { binding.iobCheckbox.isChecked = !binding.iobCheckbox.isChecked } + binding.cobEnabledIcon.setOnClickListener { binding.cobCheckbox.isChecked = !binding.cobCheckbox.isChecked; processCobCheckBox(); } + binding.iobEnabledIcon.setOnClickListener { if (!binding.cobCheckbox.isChecked) binding.iobCheckbox.isChecked = !binding.iobCheckbox.isChecked } // cancel button binding.cancel.setOnClickListener { aapsLogger.debug(LTag.APS, "Dialog canceled: ${this.javaClass.name}") From ae0996c0e75d431a665a1d777aaecc50d4d0ff3a Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 12 Jan 2022 16:56:41 +0100 Subject: [PATCH 13/14] Wear: make WF config simplify UI translatable --- wear/src/main/res/values/arrays.xml | 8 ++++---- wear/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wear/src/main/res/values/arrays.xml b/wear/src/main/res/values/arrays.xml index 6a753edec5..f8ea2c4bfb 100644 --- a/wear/src/main/res/values/arrays.xml +++ b/wear/src/main/res/values/arrays.xml @@ -66,10 +66,10 @@ - Off - During Charging - Always On Mode - Always On and Charging + @string/simple_ui_off + @string/simple_ui_charging + @string/simple_ui_always_on + @string/simple_ui_always_on_charging diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index a83cb9bacd..f30fed3c74 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -157,5 +157,9 @@ Bolus progress and cancel Bolus progress and cancel with less vibrations + Off + During Charging + Always On Mode + Always On and Charging From 90e9350f6bd454d8fb3528442e609d1232630ea9 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 12 Jan 2022 17:17:43 +0100 Subject: [PATCH 14/14] Wear: make rotarty input plus minus dynamic --- .../interaction/utils/PlusMinusEditText.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java index 54780c83ac..b85f09a8c6 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java @@ -3,19 +3,20 @@ package info.nightscout.androidaps.interaction.utils; import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.support.wearable.input.RotaryEncoder; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import androidx.core.view.InputDeviceCompat; +import androidx.core.view.MotionEventCompat; + import java.text.NumberFormat; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; - /** * Created by mike on 28.06.2016. */ @@ -35,6 +36,12 @@ public class PlusMinusEditText implements View.OnKeyListener, boolean allowZero = false; boolean roundRobin; + private int mChangeCounter = 0; + private long mLastChange = 0; + private final static int THRESHOLD_COUNTER = 5; + private final static int THRESHOLD_COUNTER_LONG = 10; + private final static int THRESHOLD_TIME = 100; + private final Handler mHandler; private ScheduledExecutorService mUpdater; @@ -68,7 +75,7 @@ public class PlusMinusEditText implements View.OnKeyListener, private static final int MSG_DEC = 1; public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero) { - this( view, editTextID, plusID, minusID, initValue, minValue, maxValue, step, formater, allowZero, false); + this(view, editTextID, plusID, minusID, initValue, minValue, maxValue, step, formater, allowZero, false); } public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, boolean roundRobin) { @@ -121,10 +128,11 @@ public class PlusMinusEditText implements View.OnKeyListener, public void setStep(Double step) { this.step = step; } + private void inc(int multiplier) { value += step * multiplier; if (value > maxValue) { - if(roundRobin){ + if (roundRobin) { value = minValue; } else { value = maxValue; @@ -134,10 +142,10 @@ public class PlusMinusEditText implements View.OnKeyListener, updateEditText(); } - private void dec( int multiplier) { + private void dec(int multiplier) { value -= step * multiplier; if (value < minValue) { - if(roundRobin){ + if (roundRobin) { value = maxValue; } else { value = minValue; @@ -211,13 +219,21 @@ public class PlusMinusEditText implements View.OnKeyListener, @Override public boolean onGenericMotion(View v, MotionEvent ev) { - if (ev.getAction() == MotionEvent.ACTION_SCROLL && RotaryEncoder.isFromRotaryEncoder(ev)) { - float delta = -RotaryEncoder.getRotaryAxisValue(ev); + if (ev.getAction() == MotionEvent.ACTION_SCROLL && ev.isFromSource(InputDeviceCompat.SOURCE_ROTARY_ENCODER)) { + long now = System.currentTimeMillis(); + if (now - mLastChange > THRESHOLD_TIME) mChangeCounter = 0; + + int dynamicMultiplier = mChangeCounter < THRESHOLD_COUNTER ? 1 : + mChangeCounter < THRESHOLD_COUNTER_LONG ? 2 : 4; + + float delta = -ev.getAxisValue(MotionEventCompat.AXIS_SCROLL); if (delta > 0) { - inc(1); + inc(dynamicMultiplier); } else { - dec(1); + dec(dynamicMultiplier); } + mLastChange = System.currentTimeMillis(); + mChangeCounter++; return true; } return false;