commit 3ad5cd420734eb7cfe9731f926c8095ad0076199
parent f154d2069581069bea148db49f78e85c789bc9a8
Author: Michael Camilleri <[email protected]>
Date: Mon, 19 Oct 2026 23:28:56 +0900
File instant reports from Control Center, the Lock Screen and Siri
This commit adds LogPassiveReportIntent, which files an instant report
without opening the app. It drives a Control Center control, which can
also sit in a Lock Screen slot or on the Action button, a round Lock
Screen widget, and an App Shortcut with phrases for Siri.
The control and the widget live in a new widget extension, where an
intent they trigger would run by default. The intent conforms to
LiveActivityIntent so the system runs it in the app instead, launching
it in the background if need be, as a notification's Instant Report
does. Location is live context and needs the app's location session,
and the store stays in the app's container, so there is no App Group
and only one process writes to it. The extension compiles the intent
but never performs it; the app supplies the filing through
AppDependencyManager.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat
| M | Notes/Design.md | | | 31 | +++++++++++++++++++++++++------ |
| M | Reportage.xcodeproj/project.pbxproj | | | 133 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | Reportage/AppDelegate.swift | | | 9 | +++++++++ |
| A | Reportage/Services/InstantReportLogger.swift | | | 42 | ++++++++++++++++++++++++++++++++++++++++++ |
| M | Reportage/Services/Prompts/PromptNotification.swift | | | 2 | +- |
| M | Reportage/Services/Prompts/PromptSettings.swift | | | 2 | +- |
| M | Reportage/Views/Home/HomeView.swift | | | 6 | +++--- |
| M | Reportage/Views/RootView.swift | | | 2 | +- |
| M | Reportage/Views/Settings/DiagnosticsSection.swift | | | 2 | +- |
| A | ReportageWidgets/Info.plist | | | 29 | +++++++++++++++++++++++++++++ |
| A | ReportageWidgets/ReportageWidgets.swift | | | 63 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | Shared/Intents/LogPassiveReportIntent.swift | | | 29 | +++++++++++++++++++++++++++++ |
| M | project.yml | | | 24 | ++++++++++++++++++++++++ |
13 files changed, 361 insertions(+), 13 deletions(-)
diff --git a/Notes/Design.md b/Notes/Design.md
@@ -88,7 +88,7 @@ The look is called Almanac: ink on paper, like a printed journal.
the accent, since a mark that small has to stand out by colour alone. All
sizes are Dynamic Type styles.
- **Tabs:** Timeline and Settings, with Visualisations joining them in
- Phase 7. The timeline keeps its serif 'Reportage' title, beside the quick
+ Phase 6. The timeline keeps its serif 'Reportage' title, beside the quick
log and new report buttons. A tapped prompt switches to the timeline to
open its survey.
- **Home screen:** reports grouped under day headings, newest first. Each
@@ -584,6 +584,16 @@ quick-log surface:
- the Action button (iPhone and Apple Watch Ultra)
- Siri and Shortcuts
+Controls and widgets live in a widget extension, and an intent they trigger
+runs in the extension's process by default. `LogPassiveReportIntent` conforms
+to `LiveActivityIntent` so the system runs it in the app's process instead,
+launching the app in the background if need be, as a notification's Instant
+Report does. Capture needs the app: location is live, and a short-lived
+extension with its own memory limit is a poor place to wait for a fix. It
+also keeps the store in the app's container, so there's no App Group and only
+one process writes to it. The extension compiles the intent but never
+performs it; the app supplies the logging through `AppDependencyManager`.
+
**The Watch app is deferred.** A prompt mirrored to the Watch already logs
an instant report from the wrist, with the iPhone capturing its location in
the background. A Watch app would add logging from the wrist without a
@@ -706,7 +716,7 @@ In order of preference:
the audio session.**
Microphone sampling is deferred. It needs its own permission and the route
-check verified on a device, so ambient noise waits for Health in Phase 6, and
+check verified on a device, so ambient noise waits for Health in Phase 5, and
microphone sampling is reconsidered then.
### Device and photos
@@ -866,13 +876,22 @@ the app as a fresh install has it. Prompt settings are kept.
manual reports, written entries, passive reports, and live context
capture (location, device, safe ambient noise).
3. **Prompts.** Scheduler, notification actions, background refresh.
-4. **Sync.** `CKSyncEngine`, both zones, first upload of the archive.
-5. **Quick logging.** `LogPassiveReportIntent` and the iOS surfaces it drives:
+4. **Quick logging.** `LogPassiveReportIntent` and the iOS surfaces it drives:
the Control Center control, Lock Screen widget, Action button, Siri and
Shortcuts. The Watch app is deferred.
-6. **Derived context.** Health, photos, and backfilling them and historical
+5. **Derived context.** Health, photos, and backfilling them and historical
weather. Live weather is part of capture (see [Weather](#weather)).
-7. **Visualisations.**
+6. **Visualisations.**
+7. **Synced schema.** Settle the [open questions](#open-questions) that change
+ synced data before the record formats are fixed: missed prompts, keeping
+ past prompt settings, place forms, adding, removing and rewording
+ questions, multi-select answers, and whether the Reporter import stays.
+8. **Sync.** `CKSyncEngine`, both zones, first upload. Sync comes last
+ because CloudKit's Production schema can only be added to, so it should
+ be deployed once, after everything else has settled the shape of the
+ data. Until then, local changes keep sync in mind: stable UUIDs,
+ `modifiedAt` updated on every edit, and no data that only one device can
+ interpret.
## Open Questions
diff --git a/Reportage.xcodeproj/project.pbxproj b/Reportage.xcodeproj/project.pbxproj
@@ -17,6 +17,7 @@
226A38BE6D7171D892EA35B3 /* FirstLaunch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE9EDC8448889EB9D4D358E /* FirstLaunch.swift */; };
22EA393B887791E20B6FE625 /* PlacePickerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B6C4141A26EED99B1F03FBE /* PlacePickerTests.swift */; };
25BC9F95DC40E31B1E4C6FBA /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BE62142CCC4A791F05163A /* Token.swift */; };
+ 275A9497C40065F5C77AE473 /* InstantReportLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 729C291798F29C69029E7DB7 /* InstantReportLogger.swift */; };
28D2CDAAB0777233D4465A83 /* ReporterArchiveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 487F88C880B5DE69964C6A37 /* ReporterArchiveTests.swift */; };
2D9BE70D44ECC3F3972DA466 /* SchemaMigrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E60426297403B9F8632343D8 /* SchemaMigrationTests.swift */; };
2EE68329C383FA1C5295ACA9 /* PlaceAnswerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9856D1F8123B9CAD7D39071D /* PlaceAnswerView.swift */; };
@@ -32,6 +33,7 @@
633A94E029055EA5D50D00AC /* PlaceRanking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76FFC5FE874467974DD6BFA0 /* PlaceRanking.swift */; };
68DDAB8BB2E679EB7EC1E9C1 /* ReporterImportPlan.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798E1DE82BD53EC5BEBA76B7 /* ReporterImportPlan.swift */; };
690A6B50550B9CE4B954CC0C /* PromptScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C4665B55B0307E899595C1D /* PromptScheduler.swift */; };
+ 6B71941AAD84B87358A969A0 /* LogPassiveReportIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90F9BD4EA70DCB46924CF9B8 /* LogPassiveReportIntent.swift */; };
6E21E729F89178EBD019980E /* InlineCasing.swift in Sources */ = {isa = PBXBuildFile; fileRef = A00E589A8387E7A1E348503C /* InlineCasing.swift */; };
6F06CC539C4D17B343A9321C /* LegacyBlob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30FFB17809ADA84F1036E2A7 /* LegacyBlob.swift */; };
7488B9EE97D419E2B6B9FCEA /* PromptNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C326FBA3249ED86912FBF5 /* PromptNotification.swift */; };
@@ -41,6 +43,7 @@
81B485BD03549DE6E7AA94A7 /* AppBadge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE5E7D863F9BD3DF363AA9A /* AppBadge.swift */; };
83E954F0DAC9719D2AA02111 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36C7E4E96538BB14AD6956CA /* HomeView.swift */; };
85A36A88AB170F0EAC0DAC03 /* QuestionPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A77AE6DE479403D1D4C9CF /* QuestionPage.swift */; };
+ 85C5BF024F19B11DBB616B5F /* ReportageWidgets.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 7EE78E311E8D8AF275123A3E /* ReportageWidgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
89AC740ACEABE2AE5453E683 /* SurveyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844ABAD88442C143BA239374 /* SurveyModel.swift */; };
89AD9247DEBDB7017EC8E017 /* reporter-fixture.json in Resources */ = {isa = PBXBuildFile; fileRef = 60457C07EF790C11D6C47EDF /* reporter-fixture.json */; };
8ADBA81D5D9ECCDCD5BDA742 /* JSONSlicerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AFF3D49ED9E8AC69390925 /* JSONSlicerTests.swift */; };
@@ -59,6 +62,7 @@
B510BB2C1C11D72DFE15E3C7 /* ReportageExportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DB6FF151DCEBC3913131834 /* ReportageExportTests.swift */; };
B6A7D4DE1FF9314F459A73CB /* EntryBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8E21C29422DA372F6363365 /* EntryBuilder.swift */; };
BD8D81CBF8C3DE544BB7540C /* DefaultQuestions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94DB0CA378AEF82B3CB27B67 /* DefaultQuestions.swift */; };
+ BDEB83CDBA9E0B4DB7712491 /* LogPassiveReportIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90F9BD4EA70DCB46924CF9B8 /* LogPassiveReportIntent.swift */; };
C5D94FEC4507054E6497E85B /* PersistenceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61C0B5BB02ECDBE84F5F73FA /* PersistenceController.swift */; };
C71E99843CC3D9DE4468B36B /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 878CE0FF7A2598F4197E8E61 /* Environment.swift */; };
C87E1C0465FE7B2917F92846 /* PromptSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB87A3E922FA7AE98B93DF1E /* PromptSettings.swift */; };
@@ -66,6 +70,7 @@
CFB0A1F9494F1D8919F48CC5 /* ContextCaptureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3157F7D5E4289B349E92402 /* ContextCaptureTests.swift */; };
D0497C9835A2502936591DC1 /* DisplayRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E609FFCB918B4EF9BFCC018 /* DisplayRule.swift */; };
D1F2257DDB68439AF352B57D /* PassiveLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46FB42E5DB43201A13D6D141 /* PassiveLog.swift */; };
+ D1FFB84FFDF0F659D8D78AEB /* ReportageWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EDD39E85D86AFF45B5672F3 /* ReportageWidgets.swift */; };
D3C3046B927DB98443E005C8 /* PlaceDirectory.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBBE80E95676BAEB53CE80E0 /* PlaceDirectory.swift */; };
D3FF67FB406DCCB78DF9D61A /* ReportSummaryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0734316A58943D5F2E26F718 /* ReportSummaryTests.swift */; };
D487802C53EA0E96698BE151 /* ContextCapture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F3237323A968FA629020DA9 /* ContextCapture.swift */; };
@@ -87,6 +92,13 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
+ AEB39310B9AF5A95182CB9BC /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = E54115BC20AD1649DD951B20 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = EBCA92AAD12311B2E8534AAE;
+ remoteInfo = ReportageWidgets;
+ };
C4BC163B82A12D0810FCC0E8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E54115BC20AD1649DD951B20 /* Project object */;
@@ -96,6 +108,20 @@
};
/* End PBXContainerItemProxy section */
+/* Begin PBXCopyFilesBuildPhase section */
+ 824B98170CD104FE531D301B /* Embed Foundation Extensions */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 13;
+ files = (
+ 85C5BF024F19B11DBB616B5F /* ReportageWidgets.appex in Embed Foundation Extensions */,
+ );
+ name = "Embed Foundation Extensions";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
/* Begin PBXFileReference section */
0734316A58943D5F2E26F718 /* ReportSummaryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportSummaryTests.swift; sourceTree = "<group>"; };
0B35602A218BE4EE399835FD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
@@ -128,6 +154,7 @@
643C730A99F0B7BA8C1F8A8E /* JSONSlicer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONSlicer.swift; sourceTree = "<group>"; };
6E382405EE9DBEC8EE616C1D /* SurveyModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveyModelTests.swift; sourceTree = "<group>"; };
7196D553D769071DB876B606 /* ReporterTimeZones.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReporterTimeZones.swift; sourceTree = "<group>"; };
+ 729C291798F29C69029E7DB7 /* InstantReportLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstantReportLogger.swift; sourceTree = "<group>"; };
74FF461F6E8A0241C18357B2 /* Vocabulary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Vocabulary.swift; sourceTree = "<group>"; };
76FFC5FE874467974DD6BFA0 /* PlaceRanking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaceRanking.swift; sourceTree = "<group>"; };
798E1DE82BD53EC5BEBA76B7 /* ReporterImportPlan.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReporterImportPlan.swift; sourceTree = "<group>"; };
@@ -135,6 +162,8 @@
7CE5E7D863F9BD3DF363AA9A /* AppBadge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppBadge.swift; sourceTree = "<group>"; };
7CE9EDC8448889EB9D4D358E /* FirstLaunch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstLaunch.swift; sourceTree = "<group>"; };
7DB6FF151DCEBC3913131834 /* ReportageExportTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportageExportTests.swift; sourceTree = "<group>"; };
+ 7EDD39E85D86AFF45B5672F3 /* ReportageWidgets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportageWidgets.swift; sourceTree = "<group>"; };
+ 7EE78E311E8D8AF275123A3E /* ReportageWidgets.appex */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.app-extension"; path = ReportageWidgets.appex; sourceTree = BUILT_PRODUCTS_DIR; };
7F9A0A87A54F3E96E079F52D /* QuestionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuestionsView.swift; sourceTree = "<group>"; };
7FD562C0C92C1D59881C771E /* ReporterImportPlanTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReporterImportPlanTests.swift; sourceTree = "<group>"; };
81BA515BEA1B0B68CE0D1326 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
@@ -144,6 +173,7 @@
87545A7909A370C668314DFF /* DiagnosticsSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiagnosticsSection.swift; sourceTree = "<group>"; };
878CE0FF7A2598F4197E8E61 /* Environment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Environment.swift; sourceTree = "<group>"; };
8E609FFCB918B4EF9BFCC018 /* DisplayRule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayRule.swift; sourceTree = "<group>"; };
+ 90F9BD4EA70DCB46924CF9B8 /* LogPassiveReportIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogPassiveReportIntent.swift; sourceTree = "<group>"; };
917C4579342FAC42F6C616FC /* ReporterImporterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReporterImporterTests.swift; sourceTree = "<group>"; };
92BFA1E8F26662DCF828DD5C /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; };
94DB0CA378AEF82B3CB27B67 /* DefaultQuestions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultQuestions.swift; sourceTree = "<group>"; };
@@ -157,6 +187,7 @@
A7DD8E44D1A1F7789F528BD3 /* EventLogTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventLogTests.swift; sourceTree = "<group>"; };
A8E21C29422DA372F6363365 /* EntryBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryBuilder.swift; sourceTree = "<group>"; };
A9C326FBA3249ED86912FBF5 /* PromptNotification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromptNotification.swift; sourceTree = "<group>"; };
+ AE6C0A180E8285C11565723B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
B007E6BACAA214C7332EF77C /* Question.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Question.swift; sourceTree = "<group>"; };
B03734F91822E7F161432075 /* Report.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Report.swift; sourceTree = "<group>"; };
B7998F9826B899741323C0C7 /* SurveyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveyView.swift; sourceTree = "<group>"; };
@@ -202,6 +233,15 @@
path = Prompts;
sourceTree = "<group>";
};
+ 12837500126587803B122AC5 /* ReportageWidgets */ = {
+ isa = PBXGroup;
+ children = (
+ AE6C0A180E8285C11565723B /* Info.plist */,
+ 7EDD39E85D86AFF45B5672F3 /* ReportageWidgets.swift */,
+ );
+ path = ReportageWidgets;
+ sourceTree = "<group>";
+ };
23711442404F0476532D0FC2 /* Survey */ = {
isa = PBXGroup;
children = (
@@ -292,6 +332,7 @@
children = (
7CE5E7D863F9BD3DF363AA9A /* AppBadge.swift */,
7CE9EDC8448889EB9D4D358E /* FirstLaunch.swift */,
+ 729C291798F29C69029E7DB7 /* InstantReportLogger.swift */,
AD85758A0521ED681067B90F /* Export */,
96D6D46E008E39350B203328 /* Narrative */,
580063E6A7AE05D5C6C16830 /* Places */,
@@ -306,12 +347,21 @@
children = (
507C6AD120A3E0F91316F4B6 /* Capture */,
E8F9E24C79DBD151637A6A00 /* Diagnostics */,
+ 72B803BC05F2124F2BE2EE3A /* Intents */,
4EF63181707B888F4ECDB980 /* Models */,
B9570B011A58C1B1BF00FB73 /* Persistence */,
);
path = Shared;
sourceTree = "<group>";
};
+ 72B803BC05F2124F2BE2EE3A /* Intents */ = {
+ isa = PBXGroup;
+ children = (
+ 90F9BD4EA70DCB46924CF9B8 /* LogPassiveReportIntent.swift */,
+ );
+ path = Intents;
+ sourceTree = "<group>";
+ };
78F7B34F781A8894EDCB8C74 /* Unit */ = {
isa = PBXGroup;
children = (
@@ -343,6 +393,7 @@
children = (
E41738BD317EF71D850CF801 /* Generated */,
4C708676FBAD641AD92F8CA0 /* Reportage */,
+ 12837500126587803B122AC5 /* ReportageWidgets */,
6939F7C2C95274DF2BB62D20 /* Shared */,
5253526A8B292306AB33EFF0 /* Support */,
78F7B34F781A8894EDCB8C74 /* Unit */,
@@ -375,6 +426,7 @@
children = (
E21F898FF60FC3A6AFCA06E9 /* Reportage Unit Tests.xctest */,
5C2AB8F226532A0889E2BCAD /* Reportage.app */,
+ 7EE78E311E8D8AF275123A3E /* ReportageWidgets.appex */,
);
name = Products;
sourceTree = "<group>";
@@ -475,10 +527,12 @@
buildConfigurationList = 0BDF6397081D7F97A8283020 /* Build configuration list for PBXNativeTarget "Reportage" */;
buildPhases = (
9F7B3262E96479048C6F2F04 /* Sources */,
+ 824B98170CD104FE531D301B /* Embed Foundation Extensions */,
);
buildRules = (
);
dependencies = (
+ 38CE7310CE3FBD324756E4CC /* PBXTargetDependency */,
);
name = Reportage;
packageProductDependencies = (
@@ -487,6 +541,23 @@
productReference = 5C2AB8F226532A0889E2BCAD /* Reportage.app */;
productType = "com.apple.product-type.application";
};
+ EBCA92AAD12311B2E8534AAE /* ReportageWidgets */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 091EB01CCA01F2C63DD0EA0F /* Build configuration list for PBXNativeTarget "ReportageWidgets" */;
+ buildPhases = (
+ 4988BD71EEB01ACD9335E067 /* Sources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = ReportageWidgets;
+ packageProductDependencies = (
+ );
+ productName = ReportageWidgets;
+ productReference = 7EE78E311E8D8AF275123A3E /* ReportageWidgets.appex */;
+ productType = "com.apple.product-type.app-extension";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -504,6 +575,10 @@
DevelopmentTeam = 7TD7PZBNXP;
ProvisioningStyle = Automatic;
};
+ EBCA92AAD12311B2E8534AAE = {
+ DevelopmentTeam = 7TD7PZBNXP;
+ ProvisioningStyle = Automatic;
+ };
};
};
buildConfigurationList = FB3AF546A563926C1C0CD963 /* Build configuration list for PBXProject "Reportage" */;
@@ -521,6 +596,7 @@
projectRoot = "";
targets = (
CADA375B316EB71CDEE1FE5B /* Reportage */,
+ EBCA92AAD12311B2E8534AAE /* ReportageWidgets */,
86F8617594446FA3ED0A3D35 /* Reportage Unit Tests */,
);
};
@@ -538,6 +614,15 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
+ 4988BD71EEB01ACD9335E067 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 6B71941AAD84B87358A969A0 /* LogPassiveReportIntent.swift in Sources */,
+ D1FFB84FFDF0F659D8D78AEB /* ReportageWidgets.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
9D9D7490B6C348C5A05545C7 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -584,8 +669,10 @@
226A38BE6D7171D892EA35B3 /* FirstLaunch.swift in Sources */,
83E954F0DAC9719D2AA02111 /* HomeView.swift in Sources */,
6E21E729F89178EBD019980E /* InlineCasing.swift in Sources */,
+ 275A9497C40065F5C77AE473 /* InstantReportLogger.swift in Sources */,
3244B8439B5E4F79FF84C156 /* JSONSlicer.swift in Sources */,
6F06CC539C4D17B343A9321C /* LegacyBlob.swift in Sources */,
+ BDEB83CDBA9E0B4DB7712491 /* LogPassiveReportIntent.swift in Sources */,
D1F2257DDB68439AF352B57D /* PassiveLog.swift in Sources */,
C5D94FEC4507054E6497E85B /* PersistenceController.swift in Sources */,
2EE68329C383FA1C5295ACA9 /* PlaceAnswerView.swift in Sources */,
@@ -631,6 +718,11 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
+ 38CE7310CE3FBD324756E4CC /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = EBCA92AAD12311B2E8534AAE /* ReportageWidgets */;
+ targetProxy = AEB39310B9AF5A95182CB9BC /* PBXContainerItemProxy */;
+ };
5E0FFA61CE9F785C1F7B062B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = CADA375B316EB71CDEE1FE5B /* Reportage */;
@@ -847,9 +939,50 @@
};
name = Debug;
};
+ C4575D5671CF17015520C6EF /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ INFOPLIST_FILE = ReportageWidgets/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = net.inqk.reportage.widgets;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = 1;
+ };
+ name = Release;
+ };
+ E0F6B15BE397B20E8A9F0039 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ INFOPLIST_FILE = ReportageWidgets/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = net.inqk.reportage.widgets;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = 1;
+ };
+ name = Debug;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
+ 091EB01CCA01F2C63DD0EA0F /* Build configuration list for PBXNativeTarget "ReportageWidgets" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ E0F6B15BE397B20E8A9F0039 /* Debug */,
+ C4575D5671CF17015520C6EF /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Debug;
+ };
0BDF6397081D7F97A8283020 /* Build configuration list for PBXNativeTarget "Reportage" */ = {
isa = XCConfigurationList;
buildConfigurations = (
diff --git a/Reportage/AppDelegate.swift b/Reportage/AppDelegate.swift
@@ -1,3 +1,4 @@
+import AppIntents
import BackgroundTasks
import SwiftUI
import UserNotifications
@@ -10,6 +11,14 @@ final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCent
private let log = EventLog.shared.category("Prompts")
+ /// Registers what App Intents need here, because the system can launch
+ /// the app in the background just to perform an intent.
+ override init() {
+ super.init()
+ let persistence = persistence
+ AppDependencyManager.shared.add(dependency: InstantReportLogger(persistence: persistence) as any InstantReportLogging)
+ }
+
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
diff --git a/Reportage/Services/InstantReportLogger.swift b/Reportage/Services/InstantReportLogger.swift
@@ -0,0 +1,42 @@
+import AppIntents
+
+/// Logs instant reports for `LogPassiveReportIntent`, which may run with the
+/// app launched in the background, as a notification's Instant Report does.
+struct InstantReportLogger: InstantReportLogging {
+ let persistence: PersistenceController
+
+ private static let log = EventLog.shared.category("Intents")
+
+ func logInstantReport() async throws {
+ let store = ReportStore(persistence: persistence)
+ Self.log.info("Filing an instant report from an intent")
+ try await PassiveLog(store: store, capture: { await ContextCapture.background.capture() })
+ .log(trigger: .intent)
+ await AppBadge.update(from: store)
+ await PromptScheduler().refresh()
+ }
+}
+
+/// Phrases for Siri and the Shortcuts app.
+struct ReportageShortcuts: AppShortcutsProvider {
+ static var appShortcuts: [AppShortcut] {
+ AppShortcut(
+ intent: LogPassiveReportIntent(),
+ phrases: [
+ "File a report in \(.applicationName)",
+ "Make a report in \(.applicationName)",
+ "Log a report in \(.applicationName)",
+ "Record a report in \(.applicationName)",
+ "File an update in \(.applicationName)",
+ "Make an update in \(.applicationName)",
+ "Log an update in \(.applicationName)",
+ "Record an update in \(.applicationName)",
+ "File an instant report in \(.applicationName)",
+ "Make an instant report in \(.applicationName)",
+ "Log an instant report in \(.applicationName)",
+ "Record an instant report in \(.applicationName)",
+ ],
+ shortTitle: "Instant Report",
+ systemImageName: "bolt.fill")
+ }
+}
diff --git a/Reportage/Services/Prompts/PromptNotification.swift b/Reportage/Services/Prompts/PromptNotification.swift
@@ -30,7 +30,7 @@ enum PromptNotification {
static var categories: Set<UNNotificationCategory> {
let log = UNNotificationAction(
identifier: instantReportAction,
- title: String(localized: "Instant Report", comment: "Notification action that logs an instant report"),
+ title: String(localized: "Instant Report", comment: "Notification action that files an instant report"),
icon: UNNotificationActionIcon(systemImageName: "bolt.fill"))
let snooze = UNNotificationAction(
identifier: snoozeAction,
diff --git a/Reportage/Services/Prompts/PromptSettings.swift b/Reportage/Services/Prompts/PromptSettings.swift
@@ -3,7 +3,7 @@ import Foundation
/// When random prompts come: how many a day, within which hours, and how far
/// apart.
///
-/// Kept in `UserDefaults` for now. Phase 4 moves it into the `Config` zone so
+/// Kept in `UserDefaults` for now. The Sync phase moves it into the `Config` zone so
/// it syncs; the per-install secret stays local.
struct PromptSettings: Codable, Equatable, Sendable {
/// Prompts are off until the user turns them on, which is when
diff --git a/Reportage/Views/Home/HomeView.swift b/Reportage/Views/Home/HomeView.swift
@@ -63,7 +63,7 @@ struct HomeView: View {
do {
try await PassiveLog(store: store).log(trigger: .app)
} catch {
- logger.error("Couldn't make a quick log: \(error)")
+ logger.error("Couldn't file an instant report: \(error)")
}
await AppBadge.update(from: store)
await PromptScheduler().refresh()
@@ -259,7 +259,7 @@ struct QuickLogButton: View {
}
.buttonStyle(.plain)
.accessibilityLabel(Text("Instant Report"))
- .accessibilityHint(Text("Logs this moment without a survey"))
+ .accessibilityHint(Text("Files this report without a survey"))
.sensoryFeedback(.success, trigger: taps)
}
}
@@ -418,7 +418,7 @@ struct ReportKindLabel: View {
let capHeight = capHeight
Group {
if isLogged {
- Text("Instant", comment: "Label for a report logged without answers, such as a quick log")
+ Text("Instant", comment: "Label for a report filed without answers, such as from the quick file button")
.eyebrow()
.italic()
} else {
diff --git a/Reportage/Views/RootView.swift b/Reportage/Views/RootView.swift
@@ -1,7 +1,7 @@
import SwiftUI
/// The app's tabs: the timeline and Settings. Visualisations join them in
-/// Phase 7.
+/// the Visualisations phase.
struct RootView: View {
@Environment(PromptInbox.self) private var inbox: PromptInbox?
@State private var tab = RootTab.timeline
diff --git a/Reportage/Views/Settings/DiagnosticsSection.swift b/Reportage/Views/Settings/DiagnosticsSection.swift
@@ -9,7 +9,7 @@ struct DiagnosticsSection: View {
.settingsRow()
SettingsNote {
Text(
- "A day of notes on what Reportage did in the background, such as logging an instant report. They say what happened, not what was recorded."
+ "A day of notes on what Reportage did in the background, such as filing an instant report. They say what happened, not what was recorded."
)
}
} header: {
diff --git a/ReportageWidgets/Info.plist b/ReportageWidgets/Info.plist
@@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>$(DEVELOPMENT_LANGUAGE)</string> + <key>CFBundleDisplayName</key> + <string>Reportage</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleIdentifier</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>$(PRODUCT_NAME)</string> + <key>CFBundlePackageType</key> + <string>XPC!</string> + <key>CFBundleShortVersionString</key> + <string>1.0.0</string> + <key>CFBundleVersion</key> + <string>$(CURRENT_PROJECT_VERSION)</string> + <key>NSExtension</key> + <dict> + <key>NSExtensionPointIdentifier</key> + <string>com.apple.widgetkit-extension</string> + </dict> +</dict> +</plist>
diff --git a/ReportageWidgets/ReportageWidgets.swift b/ReportageWidgets/ReportageWidgets.swift
@@ -0,0 +1,63 @@
+import AppIntents
+import SwiftUI
+import WidgetKit
+
+@main
+struct ReportageWidgets: WidgetBundle {
+ var body: some Widget {
+ InstantReportControl()
+ InstantReportWidget()
+ }
+}
+
+/// Logs an instant report from Control Center, the Lock Screen or the Action
+/// button. The intent runs in the app, so nothing here touches the store.
+struct InstantReportControl: ControlWidget {
+ var body: some ControlWidgetConfiguration {
+ StaticControlConfiguration(kind: "net.inqk.reportage.instant-report") {
+ ControlWidgetButton(action: LogPassiveReportIntent()) {
+ Label("Instant Report", systemImage: "bolt.fill")
+ }
+ }
+ .displayName("Instant Report")
+ .description("Files this report without a survey.")
+ }
+}
+
+/// A Lock Screen button that logs an instant report. It never changes, so
+/// its timeline has a single entry.
+struct InstantReportWidget: Widget {
+ var body: some WidgetConfiguration {
+ StaticConfiguration(kind: "net.inqk.reportage.instant-report-widget", provider: Provider()) { _ in
+ Button(intent: LogPassiveReportIntent()) {
+ ZStack {
+ AccessoryWidgetBackground()
+ Image(systemName: "bolt.fill")
+ .font(.title2.weight(.semibold))
+ }
+ }
+ .buttonStyle(.plain)
+ .accessibilityLabel(Text("Instant Report"))
+ .containerBackground(for: .widget) { Color.clear }
+ }
+ .configurationDisplayName("Instant Report")
+ .description("Files this report without a survey.")
+ .supportedFamilies([.accessoryCircular])
+ }
+
+ struct Provider: TimelineProvider {
+ func placeholder(in context: Context) -> Entry { Entry() }
+
+ func getSnapshot(in context: Context, completion: @escaping (Entry) -> Void) {
+ completion(Entry())
+ }
+
+ func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> Void) {
+ completion(Timeline(entries: [Entry()], policy: .never))
+ }
+ }
+
+ struct Entry: TimelineEntry {
+ var date = Date.distantPast
+ }
+}
diff --git a/Shared/Intents/LogPassiveReportIntent.swift b/Shared/Intents/LogPassiveReportIntent.swift
@@ -0,0 +1,29 @@
+import AppIntents
+
+/// Logs an instant report from Shortcuts, Siri, the Action button, the
+/// Control Center control and the Lock Screen widget.
+///
+/// Controls and widgets live in the widget extension, and by default an
+/// intent they trigger runs there. Conforming to `LiveActivityIntent` makes
+/// the system run it in the app's process instead, launched in the
+/// background if need be. Capturing the moment needs the app: location is
+/// live context, and the store lives in the app's container.
+struct LogPassiveReportIntent: AppIntent, LiveActivityIntent {
+ static let title: LocalizedStringResource = "Instant Report"
+ static let description = IntentDescription(
+ "Files this report without a survey. You can fill it in later, or leave it as it is.")
+ static let supportedModes: IntentModes = .background
+
+ @Dependency private var logger: any InstantReportLogging
+
+ func perform() async throws -> some IntentResult & ProvidesDialog {
+ try await logger.logInstantReport()
+ return .result(dialog: "Filed.")
+ }
+}
+
+/// What the intent needs from the app. The widget extension compiles the
+/// intent but never performs it, so it only needs to see this protocol.
+protocol InstantReportLogging: Sendable {
+ func logInstantReport() async throws
+}
diff --git a/project.yml b/project.yml
@@ -26,6 +26,8 @@ targets:
sources:
- Reportage
- Shared
+ dependencies:
+ - target: ReportageWidgets
info:
path: Reportage/Info.plist
properties:
@@ -57,6 +59,28 @@ targets:
Release:
OTHER_LDFLAGS: $(inherited) -Wl,-no_deduplicate
+ ReportageWidgets:
+ type: app-extension
+ platform: iOS
+ sources:
+ - ReportageWidgets
+ # Controls and widgets need the intent's type; it runs in the app.
+ - Shared/Intents/LogPassiveReportIntent.swift
+ info:
+ path: ReportageWidgets/Info.plist
+ properties:
+ CFBundleDisplayName: Reportage
+ CFBundleShortVersionString: "1.0.0"
+ CFBundleVersion: $(CURRENT_PROJECT_VERSION)
+ NSExtension:
+ NSExtensionPointIdentifier: com.apple.widgetkit-extension
+ settings:
+ base:
+ PRODUCT_BUNDLE_IDENTIFIER: net.inqk.reportage.widgets
+ INFOPLIST_FILE: ReportageWidgets/Info.plist
+ TARGETED_DEVICE_FAMILY: "1"
+ CODE_SIGN_STYLE: Automatic
+
Reportage Unit Tests:
type: bundle.unit-test
platform: iOS