Files
noo/lib/services/pick_intent_service.dart
ayushya 44a23c3632
Build APK / build (push) Successful in 7m40s
Add GET_CONTENT picker support, fix account/login bugs, restyle selection UI
- Let Noo be picked as a source (Files + Photos) by other apps' native
  file/photo pickers via Android's GET_CONTENT intent, mirroring the
  existing "Share to Noo" plumbing: MainActivity.kt/PickIntentService/
  PickRequest, ServerProvider.pickRequest/confirmPick/cancelPick, and
  pick-mode tap handling in FilesView/PhotosView. While picking, the
  bottom nav and MoreTabsButton are restricted to Files/Photos only.
- Fix two account bugs: testConnection() failures no longer delete a
  still-valid stored app password (only an actual 401 does), and
  switchAccount() now retries a nominally-active-but-logged-out account
  instead of no-op'ing - both were silently locking users out of "Continue
  as" with no way back in except removing and re-adding the account
  (now exposed via login_view.dart's inline remove button).
- Fix the login WebView: clear cookies before every load so "Add Account"
  can't silently reuse an existing session, and push it as a
  non-animated route to avoid a known WebView-as-PlatformView black-screen-
  on-pop issue under Impeller.
- Redesign the Files/Photos selection toolbar to take over the top app bar
  entirely (SyncedHeaderScaffold.selectionBar) instead of sitting as a
  second bar under the controls row, with a horizontally-scrollable,
  uniformly-colored actions row and the same one-shot scroll-hint nudge
  the controls row uses.
- Redesign ShareUploadView to share the same SyncedHeaderScaffold chrome
  as every tab, with the uploading-file summary (marqueed via the new
  shared MarqueeTitle widget) and upload button grouped into one
  rounded/elevated bottom sheet.
- Restyle ShareSheet to open on the same DetailsHeader every other
  per-item sheet uses, and fix a couple of small design-language drifts
  (hardcoded text style, a non-rounded icon).
- Settings' account card: icon buttons with tooltips instead of text
  buttons for refresh/logout/remove, divider removed.
2026-09-17 23:36:54 -04:00

48 lines
1.6 KiB
Dart

import 'package:flutter/services.dart';
import '../models/pick_request.dart';
/// Talks to `MainActivity.kt`'s hand-rolled GET_CONTENT picker handling
/// (mirrors `ShareIntentService`'s split between a cold-start check and a
/// stream for an intent arriving while the app is already running - the
/// same `singleTask` launch mode applies here).
class PickIntentService {
static const _methodChannel = MethodChannel('dev.ayushya.noo/pick_intent');
static const _newPickChannel = EventChannel(
'dev.ayushya.noo/pick_intent/new',
);
/// Non-null if the app was launched cold as another app's file/photo
/// picker.
static Future<PickRequest?> getPickRequest() async {
final result = await _methodChannel.invokeMethod<Map<dynamic, dynamic>>(
'getPickRequest',
);
return result == null ? null : PickRequest.fromMap(result);
}
/// Emits whenever the app is asked to act as a picker while already
/// running.
static Stream<PickRequest> get onNewPickRequest {
return _newPickChannel.receiveBroadcastStream().map(
(event) => PickRequest.fromMap(event as Map<dynamic, dynamic>),
);
}
/// Hands the already-downloaded local files back to the caller and closes
/// the picker. [mimeTypes] is parallel to [localPaths].
static Future<void> finishPick(
List<String> localPaths,
List<String> mimeTypes,
) {
return _methodChannel.invokeMethod('finishPick', {
'paths': localPaths,
'mimeTypes': mimeTypes,
});
}
/// Backs out of picking mode with no result, closing the picker.
static Future<void> cancelPick() {
return _methodChannel.invokeMethod('cancelPick');
}
}