use natural order when sorting by name items, albums, tags
This commit is contained in:
parent
36d92aaf38
commit
1a92768c5c
9 changed files with 13 additions and 9 deletions
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
## <a id="unreleased"></a>[Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- use natural order when sorting by name items, albums, tags
|
||||
|
||||
### Fixed
|
||||
|
||||
- screensaver stopping when device orientation changes
|
||||
|
|
|
@ -819,7 +819,7 @@ class AvesEntry {
|
|||
// 1) title ascending
|
||||
// 2) extension ascending
|
||||
static int compareByName(AvesEntry a, AvesEntry b) {
|
||||
final c = compareAsciiUpperCase(a.bestTitle ?? '', b.bestTitle ?? '');
|
||||
final c = compareAsciiUpperCaseNatural(a.bestTitle ?? '', b.bestTitle ?? '');
|
||||
return c != 0 ? c : compareAsciiUpperCase(a.extension ?? '', b.extension ?? '');
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ abstract class CollectionFilter extends Equatable implements Comparable<Collecti
|
|||
int compareTo(CollectionFilter other) {
|
||||
final c = displayPriority.compareTo(other.displayPriority);
|
||||
// assume we compare context-independent labels
|
||||
return c != 0 ? c : compareAsciiUpperCase(universalLabel, other.universalLabel);
|
||||
return c != 0 ? c : compareAsciiUpperCaseNatural(universalLabel, other.universalLabel);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ mixin AlbumMixin on SourceBase {
|
|||
int compareAlbumsByName(String a, String b) {
|
||||
final ua = getAlbumDisplayName(null, a);
|
||||
final ub = getAlbumDisplayName(null, b);
|
||||
final c = compareAsciiUpperCase(ua, ub);
|
||||
final c = compareAsciiUpperCaseNatural(ua, ub);
|
||||
if (c != 0) return c;
|
||||
final va = androidFileUtils.getStorageVolume(a)?.path ?? '';
|
||||
final vb = androidFileUtils.getStorageVolume(b)?.path ?? '';
|
||||
return compareAsciiUpperCase(va, vb);
|
||||
return compareAsciiUpperCaseNatural(va, vb);
|
||||
}
|
||||
|
||||
void notifyAlbumsChanged() {
|
||||
|
|
|
@ -64,7 +64,7 @@ mixin TagMixin on SourceBase {
|
|||
}
|
||||
|
||||
void updateTags() {
|
||||
final updatedTags = visibleEntries.expand((entry) => entry.tags).toSet().toList()..sort(compareAsciiUpperCase);
|
||||
final updatedTags = visibleEntries.expand((entry) => entry.tags).toSet().toList()..sort(compareAsciiUpperCaseNatural);
|
||||
if (!listEquals(updatedTags, sortedTags)) {
|
||||
sortedTags = List.unmodifiable(updatedTags);
|
||||
invalidateTagFilterSummary();
|
||||
|
|
|
@ -192,7 +192,7 @@ class _TagEditorPageState extends State<TagEditorPage> {
|
|||
return entryCountByTag.entries.toList()
|
||||
..sort((kv1, kv2) {
|
||||
final c = kv2.value.compareTo(kv1.value);
|
||||
return c != 0 ? c : compareAsciiUpperCase(kv1.key, kv2.key);
|
||||
return c != 0 ? c : compareAsciiUpperCaseNatural(kv1.key, kv2.key);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class _CreateAlbumDialogState extends State<CreateAlbumDialog> {
|
|||
final volumeTiles = <Widget>[];
|
||||
if (_allVolumes.length > 1) {
|
||||
final byPrimary = groupBy<StorageVolume, bool>(_allVolumes, (volume) => volume.isPrimary);
|
||||
int compare(StorageVolume a, StorageVolume b) => compareAsciiUpperCase(a.path, b.path);
|
||||
int compare(StorageVolume a, StorageVolume b) => compareAsciiUpperCaseNatural(a.path, b.path);
|
||||
final primaryVolumes = (byPrimary[true] ?? [])..sort(compare);
|
||||
final otherVolumes = (byPrimary[false] ?? [])..sort(compare);
|
||||
volumeTiles.addAll([
|
||||
|
|
|
@ -200,7 +200,7 @@ class _FilePickerState extends State<FilePicker> {
|
|||
contents.add(entity);
|
||||
}
|
||||
}, onDone: () {
|
||||
_contents = contents..sort((a, b) => compareAsciiUpperCase(pContext.split(a.path).last, pContext.split(b.path).last));
|
||||
_contents = contents..sort((a, b) => compareAsciiUpperCaseNatural(pContext.split(a.path).last, pContext.split(b.path).last));
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class BasicSection extends StatelessWidget {
|
|||
}
|
||||
|
||||
Widget _buildChips(BuildContext context) {
|
||||
final tags = entry.tags.toList()..sort(compareAsciiUpperCase);
|
||||
final tags = entry.tags.toList()..sort(compareAsciiUpperCaseNatural);
|
||||
final album = entry.directory;
|
||||
final filters = {
|
||||
MimeFilter(entry.mimeType),
|
||||
|
|
Loading…
Reference in a new issue