summaryrefslogtreecommitdiff
path: root/plugins/aves_model/lib/src/settings
diff options
context:
space:
mode:
authormirror <mirror@localhost>2026-11-22 08:41:00 +0900
committermirror <mirror@localhost>2026-11-22 08:41:00 +0900
commit449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch)
treec131c3528c4d517f56e19b854a7453fedb097d40 /plugins/aves_model/lib/src/settings
downloadaves-src-master.tar.gz
aves-src-master.zip
snapshot of aves v1.13.12 (secrets removed: android/app/google-services.json)HEADv1.13.12master
Diffstat (limited to 'plugins/aves_model/lib/src/settings')
-rw-r--r--plugins/aves_model/lib/src/settings/access.dart105
-rw-r--r--plugins/aves_model/lib/src/settings/enums.dart71
-rw-r--r--plugins/aves_model/lib/src/settings/event.dart11
-rw-r--r--plugins/aves_model/lib/src/settings/keys.dart199
-rw-r--r--plugins/aves_model/lib/src/settings/store.dart39
5 files changed, 425 insertions, 0 deletions
diff --git a/plugins/aves_model/lib/src/settings/access.dart b/plugins/aves_model/lib/src/settings/access.dart
new file mode 100644
index 0000000..c87fe22
--- /dev/null
+++ b/plugins/aves_model/lib/src/settings/access.dart
@@ -0,0 +1,105 @@
+import 'package:aves_model/aves_model.dart';
+import 'package:collection/collection.dart';
+
+mixin SettingsAccess {
+ bool get initialized;
+
+ SettingsStore get store;
+
+ Stream<SettingsChangedEvent> get updateStream;
+
+ void notifyKeyChange(String key, dynamic oldValue, dynamic newValue);
+
+ void notifyListeners();
+
+ void set(String key, dynamic newValue) {
+ var oldValue = store.get(key);
+ if (newValue == null) {
+ store.remove(key);
+ } else if (newValue is String) {
+ oldValue = getString(key);
+ store.setString(key, newValue);
+ } else if (newValue is List<String>) {
+ oldValue = getStringList(key);
+ store.setStringList(key, newValue);
+ } else if (newValue is int) {
+ oldValue = getInt(key);
+ store.setInt(key, newValue);
+ } else if (newValue is double) {
+ oldValue = getDouble(key);
+ store.setDouble(key, newValue);
+ } else if (newValue is bool) {
+ oldValue = getBool(key);
+ store.setBool(key, newValue);
+ }
+ if (oldValue != newValue) {
+ notifyKeyChange(key, oldValue, newValue);
+ notifyListeners();
+ }
+ }
+
+ // getters
+
+ bool? getBool(String key) {
+ try {
+ return store.getBool(key);
+ } catch (error) {
+ // ignore, could be obsolete value of different type
+ return null;
+ }
+ }
+
+ int? getInt(String key) {
+ try {
+ return store.getInt(key);
+ } catch (error) {
+ // ignore, could be obsolete value of different type
+ return null;
+ }
+ }
+
+ double? getDouble(String key) {
+ try {
+ return store.getDouble(key);
+ } catch (error) {
+ // ignore, could be obsolete value of different type
+ return null;
+ }
+ }
+
+ String? getString(String key) {
+ try {
+ return store.getString(key);
+ } catch (error) {
+ // ignore, could be obsolete value of different type
+ return null;
+ }
+ }
+
+ List<String>? getStringList(String key) {
+ try {
+ return store.getStringList(key);
+ } catch (error) {
+ // ignore, could be obsolete value of different type
+ return null;
+ }
+ }
+
+ T getEnumOrDefault<T>(String key, T defaultValue, Iterable<T> values) {
+ try {
+ final valueString = store.getString(key);
+ for (final v in values) {
+ if (v.toString() == valueString) {
+ return v;
+ }
+ }
+ } catch (error) {
+ // ignore, could be obsolete value of different type
+ }
+ return defaultValue;
+ }
+
+ List<T> getEnumListOrDefault<T extends Object>(String key, List<T> defaultValue, Iterable<T> values) {
+ return store.getStringList(key)?.map((s) => values.firstWhereOrNull((v) => v.toString() == s)).nonNulls.toList() ?? defaultValue;
+ }
+}
diff --git a/plugins/aves_model/lib/src/settings/enums.dart b/plugins/aves_model/lib/src/settings/enums.dart
new file mode 100644
index 0000000..fa6945d
--- /dev/null
+++ b/plugins/aves_model/lib/src/settings/enums.dart
@@ -0,0 +1,71 @@
+enum AccessibilityAnimations { system, disabled, enabled }
+
+enum AccessibilityTimeout { system, s1, s3, s5, s10, s30 }
+
+enum AvesThemeBrightness { system, light, dark, black }
+
+enum AvesThemeColorMode { monochrome, polychrome }
+
+enum ConfirmationDialog { createVault, deleteForever, moveToBin, moveUndatedItems }
+
+enum CoordinateFormat { dms, ddm, decimal }
+
+enum DisplayRefreshRateMode { auto, highest, lowest }
+
+enum EntryBackground { black, white, checkered }
+
+enum HomePageSetting { collection, albums, tags, explorer }
+
+enum KeepScreenOn { never, videoPlayback, viewerOnly, always }
+
+enum MaxBrightness { never, viewerOnly, always }
+
+enum OverlayHistogramStyle { none, rgb, luminance }
+
+enum SlideshowVideoPlayback { skip, playMuted, playWithSound }
+
+enum SubtitlePosition { top, bottom }
+
+enum ThumbnailOverlayLocationIcon { located, unlocated, none }
+
+enum ThumbnailOverlayTagIcon { tagged, untagged, none }
+
+enum UnitSystem { metric, imperial }
+
+enum VideoAutoPlayMode { disabled, playMuted, playWithSound }
+
+enum VideoBackgroundMode { disabled, pip }
+
+enum VideoLoopMode { never, shortOnly, always }
+
+enum VideoResumptionMode { never, ask, always }
+
+enum ViewerTransition { slide, parallax, fade, zoomIn, none, random }
+
+enum WidgetDisplayedItem { random, mostRecent }
+
+enum WidgetOpenPage { home, collection, viewer, updateWidget }
+
+enum WidgetOutline {
+ none,
+ black,
+ white,
+ // system brightness dependent (low contrast):
+ // - white on light theme
+ // - black on dark theme
+ systemBlackAndWhite,
+ // system brightness dependent (high contrast):
+ // - black on light theme
+ // - white on dark theme
+ systemBlackAndWhiteHighContrast,
+ // system brightness dependent (low contrast):
+ // light dynamic colour on light theme
+ // dark dynamic colour on dark theme.
+ systemDynamicLowContrast,
+ // system brightness dependent (high contrast):
+ // dark dynamic colour on light theme
+ // light dynamic colour on dark theme.
+ systemDynamic,
+}
+
+enum WidgetShape { rrect, circle, heart, concaveSquare, wavyCircle16, tearRectLeft, tearRectRight, bumpyRows, bumpyColumns }
diff --git a/plugins/aves_model/lib/src/settings/event.dart b/plugins/aves_model/lib/src/settings/event.dart
new file mode 100644
index 0000000..22b3bfa
--- /dev/null
+++ b/plugins/aves_model/lib/src/settings/event.dart
@@ -0,0 +1,11 @@
+import 'package:meta/meta.dart';
+
+@immutable
+class SettingsChangedEvent {
+ final String key;
+ final dynamic oldValue;
+ final dynamic newValue;
+
+ // old and new values as stored, e.g. `List<String>` for collections
+ const SettingsChangedEvent(this.key, this.oldValue, this.newValue);
+}
diff --git a/plugins/aves_model/lib/src/settings/keys.dart b/plugins/aves_model/lib/src/settings/keys.dart
new file mode 100644
index 0000000..f85d21d
--- /dev/null
+++ b/plugins/aves_model/lib/src/settings/keys.dart
@@ -0,0 +1,199 @@
+class SettingKeys {
+ static bool isInternalKey(String key) => _internalKeys.contains(key) || key.startsWith(_widgetKeyPrefix);
+
+ static const Set<String> _internalKeys = {
+ hasAcceptedTermsKey,
+ catalogTimeZoneOffsetMillisKey,
+ searchHistoryKey,
+ platformAccelerometerRotationKey,
+ platformTransitionAnimationScaleKey,
+ topEntryIdsKey,
+ recentDestinationAlbumsKey,
+ recentTagsKey,
+ debugShowViewerTilesKey,
+ };
+
+ static const _widgetKeyPrefix = 'widget_';
+
+ // app
+ static const hasAcceptedTermsKey = 'has_accepted_terms';
+ static const canUseAnalysisServiceKey = 'can_use_analysis_service';
+ static const isInstalledAppAccessAllowedKey = 'is_installed_app_access_allowed';
+ static const isErrorReportingAllowedKey = 'is_crashlytics_enabled';
+ static const localeKey = 'locale';
+ static const forceWesternArabicNumeralsKey = 'force_western_arabic_numerals';
+ static const catalogTimeZoneOffsetMillisKey = 'catalog_time_zone_raw_offset_millis';
+ static const tileExtentPrefixKey = 'tile_extent_';
+ static const tileLayoutPrefixKey = 'tile_layout_';
+ static const entryRenamingPatternKey = 'entry_renaming_pattern';
+ static const topEntryIdsKey = 'top_entry_ids';
+ static const recentDestinationAlbumsKey = 'recent_destination_albums';
+ static const recentTagsKey = 'recent_tags';
+
+ // debug
+ static const debugShowViewerTilesKey = 'debug_show_viewer_tiles';
+
+ // display
+ static const displayRefreshRateModeKey = 'display_refresh_rate_mode';
+ static const themeBrightnessKey = 'theme_brightness';
+ static const themeColorModeKey = 'theme_color_mode';
+ static const enableDynamicColorKey = 'dynamic_color';
+ static const enableBlurEffectKey = 'enable_overlay_blur_effect';
+ static const maxBrightnessKey = 'max_brightness';
+ static const forceTvLayoutKey = 'force_tv_layout';
+
+ // navigation
+ static const mustBackTwiceToExitKey = 'must_back_twice_to_exit';
+ static const keepScreenOnKey = 'keep_screen_on';
+ static const homePageKey = 'home_page';
+ static const homeCustomCollectionKey = 'home_custom_collection';
+ static const homeCustomExplorerPathKey = 'home_custom_explorer_path';
+ static const confirmCreateVaultKey = 'confirm_create_vault';
+ static const confirmDeleteForeverKey = 'confirm_delete_forever';
+ static const confirmMoveToBinKey = 'confirm_move_to_bin';
+ static const confirmMoveUndatedItemsKey = 'confirm_move_undated_items';
+ static const confirmAfterMoveToBinKey = 'confirm_after_move_to_bin';
+ static const setMetadataDateBeforeFileOpKey = 'set_metadata_date_before_file_op';
+ static const drawerTypeBookmarksKey = 'drawer_type_bookmarks';
+ static const drawerAlbumBookmarksKey = 'drawer_album_bookmarks';
+ static const drawerPageBookmarksKey = 'drawer_page_bookmarks';
+ static const bottomNavigationActionsKey = 'bottom_navigation_actions';
+
+ // collection
+ static const collectionBurstPatternsKey = 'collection_burst_patterns';
+ static const collectionGroupFactorKey = 'collection_group_factor';
+ static const collectionSortFactorKey = 'collection_sort_factor';
+ static const collectionSortReverseKey = 'collection_sort_reverse';
+ static const collectionBrowsingQuickActionsKey = 'collection_browsing_quick_actions';
+ static const collectionSelectionQuickActionsKey = 'collection_selection_quick_actions';
+ static const showThumbnailFavouriteKey = 'show_thumbnail_favourite';
+ static const showThumbnailHdrKey = 'show_thumbnail_hdr';
+ static const thumbnailLocationIconKey = 'thumbnail_location_icon';
+ static const thumbnailTagIconKey = 'thumbnail_tag_icon';
+ static const showThumbnailMotionPhotoKey = 'show_thumbnail_motion_photo';
+ static const showThumbnailRatingKey = 'show_thumbnail_rating';
+ static const showThumbnailRawKey = 'show_thumbnail_raw';
+ static const showThumbnailVideoDurationKey = 'show_thumbnail_video_duration';
+
+ // filter grids
+ static const albumSectionFactorKey = 'album_section_factor';
+ static const albumSortFactorKey = 'album_sort_factor';
+ static const countrySortFactorKey = 'country_sort_factor';
+ static const stateSortFactorKey = 'state_sort_factor';
+ static const placeSortFactorKey = 'place_sort_factor';
+ static const tagSortFactorKey = 'tag_sort_factor';
+ static const albumSortReverseKey = 'album_sort_reverse';
+ static const countrySortReverseKey = 'country_sort_reverse';
+ static const stateSortReverseKey = 'state_sort_reverse';
+ static const placeSortReverseKey = 'place_sort_reverse';
+ static const tagSortReverseKey = 'tag_sort_reverse';
+ static const albumGroupsKey = 'album_groups';
+ static const tagGroupsKey = 'tag_groups';
+ static const pinnedFiltersKey = 'pinned_filters';
+ static const hiddenFiltersKey = 'hidden_filters';
+ static const deactivatedHiddenFiltersKey = 'deactivated_hidden_filters';
+ static const showTitleQueryPrefixKey = 'show_title_query_';
+
+ // viewer
+ static const viewerQuickActionsKey = 'viewer_quick_actions';
+ static const showOverlayOnOpeningKey = 'show_overlay_on_opening';
+ static const showOverlayMinimapKey = 'show_overlay_minimap';
+ static const showOverlayZoomLevelKey = 'show_overlay_zoom_level';
+ static const overlayHistogramStyleKey = 'show_overlay_histogram';
+ static const showOverlayInfoKey = 'show_overlay_info';
+ static const showOverlayDescriptionKey = 'show_overlay_description';
+ static const showOverlayRatingTagsKey = 'show_overlay_rating_tags';
+ static const showOverlayShootingDetailsKey = 'show_overlay_shooting_details';
+ static const showOverlayThumbnailPreviewKey = 'show_overlay_thumbnail_preview';
+ static const viewerGestureSideTapNextKey = 'viewer_gesture_side_tap_next';
+ static const viewerUseCutoutKey = 'viewer_use_cutout';
+ static const enableMotionPhotoAutoPlayKey = 'motion_photo_auto_play';
+ static const imageBackgroundKey = 'image_background';
+
+ // video
+ static const enableVideoHardwareAccelerationKey = 'video_hwaccel_mediacodec';
+ static const videoBackgroundModeKey = 'video_background_mode';
+ static const videoAutoPlayModeKey = 'video_auto_play_mode';
+ static const videoLoopModeKey = 'video_loop';
+ static const videoResumptionModeKey = 'video_resumption_mode';
+ static const videoControlActionsKey = 'video_control_actions';
+ static const videoGestureDoubleTapTogglePlayKey = 'video_gesture_double_tap_toggle_play';
+ static const videoGestureSideDoubleTapSeekKey = 'video_gesture_side_double_tap_skip';
+ static const videoGestureVerticalDragBrightnessVolumeKey = 'video_gesture_vertical_drag_brightness_volume';
+
+ // subtitles
+ static const subtitleFontSizeKey = 'subtitle_font_size';
+ static const subtitleTextAlignmentKey = 'subtitle_text_alignment';
+ static const subtitleTextPositionKey = 'subtitle_text_position';
+ static const subtitleShowOutlineKey = 'subtitle_show_outline';
+ static const subtitleTextColorKey = 'subtitle_text_color_string';
+ static const subtitleBackgroundColorKey = 'subtitle_background_color_string';
+
+ // info
+ static const infoMapZoomKey = 'info_map_zoom';
+ static const coordinateFormatKey = 'coordinates_format';
+ static const unitSystemKey = 'unit_system';
+
+ // tag editor
+
+ static const tagEditorCurrentFilterSectionExpandedKey = 'tag_editor_current_filter_section_expanded';
+ static const tagEditorExpandedSectionKey = 'tag_editor_expanded_section';
+
+ // converter
+
+ static const convertMimeTypeKey = 'convert_mime_type';
+ static const convertQualityKey = 'convert_quality';
+ static const convertWriteMetadataKey = 'convert_write_metadata';
+
+ // map
+ static const mapStyleKey = 'info_map_style';
+ static const mapDefaultCenterKey = 'map_default_center';
+ static const customMapStylesKey = 'custom_map_styles';
+
+ // search
+ static const saveSearchHistoryKey = 'save_search_history';
+ static const searchHistoryKey = 'search_history';
+
+ // bin
+ static const enableBinKey = 'enable_bin';
+
+ // accessibility
+ static const showPinchGestureAlternativesKey = 'show_pinch_gesture_alternatives';
+ static const accessibilityAnimationsKey = 'accessibility_animations';
+ static const timeToTakeActionKey = 'time_to_take_action';
+
+ // screen saver
+ static const screenSaverFillScreenKey = 'screen_saver_fill_screen';
+ static const screenSaverAnimatedZoomEffectKey = 'screen_saver_animated_zoom_effect';
+ static const screenSaverTransitionKey = 'screen_saver_transition';
+ static const screenSaverVideoPlaybackKey = 'screen_saver_video_playback';
+ static const screenSaverIntervalKey = 'screen_saver_interval';
+ static const screenSaverCollectionFiltersKey = 'screen_saver_collection_filters';
+
+ // slideshow
+ static const slideshowRepeatKey = 'slideshow_loop';
+ static const slideshowShuffleKey = 'slideshow_shuffle';
+ static const slideshowFillScreenKey = 'slideshow_fill_screen';
+ static const slideshowAnimatedZoomEffectKey = 'slideshow_animated_zoom_effect';
+ static const slideshowTransitionKey = 'slideshow_transition';
+ static const slideshowVideoPlaybackKey = 'slideshow_video_playback';
+ static const slideshowIntervalKey = 'slideshow_interval';
+
+ // widget
+ static const widgetOutlinePrefixKey = '${_widgetKeyPrefix}outline_';
+ static const widgetShapePrefixKey = '${_widgetKeyPrefix}shape_';
+ static const widgetCollectionFiltersPrefixKey = '${_widgetKeyPrefix}collection_filters_';
+ static const widgetOpenPagePrefixKey = '${_widgetKeyPrefix}open_page_';
+ static const widgetDisplayedItemPrefixKey = '${_widgetKeyPrefix}displayed_item_';
+ static const widgetUriPrefixKey = '${_widgetKeyPrefix}uri_';
+
+ // platform settings
+ // cf Android `Settings.System.ACCELEROMETER_ROTATION`
+ static const platformAccelerometerRotationKey = 'accelerometer_rotation';
+
+ // cf Android `Settings.Global.TRANSITION_ANIMATION_SCALE`
+ static const platformTransitionAnimationScaleKey = 'transition_animation_scale';
+
+ // cf Android `Settings.Secure.LONG_PRESS_TIMEOUT`
+ static const platformLongPressTimeoutMillisKey = 'long_press_timeout';
+}
diff --git a/plugins/aves_model/lib/src/settings/store.dart b/plugins/aves_model/lib/src/settings/store.dart
new file mode 100644
index 0000000..84a7feb
--- /dev/null
+++ b/plugins/aves_model/lib/src/settings/store.dart
@@ -0,0 +1,39 @@
+abstract class SettingsStore {
+ bool get initialized;
+
+ Future<void> init();
+
+ Future<void> reload();
+
+ Future<bool> clear();
+
+ Future<bool> remove(String key);
+
+ // get
+
+ Set<String> getKeys();
+
+ Object? get(String key);
+
+ bool? getBool(String key);
+
+ int? getInt(String key);
+
+ double? getDouble(String key);
+
+ String? getString(String key);
+
+ List<String>? getStringList(String key);
+
+ // set
+
+ Future<bool> setBool(String key, bool value);
+
+ Future<bool> setInt(String key, int value);
+
+ Future<bool> setDouble(String key, double value);
+
+ Future<bool> setString(String key, String value);
+
+ Future<bool> setStringList(String key, List<String> value);
+}