Skip to content
16 changes: 8 additions & 8 deletions CLAUDE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ Eine wartbare Basis, damit Features unabhängig voneinander wachsen können.
| 4.28 | Als Nutzer möchte ich, dass sich auf dem Handy nur das Vollbild des Players ins Querformat dreht. | Handys (kürzeste Seite unter 600 dp) bleiben überall hochkant, auch der aufgeklappte Player. Kippen des Handys meldet das System samt Richtung (Android `OrientationEventListener`, iOS UIDevice; bei aktiver Drehsperre nicht): mit einem breiten Video im aufgeklappten Player öffnet es das Vollbild, aufrecht halten beendet es. Eine Haltung zählt erst nach 0,25 s (schräg gehalten flippte das Video sonst kurz), nicht bei gesperrter oder verlassener App, und es gibt immer nur ein Vollbild (beim Entsperren öffneten sich sonst mehrere). Nach Verlassen per Knopf im Querformat öffnet erst wieder Kippen nach einmal aufrecht halten (vorher sprang es sofort zurück ins Vollbild). Tablets drehen sich überall. | Next | 🟡 Ungetestet auf Gerät |
| 4.29 | Als Nutzer möchte ich einen ruhigen Übergang ins Vollbild und Shorts, deren Knöpfe das Video wenig verdecken. | Vollbild wie bei YouTube: das Video löst sich von seinem Platz, wächst und dreht sich mit dem Handy, während die App dahinter schwarz wird; erst dann dreht sich der Bildschirm unsichtbar darunter (ohne die Dreh-Animation des Systems, die das schon gedrehte Bild noch einmal drehte; Android: harter Schnitt auf Handys, die Dreh-Animation des Systems ist aus; das kurz gestreckte alte Bild liegt unter der Schwarzblende). Verlassen (Knopf, Zurück, aufrecht halten) läuft rückwärts. Auf iOS war die Drehung trotzdem zu sehen; jetzt blendet die App auf beiden Plattformen stattdessen nach Schwarz, dreht sich darunter und blendet wieder ein (0,12 s abdunkeln, warten bis das Fenster gedreht ist und zwei Bilder gemalt sind, 0,2 s aufhellen) (der bewegte Übergang bleibt im Code abschaltbar erhalten). Per Knopf im Hochformat wächst das Video ungedreht, der Bildschirm dreht sich sichtbar. Ohne Animationen (Bedienungshilfen) springt es. Shorts: während ein Short läuft, bleiben rechts nur Performer, Bewertung und O-Zähler, oben Vollbild und Ton; Später ansehen, Ganzes Video, ⋮, Mischen und Shorts-Einstellungen gleiten beim Pausieren herein. Text unten links (Studio, Performer, Titel, Tags, Wiedergaben) und der Umschalter „Shorts \| Loops“ blenden 2 s nach jedem Wischen und nach der Rückkehr in den Tab aus und erscheinen beim Pausieren wieder. Ohne Shorts und mit Screenreader ist alles sichtbar. | Next | 🟡 Ungetestet auf Gerät |
| 4.30 | Als Nutzer möchte ich Marker bearbeiten und löschen. | Langes Drücken auf einen Marker im Player (Kapitel) oder im Marker-Raster (dort auch ⋮) öffnet ein Menü: im Raster Abspielen und Als Loop abspielen, dann „Marker bearbeiten“ (dasselbe Sheet wie beim Setzen, vorausgefüllt mit Titel, Haupt-Tag und Ende; gesendet wird nur, was sich geändert hat, das Ende nur bei Servern mit Endzeiten) und „Marker löschen“ (mit Rückfrage). Kapitel, Marker-Raster und -Zähler laden danach neu. Auch in der Demo. | Next | 🟡 Ungetestet auf Gerät |
| 4.31 | Als Nutzer möchte ich, dass das Video den ganzen Bildschirm füllt, ohne schwarze Balken (GitHub #58). | Der Zwei-Finger-Zoom (4.22) wächst stufenlos mit den Fingern (1–4×) und rastet kurz bei 1× (Breite bzw. Höhe füllt den Bereich) und dort ein, wo das Video den ganzen Bereich bedeckt (±7 %, mit Haptik): keine schwarzen Balken mehr, was übersteht, wird abgeschnitten. Die Position rastet in der Mitte und an den Rändern ein (14 px, senkrecht und waagerecht). Gezeichnet als Transform des Video-Bereichs (`ZoomedVideo`), die Steuerung darin wird gegengerechnet (`ZoomCounter`) und bleibt normal groß; mpvs `video-zoom` bleibt im Rechteck des Videos und ging deshalb nicht. Das Einrasten gilt für jeden Bereich neu (Vollbild, gedrehter Bildschirm) und bleibt über andere Szenen; ein Zoom darüber wird mit der Szene zurückgesetzt. Das Doppeltipp-Feedback beim Spulen (4.11) ist eine Halbscheibe mit Kreisbogen über den äußeren 30 % der angetippten Seite, der Text zum Rand hin. | Next | 🟡 Ungetestet auf Gerät |
| 4.31 | Als Nutzer möchte ich, dass das Video den ganzen Bildschirm füllt, ohne schwarze Balken (GitHub #58). | Der Zwei-Finger-Zoom (4.22) wächst stufenlos mit den Fingern (1–4×) und rastet kurz bei 1× (Breite bzw. Höhe füllt den Bereich) und dort ein, wo das Video den ganzen Bereich bedeckt (±7 %, mit Haptik): keine schwarzen Balken mehr, was übersteht, wird abgeschnitten. Die Position rastet in der Mitte und an den Rändern ein (14 px, senkrecht und waagerecht). Zum Haptik-Tick zeigt das Zoom-Label beim Einrasten „Original“ bzw. „Füllen“ in der Akzentfarbe (kurzes Aufploppen), beim Pan-Snap erscheinen dünne Hilfslinien; bei reduzierten Animationen ohne Ploppen und Blenden. Gezeichnet als Transform des Video-Bereichs (`ZoomedVideo`), die Steuerung darin wird gegengerechnet (`ZoomCounter`) und bleibt normal groß; mpvs `video-zoom` bleibt im Rechteck des Videos und ging deshalb nicht. Das Einrasten gilt für jeden Bereich neu (Vollbild, gedrehter Bildschirm) und bleibt über andere Szenen; ein Zoom darüber wird mit der Szene zurückgesetzt. Das Doppeltipp-Feedback beim Spulen (4.11) ist eine Halbscheibe mit Kreisbogen über den äußeren 30 % der angetippten Seite, der Text zum Rand hin. | Next | 🟡 Ungetestet auf Gerät |
| 4.32 | Als Nutzer möchte ich Untertitel sehen, die Stash zur Szene hat (GitHub #57). | Hat die Szene Untertitel (`captions`, geladen über `paths.caption?lang=&type=`), erscheint oben im Player ein Untertitel-Knopf mit Auswahl (Aus oder je eine Sprache, bei mehreren Formaten mit Format). Die Wahl gilt als Sprache auch für die nächsten Szenen und wird dort eingeschaltet, sobald die Datei geladen ist, sofern es die Sprache gibt. Dargestellt von media_kit; mpv fügt die Datei per `sub-add` hinzu. Nicht für Cast. Die Demo hat Untertitel (en, de) für jede Szene. | Next | 🟡 Ungetestet auf Gerät |
30 changes: 17 additions & 13 deletions docs/RELEASE_NOTES_next.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# StashTube 1.0.0-beta.8
# StashTube 1.0.0-beta.9

Pre-release. The pipeline picks the version (next beta after `v1.0.0-beta.7`).
Pre-release. The pipeline picks the version (next beta after `v1.0.0-beta.8`).

## What's new

- **Subtitles** – pick the captions your Stash has for a video from the new button in the player's top bar. The language is remembered for the next videos. The built-in demo has English and German subtitles to try it.
- **Zoom without black bars** – spread two fingers to fill the whole screen. The zoom grows continuously (up to 4×) and snaps at the fitted size and at full width/height, the position snaps to the center and the edges, each with a light haptic tick. Works inline, in fullscreen and after turning the phone.
- **Double tap to skip** – a half disc over the tapped side (like YouTube) with the total jump, fading in and out.
- **Playback** – videos can buffer fully before playing, position and picture are kept when you return to the app, the position is saved at once, a countdown runs before the next video of a queue, and the current frame can be saved.
- **Feedback and bugs** – Settings → About opens the GitHub issue forms.
- **Back where you were** – lists keep their place when you turn the phone for fullscreen and come back to them.
- **Favorites** – the avatars at the top pick "All" or one performer (a long press opens the channel), with a header and "View channel".
- **Zoom snap feedback** – "Original" and "Fill" show when the pinch zoom snaps, and guide lines where the picture snaps to the center or an edge.
- **PIN with biometrics** – changing the PIN or turning the app lock off also accepts Face ID or the fingerprint, so a forgotten PIN can be replaced.
- **Proxy warning** – a banner names both addresses when the server hands out media URLs on another address than the one StashTube connects to (a reverse proxy without `Host` / `X-Forwarded-Proto`), and how to fix it.

## Fixes and internals
## Security

- CI: generated l10n files regenerated with the CI's Flutter version (the generated-files check failed on `develop`).
- The pinch zoom is drawn by Flutter instead of mpv (`video-zoom` stays inside the video's rectangle); the controls keep their size.
- The API key and the session cookie only go to the server's own address (scheme, host and port): never to media URLs pointing elsewhere, and not along a redirect that leaves the server.
- The PIN is stored as PBKDF2-HMAC-SHA256. PINs of earlier versions keep working and are converted after the next correct entry.
- If the PIN can't be read (e.g. after restoring a backup), the app stays locked instead of opening: biometrics lead to a new PIN, otherwise the app can be reset.
- A password in a server address (`https://user:pass@host`) is kept in the secure storage instead of the settings; existing servers move on the first start.

## Issues
## Fixes and internals

Closes #57 (subtitles) and #58 (zoom/crop).
- GraphQL responses are no longer written into a cache that was never read.
- The preview check stops after the status instead of downloading whole files from servers that ignore `Range`.
- The password login gives up after 20 s instead of waiting forever.

## Not tested on a device yet

Pinch snapping and haptics (inline, fullscreen, turning), the skip half disc, subtitles on a real server, buffering and the queue countdown.
Proxy warning on a misconfigured server, the lost-PIN screen, and upgrading a PIN set by beta.8 or earlier.
2 changes: 1 addition & 1 deletion docs/UX_REVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Alle Quick Wins sind auf `feature/ux-review` umgesetzt (Phase 2, Schritt 1).
| CTRL-2 | Einmalige Gesten-Tipps, in den Einstellungen erneut zeigbar | ✅ |
| CTRL-3 | Touch-Sperre im Vollbild | ✅ |
| PL-1 | Zu Gruppe hinzufügen, neue Gruppe | ✅ |
| SUB-1 | Abos: Favoriten-Avatare und ihr Feed (optionaler Tab, „Du“, Home) | ✅ |
| SUB-1 | Abos: Favoriten-Avatare als Auswahl („Alle“ oder ein Darsteller) und ihr Feed (optionaler Tab, „Du“, Home) | ✅ |
| NOTIF-1 | „N neu seit deinem letzten Besuch“, Meldung bei fertigen Server-Aufgaben (nur in der App) | ✅ |
| – | Kapitel mit Vorschaubildern, Favorit in der Kanalzeile, „In Stash öffnen“, Würfel, Seh-Diagramm, Wischen zwischen Kanal-Tabs, Bild nach unten wischen zum Schließen, Pfeiltasten in der Suche, Links öffnen | ✅ |
| – | Sleep-Timer, Offline-Downloads, System-Benachrichtigungen | offen |
Expand Down
19 changes: 16 additions & 3 deletions lib/core/config/image_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@ import 'dart:async';
import 'package:flutter/painting.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:http/http.dart' as http;

import '../network/origin_guard.dart';

/// The cache behind every `CachedNetworkImage` of server images: the
/// default cache's files and limits, but its downloads go through an
/// [OriginGuardClient], so a redirect away from the server doesn't take
/// the API key or session cookie along. Pass it as `cacheManager` to every
/// cached image; `DefaultCacheManager` itself must not be used next to it
/// (same key, same files).
final stashImageCacheManager = CacheManager(
Config(DefaultCacheManager.key, fileService: HttpFileService(httpClient: OriginGuardClient(http.Client()))),
);

/// Empties the image cache, e.g. when a server is removed: its thumbnails
/// must not stay on the device. Overridden in `main()` with
/// [clearDeviceImageCache]; does nothing elsewhere (tests have no cache).
final clearImageCacheProvider = Provider<void Function()>((ref) => () {});

/// Clears the images held in memory and the files `CachedNetworkImage`
/// keeps in the default cache manager. Best effort, and not awaited.
/// Clears the images held in memory and the files of
/// [stashImageCacheManager]. Best effort, and not awaited.
void clearDeviceImageCache() {
PaintingBinding.instance.imageCache
..clear()
..clearLiveImages();
unawaited(DefaultCacheManager().emptyCache().catchError((Object _) {}));
unawaited(stashImageCacheManager.emptyCache().catchError((Object _) {}));
}
19 changes: 18 additions & 1 deletion lib/core/config/secret_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ abstract interface class SecretStore {

/// Deletes every secret whose key passes [test], e.g. a removed server's.
Future<void> deleteWhere(bool Function(String key) test);

/// Deletes every secret, also ones that couldn't be read.
Future<void> clear();
}

class SecureSecretStore implements SecretStore {
Expand All @@ -28,7 +31,8 @@ class SecureSecretStore implements SecretStore {
values = await storage.readAll();
} catch (e) {
// Unreadable (e.g. a restored Android backup): start empty, the user
// enters the key again.
// enters the key again. A PIN lost with it keeps the app locked
// (AppLockSettings.pinLost).
debugPrint('Secure storage unreadable: $e');
values = {};
}
Expand Down Expand Up @@ -59,6 +63,16 @@ class SecureSecretStore implements SecretStore {
await write(key, null);
}
}

@override
Future<void> clear() async {
_cache.clear();
try {
await _storage.deleteAll();
} catch (e) {
debugPrint('Secure storage not cleared: $e');
}
}
}

/// In memory only: the default in tests, which don't override
Expand All @@ -82,6 +96,9 @@ class MemorySecretStore implements SecretStore {

@override
Future<void> deleteWhere(bool Function(String key) test) async => values.removeWhere((key, _) => test(key));

@override
Future<void> clear() async => values.clear();
}

/// Overridden in `main()` with the [SecureSecretStore] loaded before `runApp`.
Expand Down
59 changes: 52 additions & 7 deletions lib/core/config/server_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ class ServerConfig {
return key == null || key.isEmpty ? const {} : {'ApiKey': key};
}

/// [baseUrl] without the user info (`user:password@`) a URL may carry
/// for a proxy's basic auth: for showing, and for links that leave the
/// app.
String get displayUrl => withoutUserInfo(baseUrl);

/// [url] without `user:password@`.
static String withoutUserInfo(String url) {
final uri = Uri.tryParse(url);
if (uri == null || uri.userInfo.isEmpty) return url;
return uri.replace(userInfo: '').toString();
}

/// [url] with [userInfo] (`user:password`) put back, as stored apart
/// from it.
static String withUserInfo(String url, String? userInfo) {
final uri = Uri.tryParse(url);
if (uri == null || userInfo == null || userInfo.isEmpty) return url;
return uri.replace(userInfo: userInfo).toString();
}

/// True for plain HTTP to a server outside the home network: the API key
/// and everything watched would cross the internet unencrypted.
bool get isUnencryptedOverInternet {
Expand Down Expand Up @@ -136,7 +156,9 @@ class ServerConfig {
}

/// A saved Stash server (2.6). Its API key and password live in the
/// [SecretStore] (2.5), not in the stored JSON.
/// [SecretStore] (2.5), not in the stored JSON; so does user info in its
/// URL (`https://user:password@host`, a proxy's basic auth): the JSON keeps
/// the URL without it ([urlAuthSecret]).
@immutable
class ServerProfile {
const ServerProfile({
Expand Down Expand Up @@ -185,23 +207,45 @@ class ServerProfile {

static String apiKeySecret(String id) => 'api_key:$id';
static String passwordSecret(String id) => 'password:$id';
static String urlAuthSecret(String id) => 'url_auth:$id';

/// The user info of [baseUrl] (`user:password`), kept as a secret; null
/// without.
String? get urlAuth {
final info = Uri.tryParse(baseUrl)?.userInfo;
return info == null || info.isEmpty ? null : info;
}

/// Without the secrets.
Map<String, dynamic> toJson() => {'id': id, 'name': name, 'url': baseUrl, if (username != null) 'username': username};
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'url': ServerConfig.withoutUserInfo(baseUrl),
if (username != null) 'username': username,
};

/// Whether a stored entry still has secrets in its JSON (API key of
/// versions before 2.5, user info in the URL, stored by older versions),
/// which saving it again moves to the secret store.
static bool hasSecretsInJson(Map<String, dynamic> json) {
final url = json['url'];
return json.containsKey('apiKey') || (url is String && (Uri.tryParse(url)?.userInfo.isNotEmpty ?? false));
}

/// Null for an entry that can't be read. Versions before 2.5 stored the
/// API key in the JSON; it is moved to the secret store on load.
/// Null for an entry that can't be read. Secrets still in the JSON
/// ([hasSecretsInJson]) are used and moved to the secret store on load.
static ServerProfile? tryFromJson(Map<String, dynamic> json, SecretStore secrets) {
final id = json['id'];
final url = json['url'];
final name = json['name'];
final legacyKey = json['apiKey'];
final username = json['username'];
if (id is! String || id.isEmpty || url is! String || url.isEmpty) return null;
final storedAuth = Uri.tryParse(url)?.userInfo ?? '';
return ServerProfile(
id: id,
name: name is String && name.isNotEmpty ? name : defaultName(url),
baseUrl: url,
baseUrl: storedAuth.isNotEmpty ? url : ServerConfig.withUserInfo(url, secrets.read(urlAuthSecret(id))),
apiKey: secrets.read(apiKeySecret(id)) ?? (legacyKey is String ? legacyKey : null),
username: username is String ? username : null,
password: secrets.read(passwordSecret(id)),
Expand Down Expand Up @@ -244,8 +288,8 @@ class ServerProfilesNotifier extends Notifier<ServerProfiles> {
profiles: [for (final p in json) ?ServerProfile.tryFromJson(p, _secrets)],
activeId: prefs.getString(_activeKey),
);
// Move API keys of older versions out of the preferences.
if (json.any((p) => p.containsKey('apiKey'))) _persist(profiles);
// Move API keys and URL passwords of older versions out of the preferences.
if (json.any(ServerProfile.hasSecretsInJson)) _persist(profiles);
_moveLegacyLists(prefs, profiles.profiles.firstOrNull?.id);
return profiles;
}
Expand Down Expand Up @@ -311,6 +355,7 @@ class ServerProfilesNotifier extends Notifier<ServerProfiles> {
for (final p in value.profiles) {
await _secrets.write(ServerProfile.apiKeySecret(p.id), p.apiKey);
await _secrets.write(ServerProfile.passwordSecret(p.id), p.password);
await _secrets.write(ServerProfile.urlAuthSecret(p.id), p.urlAuth);
}
await prefs.setString(_profilesKey, jsonEncode([for (final p in value.profiles) p.toJson()]));
if (value.activeId == null) {
Expand Down
Loading
Loading