Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download treatments originated from xDrip as well #3357

Merged
merged 3 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public static boolean processTreatmentResponse(final String response) throws Exc
} catch (JSONException e) {
//
}

boolean skip_from_xdrip = Pref.getBooleanDefaultFalse("cloud_storage_api_skip_download_from_xdrip");

// extract blood test data if present
try {
if (!from_xdrip) {
Expand Down Expand Up @@ -130,7 +133,7 @@ public static boolean processTreatmentResponse(final String response) throws Exc
Treatments existing = Treatments.byuuid(nightscout_id);
if (existing == null)
existing = Treatments.byuuid(uuid);
if ((existing == null) && (!from_xdrip)) {
if ((existing == null) && !(from_xdrip && skip_from_xdrip)) {
// check for close timestamp duplicates perhaps
existing = Treatments.byTimestamp(timestamp, 60000);
if (!((existing != null) && (JoH.roundDouble(existing.insulin, 2) == JoH.roundDouble(insulin, 2))
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,8 @@
<string name="use_mobile_data">Use mobile data</string>
<string name="summary_cloud_storage_api_download_enable">Also try to download treatments from Nightscout</string>
<string name="title_cloud_storage_api_download_enable">Download treatments</string>
<string name="title_cloud_storage_api_download_from_xdrip">Skip items from xDrip</string>
<string name="summary_cloud_storage_api_download_from_xdrip">Avoid downloading items uploaded by xDrip</string>
<string name="summary_bluetooth_meter_for_calibrations_auto">Calibrate using new blood glucose readings if the conditions appear right to do so without asking confirmation (experimental)</string>
<string name="title_bluetooth_meter_for_calibrations_auto">Automatic Calibration</string>
<string name="title_rest_api_extra_options">Extra Options</string>
Expand Down
20 changes: 15 additions & 5 deletions app/src/main/res/xml/pref_data_source.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,21 @@
android:singleLine="true"
android:summary="@string/summary_nsfollow_url"
android:title="@string/title_nsfollow_url" />
<CheckBoxPreference
android:defaultValue="false"
android:key="nsfollow_download_treatments"
android:summary="@string/summary_nsfollow_download_treatments"
android:title="@string/title_nsfollow_download_treatments" />
<PreferenceScreen
android:key="_nsfollow_download_treatments_screen"
android:title="@string/title_nsfollow_download_treatments">
<CheckBoxPreference
android:defaultValue="false"
android:key="nsfollow_download_treatments"
android:summary="@string/summary_nsfollow_download_treatments"
android:title="@string/title_nsfollow_download_treatments" />
<SwitchPreference
android:defaultValue="true"
android:dependency="nsfollow_download_treatments"
android:key="cloud_storage_api_skip_download_from_xdrip"
android:summary="@string/summary_cloud_storage_api_download_from_xdrip"
android:title="@string/title_cloud_storage_api_download_from_xdrip" />
</PreferenceScreen>
<ListPreference
android:defaultValue="0"
android:key="nsfollow_lag"
Expand Down
23 changes: 17 additions & 6 deletions app/src/main/res/xml/pref_data_sync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,23 @@
android:key="cloud_storage_api_base"
android:title="@string/pref_title_api_url" />

<SwitchPreference
android:defaultValue="true"
android:dependency="cloud_storage_api_enable"
android:key="cloud_storage_api_download_enable"
android:summary="@string/summary_cloud_storage_api_download_enable"
android:title="@string/title_cloud_storage_api_download_enable" />
<PreferenceScreen
android:key="download_treatments_screen"
android:title="@string/title_cloud_storage_api_download_enable"
android:dependency="cloud_storage_api_enable">
<SwitchPreference
android:defaultValue="true"
android:dependency="cloud_storage_api_enable"
android:key="cloud_storage_api_download_enable"
android:summary="@string/summary_cloud_storage_api_download_enable"
android:title="@string/title_cloud_storage_api_download_enable" />
<SwitchPreference
android:defaultValue="true"
android:dependency="cloud_storage_api_download_enable"
android:key="cloud_storage_api_skip_download_from_xdrip"
android:summary="@string/summary_cloud_storage_api_download_from_xdrip"
android:title="@string/title_cloud_storage_api_download_from_xdrip" />
</PreferenceScreen>
<CheckBoxPreference
android:defaultValue="false"
android:dependency="cloud_storage_api_download_enable"
Expand Down
Loading