Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add F-Droid build without Google services

Barnabas5e4a4783ef14
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 7833ef87..8d1150af 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -53,6 +53,19 @@ android {
create("playstore") {
dimension = "distribution"
}
+ // GMS-free build for F-Droid: no Chromecast, Wear bridge, or in-app updater.
+ create("fdroid") {
+ dimension = "distribution"
+ }
+ }
+
+ // GMS-touching Kotlin (cast + wear) is shared by github + playstore only.
+ // fdroid gets src/fdroid/kotlin instead, which has no Google Play Services.
+ // Uses java.srcDir (kotlin-android compiles it too) for broad Gradle/Kotlin
+ // plugin compatibility.
+ sourceSets {
+ getByName("github").java.srcDir("src/gms/kotlin")
+ getByName("playstore").java.srcDir("src/gms/kotlin")
}
buildTypes {
@@ -84,11 +97,18 @@ flutter {
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
- implementation("com.google.android.gms:play-services-cast-framework:21.5.0")
- // Wearable Data Layer — pushes ABS session credentials to the
- // paired Wear OS app so the watch can sign in without the user
- // typing anything on the watch keyboard.
- implementation("com.google.android.gms:play-services-wearable:19.0.0")
- implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.9.0")
+ // Google Play Services — Chromecast + Wearable Data Layer (pushes ABS
+ // session credentials to the paired Wear OS app so the watch can sign in
+ // without typing on the watch keyboard). Scoped to github + playstore so
+ // the fdroid flavor links no GMS.
+ val gmsImpl = listOf(
+ "com.google.android.gms:play-services-cast-framework:21.5.0",
+ "com.google.android.gms:play-services-wearable:19.0.0",
+ "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.9.0",
+ )
+ gmsImpl.forEach {
+ add("githubImplementation", it)
+ add("playstoreImplementation", it)
+ }
}
\ No newline at end of file
diff --git a/android/app/src/fdroid/AndroidManifest.xml b/android/app/src/fdroid/AndroidManifest.xml
new file mode 100644
index 00000000..73f9d17f
--- /dev/null
+++ b/android/app/src/fdroid/AndroidManifest.xml
@@ -0,0 +1,27 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools">
+
+ <!-- F-Droid (GMS-free) overlay. MANAGE_EXTERNAL_STORAGE is kept on purpose
+ so custom download locations still work. Everything below is removed
+ because it depends on Google Play Services or is superseded by
+ F-Droid's own update mechanism. -->
+
+ <!-- In-app APK updater: F-Droid updates apps itself -->
+ <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove"/>
+
+ <application>
+ <!-- Chromecast (GMS) -->
+ <meta-data
+ android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
+ tools:node="remove"/>
+ <service android:name=".CastForegroundService" tools:node="remove"/>
+
+ <!-- Android Auto (GMS) -->
+ <meta-data android:name="com.google.android.gms.car.application" tools:node="remove"/>
+ <meta-data android:name="com.google.android.gms.car.notification.SmallIcon" tools:node="remove"/>
+
+ <!-- Wear OS Data Layer (GMS) -->
+ <service android:name=".WearAuthListenerService" tools:node="remove"/>
+ <service android:name=".WearPlayerCommandListenerService" tools:node="remove"/>
+ </application>
+</manifest>
diff --git a/android/app/src/fdroid/kotlin/com/barnabas/absorb/PlatformIntegration.kt b/android/app/src/fdroid/kotlin/com/barnabas/absorb/PlatformIntegration.kt
new file mode 100644
index 00000000..98dd6e17
--- /dev/null
+++ b/android/app/src/fdroid/kotlin/com/barnabas/absorb/PlatformIntegration.kt
@@ -0,0 +1,19 @@
+package com.barnabas.absorb
+
+import android.app.Activity
+import io.flutter.embedding.engine.FlutterEngine
+
+/**
+ * F-Droid (GMS-free) build: the Chromecast and Wear OS Data Layer channels are
+ * absent because they depend on Google Play Services. This no-op twin keeps
+ * MainActivity flavor-agnostic.
+ *
+ * The Dart side never invokes these channels in the fdroid flavor (the cast UI
+ * is stubbed out), and if it did, the resulting MissingPluginException is
+ * already caught by the existing try/catch in the Dart services.
+ */
+object PlatformIntegration {
+ fun registerChannels(activity: Activity, flutterEngine: FlutterEngine) {
+ // no-op: cast + wear bridges require Google Play Services
+ }
+}
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/AbsorbCastOptionsProvider.kt b/android/app/src/gms/kotlin/com/barnabas/absorb/AbsorbCastOptionsProvider.kt
similarity index 100%
rename from android/app/src/main/kotlin/com/barnabas/absorb/AbsorbCastOptionsProvider.kt
rename to android/app/src/gms/kotlin/com/barnabas/absorb/AbsorbCastOptionsProvider.kt
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/CastForegroundService.kt b/android/app/src/gms/kotlin/com/barnabas/absorb/CastForegroundService.kt
similarity index 100%
rename from android/app/src/main/kotlin/com/barnabas/absorb/CastForegroundService.kt
rename to android/app/src/gms/kotlin/com/barnabas/absorb/CastForegroundService.kt
diff --git a/android/app/src/gms/kotlin/com/barnabas/absorb/PlatformIntegration.kt b/android/app/src/gms/kotlin/com/barnabas/absorb/PlatformIntegration.kt
new file mode 100644
index 00000000..b1f5dbb8
--- /dev/null
+++ b/android/app/src/gms/kotlin/com/barnabas/absorb/PlatformIntegration.kt
@@ -0,0 +1,97 @@
+package com.barnabas.absorb
+
+import android.app.Activity
+import io.flutter.embedding.engine.FlutterEngine
+import io.flutter.plugin.common.MethodChannel
+
+/**
+ * GMS-backed platform channels (Chromecast foreground service + Wear OS Data
+ * Layer bridges). Compiled into the `github` and `playstore` flavors via the
+ * shared `src/gms` source set. The `fdroid` flavor ships a no-op twin of this
+ * object so the app builds without Google Play Services.
+ *
+ * The non-GMS channels (EQ, storage) stay registered in MainActivity.
+ */
+object PlatformIntegration {
+ fun registerChannels(activity: Activity, flutterEngine: FlutterEngine) {
+ val messenger = flutterEngine.dartExecutor.binaryMessenger
+
+ MethodChannel(messenger, "com.absorb.cast_service")
+ .setMethodCallHandler { call, result ->
+ when (call.method) {
+ "start" -> {
+ CastForegroundService.start(activity)
+ result.success(true)
+ }
+ "stop" -> {
+ CastForegroundService.stop(activity)
+ result.success(true)
+ }
+ else -> result.notImplemented()
+ }
+ }
+
+ // Bridge ABS playback state to the watch so it can render Now
+ // Playing without making its own API calls.
+ MethodChannel(messenger, "com.barnabas.absorb/wear_player")
+ .setMethodCallHandler { call, result ->
+ when (call.method) {
+ "publish" -> {
+ WearPlayerBridge.publish(
+ context = activity.applicationContext,
+ hasBook = call.argument<Boolean>("hasBook") ?: false,
+ itemId = call.argument<String>("itemId"),
+ title = call.argument<String>("title"),
+ author = call.argument<String>("author"),
+ chapter = call.argument<String>("chapter"),
+ isPlaying = call.argument<Boolean>("isPlaying") ?: false,
+ positionMs = (call.argument<Number>("positionMs") ?: 0).toLong(),
+ durationMs = (call.argument<Number>("durationMs") ?: 0).toLong(),
+ speed = (call.argument<Number>("speed") ?: 1.0).toFloat(),
+ skipBackSec = (call.argument<Number>("skipBackSec") ?: 10).toInt(),
+ skipForwardSec = (call.argument<Number>("skipForwardSec") ?: 30).toInt(),
+ )
+ result.success(true)
+ }
+ else -> result.notImplemented()
+ }
+ }
+
+ // Bridge ABS auth state to the paired Wear OS app (AbsorbWear)
+ // over the Google Play Services Wearable Data Layer.
+ MethodChannel(messenger, "com.barnabas.absorb/wear_auth")
+ .setMethodCallHandler { call, result ->
+ when (call.method) {
+ "publish" -> {
+ val serverUrl = call.argument<String>("serverUrl")
+ val accessToken = call.argument<String>("accessToken")
+ val username = call.argument<String>("username") ?: ""
+ if (serverUrl == null || accessToken == null) {
+ result.error("MISSING_ARGS", "serverUrl and accessToken are required", null)
+ return@setMethodCallHandler
+ }
+ @Suppress("UNCHECKED_CAST")
+ val headers = (call.argument<Map<String, Any?>>("customHeaders") ?: emptyMap())
+ .mapNotNull { (k, v) -> if (v is String) k to v else null }
+ .toMap()
+ WearAuthBridge.publish(
+ context = activity.applicationContext,
+ serverUrl = serverUrl,
+ accessToken = accessToken,
+ refreshToken = call.argument<String>("refreshToken"),
+ username = username,
+ userId = call.argument<String>("userId"),
+ isLegacyToken = call.argument<Boolean>("isLegacyToken") ?: false,
+ customHeaders = headers,
+ )
+ result.success(true)
+ }
+ "clear" -> {
+ WearAuthBridge.clear(activity.applicationContext)
+ result.success(true)
+ }
+ else -> result.notImplemented()
+ }
+ }
+ }
+}
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/WearAuthBridge.kt b/android/app/src/gms/kotlin/com/barnabas/absorb/WearAuthBridge.kt
similarity index 100%
rename from android/app/src/main/kotlin/com/barnabas/absorb/WearAuthBridge.kt
rename to android/app/src/gms/kotlin/com/barnabas/absorb/WearAuthBridge.kt
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/WearAuthListenerService.kt b/android/app/src/gms/kotlin/com/barnabas/absorb/WearAuthListenerService.kt
similarity index 100%
rename from android/app/src/main/kotlin/com/barnabas/absorb/WearAuthListenerService.kt
rename to android/app/src/gms/kotlin/com/barnabas/absorb/WearAuthListenerService.kt
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/WearPlayerBridge.kt b/android/app/src/gms/kotlin/com/barnabas/absorb/WearPlayerBridge.kt
similarity index 100%
rename from android/app/src/main/kotlin/com/barnabas/absorb/WearPlayerBridge.kt
rename to android/app/src/gms/kotlin/com/barnabas/absorb/WearPlayerBridge.kt
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/WearPlayerCommandListenerService.kt b/android/app/src/gms/kotlin/com/barnabas/absorb/WearPlayerCommandListenerService.kt
similarity index 100%
rename from android/app/src/main/kotlin/com/barnabas/absorb/WearPlayerCommandListenerService.kt
rename to android/app/src/gms/kotlin/com/barnabas/absorb/WearPlayerCommandListenerService.kt
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt b/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt
index ba04e3f7..2d9427c1 100644
--- a/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt
+++ b/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt
@@ -104,83 +104,9 @@ class MainActivity : AudioServiceActivity() {
}
}
- MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.absorb.cast_service")
- .setMethodCallHandler { call, result ->
- when (call.method) {
- "start" -> {
- CastForegroundService.start(this)
- result.success(true)
- }
- "stop" -> {
- CastForegroundService.stop(this)
- result.success(true)
- }
- else -> result.notImplemented()
- }
- }
-
- // Bridge ABS playback state to the watch so it can render Now
- // Playing without making its own API calls.
- MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.barnabas.absorb/wear_player")
- .setMethodCallHandler { call, result ->
- when (call.method) {
- "publish" -> {
- WearPlayerBridge.publish(
- context = applicationContext,
- hasBook = call.argument<Boolean>("hasBook") ?: false,
- itemId = call.argument<String>("itemId"),
- title = call.argument<String>("title"),
- author = call.argument<String>("author"),
- chapter = call.argument<String>("chapter"),
- isPlaying = call.argument<Boolean>("isPlaying") ?: false,
- positionMs = (call.argument<Number>("positionMs") ?: 0).toLong(),
- durationMs = (call.argument<Number>("durationMs") ?: 0).toLong(),
- speed = (call.argument<Number>("speed") ?: 1.0).toFloat(),
- skipBackSec = (call.argument<Number>("skipBackSec") ?: 10).toInt(),
- skipForwardSec = (call.argument<Number>("skipForwardSec") ?: 30).toInt(),
- )
- result.success(true)
- }
- else -> result.notImplemented()
- }
- }
-
- // Bridge ABS auth state to the paired Wear OS app (AbsorbWear)
- // over the Google Play Services Wearable Data Layer.
- MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.barnabas.absorb/wear_auth")
- .setMethodCallHandler { call, result ->
- when (call.method) {
- "publish" -> {
- val serverUrl = call.argument<String>("serverUrl")
- val accessToken = call.argument<String>("accessToken")
- val username = call.argument<String>("username") ?: ""
- if (serverUrl == null || accessToken == null) {
- result.error("MISSING_ARGS", "serverUrl and accessToken are required", null)
- return@setMethodCallHandler
- }
- @Suppress("UNCHECKED_CAST")
- val headers = (call.argument<Map<String, Any?>>("customHeaders") ?: emptyMap())
- .mapNotNull { (k, v) -> if (v is String) k to v else null }
- .toMap()
- WearAuthBridge.publish(
- context = applicationContext,
- serverUrl = serverUrl,
- accessToken = accessToken,
- refreshToken = call.argument<String>("refreshToken"),
- username = username,
- userId = call.argument<String>("userId"),
- isLegacyToken = call.argument<Boolean>("isLegacyToken") ?: false,
- customHeaders = headers,
- )
- result.success(true)
- }
- "clear" -> {
- WearAuthBridge.clear(applicationContext)
- result.success(true)
- }
- else -> result.notImplemented()
- }
- }
+ // GMS-backed channels (cast foreground service, wear bridges).
+ // Resolves to the real impl in github/playstore, no-op in fdroid.
+ PlatformIntegration.registerChannels(this, flutterEngine)
}
private fun handleInit(result: MethodChannel.Result) {
diff --git a/fdroid/com.barnabas.absorb.yml b/fdroid/com.barnabas.absorb.yml
new file mode 100644
index 00000000..0e74ccd0
--- /dev/null
+++ b/fdroid/com.barnabas.absorb.yml
@@ -0,0 +1,61 @@
+# DRAFT F-Droid metadata for the official fdroiddata repo.
+# Copy to fdroiddata/metadata/com.barnabas.absorb.yml when opening the merge request.
+#
+# The load-bearing custom bits (verified against this repo) are the `fdroid`
+# flavor selection and the prebuild steps that strip the Chromecast plugin so
+# the APK links no Google Play Services. The Flutter SDK plumbing (srclibs /
+# buildserver image) should be matched to fdroiddata's CURRENT convention for
+# Flutter apps — copy the `srclibs`/`sudo` lines from a recently-merged Flutter
+# app in fdroiddata rather than trusting a pinned version here.
+
+Categories:
+ - Multimedia
+License: GPL-3.0-or-later
+AuthorName: Nathan Poulson
+SourceCode: https://github.com/pounat/absorb
+IssueTracker: https://github.com/pounat/absorb/issues
+
+AutoName: Absorb
+Description: |-
+ An open-source client for Audiobookshelf servers. Stream and download your
+ audiobooks and podcasts, with chapter navigation, sleep timer, equalizer,
+ Android Auto, and home-screen widgets.
+
+ Note: the F-Droid build omits Chromecast and the Wear OS companion login
+ bridge, which both require proprietary Google Play Services.
+
+RepoType: git
+Repo: https://github.com/pounat/absorb.git
+
+Builds:
+ - versionName: 1.8.91
+ versionCode: 159
+ commit: v1.8.91 # tag the release commit; update per submission
+ subdir: android/app
+ # --- Flutter SDK: match fdroiddata's current Flutter convention ---
+ # e.g. srclibs: [flutter@<tag>] plus the flutter precommand in `prebuild`,
+ # or the buildserver's bundled flutter. Left intentionally unset here.
+ gradle:
+ - fdroid
+ rm:
+ - lib/services/chromecast_service.dart
+ - lib/widgets/chromecast_button.dart
+ prebuild:
+ # Swap the GMS-free stubs into the real filenames.
+ - mv lib/services/chromecast_service_stub.dart lib/services/chromecast_service.dart
+ - mv lib/widgets/chromecast_button_stub.dart lib/widgets/chromecast_button.dart
+ # Drop the Chromecast plugin so its play-services-cast AAR is never pulled.
+ # Keep pubspec.lock: pub get drops just flutter_chrome_cast (and its
+ # orphaned cast deps) while every other version stays pinned. Deleting
+ # the lock forces a full re-resolve that drifts e.g. flutter_carplay to
+ # an API-incompatible version and breaks the build.
+ - sed -i '/flutter_chrome_cast:/d' pubspec.yaml
+ - flutter pub get
+ output: build/app/outputs/flutter-apk/app-fdroid-release.apk
+
+# F-Droid signs with its own key (no reproducible-build setup yet), so F-Droid
+# installs are independent of the GitHub-flavor APK signature.
+AutoUpdateMode: Version
+UpdateCheckMode: Tags
+CurrentVersion: 1.8.91
+CurrentVersionCode: 159
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 9396a670..66294823 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -47,6 +47,10 @@ class SettingsScreen extends StatefulWidget {
class _SettingsScreenState extends State<SettingsScreen> {
static const _isPlayStoreBuild = bool.fromEnvironment('PLAYSTORE_BUILD');
static const _isGithubBuild = bool.fromEnvironment('GITHUB_BUILD');
+ // Distribution label shown next to the version. The F-Droid build passes
+ // neither define, so it falls through here.
+ static String get _flavorLabel =>
+ _isGithubBuild ? 'GitHub' : _isPlayStoreBuild ? 'Play Store' : 'F-Droid';
AutoRewindSettings _rewindSettings = const AutoRewindSettings();
double _defaultSpeed = 1.0;
@@ -2455,7 +2459,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
mainAxisSize: MainAxisSize.min,
children: [
Text(
- l.appVersionFormat(_appVersion),
+ // Flavor prefix is an Android distribution concept
+ // (GitHub / Play Store / F-Droid). iOS has no flavor, so
+ // it keeps the plain version.
+ Platform.isIOS
+ ? l.appVersionFormat(_appVersion)
+ : '$_flavorLabel - $_appVersion',
style: tt.bodySmall?.copyWith(
color: cs.onSurfaceVariant.withValues(alpha: 0.4)),
),
diff --git a/lib/services/chromecast_service.dart b/lib/services/chromecast_service.dart
index 797f093d..4b602794 100644
--- a/lib/services/chromecast_service.dart
+++ b/lib/services/chromecast_service.dart
@@ -16,6 +16,10 @@ class ChromecastService extends ChangeNotifier {
factory ChromecastService() => _instance;
ChromecastService._();
+ /// Whether Chromecast is available in this build. True here; the GMS-free
+ /// F-Droid stub sets it false so the UI hides all cast entry points.
+ static const bool castSupported = true;
+
CastConnectionState _connectionState = CastConnectionState.disconnected;
CastPlaybackState _playbackState = CastPlaybackState.idle;
diff --git a/lib/services/chromecast_service_stub.dart b/lib/services/chromecast_service_stub.dart
new file mode 100644
index 00000000..67587706
--- /dev/null
+++ b/lib/services/chromecast_service_stub.dart
@@ -0,0 +1,88 @@
+import 'dart:async';
+import 'package:flutter/foundation.dart';
+
+import 'api_service.dart';
+
+// GMS-free stub of ChromecastService for the F-Droid flavor. Chromecast needs
+// Google Play Services, which F-Droid disallows, so this no-op twin replaces
+// the real service (and `flutter_chrome_cast` is stripped from pubspec) at
+// build time via the fdroiddata recipe. The public surface mirrors the real
+// service so every caller compiles unchanged; everything reports
+// "not connected" so the cast UI stays dormant.
+//
+// The two plugin-typed members of the real service (`devicesStream`,
+// `connectToDevice`) are intentionally absent — they're only referenced by the
+// real chromecast_button.dart, which is swapped for its stub alongside this.
+
+enum CastConnectionState { disconnected, connecting, connected }
+enum CastPlaybackState { idle, loading, playing, paused, buffering }
+
+class ChromecastService extends ChangeNotifier {
+ static final ChromecastService _instance = ChromecastService._();
+ factory ChromecastService() => _instance;
+ ChromecastService._();
+
+ /// GMS-free build: Chromecast is unavailable, so the UI hides every cast
+ /// entry point (the cast button is filtered out of the card action menu).
+ static const bool castSupported = false;
+
+ CastConnectionState get connectionState => CastConnectionState.disconnected;
+ CastPlaybackState get playbackState => CastPlaybackState.idle;
+ bool get isConnected => false;
+ bool get isCasting => false;
+ bool get isPlaying => false;
+
+ String? get castingItemId => null;
+ String? get castingEpisodeId => null;
+ String? get castingTitle => null;
+ String? get castingAuthor => null;
+ String? get castingCoverUrl => null;
+ double get castingDuration => 0;
+ List<dynamic> get castingChapters => const [];
+ Duration get castPosition => Duration.zero;
+ String? get connectedDeviceName => null;
+
+ Stream<Duration>? get castPositionStream => null;
+
+ String? get currentChapterTitle => null;
+ Map<String, dynamic>? get currentChapter => null;
+
+ double get volume => 1.0;
+ double get castSpeed => 1.0;
+
+ static void setOnBookFinishedCallback(void Function(String itemId)? cb) {}
+ static void setOnPlaybackStateChangedCallback(void Function(bool isPlaying)? cb) {}
+
+ Future<void> init() async {}
+
+ Future<void> disconnect() async {}
+
+ Future<bool> castItem({
+ required ApiService api,
+ required String itemId,
+ required String title,
+ required String author,
+ required String? coverUrl,
+ required double totalDuration,
+ required List<dynamic> chapters,
+ double startTime = 0,
+ String? episodeId,
+ }) async => false;
+
+ Future<void> setVolume(double value) async {}
+
+ Future<void> play() async {}
+ Future<void> pause() async {}
+ Future<void> togglePlayPause() async {}
+
+ Future<void> seekTo(Duration position) async {}
+ Future<void> skipForward([int s = 30]) async {}
+ Future<void> skipBackward([int s = 10]) async {}
+
+ Future<void> setSpeed(double speed) async {}
+
+ Future<void> stopCasting() async {}
+
+ Future<void> skipToNextChapter() async {}
+ Future<void> skipToPreviousChapter() async {}
+}
diff --git a/lib/widgets/card_button_config.dart b/lib/widgets/card_button_config.dart
index 5b7dcaf7..b5395bfd 100644
--- a/lib/widgets/card_button_config.dart
+++ b/lib/widgets/card_button_config.dart
@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
+import '../services/chromecast_service.dart';
import '../services/wording.dart';
class CardButtonDef {
@@ -42,8 +43,14 @@ String localizedCardButtonLabel(AppLocalizations l, CardButtonDef def) {
return def.label;
}
-/// Button IDs that are hidden on iOS (features not yet supported).
-final Set<String> _iosHiddenButtons = Platform.isIOS ? const {'cast'} : const {};
+/// Button IDs hidden in this build / on this platform.
+/// - iOS: cast UI not supported through the plugin yet.
+/// - F-Droid (GMS-free): Chromecast needs Google Play Services, so the stub
+/// service reports castSupported=false and the button is dropped entirely.
+final Set<String> _hiddenButtons = {
+ if (Platform.isIOS) 'cast',
+ if (!ChromecastService.castSupported) 'cast',
+};
const _allCardButtons = [
CardButtonDef('chapters', 'Chapters', Icons.list_rounded),
@@ -62,7 +69,7 @@ const _allCardButtons = [
/// Card buttons filtered for the current platform.
final List<CardButtonDef> allCardButtons =
- _allCardButtons.where((b) => !_iosHiddenButtons.contains(b.id)).toList();
+ _allCardButtons.where((b) => !_hiddenButtons.contains(b.id)).toList();
/// Look up a button definition by ID.
CardButtonDef? buttonDefById(String id) {
diff --git a/lib/widgets/chromecast_button_stub.dart b/lib/widgets/chromecast_button_stub.dart
new file mode 100644
index 00000000..39d0627b
--- /dev/null
+++ b/lib/widgets/chromecast_button_stub.dart
@@ -0,0 +1,29 @@
+import 'package:flutter/material.dart';
+import '../services/api_service.dart';
+
+// GMS-free stub of chromecast_button.dart for the F-Droid flavor. Chromecast
+// needs Google Play Services, so the picker is a no-op and the control sheet
+// renders nothing. Swapped in (with chromecast_service_stub.dart) at build time
+// via the fdroiddata recipe. Signatures mirror the real file so callers in
+// card_buttons.dart etc. compile unchanged.
+
+/// No-op on F-Droid: there are no cast devices without Google Play Services.
+void showCastDevicePicker(
+ BuildContext context, {
+ ApiService? api,
+ String? itemId,
+ String? title,
+ String? author,
+ String? coverUrl,
+ double? totalDuration,
+ List<dynamic>? chapters,
+ String? episodeId,
+}) {}
+
+/// Empty on F-Droid: the cast control sheet is never shown (cast never connects).
+class CastControlSheet extends StatelessWidget {
+ const CastControlSheet({super.key});
+
+ @override
+ Widget build(BuildContext context) => const SizedBox.shrink();
+}