diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 128e4aa..b5662f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,3 +28,15 @@ jobs: java-version: 21 - run: flutter build apk --debug --flavor sideload - run: flutter build apk --debug --flavor play + + ios: + # Proves the iOS project compiles (Swift, Xcode project, plugins). Unsigned: signing happens on the owner's Mac. + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 + with: + channel: stable + cache: true + - run: flutter pub get + - run: flutter build ios --debug --no-codesign diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2deb6..377cd62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- iPhone: Pagemark now runs on iOS (reading and backup reminders, Face ID, barcode scanning). The app-switcher preview is covered while the Locked tab is open. iPhone only for now (no iPad layout yet). + +### Changed +- iPhone: lock screens say Touch ID on phones that have it instead of Face ID; the home-screen widget page and the "Open security settings" button are hidden on iPhone, where they cannot work yet. + +### Fixed +- iPhone: after restoring a backup, Pagemark explains how to close and reopen it, because iOS apps cannot close themselves. + ## [1.1.1] - 2026-10-18 ### Fixed diff --git a/assets/guide.md b/assets/guide.md index de29cd2..6be0671 100644 --- a/assets/guide.md +++ b/assets/guide.md @@ -98,7 +98,7 @@ Go to Settings → Notifications. Your phone may ask if Pagemark can send notifi - **Remind me to back up** reminds you every week, 2 weeks or month to save a copy of your library. Choose **How often**. ## Home-screen widget -Go to Settings → Widget and shortcuts to choose whether the widget shows book titles. To add it, press and hold an empty spot on your home screen, tap **Widgets**, find **Pagemark** and tap **Add**. It shows the books you are reading and your yearly goal. It never shows your locked books. +The widget is on Android only for now. Go to Settings → Widget and shortcuts to choose whether the widget shows book titles. To add it, press and hold an empty spot on your home screen, tap **Widgets**, find **Pagemark** and tap **Add**. It shows the books you are reading and your yearly goal. It never shows your locked books. ## Quick ways in Press and hold the Pagemark icon on your home screen for two shortcuts: **Add book** and **Reading now** (only the books you are reading). diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 50afb5e..b9e4db8 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -108,6 +108,11 @@ Running-timer notification that shows on the lock screen; timer without logging --- +### Post-publish: GitHub cleanup (after the first App Store / Play release) +- One `main` branch for every platform and store; Android `sideload`/`play` are flavors, iOS is `flutter build ipa`. No long-lived per-store branches; releases are tags (`vX.Y.Z`, `vX.Y.Z-ios` if iOS needs its own build). +- Merge `ios-first-build` (with the release fixes) into `main`, then delete it and `Pagemark-APK`; merge or close `privacy-page`. +- Protect `main`: pull requests only, CI required (both Android flavors + an iOS `--no-codesign` build). Turn on "Automatically delete head branches". + ## 4. Working away from home ### Get a working checkout (any OS) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 036a370..42a67f0 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 8482BBE900D8D694966A2A06 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3508BB1B8274BA89810BB1D2 /* Pods_Runner.framework */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + A1B2C3D41F00000000000002 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = A1B2C3D41F00000000000001 /* PrivacyInfo.xcprivacy */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; C05E3ED2EA0D87006E4BE082 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 281E730E93B50230414F50BD /* Pods_RunnerTests.framework */; }; /* End PBXBuildFile section */ @@ -67,6 +68,7 @@ 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + A1B2C3D41F00000000000001 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9989FA84709C9A8E176CB61E /* Pods-Runner.debug-sideload.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug-sideload.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug-sideload.xcconfig"; sourceTree = ""; }; A815C38AF803120FE072AA59 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; @@ -175,6 +177,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 97C147021CF9000F007C117D /* Info.plist */, + A1B2C3D41F00000000000001 /* PrivacyInfo.xcprivacy */, 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, @@ -289,6 +292,7 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + A1B2C3D41F00000000000002 /* PrivacyInfo.xcprivacy in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -529,7 +533,7 @@ SDKROOT = iphoneos; STRING_CATALOG_GENERATE_SYMBOLS = YES; SUPPORTED_PLATFORMS = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; VALIDATE_PRODUCT = YES; }; name = Profile; @@ -653,7 +657,7 @@ SDKROOT = iphoneos; STRING_CATALOG_GENERATE_SYMBOLS = YES; SUPPORTED_PLATFORMS = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; VALIDATE_PRODUCT = YES; }; name = "Profile-sideload"; @@ -728,7 +732,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; STRING_CATALOG_GENERATE_SYMBOLS = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Debug; }; @@ -782,7 +786,7 @@ SUPPORTED_PLATFORMS = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; VALIDATE_PRODUCT = YES; }; name = Release; @@ -919,7 +923,7 @@ SUPPORTED_PLATFORMS = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; VALIDATE_PRODUCT = YES; }; name = "Release-sideload"; @@ -994,7 +998,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; STRING_CATALOG_GENERATE_SYMBOLS = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = "Debug-sideload"; }; diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 1b13a56..399ffb4 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -3,16 +3,47 @@ import UIKit @main @objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate { + /// Set from Dart (`Secure.set`) while the locked library is on screen. + private var secure = false + private let coverTag = 0x5061_6765 // "Page" + override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { // lets flutter_local_notifications show reminders while Pagemark is open UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate + // iOS has no FLAG_SECURE: cover the window before the app-switcher snapshot is taken + NotificationCenter.default.addObserver(self, selector: #selector(sceneWillDeactivate(_:)), name: UIScene.willDeactivateNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(sceneDidActivate(_:)), name: UIScene.didActivateNotification, object: nil) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + guard let registrar = engineBridge.pluginRegistry.registrar(forPlugin: "PagemarkSecure") else { return } + let channel = FlutterMethodChannel(name: "pagemark/secure", binaryMessenger: registrar.messenger()) + channel.setMethodCallHandler { [weak self] call, result in + guard call.method == "setSecure", let on = call.arguments as? Bool else { + result(FlutterMethodNotImplemented) + return + } + self?.secure = on + result(nil) + } + } + + @objc private func sceneWillDeactivate(_ note: Notification) { + guard secure, let window = (note.object as? UIWindowScene)?.windows.first(where: { $0.isKeyWindow }) ?? (note.object as? UIWindowScene)?.windows.first, + window.viewWithTag(coverTag) == nil else { return } + let cover = UIView(frame: window.bounds) + cover.tag = coverTag + cover.backgroundColor = .systemBackground + cover.autoresizingMask = [.flexibleWidth, .flexibleHeight] + window.addSubview(cover) + } + + @objc private func sceneDidActivate(_ note: Notification) { + (note.object as? UIWindowScene)?.windows.forEach { $0.viewWithTag(coverTag)?.removeFromSuperview() } } } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 845ac56..85325d4 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -24,6 +24,8 @@ ???? CFBundleVersion $(FLUTTER_BUILD_NUMBER) + ITSAppUsesNonExemptEncryption + LSRequiresIPhoneOS NSCameraUsageDescription @@ -65,12 +67,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - diff --git a/ios/Runner/PrivacyInfo.xcprivacy b/ios/Runner/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..215a9bb --- /dev/null +++ b/ios/Runner/PrivacyInfo.xcprivacy @@ -0,0 +1,31 @@ + + + + + NSPrivacyTracking + + NSPrivacyTrackingDomains + + NSPrivacyCollectedDataTypes + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + + diff --git a/lib/lock.dart b/lib/lock.dart index c5dc983..815ecb0 100644 --- a/lib/lock.dart +++ b/lib/lock.dart @@ -200,6 +200,17 @@ class LockService { } } + /// iOS only: true when the device unlocks with Touch ID rather than Face ID, so screens name the right one. + static Future hasTouchId() async { + if (defaultTargetPlatform != TargetPlatform.iOS) return false; + try { + final types = await _auth.getAvailableBiometrics(); + return types.contains(BiometricType.fingerprint) && !types.contains(BiometricType.face); + } catch (_) { + return false; + } + } + /// Does the phone offer a *strong* biometric (fingerprint)? Face unlock on many Android phones is only "weak". /// iOS never reports strong/weak: Face ID and Touch ID are both strong, and come back as face or fingerprint. static Future strongBiometricAvailable() async { diff --git a/lib/lock_ui.dart b/lib/lock_ui.dart index 436b641..a189430 100644 --- a/lib/lock_ui.dart +++ b/lib/lock_ui.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart' show defaultTargetPlatform; import 'package:flutter/services.dart'; import 'lock.dart'; import 'widgets.dart'; @@ -291,7 +292,8 @@ class _LockGateState extends State { textAlign: TextAlign.center, ), const SizedBox(height: 12), - FilledButton(onPressed: openSecuritySettings, child: const Text('Open security settings')), + // iOS has no way to open its passcode settings from an app + if (defaultTargetPlatform == TargetPlatform.android) FilledButton(onPressed: openSecuritySettings, child: const Text('Open security settings')), TextButton(onPressed: _load, child: const Text('Try again')), ] else FilledButton.icon(onPressed: _device, icon: Icon(biometricIcon), label: const Text('Unlock')), diff --git a/lib/main.dart b/lib/main.dart index efba87f..f8ad1d7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,12 +5,14 @@ import 'app_lock.dart'; import 'backup_reminder.dart'; import 'covers.dart'; import 'export.dart'; +import 'lock.dart'; import 'log.dart'; import 'notifier.dart'; import 'privacy.dart'; import 'db.dart'; import 'themes.dart'; import 'ui.dart'; +import 'widgets.dart'; final db = AppDb(); late SharedPreferences prefs; @@ -33,6 +35,7 @@ Future main() async { hideLockedTab.value = prefs.getBool('hide_locked') ?? false; hideLockedTab.addListener(() => prefs.setBool('hide_locked', hideLockedTab.value)); initAppLockSettings(); + iosTouchId = await LockService.hasTouchId(); for (final k in prefs.getKeys().where((k) => k.startsWith('bk_')).toList()) { await prefs.remove(k); // leftovers of the Google Drive backup, removed in 0.8.2 } diff --git a/lib/restore_ui.dart b/lib/restore_ui.dart index e4a4ea6..d3bb52f 100644 --- a/lib/restore_ui.dart +++ b/lib/restore_ui.dart @@ -1,5 +1,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart' show TargetPlatform, defaultTargetPlatform; import 'package:flutter/services.dart' show SystemNavigator; import 'package:intl/intl.dart'; import 'package:path_provider/path_provider.dart'; @@ -55,10 +56,15 @@ Future restoreFlow(BuildContext context, File picked) async { barrierDismissible: false, builder: (c) => AlertDialog( title: const Text('Restored'), - content: Text('Pagemark will now close. Open it again to see your restored library.' + content: Text(defaultTargetPlatform == TargetPlatform.iOS + ? 'Swipe up from the bottom of the screen and pause, swipe Pagemark away, then open it again to see your restored library.' + : 'Pagemark will now close. Open it again to see your restored library.' '${check.lockedBooks > 0 ? '\n\nYour ${check.lockedBooks} locked book${check.lockedBooks == 1 ? '' : 's'} came back too, but your PIN is not part of backups. ' 'Open the Locked tab and set a new PIN to reach ${check.lockedBooks == 1 ? 'it' : 'them'}.' : ''}'), - actions: [FilledButton(onPressed: () => SystemNavigator.pop(), child: const Text('Close Pagemark'))], // a graceful exit, not exit(0) + // iOS ignores SystemNavigator.pop and forbids quitting in code, so the user closes it from the app switcher + actions: [ + if (defaultTargetPlatform != TargetPlatform.iOS) FilledButton(onPressed: () => SystemNavigator.pop(), child: const Text('Close Pagemark')), // a graceful exit, not exit(0) + ], ), ); } diff --git a/lib/ui/settings.dart b/lib/ui/settings.dart index b9cf316..a4ae88c 100644 --- a/lib/ui/settings.dart +++ b/lib/ui/settings.dart @@ -31,7 +31,8 @@ class SettingsPage extends StatelessWidget { const Divider(), _row(context, Icons.palette_outlined, SettingsTitles.appearance, 'Choose your colours', () => const _AppearancePage()), _row(context, Icons.notifications_active_outlined, SettingsTitles.notifications, 'Reading and backup reminders', () => const _NotificationsPage()), - _row(context, Icons.widgets_outlined, SettingsTitles.widget, 'Home-screen widget and icon shortcuts', () => const _WidgetPage()), + // the home-screen widget is Android-only for now (iOS needs a WidgetKit extension) + if (defaultTargetPlatform == TargetPlatform.android) _row(context, Icons.widgets_outlined, SettingsTitles.widget, 'Home-screen widget and icon shortcuts', () => const _WidgetPage()), _row(context, Icons.lock_outline, SettingsTitles.privacy, 'PIN, $biometricName and your private library', () => _PrivacyPage(onLockNow: onLockNow)), _row(context, Icons.cloud_upload_outlined, SettingsTitles.backup, 'Keep your library safe, or bring it back', () => const BackupSettingsPage()), _row(context, Icons.swap_horiz, SettingsTitles.importExport, 'Bring books in from another app, or take your list out', () => const _ImportExportPage()), diff --git a/lib/widgets.dart b/lib/widgets.dart index b559f65..036ce70 100644 --- a/lib/widgets.dart +++ b/lib/widgets.dart @@ -48,9 +48,11 @@ class _ExpandableTextState extends State { /// Words that differ between phones, so screens name what the user actually has. bool get _ios => defaultTargetPlatform == TargetPlatform.iOS; -String get biometricName => _ios ? 'Face ID' : 'fingerprint'; -String get biometricNameCap => _ios ? 'Face ID' : 'Fingerprint'; -IconData get biometricIcon => _ios ? Icons.face : Icons.fingerprint; +/// True on an iPhone/iPad with Touch ID instead of Face ID (iPhone SE); set once at start by `LockService.hasTouchId`. +bool iosTouchId = false; +String get biometricName => _ios ? (iosTouchId ? 'Touch ID' : 'Face ID') : 'fingerprint'; +String get biometricNameCap => _ios ? (iosTouchId ? 'Touch ID' : 'Face ID') : 'Fingerprint'; +IconData get biometricIcon => _ios && !iosTouchId ? Icons.face : Icons.fingerprint; String get phoneSettingsName => _ios ? 'iPhone Settings' : 'Android Settings'; String get cloudDriveName => _ios ? 'iCloud Drive' : 'Google Drive'; diff --git a/test/ios_test.dart b/test/ios_test.dart new file mode 100644 index 0000000..93b9a62 --- /dev/null +++ b/test/ios_test.dart @@ -0,0 +1,38 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pagemark/lock.dart'; +import 'package:pagemark/widgets.dart'; + +void main() { + tearDown(() { + debugDefaultTargetPlatformOverride = null; + iosTouchId = false; + }); + + test('Android keeps its words', () { + debugDefaultTargetPlatformOverride = TargetPlatform.android; + expect(biometricName, 'fingerprint'); + expect(biometricNameCap, 'Fingerprint'); + expect(phoneSettingsName, 'Android Settings'); + expect(cloudDriveName, 'Google Drive'); + }); + + test('iPhone with Face ID', () { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + expect(biometricName, 'Face ID'); + expect(phoneSettingsName, 'iPhone Settings'); + expect(cloudDriveName, 'iCloud Drive'); + }); + + test('iPhone with Touch ID never says Face ID', () { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + iosTouchId = true; + expect(biometricName, 'Touch ID'); + expect(biometricNameCap, 'Touch ID'); + }); + + test('Touch ID detection is iOS-only', () async { + debugDefaultTargetPlatformOverride = TargetPlatform.android; + expect(await LockService.hasTouchId(), isFalse); + }); +}