From e83355ab59519e04defcbe91fec6de3203d06e3b Mon Sep 17 00:00:00 2001 From: Adil Hanney Date: Fri, 26 Jul 2024 22:01:15 +0100 Subject: [PATCH] feat: button to open Saber folder --- lib/i18n/_missing_translations.yaml | 49 +++++++++++++++++++++++++++++ lib/i18n/strings.g.dart | 1 + lib/i18n/strings.i18n.yaml | 1 + lib/pages/home/settings.dart | 26 +++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/lib/i18n/_missing_translations.yaml b/lib/i18n/_missing_translations.yaml index c16cf51ad..f3e8ddaac 100644 --- a/lib/i18n/_missing_translations.yaml +++ b/lib/i18n/_missing_translations.yaml @@ -68,6 +68,7 @@ ar: onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) resyncEverything(OUTDATED): Resync everything + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -135,7 +136,21 @@ ar: bgPatterns: tablature(OUTDATED): Tablature cs: + settings: + prefLabels: + customDataDir(OUTDATED): Custom Saber folder + openDataDir: Open Saber folder + customDataDir: + mustBeEmpty(OUTDATED): Selected folder must be empty + mustBeDoneSyncing(OUTDATED): Make sure syncing is complete before changing the folder de: + settings: + prefLabels: + customDataDir(OUTDATED): Custom Saber folder + openDataDir: Open Saber folder + customDataDir: + mustBeEmpty(OUTDATED): Selected folder must be empty + mustBeDoneSyncing(OUTDATED): Make sure syncing is complete before changing the folder es: common: done(OUTDATED): Done @@ -156,6 +171,7 @@ es: onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) resyncEverything(OUTDATED): Resync everything + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -228,6 +244,7 @@ fa: onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) resyncEverything(OUTDATED): Resync everything + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -294,6 +311,7 @@ fr: off(OUTDATED): No sound onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -377,6 +395,7 @@ he: onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) resyncEverything(OUTDATED): Resync everything + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -533,6 +552,7 @@ hu: phone(OUTDATED): Phone tablet(OUTDATED): Tablet resyncEverything(OUTDATED): Resync everything + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -657,6 +677,13 @@ hu: lockAxisAlignedPan(OUTDATED): Lock panning to horizontal or vertical needsToSaveBeforeExiting(OUTDATED): Saving your changes... You can safely exit the editor when it's done it: + settings: + prefLabels: + customDataDir(OUTDATED): Custom Saber folder + openDataDir: Open Saber folder + customDataDir: + mustBeEmpty(OUTDATED): Selected folder must be empty + mustBeDoneSyncing(OUTDATED): Make sure syncing is complete before changing the folder ja: common: done(OUTDATED): Done @@ -716,6 +743,7 @@ ja: onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) resyncEverything(OUTDATED): Resync everything + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -810,6 +838,7 @@ pt-BR: onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) resyncEverything(OUTDATED): Resync everything + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -874,6 +903,13 @@ pt-BR: watchServer(OUTDATED): Watch for updates on the server watchServerReadOnly(OUTDATED): Editing is disabled while watching the server ru: + settings: + prefLabels: + customDataDir(OUTDATED): Custom Saber folder + openDataDir: Open Saber folder + customDataDir: + mustBeEmpty(OUTDATED): Selected folder must be empty + mustBeDoneSyncing(OUTDATED): Make sure syncing is complete before changing the folder tr: common: done(OUTDATED): Done @@ -887,6 +923,7 @@ tr: off(OUTDATED): No sound onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) + openDataDir: Open Saber folder customDataDir: cancel(OUTDATED): Cancel select(OUTDATED): Select @@ -942,12 +979,17 @@ zh-Hans-CN: continueBtn(OUTDATED): Continue settings: prefLabels: + customDataDir(OUTDATED): Custom Saber folder pencilSoundSetting(OUTDATED): Pencil sound effect prefDescriptions: pencilSoundSetting: off(OUTDATED): No sound onButNotInSilentMode(OUTDATED): Enabled (unless in silent mode) onAlways(OUTDATED): Enabled (even in silent mode) + openDataDir: Open Saber folder + customDataDir: + mustBeEmpty(OUTDATED): Selected folder must be empty + mustBeDoneSyncing(OUTDATED): Make sure syncing is complete before changing the folder login: notYou(rich)(OUTDATED): "Not you? ${undoLogin(Choose another account)}." status: @@ -992,3 +1034,10 @@ zh-Hans-CN: watchServer(OUTDATED): Watch for updates on the server watchServerReadOnly(OUTDATED): Editing is disabled while watching the server zh-Hant-TW: + settings: + prefLabels: + customDataDir(OUTDATED): Custom Saber folder + openDataDir: Open Saber folder + customDataDir: + mustBeEmpty(OUTDATED): Selected folder must be empty + mustBeDoneSyncing(OUTDATED): Make sure syncing is complete before changing the folder diff --git a/lib/i18n/strings.g.dart b/lib/i18n/strings.g.dart index 954427f47..44edbee32 100644 --- a/lib/i18n/strings.g.dart +++ b/lib/i18n/strings.g.dart @@ -218,6 +218,7 @@ class _StringsSettingsEn { ]; late final _StringsSettingsResetEn reset = _StringsSettingsResetEn._(_root); String get resyncEverything => 'Resync everything'; + String get openDataDir => 'Open Saber folder'; late final _StringsSettingsCustomDataDirEn customDataDir = _StringsSettingsCustomDataDirEn._(_root); } diff --git a/lib/i18n/strings.i18n.yaml b/lib/i18n/strings.i18n.yaml index 94fd424bf..4d441834a 100644 --- a/lib/i18n/strings.i18n.yaml +++ b/lib/i18n/strings.i18n.yaml @@ -140,6 +140,7 @@ settings: title: "Reset this setting?" button: Reset resyncEverything: Resync everything + openDataDir: Open Saber folder customDataDir: cancel: Cancel select: Select diff --git a/lib/pages/home/settings.dart b/lib/pages/home/settings.dart index a8002a749..0b861614d 100644 --- a/lib/pages/home/settings.dart +++ b/lib/pages/home/settings.dart @@ -20,6 +20,7 @@ import 'package:saber/components/settings/update_manager.dart'; import 'package:saber/components/theming/adaptive_alert_dialog.dart'; import 'package:saber/components/theming/adaptive_toggle_buttons.dart'; import 'package:saber/data/editor/pencil_sound.dart'; +import 'package:saber/data/file_manager/file_manager.dart'; import 'package:saber/data/flavor_config.dart'; import 'package:saber/data/locales.dart'; import 'package:saber/data/prefs.dart'; @@ -512,6 +513,31 @@ class _SettingsPageState extends State { title: t.settings.prefLabels.customDataDir, icon: Icons.folder, ), + if (Platform.isWindows || + Platform.isLinux || + Platform.isMacOS || + Platform.isAndroid) + SettingsButton( + title: t.settings.openDataDir, + icon: Icons.folder_open, + onPressed: () { + if (Platform.isWindows) { + Process.run('explorer', [FileManager.documentsDirectory]); + } else if (Platform.isLinux) { + Process.run('xdg-open', [FileManager.documentsDirectory]); + } else if (Platform.isMacOS) { + Process.run('open', [FileManager.documentsDirectory]); + } else if (Platform.isAndroid) { + Process.run('am', [ + 'start', + '-a', + 'android.intent.action.VIEW', + '-d', + 'file://${FileManager.documentsDirectory}' + ]); + } + }, + ), if (requiresManualUpdates || Prefs.shouldCheckForUpdates.value != Prefs.shouldCheckForUpdates.defaultValue) ...[