feat(settings): add extension verification browser mode preference

Let users choose whether signed-session verification opens in the
external browser or in-app browser first, with automatic fallback to
the other mode when launch fails.
This commit is contained in:
zarzet
2026-07-01 08:18:31 +07:00
parent eb36b0bb7b
commit 08c738dc69
7 changed files with 147 additions and 13 deletions
@@ -2098,6 +2098,7 @@ class DownloadQueueNotifier extends Notifier<DownloadQueueState> {
final opened = await openPendingExtensionVerification(
normalizedExtensionId,
browserMode: ref.read(settingsProvider).extensionVerificationBrowserMode,
);
if (!opened) return false;
+24
View File
@@ -28,6 +28,10 @@ class SettingsNotifier extends Notifier<AppSettings> {
'album',
'playlist',
};
static const Set<String> _extensionVerificationBrowserModeValues = {
'external_first',
'in_app_first',
};
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
final FlutterSecureStorage _secureStorage = const FlutterSecureStorage();
@@ -79,6 +83,10 @@ class SettingsNotifier extends Notifier<AppSettings> {
defaultSearchTab: sanitizedDefaultSearchTab,
defaultService: loaded.defaultService,
searchProvider: loaded.searchProvider,
extensionVerificationBrowserMode:
_normalizeExtensionVerificationBrowserMode(
loaded.extensionVerificationBrowserMode,
),
);
await _runMigrations(prefs);
@@ -270,6 +278,14 @@ class SettingsNotifier extends Notifier<AppSettings> {
return 'all';
}
String _normalizeExtensionVerificationBrowserMode(String value) {
final normalized = value.trim().toLowerCase();
if (_extensionVerificationBrowserModeValues.contains(normalized)) {
return normalized;
}
return 'external_first';
}
String? _sanitizeRetiredBuiltInProviderId(String? providerId) {
final normalized = providerId?.trim().toLowerCase();
if (normalized == null || normalized.isEmpty) return providerId;
@@ -557,6 +573,14 @@ class SettingsNotifier extends Notifier<AppSettings> {
_saveSettings();
}
void setExtensionVerificationBrowserMode(String mode) {
state = state.copyWith(
extensionVerificationBrowserMode:
_normalizeExtensionVerificationBrowserMode(mode),
);
_saveSettings();
}
void setLocale(String locale) {
state = state.copyWith(locale: locale);
_saveSettings();
+3
View File
@@ -686,6 +686,9 @@ class TrackNotifier extends Notifier<TrackState> {
try {
final opened = await openPendingExtensionVerification(
normalizedExtensionId,
browserMode: ref
.read(settingsProvider)
.extensionVerificationBrowserMode,
);
if (!opened) return false;