From 0d00787e68cc80abebca4df4bcb5b9245f2e6498 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 25 Jan 2016 03:41:28 +0100 Subject: [PATCH] add widget range lines --- .../eveningoutpost/dexdrip/utils/Preferences.java | 15 +++++++++++++++ .../com/eveningoutpost/dexdrip/xDripWidget.java | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utils/Preferences.java b/app/src/main/java/com/eveningoutpost/dexdrip/utils/Preferences.java index e1ee59bc35..aa1fa9aa10 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utils/Preferences.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utils/Preferences.java @@ -736,6 +736,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { final PreferenceScreen calibrationAlertsScreen = (PreferenceScreen) findPreference("calibration_alerts_screen"); final PreferenceCategory alertsCategory = (PreferenceCategory) findPreference("alerts_category"); final Preference disableAlertsStaleDataMinutes = findPreference("disable_alerts_stale_data_minutes"); + final Preference widgetRangeLines = findPreference("widget_range_lines"); + disableAlertsStaleDataMinutes.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { @@ -1047,6 +1049,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } }); + // Pebble Trend (just major change) pebbleSync2.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override @@ -1193,6 +1196,18 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { //bindWidgetUpdater(); + widgetRangeLines.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + Context context = preference.getContext(); + if(AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, xDripWidget.class)).length > 0){ + context.startService(new Intent(context, WidgetUpdateService.class)); + } + return true; + } + }); + + bindPreferenceSummaryToValue(transmitterId); transmitterId.getEditText().setFilters(new InputFilter[]{new InputFilter.AllCaps()}); diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/xDripWidget.java b/app/src/main/java/com/eveningoutpost/dexdrip/xDripWidget.java index 197d11a1af..9396110665 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/xDripWidget.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/xDripWidget.java @@ -75,6 +75,9 @@ private static void updateAppWidget(Context context, AppWidgetManager appWidgetM private static void displayCurrentInfo(AppWidgetManager appWidgetManager, int appWidgetId, Context context, RemoteViews views) { BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(context); BgReading lastBgreading = BgReading.lastNoSenssor(); + + final boolean showLines = Home.getPreferencesBoolean("widget_range_lines", false); + if (lastBgreading != null) { double estimate = 0; double estimated_delta = -9999; @@ -85,7 +88,7 @@ private static void displayCurrentInfo(AppWidgetManager appWidgetManager, int ap .setBgGraphBuilder(bgGraphBuilder) //.setShowFiltered(Home.getPreferencesBooleanDefaultFalse("show_filtered_curve")) .setBackgroundColor(ColorCache.getCol(ColorCache.X.color_widget_chart_background)) - .setHeight(height).setWidth(width).build()); + .setHeight(height).setWidth(width).showHighLine(showLines).showLowLine(showLines).build()); estimate = lastBgreading.calculated_value; String extrastring = "";