Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add GitHub-only auto-update checker and build scripts

Nathan Poulson6f3ede73cfd1
diff --git a/build_bundle.sh b/build_bundle.sh
new file mode 100644
index 00000000..3b91d126
--- /dev/null
+++ b/build_bundle.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+flutter build appbundle --release "$@" && cd build/app/outputs/bundle/release
diff --git a/build_github.sh b/build_github.sh
new file mode 100644
index 00000000..e554b379
--- /dev/null
+++ b/build_github.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+flutter build apk --release --dart-define=GITHUB_BUILD=true "$@" && cd build/app/outputs/apk/release
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index 2e47c5da..e822ac63 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -19,6 +19,8 @@ import 'library_screen.dart';
import 'stats_screen.dart';
import 'settings_screen.dart';
import '../widgets/welcome_sheet.dart';
+import '../services/update_checker_service.dart';
+import 'package:url_launcher/url_launcher.dart';
class AppShell extends StatefulWidget {
const AppShell({super.key});
@@ -150,6 +152,38 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver, Ticker
_deriveCoverScheme();
context.read<LibraryProvider>().addListener(_onLibraryChanged);
WelcomeSheet.showIfNeeded(context);
+ _checkForUpdate();
+ }
+
+ static const _isGithubBuild = bool.fromEnvironment('GITHUB_BUILD');
+
+ void _checkForUpdate() async {
+ if (!_isGithubBuild) return;
+ final info = await UpdateCheckerService.check();
+ if (info == null || !mounted) return;
+ showDialog(
+ context: context,
+ builder: (ctx) => AlertDialog(
+ title: Text('Update available'),
+ content: Text('A new version of Absorb is available: ${info.latestVersion}\n\nYou are on ${info.currentVersion}.'),
+ actions: [
+ TextButton(
+ onPressed: () {
+ UpdateCheckerService.dismiss(info.latestVersion);
+ Navigator.pop(ctx);
+ },
+ child: const Text('Later'),
+ ),
+ FilledButton(
+ onPressed: () {
+ Navigator.pop(ctx);
+ launchUrl(Uri.parse(info.downloadUrl), mode: LaunchMode.externalApplication);
+ },
+ child: const Text('Download'),
+ ),
+ ],
+ ),
+ );
}
@override