#598 support for Sony predictive capture as burst
This commit is contained in:
parent
03df8fbd26
commit
1e9b931758
5 changed files with 47 additions and 11 deletions
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
## <a id="unreleased"></a>[Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Collection: support for Sony predictive capture as burst
|
||||
|
||||
## <a id="v1.8.5"></a>[v1.8.5] - 2023-04-18
|
||||
|
||||
### Added
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
|
||||
import 'package:aves/model/entry/entry.dart';
|
||||
import 'package:aves/model/multipage.dart';
|
||||
import 'package:aves/ref/bursts.dart';
|
||||
import 'package:aves/ref/mime_types.dart';
|
||||
import 'package:aves/services/common/services.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
@ -17,15 +18,8 @@ extension ExtraAvesEntryMultipage on AvesEntry {
|
|||
bool get isMotionPhoto => (catalogMetadata?.isMotionPhoto ?? false) || _isMotionPhotoLegacy;
|
||||
|
||||
String? getBurstKey(List<String> patterns) {
|
||||
if (filenameWithoutExtension != null) {
|
||||
for (final pattern in patterns) {
|
||||
final match = RegExp(pattern).firstMatch(filenameWithoutExtension!);
|
||||
if (match != null) {
|
||||
return '$directory/${match.group(1)}';
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
final key = BurstPatterns.getKeyForName(filenameWithoutExtension, patterns);
|
||||
return key != null ? '$directory/$key' : null;
|
||||
}
|
||||
|
||||
Future<MultiPageInfo?> getMultiPageInfo() async {
|
||||
|
|
|
@ -309,6 +309,7 @@ class Settings extends ChangeNotifier {
|
|||
if (videoBackgroundMode == VideoBackgroundMode.pip && !device.supportPictureInPicture) {
|
||||
_set(videoBackgroundModeKey, null);
|
||||
}
|
||||
collectionBurstPatterns = collectionBurstPatterns.where(BurstPatterns.options.contains).toList();
|
||||
}
|
||||
|
||||
// app
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
class BurstPatterns {
|
||||
static const samsung = r'^(\d{8}_\d{6})_(\d+)$';
|
||||
static const sony = r'^DSC_\d+_BURST(\d{17})(_COVER)?$';
|
||||
static const _keyGroupName = 'key';
|
||||
|
||||
static const samsung = r'^(?<key>\d{8}_\d{6})_(\d+)$';
|
||||
static const sony = r'^DSC(PDC)?_\d+_BURST(?<key>\d{17})(_COVER)?$';
|
||||
|
||||
static final options = [
|
||||
BurstPatterns.samsung,
|
||||
|
@ -33,6 +35,22 @@ class BurstPatterns {
|
|||
_Manufacturers.samsung: samsung,
|
||||
_Manufacturers.sony: sony,
|
||||
};
|
||||
|
||||
static String? getKeyForName(String? filename, List<String> patterns) {
|
||||
if (filename != null) {
|
||||
for (final pattern in patterns) {
|
||||
final match = RegExp(pattern).firstMatch(filename);
|
||||
if (match != null) {
|
||||
if (match.groupNames.contains(_keyGroupName)) {
|
||||
return match.namedGroup(_keyGroupName);
|
||||
}
|
||||
// fallback to fetching group by index for backward compatibility
|
||||
return match.group(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// values as returned by `DeviceInfoPlugin().androidInfo`
|
||||
|
|
19
test/ref/bursts_test.dart
Normal file
19
test/ref/bursts_test.dart
Normal file
|
@ -0,0 +1,19 @@
|
|||
import 'package:aves/ref/bursts.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('Samsung burst', () {
|
||||
expect(BurstPatterns.getKeyForName('20151021_072800_006', [BurstPatterns.samsung]), '20151021_072800');
|
||||
expect(BurstPatterns.getKeyForName('20151021_072800_007', [BurstPatterns.samsung]), '20151021_072800');
|
||||
});
|
||||
|
||||
test('Sony burst', () {
|
||||
expect(BurstPatterns.getKeyForName('DSC_0006_BURST20151021072800123', [BurstPatterns.sony]), '20151021072800123');
|
||||
expect(BurstPatterns.getKeyForName('DSC_0007_BURST20151021072800123', [BurstPatterns.sony]), '20151021072800123');
|
||||
});
|
||||
|
||||
test('Sony predictive capture', () {
|
||||
expect(BurstPatterns.getKeyForName('DSCPDC_0002_BURST20180619163426901', [BurstPatterns.sony]), '20180619163426901');
|
||||
expect(BurstPatterns.getKeyForName('DSCPDC_0003_BURST20180619163426901_COVER', [BurstPatterns.sony]), '20180619163426901');
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue