8000 Brand connected glucose surfaces as OpenGlucose by shroominic · Pull Request #62 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ expectations are defined in [docs/compatibility.md](docs/compatibility.md).

## [Unreleased]

### Changed

- The connected dashboard and live glucose surfaces now use the OpenGlucose
brand instead of exposing the connected sensor name. Sensor identity remains
available in Settings.

## [0.1.3] - 2026-08-16

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.json.JSONObject;

public final class GlucoseLiveUpdateService extends Service {
private static final String BRAND_NAME = "OpenGlucose";
static final String ACTION_UPSERT =
"com.aidex.aidex_flutter.action.UPSERT_LIVE_UPDATE";
static final String ACTION_END =
Expand Down Expand Up @@ -117,7 +118,6 @@ private void stopForegroundCompat() {
}

private Notification buildNotification(Map<String, Object> payload) {
final String sensorName = stringValue(payload, "sensorName", "OpenGlucose");
final String valueText = stringValue(payload, "valueText", "--");
final String unitText = stringValue(payload, "unitText", "mg/dL");
final String detailText = stringValue(payload, "detailText", "Waiting for sensor");
Expand All @@ -133,13 +133,13 @@ private Notification buildNotification(Map<String, Object> payload) {
}

final boolean hasValue = valueText != null && !"--".equals(valueText) && !valueText.isEmpty();
final String title = hasValue ? valueText + " " + unitText : sensorName;
final String title = hasValue ? valueText + " " + unitText : BRAND_NAME;
final String text =
detailText != null && !detailText.isEmpty()
? detailText
: fallbackDetail(stageLabel, lastReadingText);
final String subText = hasValue ? sensorName : stageLabel;
final String bigText = buildBigText(sensorName, text, trendSymbol, deltaText);
final String subText = BRAND_NAME;
final String bigText = buildBigText(BRAND_NAME, text, trendSymbol, deltaText);
final Notification publicVersion = buildRedactedNotification(payload);

final Notification.Builder builder;
Expand Down Expand Up @@ -187,9 +187,9 @@ static Notification buildRedactedNotificationForTest(
}
return builder
.setSmallIcon(R.drawable.ic_glucose_notification)
.setContentTitle("OpenGlucose")
.setContentTitle(BRAND_NAME)
.setContentText("Open the app to view your glucose")
.setSubText(stageLabel == null || stageLabel.isEmpty() ? "Sensor active" : stageLabel)
.setSubText(BRAND_NAME)
.setContentIntent(contentIntent)
.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_PUBLIC)
Expand All @@ -213,7 +213,7 @@ private Notification buildRedactedNotification(Map<String, Object> payload) {
.setSmallIcon(R.drawable.ic_glucose_notification)
.setContentTitle(remainingMinutes + " min")
.setContentText("Sensor warming up")
.setSubText("Warmup")
.setSubText(BRAND_NAME)
.setContentIntent(buildLaunchIntent())
.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_PUBLIC)
Expand Down Expand Up @@ -345,12 +345,12 @@ private Map<String, Object> loadPersistedPayload() {

private Map<String, Object> buildFallbackPayload() {
final SharedPreferences preferences = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
final String sensorName = preferences.getString(PREF_BACKGROUND_SENSOR, null);
if (sensorName == null || sensorName.isEmpty()) {
final String configuredSensorName = preferences.getString(PREF_BACKGROUND_SENSOR, null);
if (configuredSensorName == null || configuredSensorName.isEmpty()) {
return Collections.emptyMap();
}
final HashMap<String, Object> payload = new HashMap<>();
payload.put("sensorName", sensorName);
payload.put("sensorName", BRAND_NAME);
payload.put("valueText", "--");
payload.put("unitText", "mg/dL");
payload.put("stageLabel", "Live");
Expand Down Expand Up @@ -386,8 +386,8 @@ static boolean hasPersistedPayload(Context context) {
}

private String buildBigText(
String sensorName, String detailText, String trendSymbol, String deltaText) {
final StringBuilder builder = new StringBuilder(sensorName);
String brandName, String detailText, String trendSymbol, String deltaText) {
final StringBuilder builder = new StringBuilder(brandName);
if (detailText != null && !detailText.isEmpty()) {
builder.append(" • ").append(detailText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct GlucoseLiveActivityAttributes: ActivityAttributes {
var recordedAt: Date?
}

// Retained for ActivityKit schema compatibility. This display-only value is
// always the OpenGlucose brand, never the connected sensor identity.
var sensorName: String
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import ActivityKit
import SwiftUI
import WidgetKit

private let openGlucoseBrandName = "OpenGlucose"

@main
struct OpenGlucoseLiveActivityWidgetBundle: WidgetBundle {
var body: some Widget {
Expand All @@ -19,7 +21,7 @@ struct OpenGlucoseLiveActivityWidget: Widget {
DynamicIsland {
DynamicIslandExpandedRegion(.leading) {
VStack(alignment: .leading, spacing: 6) {
Text(context.attributes.sensorName)
Text(openGlucoseBrandName)
.font(.headline.weight(.semibold))
.lineLimit(1)
.minimumScaleFactor(0.8)
Expand Down Expand Up @@ -105,7 +107,7 @@ private struct GlucoseLiveActivityLockScreenView: View {
var body: some View {
VStack(alignment: .leading, spacing: 20) {
HStack(alignment: .top, spacing: 12) {
Text(context.attributes.sensorName)
Text(openGlucoseBrandName)
.font(.headline.weight(.semibold))
.lineLimit(1)
.minimumScaleFactor(0.8)
Expand Down
11 changes: 8 additions & 3 deletions openhealth/ios/Runner/GlucoseLiveActivityController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ final class GlucoseLiveActivityController {
}

func upsertBackgroundGlucose(
sensorName: String,
sensorName _: String,
valueMgdl: Int,
observedAt: Date
) {
Expand All @@ -261,7 +261,7 @@ final class GlucoseLiveActivityController {
} catch {
return
}
payload["sensorName"] = sensorName
payload[ 1798 "sensorName"] = "OpenGlucose"
payload["stageCode"] = "live"
payload["stageLabel"] = "LIVE"
payload["valueText"] = String(valueMgdl)
Expand Down Expand Up @@ -461,7 +461,12 @@ enum LiveActivityLockScreenRedaction {
to payload: [String: Any],
sensitiveContentEnabled: Bool
) -> [String: Any] {
sensitiveContentEnabled ? payload : redact(payload)
guard sensitiveContentEnabled else {
return redact(payload)
}
var brandedPayload = payload
brandedPayload["sensorName"] = "OpenGlucose"
return brandedPayload
}

static func redact(_ payload: [String: Any]) -> [String: Any] {
Expand Down
2 changes: 1 addition & 1 deletion openhealth/ios/RunnerTests/RunnerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ final class LiveActivityLockScreenRedactionTests: XCTestCase {
to: payload,
sensitiveContentEnabled: true
)
XCTAssertEqual(consented["sensorName"] as? String, "Private sensor name")
XCTAssertEqual(consented["sensorName"] as? String, "OpenGlucose")
XCTAssertEqual(consented["valueText"] as? String, "112")
XCTAssertEqual(consented["unitText"] as? String, "mg/dL")
XCTAssertEqual(consented["lastReadingText"] as? String, "14:55")
Expand Down
2 changes: 1 addition & 1 deletion openhealth/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ class _DashboardView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
snapshot.sensor.displayName,
'OpenGlucose',
style: theme.textTheme.headlineSmall?.copyWith(
fontWeight: FontWeight.w900,
),
Expand Down
8 changes: 6 additions & 2 deletions openhealth/lib/src/live_activity_payload.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:cgm_core/cgm_core.dart';
import 'display_preferences.dart';
import 'session_presentation.dart';

const liveSurfaceBrandName = 'OpenGlucose';

class LiveActivityPayload {
const LiveActivityPayload({
required this.sensorName,
Expand All @@ -19,6 +21,8 @@ class LiveActivityPayload {
this.recordedAtIso8601,
});

/// Legacy platform-contract key. Production builders store the app brand,
/// never the connected sensor identity, in this display-only field.
final String sensorName;
final String stageCode;
final String stageLabel;
Expand Down Expand Up @@ -87,7 +91,7 @@ LiveActivityPayload buildLiveActivityPayload({
);
if (warmup != null) {
return LiveActivityPayload(
sensorName: snapshot.sensor.displayName,
sensorName: liveSurfaceBrandName,
stageCode: 'progress',
stageLabel: warmupStageLabel(warmup).toUpperCase(),
valueText: warmupBigValueText(warmup),
Expand Down Expand Up @@ -134,7 +138,7 @@ LiveActivityPayload buildLiveActivityPayload({
: 'Updated $readingTime';

return LiveActivityPayload(
sensorName: snapshot.sensor.displayName,
sensorName: liveSurfaceBrandName,
stageCode: stageCode,
stageLabel: stageLabel,
valueText: valueText,
Expand Down
2 changes: 2 additions & 0 deletions openhealth/test/live_activity_payload_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void main() {
);

expect(payload.stageCode, 'progress');
expect(payload.sensorName, liveSurfaceBrandName);
expect(payload.stageLabel, 'WARMUP');
expect(payload.valueText, '57');
expect(payload.unitText, 'min');
Expand Down Expand Up @@ -259,6 +260,7 @@ void main() {
);

expect(payload.stageCode, 'live');
expect(payload.sensorName, liveSurfaceBrandName);
expect(payload.stageLabel, 'Connected');
expect(payload.trendSymbol, '↑');
expect(payload.deltaText, '+14');
Expand Down
13 changes: 13 additions & 0 deletions openhealth/test/privacy_release_defaults_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ void main() {
contains('getBoolean(PREF_SENSITIVE_LOCK_SCREEN_OPT_IN, false)'),
);
expect(android, contains('buildRedactedNotification(payload)'));
expect(android, contains('BRAND_NAME = "OpenGlucose"'));
expect(android, contains('.setSubText(BRAND_NAME)'));
expect(
android,
isNot(contains('buildBigText(sensorName')),
reason: 'Live notifications must not render the connected sensor name.',
);
expect(android, contains('validatedWarmupMinutes(payload)'));
expect(android, contains('.setPublicVersion(publicVersion)'));
expect(android, contains('Open the app to view your glucose'));
Expand All @@ -76,6 +83,12 @@ void main() {
expect(ios, contains('"sensorName": "OpenGlucose"'));
expect(ios, contains('let sensorName = displayPayload["sensorName"]'));
expect(ios, contains('sensorName: displaySensorName'));
final iosWidget = _read(
'ios/OpenGlucoseLiveActivityWidget/'
'OpenGlucoseLiveActivityWidget.swift',
);
expect(iosWidget, contains('openGlucoseBrandName = "OpenGlucose"'));
expect(iosWidget, isNot(contains('Text(context.attributes.sensorName)')));
expect(ios, contains('clearPersistedBackgroundPayload()'));
expect(
iosBridge,
Expand Down
7 changes: 7 additions & 0 deletions openhealth/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,15 @@ void main() {
await tester.pump(const Duration(milliseconds: 500));

expect(find.text('Connected'), findsOneWidget);
expect(find.text('OpenGlucose'), findsOneWidget);
expect(find.text('AiDEX Demo 07A12'), findsNothing);
expect(find.text('History'), findsOneWidget);
expect(find.text('DEMO DATA — NOT REAL GLUCOSE'), findsOneWidget);

await tester.tap(find.byIcon(Icons.tune_rounded));
await tester.pumpAndSettle();
expect(find.text('AiDEX Demo 07A12'), findsOneWidget);

await tester.pumpWidget(const SizedBox.shrink());
controller.dispose();
});
Expand Down
0