Skip to content

Commit

Permalink
core: enable/disable "include videos" option
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Nov 18, 2024
1 parent f4e706f commit 1bd172f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/controller/indexer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Indexer<T extends Track> {
Indexer._internal();

bool get _defaultUseMediaStore => settings.useMediaStore.value;
bool get _includeVideosAsTracks => true; // TODO: settings.includeVideosAsTracks.value
bool get _includeVideosAsTracks => settings.includeVideos.value;

void _clearTracksDBAndReOpen() {
_tracksDBManager
Expand Down
5 changes: 5 additions & 0 deletions lib/controller/settings_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class _SettingsController with SettingsFileWriter {
final albumListTileHeight = 90.0.obs;

final useMediaStore = false.obs;
final includeVideos = true.obs;
final displayTrackNumberinAlbumPage = true.obs;
final albumCardTopRightDate = true.obs;
final forceSquaredTrackThumbnail = false.obs;
Expand Down Expand Up @@ -402,6 +403,7 @@ class _SettingsController with SettingsFileWriter {
albumListTileHeight.value = json['albumListTileHeight'] ?? albumListTileHeight.value;

useMediaStore.value = json['useMediaStore'] ?? useMediaStore.value;
includeVideos.value = json['includeVideos'] ?? includeVideos.value;
displayTrackNumberinAlbumPage.value = json['displayTrackNumberinAlbumPage'] ?? displayTrackNumberinAlbumPage.value;
albumCardTopRightDate.value = json['albumCardTopRightDate'] ?? albumCardTopRightDate.value;
forceSquaredTrackThumbnail.value = json['forceSquaredTrackThumbnail'] ?? forceSquaredTrackThumbnail.value;
Expand Down Expand Up @@ -596,6 +598,7 @@ class _SettingsController with SettingsFileWriter {
'albumListTileHeight': albumListTileHeight.value,

'useMediaStore': useMediaStore.value,
'includeVideos': includeVideos.value,
'displayTrackNumberinAlbumPage': displayTrackNumberinAlbumPage.value,
'albumCardTopRightDate': albumCardTopRightDate.value,
'forceSquaredTrackThumbnail': forceSquaredTrackThumbnail.value,
Expand Down Expand Up @@ -752,6 +755,7 @@ class _SettingsController with SettingsFileWriter {
double? albumThumbnailSizeinList,
double? albumListTileHeight,
bool? useMediaStore,
bool? includeVideos,
bool? displayTrackNumberinAlbumPage,
bool? albumCardTopRightDate,
bool? forceSquaredTrackThumbnail,
Expand Down Expand Up @@ -921,6 +925,7 @@ class _SettingsController with SettingsFileWriter {
if (albumListTileHeight != null) this.albumListTileHeight.value = albumListTileHeight;

if (useMediaStore != null) this.useMediaStore.value = useMediaStore;
if (includeVideos != null) this.includeVideos.value = includeVideos;

if (displayTrackNumberinAlbumPage != null) this.displayTrackNumberinAlbumPage.value = displayTrackNumberinAlbumPage;
if (albumCardTopRightDate != null) this.albumCardTopRightDate.value = albumCardTopRightDate;
Expand Down
1 change: 1 addition & 0 deletions lib/core/translations/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ abstract class LanguageKeys {
String get IMPORT_TIME_RANGE => _getKey('IMPORT_TIME_RANGE');
String get IMPORT_YOUTUBE_HISTORY_GUIDE => _getKey('IMPORT_YOUTUBE_HISTORY_GUIDE');
String get IMPORT_YOUTUBE_HISTORY => _getKey('IMPORT_YOUTUBE_HISTORY');
String get INCLUDE_VIDEOS => _getKey('INCLUDE_VIDEOS');
String get INDEX_REFRESH_REQUIRED => _getKey('INDEX_REFRESH_REQUIRED');
String get INDEXER_NOTE => _getKey('INDEXER_NOTE');
String get INDEXER_SUBTITLE => _getKey('INDEXER_SUBTITLE');
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/pages/onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class _FirstRunConfigureScreenState extends State<FirstRunConfigureScreen> {
Widget build(BuildContext context) {
const indexer = IndexerSettings();
final useMediaStore = indexer.getMediaStoreWidget();
final includeVideosWidget = indexer.getIncludeVideosWidget();
final foldersToScan = indexer.getFoldersToScanWidget(context: context, initiallyExpanded: true);
final foldersToExclude = indexer.getFoldersToExcludeWidget(context: context, initiallyExpanded: true);
final groupArtworksByAlbum = indexer.getGroupArtworksByAlbumWidget();
Expand Down Expand Up @@ -173,6 +174,7 @@ class _FirstRunConfigureScreenState extends State<FirstRunConfigureScreen> {
performanceTile,
libraryTabsTile,
if (useMediaStore != null) useMediaStore,
includeVideosWidget,
groupArtworksByAlbum,
foldersToScan,
foldersToExclude,
Expand Down
31 changes: 29 additions & 2 deletions lib/ui/widgets/settings/indexer_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum _IndexerSettingsKeys {
minimumFileSize,
minimumTrackDur,
useMediaStore,
includeVideos,
refreshOnStartup,
missingTracks,
reindex,
Expand All @@ -64,6 +65,7 @@ class IndexerSettings extends SettingSubpageProvider {
_IndexerSettingsKeys.minimumFileSize: [lang.MIN_FILE_SIZE],
_IndexerSettingsKeys.minimumTrackDur: [lang.MIN_FILE_DURATION],
_IndexerSettingsKeys.useMediaStore: [lang.USE_MEDIA_STORE, lang.USE_MEDIA_STORE_SUBTITLE],
_IndexerSettingsKeys.includeVideos: [lang.INCLUDE_VIDEOS],
_IndexerSettingsKeys.refreshOnStartup: [lang.REFRESH_ON_STARTUP],
_IndexerSettingsKeys.missingTracks: [lang.MISSING_TRACKS],
_IndexerSettingsKeys.reindex: [lang.RE_INDEX, lang.RE_INDEX_SUBTITLE],
Expand Down Expand Up @@ -110,6 +112,29 @@ class IndexerSettings extends SettingSubpageProvider {
);
}

Widget getIncludeVideosWidget() {
return getItemWrapper(
key: _IndexerSettingsKeys.includeVideos,
child: ObxO(
rx: settings.includeVideos,
builder: (context, includeVideos) => CustomSwitchListTile(
bgColor: getBgColor(_IndexerSettingsKeys.includeVideos),
leading: StackedIcon(
baseIcon: Broken.video_play,
secondaryIcon: Broken.tick_circle,
secondaryIconSize: 12.0,
),
title: lang.INCLUDE_VIDEOS,
value: includeVideos,
onChanged: (isTrue) {
settings.save(includeVideos: !isTrue);
showRefreshPromptDialog(false);
},
),
),
);
}

Widget getGroupArtworksByAlbumWidget() {
return getItemWrapper(
key: _IndexerSettingsKeys.groupArtworksByAlbum,
Expand Down Expand Up @@ -302,7 +327,8 @@ class IndexerSettings extends SettingSubpageProvider {
const refreshIconKey1 = 'kurukuru';
const refreshIconKey2 = 'kururin';

final useMediaStore = getMediaStoreWidget();
final useMediaStoreWidget = getMediaStoreWidget();
final includeVideosWidget = getIncludeVideosWidget();
return SettingsCard(
title: lang.INDEXER,
subtitle: lang.INDEXER_SUBTITLE,
Expand Down Expand Up @@ -563,7 +589,8 @@ class IndexerSettings extends SettingSubpageProvider {
),
),
),
if (useMediaStore != null) useMediaStore,
if (useMediaStoreWidget != null) useMediaStoreWidget,
includeVideosWidget,
getItemWrapper(
key: _IndexerSettingsKeys.refreshOnStartup,
child: Obx(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 4.6.96-beta+241118167
version: 4.7.0-beta+241118187

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down

0 comments on commit 1bd172f

Please sign in to comment.