Skip to content

Commit a8bb2eb

Browse files
committed
#1539 locked: review, prevent rename / metadata export
1 parent bb6c2c3 commit a8bb2eb

File tree

8 files changed

+39
-35
lines changed

8 files changed

+39
-35
lines changed

lib/model/entry/extensions/metadata_edition.dart

+13-13
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
3737
return {};
3838
}
3939

40-
if (canEditExif && appliedModifier.fields.any((v) => v.type == MetadataType.exif)) {
40+
if (isExifEditionSupported && appliedModifier.fields.any((v) => v.type == MetadataType.exif)) {
4141
final newFields = await metadataEditService.editExifDate(this, appliedModifier);
4242
if (newFields.isNotEmpty) {
4343
dataTypes.addAll({
@@ -47,7 +47,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
4747
}
4848
}
4949

50-
if (canEditXmp && appliedModifier.fields.any((v) => v.type == MetadataType.xmp)) {
50+
if (isXmpEditionSupported && appliedModifier.fields.any((v) => v.type == MetadataType.xmp)) {
5151
final metadata = {
5252
MetadataType.xmp: await _editXmp((descriptions) {
5353
switch (appliedModifier.action) {
@@ -94,7 +94,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
9494

9595
final missingDate = await _missingDateCheckAndExifEdit(dataTypes);
9696

97-
if (canEditExif) {
97+
if (isExifEditionSupported) {
9898
// clear every GPS field
9999
final exifFields = Map<MetadataField, dynamic>.fromEntries(MetadataFields.exifGpsFields.map((k) => MapEntry(k, null)));
100100
// add latitude & longitude, if any
@@ -110,7 +110,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
110110
}
111111
metadata[MetadataType.exif] = Map<String, dynamic>.fromEntries(exifFields.entries.map((kv) => MapEntry(kv.key.toPlatform!, kv.value)));
112112

113-
if (canEditXmp && missingDate != null) {
113+
if (isXmpEditionSupported && missingDate != null) {
114114
metadata[MetadataType.xmp] = await _editXmp((descriptions) {
115115
editCreateDateXmp(descriptions, missingDate);
116116
return true;
@@ -236,14 +236,14 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
236236
final title = fields[DescriptionField.title];
237237
final description = fields[DescriptionField.description];
238238

239-
if (canEditExif && editDescription) {
239+
if (isExifEditionSupported && editDescription) {
240240
metadata[MetadataType.exif] = {
241241
MetadataField.exifImageDescription.toPlatform!: null,
242242
MetadataField.exifUserComment.toPlatform!: null,
243243
};
244244
}
245245

246-
if (canEditIptc) {
246+
if (isIptcEditionSupported) {
247247
final iptc = await metadataFetchService.getIptc(this);
248248
if (iptc != null) {
249249
if (editTitle) {
@@ -256,7 +256,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
256256
}
257257
}
258258

259-
if (canEditXmp) {
259+
if (isXmpEditionSupported) {
260260
metadata[MetadataType.xmp] = await _editXmp((descriptions) {
261261
var modified = false;
262262
if (editTitle) {
@@ -304,15 +304,15 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
304304

305305
final missingDate = await _missingDateCheckAndExifEdit(dataTypes);
306306

307-
if (canEditIptc) {
307+
if (isIptcEditionSupported) {
308308
final iptc = await metadataFetchService.getIptc(this);
309309
if (iptc != null) {
310310
editIptcValues(iptc, IPTC.applicationRecord, IPTC.keywordsTag, tags);
311311
metadata[MetadataType.iptc] = iptc;
312312
}
313313
}
314314

315-
if (canEditXmp) {
315+
if (isXmpEditionSupported) {
316316
metadata[MetadataType.xmp] = await _editXmp((descriptions) {
317317
final modified = editTagsXmp(descriptions, tags);
318318
if (modified && missingDate != null) {
@@ -342,7 +342,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
342342

343343
final missingDate = await _missingDateCheckAndExifEdit(dataTypes);
344344

345-
if (canEditXmp) {
345+
if (isXmpEditionSupported) {
346346
metadata[MetadataType.xmp] = await _editXmp((descriptions) {
347347
final modified = editRatingXmp(descriptions, rating);
348348
if (modified && missingDate != null) {
@@ -368,7 +368,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
368368
final dataTypes = <EntryDataType>{};
369369
final metadata = <MetadataType, dynamic>{};
370370

371-
if (!canEditXmp) return dataTypes;
371+
if (!isXmpEditionSupported) return dataTypes;
372372

373373
final missingDate = await _missingDateCheckAndExifEdit(dataTypes);
374374

@@ -509,7 +509,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
509509
return null;
510510
}
511511

512-
if (canEditExif) {
512+
if (isExifEditionSupported) {
513513
final newFields = await metadataEditService.editExifDate(this, DateModifier.setCustom(const {MetadataField.exifDateOriginal}, date));
514514
if (newFields.isNotEmpty) {
515515
dataTypes.addAll({
@@ -524,7 +524,7 @@ extension ExtraAvesEntryMetadataEdition on AvesEntry {
524524
}
525525

526526
Future<DateModifier?> _applyDateModifierToEntry(DateModifier modifier) async {
527-
Set<MetadataField> mainMetadataDate() => {canEditExif ? MetadataField.exifDateOriginal : MetadataField.xmpXmpCreateDate};
527+
Set<MetadataField> mainMetadataDate() => {isExifEditionSupported ? MetadataField.exifDateOriginal : MetadataField.xmpXmpCreateDate};
528528

529529
switch (modifier.action) {
530530
case DateEditAction.copyField:

lib/model/entry/extensions/props.dart

+12-12
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,29 @@ extension ExtraAvesEntryProps on AvesEntry {
112112

113113
bool get canEdit => !settings.isReadOnly && path != null && !trashed && (_isMediaStoreContent || _isVaultContent);
114114

115-
bool get canEditDate => canEdit && (canEditExif || canEditXmp);
115+
bool get canEditDate => canEdit && (isExifEditionSupported || isXmpEditionSupported);
116116

117-
bool get canEditLocation => canEdit && (canEditExif || mimeType == MimeTypes.mp4);
117+
bool get canEditLocation => canEdit && (isExifEditionSupported || mimeType == MimeTypes.mp4);
118118

119-
bool get canEditTitleDescription => canEdit && canEditXmp;
119+
bool get canEditTitleDescription => canEdit && isXmpEditionSupported;
120120

121-
bool get canEditRating => canEdit && canEditXmp;
121+
bool get canEditRating => canEdit && isXmpEditionSupported;
122122

123-
bool get canEditTags => canEdit && canEditXmp;
123+
bool get canEditTags => canEdit && isXmpEditionSupported;
124124

125-
bool get canRotate => canEdit && (canEditExif || mimeType == MimeTypes.mp4);
125+
bool get canRotate => canEdit && (isExifEditionSupported || mimeType == MimeTypes.mp4);
126126

127-
bool get canFlip => canEdit && canEditExif;
127+
bool get canFlip => canEdit && isExifEditionSupported;
128128

129129
// app support
130130

131-
bool get canDecode => AppSupport.canDecode(mimeType);
131+
bool get isDecodingSupported => AppSupport.canDecode(mimeType);
132132

133-
bool get canEditExif => AppSupport.canEditExif(mimeType);
133+
bool get isExifEditionSupported => AppSupport.canEditExif(mimeType);
134134

135-
bool get canEditIptc => AppSupport.canEditIptc(mimeType);
135+
bool get isIptcEditionSupported => AppSupport.canEditIptc(mimeType);
136136

137-
bool get canEditXmp => AppSupport.canEditXmp(mimeType);
137+
bool get isXmpEditionSupported => AppSupport.canEditXmp(mimeType);
138138

139-
bool get canRemoveMetadata => AppSupport.canRemoveMetadata(mimeType);
139+
bool get isMetadataRemovalSupported => AppSupport.canRemoveMetadata(mimeType);
140140
}

lib/widgets/collection/entry_set_action_delegate.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ class EntrySetActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAware
670670
}
671671

672672
Future<void> _removeMetadata(BuildContext context) async {
673-
final entries = await _getEditableTargetItems(context, canEdit: (entry) => entry.canRemoveMetadata);
673+
final entries = await _getEditableTargetItems(context, canEdit: (entry) => entry.isMetadataRemovalSupported);
674674
if (entries == null || entries.isEmpty) return;
675675

676676
final types = await selectMetadataToRemove(context, entries);

lib/widgets/common/thumbnail/image.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class _ThumbnailImageState extends State<ThumbnailImage> {
103103
}
104104

105105
void _initProvider() {
106-
if (!entry.canDecode) return;
106+
if (!entry.isDecodingSupported) return;
107107

108108
_lastException = null;
109109
_providers.clear();
@@ -192,7 +192,7 @@ class _ThumbnailImageState extends State<ThumbnailImage> {
192192
@override
193193
Widget build(BuildContext context) {
194194
final animate = context.select<Settings, bool>((v) => v.animate);
195-
if (!entry.canDecode || _lastException != null) {
195+
if (!entry.isDecodingSupported || _lastException != null) {
196196
return _buildError(context, animate);
197197
}
198198

lib/widgets/viewer/action/entry_action_delegate.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMix
148148
switch (action) {
149149
case EntryAction.rotateCCW:
150150
case EntryAction.rotateCW:
151-
return targetEntry.canRotate;
152151
case EntryAction.flip:
153-
return targetEntry.canFlip;
154152
case EntryAction.editDate:
155153
case EntryAction.editLocation:
156154
case EntryAction.editTitleDescription:
@@ -163,6 +161,7 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMix
163161
case EntryAction.viewMotionPhotoVideo:
164162
return _metadataActionDelegate.canApply(targetEntry, action);
165163
case EntryAction.convert:
164+
case EntryAction.rename:
166165
case EntryAction.copy:
167166
case EntryAction.move:
168167
return !availability.isLocked;

lib/widgets/viewer/action/entry_info_action_delegate.dart

+8-3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class EntryInfoActionDelegate with FeedbackMixin, PermissionAwareMixin, EntryEdi
6767
bool canApply(AvesEntry targetEntry, EntryAction action) {
6868
switch (action) {
6969
// general
70+
case EntryAction.rotateCCW:
71+
case EntryAction.rotateCW:
72+
return targetEntry.canRotate;
73+
case EntryAction.flip:
74+
return targetEntry.canFlip;
7075
case EntryAction.editDate:
7176
return targetEntry.canEditDate;
7277
case EntryAction.editLocation:
@@ -78,15 +83,15 @@ class EntryInfoActionDelegate with FeedbackMixin, PermissionAwareMixin, EntryEdi
7883
case EntryAction.editTags:
7984
return targetEntry.canEditTags;
8085
case EntryAction.removeMetadata:
81-
return targetEntry.canRemoveMetadata;
86+
return targetEntry.canEdit && targetEntry.isMetadataRemovalSupported;
8287
case EntryAction.exportMetadata:
83-
return true;
88+
return !availability.isLocked;
8489
// GeoTIFF
8590
case EntryAction.showGeoTiffOnMap:
8691
return true;
8792
// motion photo
8893
case EntryAction.convertMotionPhotoToStillImage:
89-
return targetEntry.canEditXmp;
94+
return targetEntry.canEdit && targetEntry.isXmpEditionSupported;
9095
case EntryAction.viewMotionPhotoVideo:
9196
return true;
9297
default:

lib/widgets/viewer/overlay/wallpaper_buttons.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class WallpaperButtons extends StatelessWidget with FeedbackMixin {
139139
provider = MemoryImage(bytes);
140140
}
141141
}
142-
} else if (entry.canDecode) {
142+
} else if (entry.isDecodingSupported) {
143143
if (entry.useTiles) {
144144
// provider image is already cropped, but not rotated
145145
needOrientation = rotationDegrees != 0 || isFlipped;

lib/widgets/viewer/visual/entry_page_view.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class _EntryPageViewState extends State<EntryPageView> with TickerProviderStateM
127127
} else if (!entry.displaySize.isEmpty) {
128128
if (entry.isVideo) {
129129
child = _buildVideoView();
130-
} else if (entry.canDecode) {
130+
} else if (entry.isDecodingSupported) {
131131
child = _buildRasterView();
132132
}
133133
}

0 commit comments

Comments
 (0)