mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-06 20:57:57 +02:00
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:
@@ -2098,6 +2098,7 @@ class DownloadQueueNotifier extends Notifier<DownloadQueueState> {
|
||||
|
||||
final opened = await openPendingExtensionVerification(
|
||||
normalizedExtensionId,
|
||||
browserMode: ref.read(settingsProvider).extensionVerificationBrowserMode,
|
||||
);
|
||||
if (!opened) return false;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -686,6 +686,9 @@ class TrackNotifier extends Notifier<TrackState> {
|
||||
try {
|
||||
final opened = await openPendingExtensionVerification(
|
||||
normalizedExtensionId,
|
||||
browserMode: ref
|
||||
.read(settingsProvider)
|
||||
.extensionVerificationBrowserMode,
|
||||
);
|
||||
if (!opened) return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user